From: Ville Skyttä Date: Sun, 14 Nov 2021 09:18:43 +0000 (+0200) Subject: Use `type -P` instead of `command -v` in tests/ bash scripts X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=28fc3578f96d34923665cfad406a9f59d70014a6;p=users%2Fdwmw2%2Fvpnc-scripts.git Use `type -P` instead of `command -v` in tests/ bash scripts The output of `command -v` is not helpful for our purposes for aliases. `type -P` works, and unportability of `-P` is not a problem in bash scripts. --- diff --git a/tests/common.sh b/tests/common.sh index 28f0b4a..ae9d626 100644 --- a/tests/common.sh +++ b/tests/common.sh @@ -19,10 +19,10 @@ builddir=${builddir:-.} srcdir=${srcdir:-.} -OPENCONNECT=${OPENCONNECT:-$(command -v openconnect)} -OCCTL=${OCCTL:-$(command -v occtl)} -OCSERV=${OCSERV:-$(command -v ocserv)} -IP=${IP:-$(command -v ip)} +OPENCONNECT=${OPENCONNECT:-$(type -P openconnect)} +OCCTL=${OCCTL:-$(type -P occtl)} +OCSERV=${OCSERV:-$(type -P ocserv)} +IP=${IP:-$(type -P ip)} if test -z "${OPENCONNECT}" || ! test -x ${OPENCONNECT};then echo "You need openconnect to run this test" @@ -81,14 +81,14 @@ update_config() { # command in the caller's PFCMD, or exit, indicating an unsupported # test. Prefer ss from iproute2 over the older netstat. have_port_finder() { - for file in $(command -v ss) /*bin/ss /usr/*bin/ss /usr/local/*bin/ss;do + for file in $(type -P ss) /*bin/ss /usr/*bin/ss /usr/local/*bin/ss;do if test -x "$file";then PFCMD="$file";return 0 fi done if test -z "$PFCMD";then - for file in $(command -v netstat) /bin/netstat /usr/bin/netstat /usr/local/bin/netstat;do + for file in $(type -P netstat) /bin/netstat /usr/bin/netstat /usr/local/bin/netstat;do if test -x "$file";then PFCMD="$file";return 0 fi diff --git a/tests/ns.sh b/tests/ns.sh index 2b65f81..e74338f 100644 --- a/tests/ns.sh +++ b/tests/ns.sh @@ -37,7 +37,7 @@ PATH=${PATH}:/usr/sbin if test -z ${IP};then - IP=$(command -v ip) + IP=$(type -P ip) fi if test "$(id -u)" != "0";then