From 14e270b7f524480351a857a008bd392277be663d Mon Sep 17 00:00:00 2001 From: Alberto Bertogli Date: Fri, 29 Oct 2021 11:11:21 +0100 Subject: [PATCH] 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 | 2 +- test/util/lib.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 "$@"