]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Make $? compatible with set -e in system tests
authorTom Krizek <tkrizek@isc.org>
Fri, 9 Jun 2023 08:57:34 +0000 (10:57 +0200)
committerTom Krizek <tkrizek@isc.org>
Fri, 14 Jul 2023 13:49:15 +0000 (15:49 +0200)
Ensure handling of return code from previous command doesn't cause the
script to halt if that code is non-zero when running with `set -e`.

19 files changed:
bin/tests/system/autosign/tests.sh
bin/tests/system/cds/tests.sh
bin/tests/system/checkconf/tests.sh
bin/tests/system/conf.sh.common
bin/tests/system/digdelv/tests.sh
bin/tests/system/dnssec/tests.sh
bin/tests/system/dnstap/tests.sh
bin/tests/system/doth/tests.sh
bin/tests/system/idna/tests.sh
bin/tests/system/inline/tests.sh
bin/tests/system/ixfr/tests.sh
bin/tests/system/masterformat/tests.sh
bin/tests/system/names/tests.sh
bin/tests/system/nsupdate/tests.sh
bin/tests/system/rndc/tests.sh
bin/tests/system/rpzrecurse/tests.sh
bin/tests/system/runtime/tests.sh
bin/tests/system/statschannel/tests.sh
bin/tests/system/tools/tests.sh

index 36dbd26ff857fd36a3506e8d3ba893c65d88874c..40136edafdca12ea72bc2c031b6910133ed2cf11 100755 (executable)
@@ -1191,8 +1191,8 @@ check_interval () {
                        if (int(x) > int(interval))
                          exit (1);
                      }
-                     END { if (int(x) > int(interval) || int(x) < int(interval-10)) exit(1) }' interval=$2
-        return $?
+                     END { if (int(x) > int(interval) || int(x) < int(interval-10)) exit(1) }' interval=$2 || return $?
+        return 0
 }
 
 echo_i "checking automatic key reloading interval ($n)"
@@ -1404,11 +1404,11 @@ $RNDCCMD 10.53.0.3 signing -nsec3param 1 1 10 12345678 delzsk.example. > signing
 for i in 0 1 2 3 4 5 6 7 8 9; do
        _ret=1
        $DIG $DIGOPTS delzsk.example NSEC3PARAM @10.53.0.3 > dig.out.ns3.1.test$n 2>&1 || ret=1
-       grep "NSEC3PARAM.*12345678" dig.out.ns3.1.test$n > /dev/null 2>&1
-       if [ $? -eq 0 ]; then
+       { grep "NSEC3PARAM.*12345678" dig.out.ns3.1.test$n > /dev/null 2>&1; rc=$?; } || true
+       if [ $rc -eq 0 ]; then
                $RNDCCMD 10.53.0.3 signing -list delzsk.example > signing.out.2.test$n 2>&1
-               grep "Creating NSEC3 chain " signing.out.2.test$n > /dev/null 2>&1
-               if [ $? -ne 0 ]; then
+               { grep "Creating NSEC3 chain " signing.out.2.test$n > /dev/null 2>&1; rc=$?; } || true
+               if [ $rc -ne 0 ]; then
                        _ret=0
                        break
                fi
@@ -1427,8 +1427,8 @@ $SETTIME -D now-1h $file > settime.out.test$n || ret=1
 for i in 0 1 2 3 4 5 6 7 8 9; do
        _ret=1
        $RNDCCMD 10.53.0.3 signing -list delzsk.example > signing.out.3.test$n 2>&1
-       grep "Signing " signing.out.3.test$n > /dev/null 2>&1
-       if [ $? -ne 0 ]; then
+       { grep "Signing " signing.out.3.test$n > /dev/null 2>&1; rc=$?; } || true
+       if [ $rc -ne 0 ]; then
                if [ $(grep "Done signing " signing.out.3.test$n | wc -l) -eq 2 ]; then
                        _ret=0
                        break
index 312197ace51d36539e242ec9417c6a97ba60a886..2eb092f4b439157ddfbfe12d3cc2aa6c0099d64a 100644 (file)
@@ -23,8 +23,7 @@ fail() {
 }
 
 runcmd() {
-        "$@" 1> out.$n 2> err.$n
-       echo $?
+        ("$@" 1> out.$n 2> err.$n; echo $?) || true
 }
 
 testcase() {
index 559d5b32dd2d79036bbead3a7f3bf2555a4f6aea..114958c1ebd5b28075ea0ed95135ee049bbc47cb 100644 (file)
@@ -55,8 +55,8 @@ do
     n=$((n + 1))
     echo_i "checking that named-checkconf detects error in $bad ($n)"
     ret=0
-    $CHECKCONF $bad > checkconf.out$n 2>&1
-    if [ $? -ne 1 ]; then ret=1; fi
+    { $CHECKCONF $bad > checkconf.out$n 2>&1; rc=$?; } || true
+    if [ $rc -ne 1 ]; then ret=1; fi
     grep "^$bad:[0-9]*: " < checkconf.out$n > /dev/null || ret=1
     case $bad in
     bad-update-policy[123].conf)
@@ -88,8 +88,8 @@ do
                good-dot-*.conf) continue;;
                esac
        fi
-       $CHECKCONF $good > checkconf.out$n 2>&1
-       if [ $? -ne 0 ]; then echo_i "failed"; ret=1; fi
+       { $CHECKCONF $good > checkconf.out$n 2>&1; rc=$?; } || true
+       if [ $rc -ne 0 ]; then echo_i "failed"; ret=1; fi
        status=$((status + ret))
 done
 
@@ -98,15 +98,14 @@ do
        n=$((n + 1))
        ret=0
 
-       $FEATURETEST --with-lmdb
-       if [ $? -eq 0 ]; then
+       if $FEATURETEST --with-lmdb; then
                echo_i "checking that named-checkconf detects no error in $lmdb ($n)"
-               $CHECKCONF $lmdb > checkconf.out$n 2>&1
-               if [ $? -ne 0 ]; then echo_i "failed"; ret=1; fi
+               { $CHECKCONF $lmdb > checkconf.out$n 2>&1; rc=$?; } || true
+               if [ $rc -ne 0 ]; then echo_i "failed"; ret=1; fi
        else
                echo_i "checking that named-checkconf detects error in $lmdb ($n)"
-               $CHECKCONF $lmdb > checkconf.out$n 2>&1
-               if [ $? -eq 0 ]; then echo_i "failed"; ret=1; fi
+               { $CHECKCONF $lmdb > checkconf.out$n 2>&1; rc=$?; } || true
+               if [ $rc -eq 0 ]; then echo_i "failed"; ret=1; fi
        fi
        status=$((status + ret))
 done
@@ -202,15 +201,15 @@ options {
     $field 0;
 };
 EOF
-    $CHECKCONF badzero.conf > checkconf.out$n.1 2>&1
-    [ $? -eq 1 ] || { echo_i "options $field failed" ; ret=1; }
+    { $CHECKCONF badzero.conf > checkconf.out$n.1 2>&1; rc=$?; } || true
+    [ $rc -eq 1 ] || { echo_i "options $field failed" ; ret=1; }
     cat > badzero.conf << EOF
 view dummy {
     $field 0;
 };
 EOF
-    $CHECKCONF badzero.conf > checkconf.out$n.2 2>&1
-    [ $? -eq 1 ] || { echo_i "view $field failed" ; ret=1; }
+    { $CHECKCONF badzero.conf > checkconf.out$n.2 2>&1; rc=$?; } || true
+    [ $rc -eq 1 ] || { echo_i "view $field failed" ; ret=1; }
     cat > badzero.conf << EOF
 options {
     $field 0;
@@ -218,8 +217,8 @@ options {
 view dummy {
 };
 EOF
-    $CHECKCONF badzero.conf > checkconf.out$n.3 2>&1
-    [ $? -eq 1 ] || { echo_i "options + view $field failed" ; ret=1; }
+    { $CHECKCONF badzero.conf > checkconf.out$n.3 2>&1; rc=$?; } || true
+    [ $rc -eq 1 ] || { echo_i "options + view $field failed" ; ret=1; }
     cat > badzero.conf << EOF
 zone dummy {
     type secondary;
@@ -227,8 +226,8 @@ zone dummy {
     $field 0;
 };
 EOF
-    $CHECKCONF badzero.conf > checkconf.out$n.4 2>&1
-    [ $? -eq 1 ] || { echo_i "zone $field failed" ; ret=1; }
+    { $CHECKCONF badzero.conf > checkconf.out$n.4 2>&1; rc=$?; } || true
+    [ $rc -eq 1 ] || { echo_i "zone $field failed" ; ret=1; }
 done
 if [ $ret -ne 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
index 1262a9a940ead56cd93c8ef0f324241a8507c46f..696f6c24541aabafd14bc720e553e97d802dbebf 100644 (file)
@@ -239,8 +239,7 @@ cat_d() {
 }
 
 digcomp() {
-    output=`$PERL $TOP_SRCDIR/bin/tests/system/digcomp.pl "$@"`
-    result=$?
+    { output=`$PERL $TOP_SRCDIR/bin/tests/system/digcomp.pl "$@"`; result=$?; } || true
     [ -n "$output" ] &&  { echo "digcomp failed:"; echo "$output"; } | cat_i
     return $result
 }
index 9a392d377d204620404cec11a66630aaf6a69822..39f6299e98851ee2590533ccf3aafa078d058671 100644 (file)
@@ -42,14 +42,13 @@ check_ttl_range() {
 
     case "$pos" in
     "3")
-    awk -v rrtype="$2" -v ttl="$3" '($4 == "IN" || $4 == "CLASS1" ) && $5 == rrtype { if ($3 <= ttl) { ok=1 } } END { exit(ok?0:1) }' < $file
+    { awk -v rrtype="$2" -v ttl="$3" '($4 == "IN" || $4 == "CLASS1" ) && $5 == rrtype { if ($3 <= ttl) { ok=1 } } END { exit(ok?0:1) }' < $file; result=$?; } || true
     ;;
     *)
-    awk -v rrtype="$2" -v ttl="$3" '($3 == "IN" || $3 == "CLASS1" ) && $4 == rrtype { if ($2 <= ttl) { ok=1 } } END { exit(ok?0:1) }' < $file
+    { awk -v rrtype="$2" -v ttl="$3" '($3 == "IN" || $3 == "CLASS1" ) && $4 == rrtype { if ($2 <= ttl) { ok=1 } } END { exit(ok?0:1) }' < $file; result=$?; } || true
     ;;
     esac
 
-   result=$?
    [ $result -eq 0 ] || echo_i "ttl check failed"
    return $result
 }
index 5e272ac1aceb1489fda8ee236f70eb3ab84c4be9..01d7924b86c6ff9ed3380ad017c42f517559a6e7 100644 (file)
@@ -83,8 +83,7 @@ israw0 () {
     < "$1" $PERL -e 'binmode STDIN;
                     read(STDIN, $input, 8);
                     ($style, $version) = unpack("NN", $input);
-                    exit 1 if ($style != 2 || $version != 0);'
-    return $?
+                    exit 1 if ($style != 2 || $version != 0);' || return $?
 }
 
 # check that a zone file is raw format, version 1
@@ -93,8 +92,7 @@ israw1 () {
     < "$1" $PERL -e 'binmode STDIN;
                     read(STDIN, $input, 8);
                      ($style, $version) = unpack("NN", $input);
-                     exit 1 if ($style != 2 || $version != 1);'
-    return $?
+                     exit 1 if ($style != 2 || $version != 1);' || return $?
 }
 
 # strip NS and RRSIG NS from input
@@ -113,8 +111,7 @@ check_secroots_layout () {
             /Start view/ { if (!empty) exit(1) }
             /Secure roots:/ { if (empty) exit(1) }
             /Negative trust anchors:/ { if (!empty) exit(1) }
-            { empty=0 }' $1
-       return $?
+            { empty=0 }' $1 || return $?
 }
 
 # Check that for a query against a validating resolver where the
@@ -2646,8 +2643,8 @@ if $PERL -e 'use Net::DNS;' 2>/dev/null
 then
     echo_i "running DNSSEC update test"
     ret=0
-    output=$($PERL dnssec_update_test.pl -s 10.53.0.3 -p "$PORT" dynamic.example.)
-    test "$?" -eq 0 || ret=1
+    { output=$($PERL dnssec_update_test.pl -s 10.53.0.3 -p "$PORT" dynamic.example.); rc=$?; } || true
+    test "$rc" -eq 0 || ret=1
     echo "$output" | cat_i
     [ $ret -eq 1 ] && status=1
 else
index 6034c830ff1769d0c9b11e20ea4d3475dafeca7d..c7965445d02e152b12a52175cdf5ad8a3846d52f 100644 (file)
@@ -42,8 +42,8 @@ for bad in bad-*.conf
 do
        ret=0
        echo_i "checking that named-checkconf detects error in $bad"
-       $CHECKCONF $bad > /dev/null 2>&1
-       if [ $? != 1 ]; then echo_i "failed"; ret=1; fi
+       { $CHECKCONF $bad > /dev/null 2>&1; rc=$?; } || true
+       if [ $rc != 1 ]; then echo_i "failed"; ret=1; fi
        status=$((status + ret))
 done
 
@@ -51,8 +51,8 @@ for good in good-*.conf
 do
        ret=0
        echo_i "checking that named-checkconf detects no error in $good"
-       $CHECKCONF $good > /dev/null 2>&1
-       if [ $? != 0 ]; then echo_i "failed"; ret=1; fi
+       { $CHECKCONF $good > /dev/null 2>&1; rc=$?; } || true
+       if [ $rc != 0 ]; then echo_i "failed"; ret=1; fi
        status=$((status + ret))
 done
 
index 59908ce4c39e6e24fa86adaa37790bcd392b5c02..3a84a30efa6745114f40656e02f1ff70d72d5b0f 100644 (file)
@@ -845,8 +845,7 @@ n=$((n + 1))
 echo_i "checking server quotas for both encrypted and unencrypted HTTP ($n)"
 ret=0
 if [ -x "$PYTHON" ]; then
-       BINDHOST="10.53.0.1" "$PYTHON" "$TOP_SRCDIR/bin/tests/system/doth/stress_http_quota.py"
-       ret=$?
+       BINDHOST="10.53.0.1" "$PYTHON" "$TOP_SRCDIR/bin/tests/system/doth/stress_http_quota.py" || ret=$?
 else
        echo_i "Python is not available. Skipping the test..."
 fi
index 594cb053b4da33352d89916ae104608b0496ce48..03c85a830448cbebf023db6820f2b68c6d0f960b 100644 (file)
@@ -93,8 +93,8 @@ idna_test() {
     echo_i "$description ($n)"
 
     ret=0
-    $DIGCMD $2 $3 > dig.out.$n 2>&1
-    if [ $? -ne 0 ]; then
+    { $DIGCMD $2 $3 > dig.out.$n 2>&1; rc=$?; } || true
+    if [ $rc -ne 0 ]; then
         echo_i "failed: dig command returned non-zero status"
         ret=1
     else
@@ -122,8 +122,8 @@ idna_fail() {
     echo_i "$description ($n)"
 
     ret=0
-    $DIGCMD $2 $3 > dig.out.$n 2>&1
-    if [ $? -eq 0 ]; then
+    { $DIGCMD $2 $3 > dig.out.$n 2>&1; rc=$?; } || true
+    if [ $rc -eq 0 ]; then
         echo_i "failed: dig command unexpectedly succeeded"
         ret=1
     fi
@@ -378,8 +378,7 @@ idna_disabled_test() {
 
 # Main test begins here
 
-$FEATURETEST --with-libidn2
-if [ $? -eq 0 ]; then
+if $FEATURETEST --with-libidn2; then
     idna_enabled_test
 else
     idna_disabled_test
index 423cfc64fe40e0d21192bbe70bb21a5988abedbf..b157d640c510fe51b22d59262d67b930727978dc 100755 (executable)
@@ -878,8 +878,8 @@ $RNDCCMD 10.53.0.7 retransfer $zone
 for i in 1 2 3 4 5 6 7 8 9 0
 do
        ret=1
-       grep "ns2.$zone. . 10 20 20 1814400 3600" ns7/named.run > /dev/null 2>&1
-       [ $? -eq 0 ] && ret=0 && break
+       { grep "ns2.$zone. . 10 20 20 1814400 3600" ns7/named.run > /dev/null 2>&1; rc=$?; } || true
+       [ $rc -eq 0 ] && ret=0 && break
        sleep 1
 done
 if [ $ret != 0 ]; then echo_i "failed"; fi
index 3c798bda9d5f900543af7bf36b1a272d5789be5e..a4a604f89739c9a707f9ebc9d3c78ef189cff54e 100644 (file)
@@ -208,8 +208,8 @@ status=$((status+ret))
 n=$((n+1))
 echo_i "testing ixfr-from-differences option ($n)"
 # ns3 is primary; ns4 is secondary
-$CHECKZONE test. ns3/mytest.db > /dev/null 2>&1
-if [ $? -ne 0 ]
+{ $CHECKZONE test. ns3/mytest.db > /dev/null 2>&1; rc=$?; } || true
+if [ $rc -ne 0 ]
 then
     echo_i "named-checkzone returned failure on ns3/mytest.db"
 fi
index 1bcddd60dec9b5fc0d1c8d501abcdbd501418fa9..da9ec87ebf30793e87db056acad845d555dd834f 100755 (executable)
@@ -24,8 +24,7 @@ israw () {
     $PERL -e 'binmode STDIN;
              read(STDIN, $input, 8);
              ($style, $version) = unpack("NN", $input);
-             exit 1 if ($style != 2 || $version > 1);' < "$1"
-    return $?
+             exit 1 if ($style != 2 || $version > 1);' < "$1" || return $?
 }
 
 isfull () {
index 1d6f63084734b38aaef9841f7bad89846a122d0e..f8768a84c92ac940e28f54a16512601fbad186de 100644 (file)
@@ -32,8 +32,7 @@ cat dig.compdis.test  |grep -v ';;' |sort > dig.compdis.sorted.test
 # the compression disabled message should be at least twice as large as with
 # compression disabled, but the content should be the same
 echo_i "Checking if responses are identical other than in message size"
-diff dig.compdis.sorted.test dig.compen.sorted.test >/dev/null
-ret=$?
+{ diff dig.compdis.sorted.test dig.compen.sorted.test >/dev/null; ret=$?; } || true
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=$((status + ret))
 
index 9fefe34fb0a5f0125cb1fdd88aa55f1b53f8bce1..b8e476dda2845a1ef5a228bdf07b7f1821164866 100755 (executable)
@@ -765,13 +765,13 @@ echo_i "check command list ($n)"
 (
 while read cmd
 do
-    echo "$cmd" | $NSUPDATE  > /dev/null 2>&1
-    if test $? -gt 1 ; then
+    { echo "$cmd" | $NSUPDATE  > /dev/null 2>&1; rc=$?; } || true
+    if test $rc -gt 1 ; then
        echo_i "failed ($cmd)"
        ret=1
     fi
-    echo "$cmd " | $NSUPDATE  > /dev/null 2>&1
-    if test $? -gt 1 ; then
+    { echo "$cmd " | $NSUPDATE  > /dev/null 2>&1; rc=$?; } || true
+    if test $rc -gt 1 ; then
        echo_i "failed ($cmd)"
        ret=1
     fi
index 379a2c176659c856479c95a6a7641da65a6cedfd..2be9594debf538c3cf12d02a3a8d4c7183890df6 100644 (file)
@@ -519,8 +519,8 @@ do
        echo_i "testing rndc buffer size limits (size=${i}) ($n)"
        ret=0
        $RNDC -s 10.53.0.4 -p ${EXTRAPORT6} -c ns4/key6.conf testgen ${i} 2>&1 > rndc.out.$i.test$n || ret=1
-       actual_size=`$GENCHECK rndc.out.$i.test$n`
-       if [ "$?" = "0" ]; then
+       { actual_size=`$GENCHECK rndc.out.$i.test$n`; rc=$?; } || true
+       if [ "$rc" = "0" ]; then
            expected_size=$((i+1))
            if [ $actual_size != $expected_size ]; then ret=1; fi
        else
index 62a5f1ee8fdafed866152f9a2b8e55e61f7a9110..052d62c1293aa6042647465170f67c1b201110a1 100644 (file)
@@ -238,8 +238,7 @@ for mode in native dnsrps; do
     for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 \
             17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
     do
-      run_query 4$n $i
-      c=`expr $c + $?`
+      run_query 4$n $i || c=$((c + 1))
     done
     skipped=$((33-c))
     if [ $skipped != $ni ]; then
index 99650619b1f356651ea62714590237235d662343..ac55f250a8e6c5a3ef5708d6d6389ee2d184942b 100644 (file)
@@ -225,8 +225,8 @@ n=$((n+1))
 echo_i "verifying that named switches UID ($n)"
 if [ "$(id -u)" -eq 0 ]; then
     ret=0
-    TEMP_NAMED_DIR=$(mktemp -d "$(pwd)/ns2/tmp.XXXXXXXX")
-    if [ "$?" -eq 0 ]; then
+    { TEMP_NAMED_DIR=$(mktemp -d "$(pwd)/ns2/tmp.XXXXXXXX"); rc=$?; } || true
+    if [ "$rc" -eq 0 ]; then
        copy_setports ns2/named-alt9.conf.in "${TEMP_NAMED_DIR}/named-alt9.conf"
        chown -R nobody: "${TEMP_NAMED_DIR}"
        chmod 0700 "${TEMP_NAMED_DIR}"
index aba4a6976b74ddac68cdbb8c6838bfe95c8ec63c..1e3a28da169005a3e3a693bc560978495620afa8 100644 (file)
@@ -59,8 +59,7 @@ getzones() {
     esac
     file=`$PERL fetch.pl -p ${EXTRAPORT1} $path`
     cp $file $file.$1.$3
-    $PERL zones-${1}.pl $file $2 2>/dev/null | sort > zones.out.$3
-    result=$?
+    { $PERL zones-${1}.pl $file $2 2>/dev/null | sort > zones.out.$3; result=$?; } || true
     return $result
 }
 
index 5730a801b96ba225b413cdc984dc48ecba88d56d..c96871cd8e3540513589324576b4f3533836d5f0 100644 (file)
@@ -16,7 +16,8 @@
 status=0
 
 checkout() {
-       case $? in
+       rc=$1
+       case $rc in
        0) : ok ;;
        *) echo_i "failed"
           status=$((status + 1))
@@ -36,12 +37,12 @@ algo=1 flags=0 iters=12 salt="aabbccdd"
 while  read name hash
 do
        echo_i "checking $NSEC3HASH $name"
-       out=`$NSEC3HASH $salt $algo $iters $name`
-       checkout
+       { out=`$NSEC3HASH $salt $algo $iters $name`; rc=$?; } || true
+       checkout $rc
 
        echo_i "checking $NSEC3HASH -r $name"
-       out=`$NSEC3HASH -r $algo $flags $iters $salt $name`
-       checkout
+       { out=`$NSEC3HASH -r $algo $flags $iters $salt $name`; rc=$?; } || true
+       checkout $rc
 
 done <<EOF
 *.w.example R53BQ7CC2UVMUBFU5OCMM6PERS9TK9EN
@@ -60,45 +61,47 @@ EOF
 
 # test empty salt
 checkempty() {
-       hash=CK0POJMG874LJREF7EFN8430QVIT8BSM checkout &&
-       hash=- checkout
+       rc=$1
+       hash=CK0POJMG874LJREF7EFN8430QVIT8BSM checkout $rc &&
+       hash=- checkout $rc
 }
 name=com algo=1 flags=1 iters=0
 echo_i "checking $NSEC3HASH '' $name"
-out=`$NSEC3HASH '' $algo $iters $name`
-checkempty
+{ out=`$NSEC3HASH '' $algo $iters $name`; rc=$?; } || true
+checkempty $rc
 echo_i "checking $NSEC3HASH - $name"
-out=`$NSEC3HASH - $algo $iters $name`
-checkempty
+{ out=`$NSEC3HASH - $algo $iters $name`; rc=$?; } || true
+checkempty $rc
 echo_i "checking $NSEC3HASH -- '' $name"
-out=`$NSEC3HASH -- '' $algo $iters $name`
-checkempty
+{ out=`$NSEC3HASH -- '' $algo $iters $name`; rc=$?; } || true
+checkempty $rc
 echo_i "checking $NSEC3HASH -- - $name"
-out=`$NSEC3HASH -- - $algo $iters $name`
-checkempty
+{ out=`$NSEC3HASH -- - $algo $iters $name`; rc=$?; } || true
+checkempty $rc
 echo_i "checking $NSEC3HASH -r '' $name"
-out=`$NSEC3HASH -r $algo $flags $iters '' $name`
-checkempty
+{ out=`$NSEC3HASH -r $algo $flags $iters '' $name`; rc=$?; } || true
+checkempty $rc
 echo_i "checking $NSEC3HASH -r - $name"
-out=`$NSEC3HASH -r $algo $flags $iters - $name`
-checkempty
+{ out=`$NSEC3HASH -r $algo $flags $iters - $name`; rc=$?; } || true
+checkempty $rc
 
 checkfail() {
-       case $? in
+       rc=$1
+       case $rc in
        0) echo_i "failed to fail"
           status=$((status + 1))
           return 1 ;;
        esac
 }
 echo_i "checking $NSEC3HASH missing args"
-out=`$NSEC3HASH 00 1 0 2>&1`
-checkfail
+{ out=`$NSEC3HASH 00 1 0 2>&1`; rc=$?; } || true
+checkfail $rc
 echo_i "checking $NSEC3HASH extra args"
-out=`$NSEC3HASH 00 1 0 two names 2>&1`
-checkfail
+{ out=`$NSEC3HASH 00 1 0 two names 2>&1`; rc=$?; } || true
+checkfail $rc
 echo_i "checking $NSEC3HASH bad option"
-out=`$NSEC3HASH -? 2>&1`
-checkfail
+{ out=`$NSEC3HASH -? 2>&1`; rc=$?; } || true
+checkfail $rc
 
 echo_i "exit status: $status"
 [ $status -eq 0 ] || exit 1