git » chasquid » commit 14e270b

test: Replace uses of `which` with `command -v`

author Alberto Bertogli
2021-10-29 10:11:21 UTC
committer Alberto Bertogli
2021-10-29 10:14:16 UTC
parent 643f7576f055f18b5dbf8bc59bd633e7806a12cf

test: Replace uses of `which` with `command -v`

The `which` command isn't guaranteed to be available, it is just
extremely common; `command -v` is the standard way to do find an
executable program. See https://lwn.net/Articles/874049/ for more
details.

This patch replaces the uses of `which` with `command -v`, which only
appears in a couple of tests.

test/t-15-driusan_dkim/run.sh +1 -1
test/util/lib.sh +1 -1

diff --git a/test/t-15-driusan_dkim/run.sh b/test/t-15-driusan_dkim/run.sh
index 85ac5d1..2bcb3c7 100755
--- a/test/t-15-driusan_dkim/run.sh
+++ b/test/t-15-driusan_dkim/run.sh
@@ -10,7 +10,7 @@ init
 check_hostaliases
 
 for binary in dkimsign dkimverify dkimkeygen; do
-	if ! which $binary > /dev/null; then
+	if ! command -v $binary > /dev/null; then
 		skip "$binary binary not found"
 		exit 0
 	fi
diff --git a/test/util/lib.sh b/test/util/lib.sh
index 25a8592..c949a5c 100644
--- a/test/util/lib.sh
+++ b/test/util/lib.sh
@@ -82,7 +82,7 @@ function run_msmtp() {
 	# msmtp binary is often g+s, which causes $HOSTALIASES to not be
 	# honoured, which breaks the tests. Copy the binary to remove the
 	# setgid bit as a workaround.
-	cp -u "`which msmtp`" "${UTILDIR}/.msmtp-bin"
+	cp -u "`command -v msmtp`" "${UTILDIR}/.msmtp-bin"
 
 	HOSTALIASES=${TBASE}/hosts \
 		${UTILDIR}/.msmtp-bin -C msmtprc "$@"