s390-tools: Replace 'which' with built-in 'command -v'

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 <bblock@linux.ibm.com>
Signed-off-by: Jan Höppner <hoeppner@linux.ibm.com>
Signed-off-by: Steffen Eiden <seiden@linux.ibm.com>
This commit is contained in:
Jan Höppner
2024-06-14 14:25:40 +02:00
committed by Steffen Eiden
parent 4d2c9267c2
commit 0b0960254e
3 changed files with 3 additions and 4 deletions
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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
+1 -2
View File
@@ -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