xref: /src/bin/sh/tests/errors/assignment-error1.0 (revision d0b2dbfa0ecf2bbc9709efc5e20baf8e4b44bbbf)
145249f15SJilles TjoelkerIFS=,
245249f15SJilles Tjoelker
345249f15SJilles TjoelkerSPECIAL="break,\
445249f15SJilles Tjoelker	:,\
545249f15SJilles Tjoelker	continue,\
645249f15SJilles Tjoelker	. /dev/null,\
745249f15SJilles Tjoelker	eval,\
845249f15SJilles Tjoelker	exec,\
945249f15SJilles Tjoelker	export -p,\
1045249f15SJilles Tjoelker	readonly -p,\
1145249f15SJilles Tjoelker	set,\
1245249f15SJilles Tjoelker	shift,\
1345249f15SJilles Tjoelker	times,\
1445249f15SJilles Tjoelker	trap,\
1545249f15SJilles Tjoelker	unset foo"
1645249f15SJilles Tjoelker
1745249f15SJilles Tjoelker# If there is no command word, the shell must abort on an assignment error.
18*f3bf9b7aSDavid E. O'Brien${SH} -c "readonly a=0; a=2; exit 0" 2>/dev/null && exit 1
1945249f15SJilles Tjoelker
2045249f15SJilles Tjoelker# Special built-in utilities must abort on an assignment error.
2145249f15SJilles Tjoelkerset -- ${SPECIAL}
2245249f15SJilles Tjoelkerfor cmd in "$@"
2345249f15SJilles Tjoelkerdo
24*f3bf9b7aSDavid E. O'Brien	${SH} -c "readonly a=0; a=2 ${cmd}; exit 0" 2>/dev/null && exit 1
2545249f15SJilles Tjoelkerdone
2645249f15SJilles Tjoelker
2745249f15SJilles Tjoelker# Other utilities must not abort; we currently still execute them.
28*f3bf9b7aSDavid E. O'Brien${SH} -c 'readonly a=0; a=1 true; exit $a' 2>/dev/null || exit 1
29*f3bf9b7aSDavid E. O'Brien${SH} -c 'readonly a=0; a=1 command :; exit $a' 2>/dev/null || exit 1
30