1#! /bin/sh 2# sh.test - check that we haven't forgotten a `test' command 3 4# Test script header. 5need_prefix=no 6if test -z "$srcdir"; then 7 srcdir=`echo "$0" | sed 's%/[^/]*$%%'` 8 test "$srcdir" = "$0" && srcdir=. 9 test "${VERBOSE+set}" != "set" && VERBOSE=yes 10fi 11. $srcdir/defs || exit 1 12 13# Check all the "portable" shell scripts. 14status=0 15scripts="$srcdir/../ltmain.sh" 16 17# Check for bad binary operators. 18if $EGREP -n -e "if[ ]+[\"']?\\$.*(=|-[lg][te]|-eq|-ne)" $scripts; then 19 echo "use \`if test \$something =' instead of \`if \$something ='" 20 status=1 21fi 22 23# Check for bad unary operators. 24if $EGREP -n -e 'if[ ]+-' $scripts; then 25 echo "use \`if test -X' instead of \`if -X'" 26 status=1 27fi 28 29# Check for using `[' instead of `test'. 30if $EGREP -n -e 'if[ ]+\[' $scripts; then 31 echo "use \`if test' instead of \`if ['" 32 status=1 33fi 34 35if $EGREP -n -e 'test[ ]+(![ ])?(-.[ ]+)?"?[.,_x]' $scripts; then 36 echo "use \`test \"X...\"' instead of \`test \"x...\"'" 37 status=1 38fi 39 40# Check for using test X... instead of test "X... 41if $EGREP -n -e 'test[ ]+(![ ])?(-.[ ]+)?X' $scripts; then 42 echo "use \`test \"X...\"' instead of \`test X'" 43 status=1 44fi 45 46# Check for using test $... instead of test "$... 47if $EGREP -n -e 'test[ ]+(![ ])?(-.[ ]+)?X?\$' $scripts; then 48 echo "use \`test \"\$...\"' instead of \`test \$'" 49 status=1 50fi 51 52# Never use test -e. 53if $EGREP -n -e 'test[ ]+(![ ])?-e' $scripts; then 54 echo "use \`test -f' instead of \`test -e'" 55 status=1 56fi 57 58# Check for problems with variable assignments. 59if $EGREP -n -e '[^ ]=[^ ].*(break|continue)' $scripts; then 60 echo "assignments on the same line as a \`break' or \`continue' may have no effect" 61 status=1 62fi 63 64# Check for uses of Xsed without corresponding echo "X 65if $EGREP -n -e '\$Xsed' $scripts | $EGREP -v -n -e '\$echo \\*"X'; then 66 echo "occurrences of \`\$Xsed\' without \`echo \"X\' on the same line" 67 status=1 68fi 69 70# Check for quotes within backquotes within quotes "`"bar"`" 71if $EGREP -n -e '"[^`"]*`[^"`]*"[^"`]*".*`[^`"]*"' $scripts | \ 72 $EGREP -v "### testsuite: skip nested quoting test$"; then 73 echo "nested quotes are dangerous" 74 status=1 75fi 76 77for s in "$srcdir/../libtool.m4" 78do 79 if $SED -n '/case \$cc_basename in/,/esac/ { 80 /^[ ]*[a-zA-Z][a-zA-Z0-9+]*[^*][ ]*)/p 81 };' $s | $EGREP .; then 82 echo "\$cc_basename matches should include a trailing \`*' in $s." 83 status=$EXIT_FAILURE 84 fi 85done 86 87exit $status 88