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 for more

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

test/t-15-driusan_dkim/ +1 -1
test/util/ +1 -1

diff --git a/test/t-15-driusan_dkim/ b/test/t-15-driusan_dkim/
index 85ac5d1..2bcb3c7 100755
--- a/test/t-15-driusan_dkim/
+++ b/test/t-15-driusan_dkim/
@@ -10,7 +10,7 @@ init
 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
diff --git a/test/util/ b/test/util/
index 25a8592..c949a5c 100644
--- a/test/util/
+++ b/test/util/
@@ -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"
 		${UTILDIR}/.msmtp-bin -C msmtprc "$@"