From 43ef67b27378393f77459b5173421c6488c40152 Mon Sep 17 00:00:00 2001 From: a1346054 <36859588+a1346054@users.noreply.github.com> Date: Wed, 8 Sep 2021 09:22:40 +0000 Subject: [PATCH] Fix test for existence of command `which` will print, even if the command does not exist, so the test will never fail. Additionally, `which` is non-standard, and has been deprecated by debian. `command -v` is the POSIX-standardized way of testing for existence of commands, and works the same even on non-POSIX systems that implement the `command` command. `command -v` will exit with 0 and print to stdout when the command exists, and will exit with 1 and *not* print anything to stdout or stderr when the command does not exist. --- doc/scripts/init/rtorrentInitTmux.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/scripts/init/rtorrentInitTmux.bash b/doc/scripts/init/rtorrentInitTmux.bash index 87144b920..6847e64a4 100755 --- a/doc/scripts/init/rtorrentInitTmux.bash +++ b/doc/scripts/init/rtorrentInitTmux.bash @@ -80,7 +80,7 @@ SCRIPTNAME=/etc/init.d/$NAME RTXMLRPCBIN="$base/bin/rtxmlrpc" checkcnfg() { - if [ -z "$(which $DAEMON)" ] ; then + if ! command -v "$DAEMON" >/dev/null ; then echo "Cannot find $DAEMON binary in PATH: $PATH" exit 3 fi