From 98c7d707f6bd538e0504df3315426d716442fe83 Mon Sep 17 00:00:00 2001 From: a1346054 <36859588+a1346054@users.noreply.github.com> Date: Mon, 12 Sep 2022 23:34:04 +0000 Subject: [PATCH] scripts: Use bash-builtin `command -v` instead of external `which` `command -v` is a bash builtin and is a standardized version of `which` --- scripts/copr-build-srpm.sh | 4 ++-- scripts/usb-descriptor-collect.sh | 18 +++++++++--------- src/Tests/Source/CheckScripts/spell-check.sh | 4 ++-- src/Tests/bash-testlib.sh | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/scripts/copr-build-srpm.sh b/scripts/copr-build-srpm.sh index 82376fb4..2026fdf9 100755 --- a/scripts/copr-build-srpm.sh +++ b/scripts/copr-build-srpm.sh @@ -17,8 +17,8 @@ # # Authors: Daniel Kopecek # -CURL=$(which curl) -JQ=$(which jq) +CURL=$(command -v curl) +JQ=$(command -v jq) if [ -z "$CURL" ]; then echo "Required curl command missing. Aborting." diff --git a/scripts/usb-descriptor-collect.sh b/scripts/usb-descriptor-collect.sh index 95a01a10..dbb08462 100755 --- a/scripts/usb-descriptor-collect.sh +++ b/scripts/usb-descriptor-collect.sh @@ -19,15 +19,15 @@ # set -e -o pipefail -SED=$(which sed) -FIND=$(which find) -LSUSB=$(which lsusb) -SHA1SUM=$(which sha1sum) -TAR=$(which tar) -MKTEMP=$(which mktemp) -CP=$(which cp) -WC=$(which wc) -RM=$(which rm) +SED=$(command -v sed) +FIND=$(command -v find) +LSUSB=$(command -v lsusb) +SHA1SUM=$(command -v sha1sum) +TAR=$(command -v tar) +MKTEMP=$(command -v mktemp) +CP=$(command -v cp) +WC=$(command -v wc) +RM=$(command -v rm) TEMPDIR=$($MKTEMP -d --tmpdir usb-descriptor-collect.XXXXXX || (echo "Failed to create temporary directory"; exit 1)) ROOTDIR="$TEMPDIR/usb-descriptor-data" diff --git a/src/Tests/Source/CheckScripts/spell-check.sh b/src/Tests/Source/CheckScripts/spell-check.sh index 5d62a2f4..c8563471 100755 --- a/src/Tests/Source/CheckScripts/spell-check.sh +++ b/src/Tests/Source/CheckScripts/spell-check.sh @@ -24,8 +24,8 @@ # check-path-exclude: doc/FOSDEM-2016/* # ################## -ASPELL=$(which aspell) -PANDOC=$(which pandoc) +ASPELL=$(command -v aspell) +PANDOC=$(command -v pandoc) SOURCE_FILEPATH="$1" diff --git a/src/Tests/bash-testlib.sh b/src/Tests/bash-testlib.sh index 1e791634..3d7aaf43 100755 --- a/src/Tests/bash-testlib.sh +++ b/src/Tests/bash-testlib.sh @@ -82,7 +82,7 @@ function execute() local valgrind="" if [ -n "$USBGUARD_TESTS_VALGRIND" ]; then - valgrind="$(which valgrind)" + valgrind="$(command -v valgrind)" fi if [ "$USBGUARD_TESTS_VALGRIND" = "off" ]; then