2010-12-21 04:19:50 -08:00
|
|
|
exec >&2
|
|
|
|
|
redo-ifchange t/shelltest.od
|
|
|
|
|
|
|
|
|
|
rm -rf $1.new $1/sh
|
|
|
|
|
mkdir $1.new
|
|
|
|
|
|
|
|
|
|
GOOD=
|
|
|
|
|
WARN=
|
|
|
|
|
|
2011-01-19 13:52:02 -08:00
|
|
|
for sh in dash sh ash mksh ksh ksh88 ksh93 pdksh bash zsh busybox; do
|
2010-12-21 04:19:50 -08:00
|
|
|
printf "Testing %s... " "$sh"
|
2011-01-02 11:49:51 -08:00
|
|
|
FOUND=`which $sh 2>/dev/null` || { echo "missing"; continue; }
|
2010-12-21 04:19:50 -08:00
|
|
|
|
2011-01-02 11:49:34 -08:00
|
|
|
# It's important for the file to actually be named 'sh'. Some
|
|
|
|
|
# shells (like bash and zsh) only go into POSIX-compatible mode if
|
|
|
|
|
# they have that name. If they're not in POSIX-compatible mode,
|
|
|
|
|
# they'll fail the test.
|
2010-12-21 04:19:50 -08:00
|
|
|
rm -f $1.new/sh
|
|
|
|
|
ln -s $FOUND $1.new/sh
|
|
|
|
|
|
|
|
|
|
set +e
|
|
|
|
|
( cd t && ../$1.new/sh shelltest.od >/dev/null 2>&1 )
|
|
|
|
|
RV=$?
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
|
|
case $RV in
|
2011-01-02 12:00:37 -08:00
|
|
|
0) echo "good"; [ -n "$GOOD" ] || GOOD=$FOUND ;;
|
2010-12-21 04:19:50 -08:00
|
|
|
42) echo "warnings"; [ -n "$WARN" ] || WARN=$FOUND ;;
|
|
|
|
|
*) echo "failed" ;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
rm -rf $1 $1.new $3
|
|
|
|
|
|
|
|
|
|
if [ -n "$GOOD" ]; then
|
|
|
|
|
echo "Selected perfect shell: $GOOD"
|
|
|
|
|
mkdir $3
|
|
|
|
|
ln -s $GOOD $3/sh
|
|
|
|
|
elif [ -n "$WARN" ]; then
|
|
|
|
|
echo "Selected mostly good shell: $WARN"
|
|
|
|
|
mkdir $3
|
|
|
|
|
ln -s $WARN $3/sh
|
|
|
|
|
else
|
|
|
|
|
echo "No good shells found! Maybe install dash, bash, or zsh."
|
|
|
|
|
exit 1
|
|
|
|
|
fi
|