diff --git a/t/shelltest.do b/t/shelltest.do index 7a7d6fc..2ec9277 100644 --- a/t/shelltest.do +++ b/t/shelltest.do @@ -1,4 +1,5 @@ set +e +export SHELLTEST_QUIET=1 ( . ./shelltest.od ) RV=$? case $RV in diff --git a/t/shelltest.od b/t/shelltest.od index ba9adec..c9059c6 100644 --- a/t/shelltest.od +++ b/t/shelltest.od @@ -14,18 +14,30 @@ # exec >&2 set +e + FAIL= + fail() { echo " failed: $1" FAIL=41 } + warn() { echo " warning: $1" [ -n "$FAIL" ] || FAIL=42 } +quiet_stderr() +{ + if [ -n "$SHELLTEST_QUIET" ]; then + "$@" 2>/dev/null + else + "$@" + fi +} + name=foo.o.o ext=.o @@ -69,7 +81,7 @@ t1=$(n 1 2 3 4 5 6 7 8 9 xx yy) chicken1=`echo " $spacey" | sed s/a/./g` -chicken2="`echo " $spacey" | sed s/a/./g`" +chicken2="`quiet_stderr echo " $spacey" | sed s/a/./g`" chicken3=$(echo " $spacey" | sed s/a/./g) chicken4="$(echo " $spacey" | sed s/a/./g)" [ "$chicken1" = " this h.s * .nd sp.ces" ] || fail 11 @@ -92,7 +104,7 @@ out=$(echo ${f1:-foo} ${f2:-foo} ${g1:=foo} ${g2:=foo}) # quoting, which is apparently required by POSIX but not supported in some # shells. But to make ash/dash not abort the test script *entirely* when it # fails, we use the $() + eval nonsense. -f3=$(eval ': ${f3:= +f3=$(quiet_stderr eval ': ${f3:= a b }' && echo "$f3") @@ -176,10 +188,10 @@ c" # it check our syntax. # bob="a b *" -bob=$(eval 'export bob=$bob:hello'; echo "$bob") +bob=$(quiet_stderr eval 'export bob=$bob:hello'; echo "$bob") #[ "$bob" = "a b *:hello" ] || warn 46 bob="a b *" -nob=$(eval 'f() { local nob=$bob:hello; echo "$nob"; }'; f) +nob=$(eval 'f() { local nob=$bob:hello; echo "$nob"; }'; quiet_stderr f) #[ "$nob" = "a b *:hello" ] || warn 47 @@ -334,7 +346,7 @@ rm -f || fail 110 HOME="$PWD/space home dir" rm -rf "$HOME" mkdir "$HOME" - cd ~ || exit 1 + quiet_stderr cd ~ || exit 1 cd .. rmdir 'space home dir' ) || warn 111