]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
Fix use of which command
authorJeffrey Walton <noloader@gmail.com>
Mon, 13 May 2019 22:58:16 +0000 (18:58 -0400)
committerJeffrey Walton <noloader@gmail.com>
Mon, 13 May 2019 22:58:16 +0000 (18:58 -0400)
The 'which' command is the wrong tool for the job for several reasons. The protable way to check if a tool is available in a shell is 'command -v'. Also see https://stackoverflow.com/q/592620/608639

Makefile.in
test/common.sh
test/test_all.sh
test/test_ci.sh
test/testbed/do-tests.sh

index f7b0a8ab4135fb8baf6a9e6b51c522563208a4a6..752001ace046257a57837af26b7d9d0d8259a9f0 100644 (file)
@@ -291,7 +291,7 @@ manpage-errors:
                        echo doc/man/man3/$${m}.3: manpage-has-bad-whatis-entry; \
                fi; \
        done || echo "WARNING!: Cannot detect manpage errors on `uname`"
-       
+
 pyldns: _ldns.la
 
 $(pywrapdir)/ldns_wrapper.c: $(PYLDNS_I_FILES) ldns/config.h
@@ -483,7 +483,7 @@ test-clean:
        tpkg -b test clean
 
 test: @TEST_P5_DNS_LDNS@
-       if test -x "`which bash`"; then bash test/test_all.sh; else sh test/test_all.sh; fi
+       if test -x "`command -v bash`"; then bash test/test_all.sh; else sh test/test_all.sh; fi
 
 
 # Recreate symbols file, only needed when API changes
index 8e3b2293ec671cd75ed013f8a41ddec80cf24b04..c57defa363fe5a8c3dbe2a176cc8445e40c2b458 100644 (file)
@@ -47,7 +47,7 @@ info () {
 # test if 'tool' is available in path and complain otherwise.
 # $1: tool
 test_tool_avail () {
-       if test ! -x "`which $1 2>&1`"; then
+       if test ! -x "`command -v $1 2>&1`"; then
                echo No "$1" in path
                exit 1
        fi
@@ -55,7 +55,7 @@ test_tool_avail () {
 
 # get ldns-testns tool in LDNS_TESTNS variable.
 get_ldns_testns () {
-       if test -x "`which ldns-testns 2>&1`"; then
+       if test -x "`command -v ldns-testns 2>&1`"; then
                LDNS_TESTNS=ldns-testns
        else
                LDNS_TESTNS=/home/wouter/bin/ldns-testns
@@ -64,7 +64,7 @@ get_ldns_testns () {
 
 # get make tool in MAKE variable, gmake is used if present.
 get_make () {
-       if test -x "`which gmake 2>&1`"; then
+       if test -x "`command -v gmake 2>&1`"; then
                MAKE=gmake
        else
                MAKE=make
@@ -73,7 +73,7 @@ get_make () {
 
 # get cc tool in CC variable, gcc is used if present.
 get_gcc () {
-       if test -x "`which gcc 2>&1`"; then
+       if test -x "`command -v gcc 2>&1`"; then
                CC=gcc
        else
                CC=cc
@@ -82,9 +82,9 @@ get_gcc () {
 
 # get pcat, pcat-print and pcat-diff
 get_pcat () {
-       PCAT=`which pcat`
-       PCAT_PRINT=`which pcat-print`
-       PCAT_DIFF=`which pcat-diff`
+       PCAT=`command -v pcat`
+       PCAT_PRINT=`command -v pcat-print`
+       PCAT_DIFF=`command -v pcat-diff`
 }
 
 # set SKIP=1 if the name is in list and tool is not available.
@@ -93,7 +93,7 @@ get_pcat () {
 # #3: name of the tool required.
 skip_if_in_list () {
        if echo $2 | grep $1 >/dev/null; then
-               if test ! -x "`which $3 2>&1`"; then
+               if test ! -x "`command -v $3 2>&1`"; then
                        SKIP=1;
                fi
        fi
index cdc4eca8c405ffeb0d60833db451244f603e2d07..767f31feb23717b8f7cad3269ad2c4c0e3578ab3 100755 (executable)
@@ -4,7 +4,7 @@ cd test
 . common.sh
 
 # find tpkg
-if test -x "`which tpkg 2>&1`"; then
+if test -x "`command -v tpkg 2>&1`"; then
        TPKG=tpkg
 else
        TPKG=$1
index 14fd6c1daad1adf69badbb4e462d467e36f1e7d6..84e9a2943939d0c02f58a6d5bf6ef5b4a1965ddf 100755 (executable)
@@ -19,7 +19,7 @@ fi
 
 if [ -z "$TPKG" -o ! -x "$TPKG" ]
 then
-        if which tpkg > /dev/null      ; then TPKG=`which tpkg`
+        if which tpkg > /dev/null      ; then TPKG=`command -v tpkg`
         elif [ -x $HOME/bin/tpkg ]     ; then TPKG=$HOME/bin/tpkg
         elif [ -x $HOME/local/bin/tpkg ]; then TPKG=$HOME/local/bin/tpkg
         elif [ -x /home/tpkg/bin/tpkg ]        ; then TPKG=/home/tpkg/bin/tpkg
index a8580746aaf2b1f82c69f78ade4ee6fbc8947e91..0e394e8c37a971665135d340699e27852eedc17b 100755 (executable)
@@ -8,12 +8,12 @@ cd testdata;
 for test in `ls *.tpkg`; do
        SKIP=0
        if echo $NEED_SPLINT | grep $test >/dev/null; then
-               if test ! -x "`which splint`"; then
+               if test ! -x "`command -v splint`"; then
                        SKIP=1;
                fi
        fi
        if echo $NEED_DOXYGEN | grep $test >/dev/null; then
-               if test ! -x "`which doxygen`"; then
+               if test ! -x "`command -v doxygen`"; then
                        SKIP=1;
                fi
        fi