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