[PATCH] ci, t, tools: use `command -v` instead of `which`

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



`which` has been deprecated in Debian's debianutils 5.0+ (currently only
Debian unstable), with no drop-in replacement:
https://salsa.debian.org/debian/debianutils/-/commit/3a8dd10b4502f7bae8fc6973c13ce23fc9da7efb

`command -v` is available in POSIX and its predecessors at least since
1994. `which` is not there in any version I'm aware of.
https://pubs.opengroup.org/onlinepubs/7908799/

Signed-off-by: Ville Skyttä <ville.skytta@xxxxxxxxxxx>
---
 ci/travis-install-pmdk.sh | 2 +-
 t/one-core-peak.sh        | 4 ++--
 tools/fio_generate_plots  | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/ci/travis-install-pmdk.sh b/ci/travis-install-pmdk.sh
index 803438f8..9163ec79 100755
--- a/ci/travis-install-pmdk.sh
+++ b/ci/travis-install-pmdk.sh
@@ -12,7 +12,7 @@ WORKDIR=$(pwd)
 #    /bin/sh: 1: clang: not found
 # if CC is not set to the full path of clang.
 #
-export CC=$(which $CC)
+export CC=$(command -v $CC)
 
 # Install PMDK libraries, because PMDK's libpmem
 # is a dependency of the librpma fio engine.
diff --git a/t/one-core-peak.sh b/t/one-core-peak.sh
index 9da8304e..466dbdd4 100755
--- a/t/one-core-peak.sh
+++ b/t/one-core-peak.sh
@@ -33,7 +33,7 @@ check_binary() {
   # Ensure the binaries are present and executable
   for bin in "$@"; do
     if [ ! -x ${bin} ]; then
-      which ${bin} >/dev/null
+      command -v ${bin} >/dev/null
       [ $? -eq 0 ] || fatal "${bin} doesn't exists or is not executable"
     fi
   done
@@ -197,7 +197,7 @@ show_nvme() {
   fw=$(cat ${device_dir}/firmware_rev | xargs) #xargs for trimming spaces
   serial=$(cat ${device_dir}/serial | xargs) #xargs for trimming spaces
   info ${device_name} "MODEL=${model} FW=${fw} serial=${serial} PCI=${pci_addr}@${link_speed} IRQ=${irq} NUMA=${numa} CPUS=${cpus} "
-  which nvme &> /dev/null
+  command -v nvme > /dev/null
   if [ $? -eq 0 ]; then
     status=""
     NCQA=$(nvme get-feature -H -f 0x7 ${device} 2>&1 |grep NCQA |cut -d ':' -f 2 | xargs)
diff --git a/tools/fio_generate_plots b/tools/fio_generate_plots
index e4558788..468cf27a 100755
--- a/tools/fio_generate_plots
+++ b/tools/fio_generate_plots
@@ -21,7 +21,7 @@ if [ -z "$1" ]; then
 	exit 1
 fi
 
-GNUPLOT=$(which gnuplot)
+GNUPLOT=$(command -v gnuplot)
 if [ ! -x "$GNUPLOT" ]
 then
 	echo You need gnuplot installed to generate graphs
-- 
2.25.1




[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux