xref: /freebsd/bin/sh/tests/errors/assignment-error1.0 (revision f4b37ed0f8b307b1f3f0f630ca725d68f1dff30d)
1# $FreeBSD$
2IFS=,
3
4SPECIAL="break,\
5	:,\
6	continue,\
7	. /dev/null,\
8	eval,\
9	exec,\
10	export -p,\
11	readonly -p,\
12	set,\
13	shift,\
14	times,\
15	trap,\
16	unset foo"
17
18# If there is no command word, the shell must abort on an assignment error.
19${SH} -c "readonly a=0; a=2; exit 0" 2>/dev/null && exit 1
20
21# Special built-in utilities must abort on an assignment error.
22set -- ${SPECIAL}
23for cmd in "$@"
24do
25	${SH} -c "readonly a=0; a=2 ${cmd}; exit 0" 2>/dev/null && exit 1
26done
27
28# Other utilities must not abort; we currently still execute them.
29${SH} -c 'readonly a=0; a=1 true; exit $a' 2>/dev/null || exit 1
30${SH} -c 'readonly a=0; a=1 command :; exit $a' 2>/dev/null || exit 1
31