xref: /freebsd/bin/sh/tests/expansion/plus-minus4.0 (revision a03411e84728e9b267056fd31c7d1d9d1dc1b01e)
1
2# These may be a bit unclear in the POSIX spec or the proposed revisions,
3# and conflict with bash's interpretation, but I think ksh93's interpretation
4# makes most sense. In particular, it makes no sense to me that single-quotes
5# must match but are not removed.
6
7e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
8h='##'
9failures=''
10ok=''
11
12testcase() {
13	code="$1"
14	expected="$2"
15	oIFS="$IFS"
16	eval "$code"
17	IFS='|'
18	result="$#|$*"
19	IFS="$oIFS"
20	if [ "x$result" = "x$expected" ]; then
21		ok=x$ok
22	else
23		failures=x$failures
24		echo "For $code, expected $expected actual $result"
25	fi
26}
27
28testcase 'set -- ${e:-'"'"'}'"'"'}'		'1|}'
29testcase "set -- \${e:-\\'}"			"1|'"
30testcase "set -- \${e:-\\'\\'}"			"1|''"
31testcase "set -- \"\${e:-'}\""			"1|'"
32testcase "set -- \"\${e:-'}'}\""		"1|''}"
33testcase "set -- \"\${e:-''}\""			"1|''"
34testcase 'set -- ${e:-\a}'			'1|a'
35testcase 'set -- "${e:-\a}"'			'1|\a'
36
37test "x$failures" = x
38