From 0b0960254e8c2b556cefa97f83651a92f54a5e42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20H=C3=B6ppner?= Date: Fri, 14 Jun 2024 14:25:40 +0200 Subject: [PATCH] s390-tools: Replace 'which' with built-in 'command -v' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are still a few scripts using the 'which' command to determine either the full path or the mere existence of an executable. Some of these scripts might run in minimal environments where 'which' is not available due to dependency restriction. 'which' is also considered unreliable for historical implementation details. Use the POSIX defined [1] built-in 'command -v' instead to reduce package dependencies and improve reliability. [1] https://pubs.opengroup.org/onlinepubs/9699919799/ Reviewed-by: Benjamin Block Signed-off-by: Jan Höppner Signed-off-by: Steffen Eiden --- iucvterm/doc/ts-shell/iucvconn_on_login | 2 +- netboot/mk-pxelinux-ramfs | 2 +- ziomon/ziomon | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/iucvterm/doc/ts-shell/iucvconn_on_login b/iucvterm/doc/ts-shell/iucvconn_on_login index 860c4ccf..92010dfa 100755 --- a/iucvterm/doc/ts-shell/iucvconn_on_login +++ b/iucvterm/doc/ts-shell/iucvconn_on_login @@ -15,7 +15,7 @@ prog_name=`basename $0` guest_name=${USER:-`whoami 2>/dev/null`} terminal=lnxhvc0 -iucvconn=`which iucvconn 2>/dev/null` +iucvconn=`command -v iucvconn 2>/dev/null` __error() { printf "$prog_name: $@\n" >&2 diff --git a/netboot/mk-pxelinux-ramfs b/netboot/mk-pxelinux-ramfs index 64ebde1c..07f8b075 100755 --- a/netboot/mk-pxelinux-ramfs +++ b/netboot/mk-pxelinux-ramfs @@ -127,7 +127,7 @@ echo "$cmd: Copying kexec" # Install both binary and required shared libraries OLDPATH=$PATH PATH=$OLDPATH:/sbin:/usr/sbin -kexec_bin=$(which kexec) +kexec_bin=$(command -v kexec) kexec_sos=$(sharedobjs $kexec_bin) PATH=$OLDPATH diff --git a/ziomon/ziomon b/ziomon/ziomon index fd6248a3..d1545ccb 100755 --- a/ziomon/ziomon +++ b/ziomon/ziomon @@ -667,8 +667,7 @@ function check_free_space_mileage() { function check_blktrace() { - which blktrace >/dev/null 2>&1; - if [ $? -ne 0 ]; then + if ! command -v blktrace >/dev/null 2>&1; then echo "$WRP_TOOLNAME: Could not find blktrace. Please make sure that the blktrace package is installed and matches the level in the documentation."; exit 1; fi