]> git.ipfire.org Git - thirdparty/ldns.git/commitdiff
Fix Shellcheck warning in test_all.sh
authorJeffrey Walton <noloader@gmail.com>
Tue, 14 May 2019 00:00:08 +0000 (20:00 -0400)
committerJeffrey Walton <noloader@gmail.com>
Tue, 14 May 2019 00:00:08 +0000 (20:00 -0400)
Also see http://github.com/koalaman/shellcheck. It should be available for install on your Linux box from the package manager.

test/test_all.sh

index 767f31feb23717b8f7cad3269ad2c4c0e3578ab3..af4a920d7e287503b73324032785010de78dd353 100755 (executable)
@@ -1,40 +1,46 @@
 #!/usr/bin/env bash
+
 # do ldns tests
 cd test
 . common.sh
 
 # find tpkg
-if test -x "`command -v tpkg 2>&1`"; then
+if test -x "$(command -v tpkg 2>&1)"; then
        TPKG=tpkg
 else
-       TPKG=$1
+       TPKG="$1"
        if [ -z "$TPKG" ]
        then
-       TPKG=$HOME/repos/tpkg/tpkg
+       TPKG="$HOME/repos/tpkg/tpkg"
        fi
 fi
 
+is_freebsd=$(uname -s 2>&1 | grep -i -c 'freebsd')
 test_tool_avail "dig"
 
-echo start the test at `date` in `pwd`
-[ "$1" = "clean" -o "$2" = "clean" ] && $TPKG clean
+echo start the test at "$(date)" in "$(pwd)"
+[ "$1" = "clean" ] || [ "$2" = "clean" ] && $TPKG clean
 $TPKG -a ../.. fake 01-compile.tpkg
-$TPKG -a ../.. fake 02-lint.tpkg               # Works only on FreeBSD really
+
+# Works only on FreeBSD really
+if [[ "$is_freebsd" -ne 0 ]]; then
+    $TPKG -a ../.. fake 02-lint.tpkg
+fi
+
 $TPKG -a ../.. fake 07-compile-examples.tpkg
 $TPKG -a ../.. fake 16-compile-builddir.tpkg
 $TPKG -a ../.. fake 30-load-pyldns.tpkg
 $TPKG -a ../.. fake 31-load-pyldnsx.tpkg
 $TPKG -a ../.. fake 32-unbound-regression.tpkg
 $TPKG -a ../.. fake 999-compile-nossl.tpkg
-which indent || $TPKG -a ../.. fake codingstyle.tpkg
+command -v indent || $TPKG -a ../.. fake codingstyle.tpkg
 
 for tests in *.tpkg
 do
-       COMMAND="$TPKG -a ../.. exe `basename $tests`"
-       echo $COMMAND
+       COMMAND="$TPKG -a ../.. exe $(basename "$tests")"
+       echo "$COMMAND"
        $COMMAND
 done 
-echo finished the test at `date` in `pwd`
+echo finished the test at "$(date)" in "$(pwd)"
 $TPKG report
 cd ..
-