xref: /freebsd/bin/sh/tests/builtins/read5.0 (revision 6b129086dcee14496517fae085b448e3edc69bc7)
1# $FreeBSD$
2
3unset LC_ALL
4LC_CTYPE=en_US.ISO8859-1
5export LC_CTYPE
6
7# Note: the first and last characters are not whitespace.
8# Exclude backslash and newline.
9bad1=`printf %03o \'\\\\`
10bad2=`printf %03o \''
11'`
12e=
13for i in 0 1 2 3; do
14	for j in 0 1 2 3 4 5 6 7; do
15		for k in 0 1 2 3 4 5 6 7; do
16			case $i$j$k in
17			000|$bad1|$bad2) continue ;;
18			esac
19			e="$e\\$i$j$k"
20		done
21	done
22done
23e=`printf "$e"`
24[ "${#e}" = 253 ] || echo length bad
25
26r1=`printf '%s\n' "$e" | { read -r x; printf '%s' "$x"; }`
27[ "$r1" = "$e" ] || echo "read with -r bad"
28r2=`printf '%s\n' "$e" | { read x; printf '%s' "$x"; }`
29[ "$r2" = "$e" ] || echo "read without -r bad 1"
30IFS=
31r3=`printf '%s\n' "$e" | { read x; printf '%s' "$x"; }`
32[ "$r3" = "$e" ] || echo "read without -r bad 2"
33