redo-sh: downgrade failures that affected dash; add a bash warning.
I feel a little dirty doing this, but the way the code was before, redo almost always picked bash as the shell. bash is way too overpowered and this led to bashisms in do scripts unnecessarily. The two failures in dash are things that I would really like to have, but they haven't materialized after 6 years, so I guess we should be realistic. To appropriately penalize bash for asking for trouble, I added a warning about [ 1 == 1 ] syntax being valid (as opposed to the POSIX correct [ 1 = 1 ]). This allows dash to be selected ahead of bash. I also moved 'sh' to the end of the list, because although it's the weakest shell on some systems, on other systems it's just bash. And I put zsh in front of bash, because fewer people have zsh and we want them to test zsh.
This commit is contained in:
parent
9354e78871
commit
0d174f92c3
3 changed files with 19 additions and 7 deletions
|
|
@ -11,8 +11,8 @@ WARN=
|
||||||
# powerful ones. We want weaker shells to take precedence, as long as they
|
# 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
|
# pass the tests, because weaker shells are more likely to point out when you
|
||||||
# use some non-portable feature.
|
# use some non-portable feature.
|
||||||
for sh in dash sh /usr/xpg4/bin/sh ash posh mksh ksh ksh88 ksh93 pdksh \
|
for sh in dash /usr/xpg4/bin/sh ash posh mksh ksh ksh88 ksh93 pdksh \
|
||||||
bash zsh busybox; do
|
zsh bash busybox sh; do
|
||||||
printf "%-30s" "Testing $sh..."
|
printf "%-30s" "Testing $sh..."
|
||||||
FOUND=`which $sh 2>/dev/null` || { echo "missing"; continue; }
|
FOUND=`which $sh 2>/dev/null` || { echo "missing"; continue; }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
# call this as ". ./dotparams.od a b" from shelltest.od
|
# call this as ". ./dotparams.od a b" from shelltest.od
|
||||||
[ "$1" = a ] && [ "$2" = b ] && [ "$#" = 2 ] || fail 115
|
[ "$1" = a ] && [ "$2" = b ] && [ "$#" = 2 ] || warn 115
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,10 @@ f3=$(quiet_stderr eval ': ${f3:=
|
||||||
g3="
|
g3="
|
||||||
a
|
a
|
||||||
b"
|
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
|
# Note: assignment of $@ in this context is unspecified (what do you even expect
|
||||||
|
|
@ -371,11 +374,20 @@ false
|
||||||
. ./nothing.od || warn 114
|
. ./nothing.od || warn 114
|
||||||
|
|
||||||
# this is actually a bash/kshism, but is allowed by POSIX: the parameters to
|
# 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
|
# '.' should be passed to the sub-script.
|
||||||
# require it, even though it's not strictly required by POSIX.
|
#
|
||||||
|
# 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
|
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
|
[ "$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
|
[ -n "$FAIL" ] || exit 40
|
||||||
exit $FAIL
|
exit $FAIL
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue