Add regression tests for /bin/sh.
[dragonfly.git] / tools / regression / bin / sh / expansion / plus-minus6.0
1 # $FreeBSD: src/tools/regression/bin/sh/expansion/plus-minus6.0,v 1.1 2010/10/29 13:42:18 jilles Exp $
2
3 failures=0
4 unset LC_ALL
5 export LC_CTYPE=en_US.ISO8859-1
6 nl='
7 '
8 i=1
9 set -f
10 while [ "$i" -le 255 ]; do
11         # A different byte still in the range 1..255.
12         i2=$((i^2+(i==2)))
13         # Add a character to work around command substitution's removal of
14         # final newlines, then remove it again.
15         c=$(printf \\"$(printf %o@ "$i")")
16         c=${c%@}
17         c2=$(printf \\"$(printf %o@ "$i2")")
18         c2=${c2%@}
19         case $c in
20                 [\'$nl'$}();&|\"`']) c=M
21         esac
22         case $c2 in
23                 [\'$nl'$}();&|\"`']) c2=N
24         esac
25         IFS=$c
26         command eval "set -- \${\$+$c2$c$c2$c$c2}"
27         if [ "$#" -ne 3 ] || [ "$1" != "$c2" ] || [ "$2" != "$c2" ] ||
28             [ "$3" != "$c2" ]; then
29                 echo "Bad results for separator $i (word $i2)" >&2
30                 : $((failures += 1))
31         fi
32         i=$((i+1))
33 done
34 exit $((failures > 0))