Skip to content

Commit

Permalink
Fix test for existence of command
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
a1346054 committed Sep 8, 2021
1 parent f03da89 commit ce92bf3
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion doc/scripts/init/rtorrentInitTmux.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ce92bf3

Please sign in to comment.