summary refs log tree commit diff
path: root/bin/cash/tests/expansion/plus-minus5.0
blob: c3b97570a9703f9c0f00017561aa8f1177f33455 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# $FreeBSD: releng/12.0/bin/sh/tests/expansion/plus-minus5.0 214492 2010-10-28 22:34:49Z jilles $

e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
h='##'
failures=''
ok=''

testcase() {
	code="$1"
	expected="$2"
	oIFS="$IFS"
	eval "$code"
	IFS='|'
	result="$#|$*"
	IFS="$oIFS"
	if [ "x$result" = "x$expected" ]; then
		ok=x$ok
	else
		failures=x$failures
		echo "For $code, expected $expected actual $result"
	fi
}

testcase 'set -- ${e:-"{x}"}'			'1|{x}'
testcase 'set -- "${e:-"{x}"}"'			'1|{x}'
testcase 'set -- ${h+"{x}"}'			'1|{x}'
testcase 'set -- "${h+"{x}"}"'			'1|{x}'
testcase 'set -- ${h:-"{x}"}'			'1|##'
testcase 'set -- "${h:-"{x}"}"'			'1|##'

test "x$failures" = x