shelltest.od: warning 84 (W84) triggered on *all* shells, not just posh.

I must have changed this at the last minute when adding it, but I don't
know why.  We were redefining f4() inside a subshell, so it never
applied to the parent shell, so it was always considered a failure.
But that's not what we were supposed to be testing.

This is just supposed to be a test of the really rare syntax of
defining a function without enclosing braces, which only fails on posh,
as far as I've seen.
This commit is contained in:
Avery Pennarun 2019-03-03 20:53:47 -05:00
commit 7895c947d5

View file

@ -323,8 +323,8 @@ foo=`exit 1`; [ "$?" != 0 ] || fail 72
f1() { echo 1; } f1() { echo 1; }
f2(){ echo 2;} f2(){ echo 2;}
f3()(echo 3) f3()(echo 3)
f4() { :; } f4() { :; } # Note: redefined on next line
: $(quiet_stderr eval 'f4()if true; then echo 4; fi') quiet_stderr eval 'f4()if true; then echo 4; fi'
f5() ( exit 5 ) f5() ( exit 5 )
[ "$(f1)" = 1 ] || fail 81 [ "$(f1)" = 1 ] || fail 81
[ "$(f2)" = 2 ] || fail 82 [ "$(f2)" = 2 ] || fail 82
@ -499,7 +499,7 @@ false
# so we ended up always using bash, which leads people to write .do scripts # so we ended up always using bash, which leads people to write .do scripts
# with bashisms. # with bashisms.
set x y z set x y z
# dotparams.od might warn 115 # dotparams.od might warn 115, but should never return nonzero
. ./dotparams.od a b || fail 117 . ./dotparams.od a b || fail 117
[ "$1-$2-$3" = "x-y-z" ] || fail 116 [ "$1-$2-$3" = "x-y-z" ] || fail 116
@ -508,7 +508,7 @@ set x y z
# dock it some points so it doesn't always end up as the primary shell. # dock it some points so it doesn't always end up as the primary shell.
[ 1 == 1 ] 2>/dev/null && warn 118 [ 1 == 1 ] 2>/dev/null && warn 118
# Some shells apparently don't support left padding in printf # Some shells or OSes apparently don't support left padding in printf
x=$(printf "a%-5sc" "b") x=$(printf "a%-5sc" "b")
[ "$x" = "ab c" ] || warn 119 [ "$x" = "ab c" ] || warn 119