]> www.infradead.org Git - users/dwmw2/vpnc-scripts.git/commitdiff
Use `type -P` instead of `command -v` in tests/ bash scripts
authorVille Skyttä <ville.skytta@iki.fi>
Sun, 14 Nov 2021 09:18:43 +0000 (11:18 +0200)
committerVille Skyttä <ville.skytta@iki.fi>
Sun, 14 Nov 2021 09:18:43 +0000 (11:18 +0200)
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.

tests/common.sh
tests/ns.sh

index 28f0b4a1ea1cec07678cd100bcf798868acc8254..ae9d626ddebba68b1ed10a54729dadf12b001fad 100644 (file)
 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
index 2b65f81abca7e0317d2e7213ad1875bdbe249418..e74338fc1142b37dc4cde4dba9f082bdb57658a9 100644 (file)
@@ -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