File: sh.test

package info (click to toggle)
libtool 1.5.6-6
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 10,444 kB
  • ctags: 896
  • sloc: sh: 10,215; ansic: 4,323; makefile: 804; cpp: 91; fortran: 19
file content (77 lines) | stat: -rwxr-xr-x 2,162 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#! /bin/sh
# sh.test - check that we haven't forgotten a `test' command

# Test script header.
need_prefix=no
if test -z "$srcdir"; then
  srcdir=`echo "$0" | sed 's%/[^/]*$%%'`
  test "$srcdir" = "$0" && srcdir=.
  test "${VERBOSE+set}" != "set" && VERBOSE=yes
fi
. $srcdir/defs || exit 1

# Check all the "portable" shell scripts.
status=0
scripts="$srcdir/../ltmain.sh"

# Check for bad binary operators.
if $EGREP -n -e "if[ 	]+[\"']?\\$.*(=|-[lg][te]|-eq|-ne)" $scripts; then
  echo "use \`if test \$something =' instead of \`if \$something ='"
  status=1
fi

# Check for bad unary operators.
if $EGREP -n -e 'if[ 	]+-' $scripts; then
  echo "use \`if test -X' instead of \`if -X'"
  status=1
fi

# Check for using `[' instead of `test'.
if $EGREP -n -e 'if[ 	]+\[' $scripts; then
  echo "use \`if test' instead of \`if ['"
  status=1
fi

if $EGREP -n -e 'test[ 	]+(![ 	])?(-.[ 	]+)?"?[.,_x]' $scripts; then
  echo "use \`test \"X...\"' instead of \`test \"x...\"'"
  status=1
fi

# Check for using test X... instead of test "X...
if $EGREP -n -e 'test[ 	]+(![ 	])?(-.[ 	]+)?X' $scripts; then
  echo "use \`test \"X...\"' instead of \`test X'"
  status=1
fi

# Check for using test $... instead of test "$...
if $EGREP -n -e 'test[ 	]+(![ 	])?(-.[ 	]+)?X?\$' $scripts; then
  echo "use \`test \"\$...\"' instead of \`test \$'"
  status=1
fi

# Never use test -e.
if $EGREP -n -e 'test[ 	]+(![ 	])?-e' $scripts; then
  echo "use \`test -f' instead of \`test -e'"
  status=1
fi

# Check for problems with variable assignments.
if $EGREP -n -e '[^	 ]=[^	 ].*(break|continue)' $scripts; then
  echo "assignments on the same line as a \`break' or \`continue' may have no effect"
  status=1
fi

# Check for uses of Xsed without corresponding echo "X
if $EGREP -n -e '\$Xsed' $scripts | $EGREP -v -n -e '\$echo \\*"X'; then
  echo "occurrences of \`\$Xsed\' without \`echo \"X\' on the same line"
  status=1
fi

# Check for quotes within backquotes within quotes "`"bar"`"
if $EGREP -n -e '"[^`"]*`[^"`]*"[^"`]*".*`[^`"]*"' $scripts | \
   $EGREP -v "### testsuite: skip nested quoting test$"; then
  echo "nested quotes are dangerous"
  status=1
fi

exit $status