xref: /freebsd/bin/sh/tests/expansion/ifs2.0 (revision d37eb51047221dc3322b34db1038ff3aa533883f)
1
2failures=0
3i=1
4set -f
5while [ "$i" -le 127 ]; do
6	# A different byte still in the range 1..127.
7	i2=$((i^2+(i==2)))
8	# Add a character to work around command substitution's removal of
9	# final newlines, then remove it again.
10	c=$(printf \\"$(printf %o@ "$i")")
11	c=${c%@}
12	c2=$(printf \\"$(printf %o@ "$i2")")
13	c2=${c2%@}
14	IFS=$c
15	set -- $c2$c$c2$c$c2
16	if [ "$#" -ne 3 ] || [ "$1" != "$c2" ] || [ "$2" != "$c2" ] ||
17	    [ "$3" != "$c2" ]; then
18		echo "Bad results for separator $i (word $i2)" >&2
19		: $((failures += 1))
20	fi
21	i=$((i+1))
22done
23exit $((failures > 0))
24