1# $FreeBSD: head/bin/sh/tests/expansion/plus-minus6.0 214512 2010-10-29 13:42:18Z jilles $
2
3failures=0
4unset LC_ALL
5export LC_CTYPE=en_US.ISO8859-1
6nl='
7'
8i=1
9set -f
10while [ "$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))
33done
34exit $((failures > 0))
35