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