diff --git a/redo-sh.do b/redo-sh.do index 0140e4d..468ddde 100644 --- a/redo-sh.do +++ b/redo-sh.do @@ -11,8 +11,8 @@ WARN= # powerful ones. We want weaker shells to take precedence, as long as they # pass the tests, because weaker shells are more likely to point out when you # use some non-portable feature. -for sh in dash sh /usr/xpg4/bin/sh ash posh mksh ksh ksh88 ksh93 pdksh \ - bash zsh busybox; do +for sh in dash /usr/xpg4/bin/sh ash posh mksh ksh ksh88 ksh93 pdksh \ + zsh bash busybox sh; do printf "%-30s" "Testing $sh..." FOUND=`which $sh 2>/dev/null` || { echo "missing"; continue; } diff --git a/t/dotparams.od b/t/dotparams.od index ab00bf4..36fa5f0 100644 --- a/t/dotparams.od +++ b/t/dotparams.od @@ -1,2 +1,2 @@ # call this as ". ./dotparams.od a b" from shelltest.od -[ "$1" = a ] && [ "$2" = b ] && [ "$#" = 2 ] || fail 115 +[ "$1" = a ] && [ "$2" = b ] && [ "$#" = 2 ] || warn 115 diff --git a/t/shelltest.od b/t/shelltest.od index c9059c6..1014032 100644 --- a/t/shelltest.od +++ b/t/shelltest.od @@ -111,7 +111,10 @@ f3=$(quiet_stderr eval ': ${f3:= g3=" a b" -[ "$f3" = "$g3" ] || fail 18 +# This is kind of a major problem, but rejecting dash and busybox sh because +# of this may cause more trouble than it's worth: people end up writing .do +# scripts with bashisms unnecessarily :( +[ "$f3" = "$g3" ] || warn 18 # Note: assignment of $@ in this context is unspecified (what do you even expect @@ -371,11 +374,20 @@ false . ./nothing.od || warn 114 # this is actually a bash/kshism, but is allowed by POSIX: the parameters to -# '.' should be passed to the sub-script. Because it's so useful, let's -# require it, even though it's not strictly required by POSIX. +# '.' should be passed to the sub-script. +# +# We used to require this, because it's so useful despite being optional in POSIX. +# But unfortunately, too many shells (including dash) can't do it, so we ended up +# always using bash, which leads people to write .do scripts with bashisms. set x y z -. ./dotparams.od a b || fail 115 +# dotparams.od might warn 115 +. ./dotparams.od a b || fail 117 [ "$1-$2-$3" = "x-y-z" ] || fail 116 +# Warn about the way bash allows '==' in its test command. +# This is the #1 bashism I've observed, and totally unnecessary, so let's +# dock it some points so it doesn't always end up as the primary shell. +[ 1 == 1 ] 2>/dev/null && warn 118 + [ -n "$FAIL" ] || exit 40 exit $FAIL