Skip to content

Commit 55c0baa

Browse files
kolyshkinrst0git
authored andcommitted
Use command -v instead of which
Unlike "which", which is a separate executable not always installed by default, "command -v" is a shell built-in available at least for bash, dash, and busybox shell. Unlike "which", "command -v" is also easier to grep for, and it is already used in a few places here. Inspired by commit 57251d8. Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
1 parent 57251d8 commit 55c0baa

File tree

6 files changed

+7
-9
lines changed

6 files changed

+7
-9
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
image: registry.fedoraproject.org/fedora:latest
1515
steps:
1616
- name: Install tools
17-
run: sudo dnf -y install git make ruff xz clang-tools-extra which codespell git-clang-format ShellCheck
17+
run: sudo dnf -y install git make ruff xz clang-tools-extra codespell git-clang-format ShellCheck
1818

1919
- uses: actions/checkout@v4
2020

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,7 +489,7 @@ lint: ruff shellcheck codespell
489489
! git --no-pager grep -E '\s+$$' \*.c \*.h
490490
.PHONY: lint ruff shellcheck codespell
491491

492-
codecov: SHELL := $(shell which bash)
492+
codecov: SHELL := $(shell command -v bash)
493493
codecov:
494494
curl -Os https://uploader.codecov.io/latest/linux/codecov
495495
chmod +x codecov

contrib/dependencies/dnf-packages.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,5 +37,4 @@ dnf install -y \
3737
python3-setuptools \
3838
python3-wheel \
3939
rubygem-asciidoctor \
40-
which \
4140
xmlto

contrib/docker_cr.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ resolve_path() {
418418
local p
419419

420420
p="${2}"
421-
if which realpath > /dev/null; then
421+
if command -v realpath > /dev/null; then
422422
p=$(realpath "${p}")
423423
fi
424424
${ECHO} "${1}: ${p}"
@@ -427,7 +427,7 @@ resolve_path() {
427427
resolve_cmd() {
428428
local cpath
429429

430-
cpath=$(which "${2}")
430+
cpath=$(command -v "${2}")
431431
resolve_path "${1}" "${cpath}"
432432
}
433433

scripts/ci/prepare-for-fedora-rawhide.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ dnf install -y \
1515
python-unversioned-command \
1616
redhat-rpm-config \
1717
sudo \
18-
tar \
19-
which
18+
tar
2019

2120
# /tmp is no longer 755 in the rawhide container image and breaks CI - fix it
2221
chmod 1777 /tmp

scripts/nmk/scripts/tools.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ MAKE := make
2323
MKDIR := mkdir -p
2424
AWK := awk
2525
PERL := perl
26-
FULL_PYTHON := $(shell which python3 2>/dev/null)
26+
FULL_PYTHON := $(shell command -v python3 2>/dev/null)
2727
PYTHON ?= $(shell basename $(FULL_PYTHON))
2828
FIND := find
2929
SH := $(shell if [ -x "$$BASH" ]; then echo $$BASH; \
@@ -36,7 +36,7 @@ CTAGS := ctags
3636
export RM HOSTLD LD HOSTCC CC CPP AS AR STRIP OBJCOPY OBJDUMP
3737
export NM SH MAKE MKDIR AWK PERL PYTHON SH CSCOPE
3838

39-
export USE_ASCIIDOCTOR ?= $(shell which asciidoctor 2>/dev/null)
39+
export USE_ASCIIDOCTOR ?= $(shell command -v asciidoctor 2>/dev/null)
4040

4141
#
4242
# Footer.

0 commit comments

Comments
 (0)