summary refs log tree commit diff
path: root/bin/cash/tests/parameters/positional2.0
blob: 51c9b566bcf318228daf6d9529a0a7b516087f5e (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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# $FreeBSD: releng/12.0/bin/sh/tests/parameters/positional2.0 228873 2011-12-25 13:24:48Z jilles $

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 -- a b; set -- p$@q'		'2|pa|bq'
testcase 'set -- a b; set -- $@q'		'2|a|bq'
testcase 'set -- a b; set -- p$@'		'2|pa|b'
testcase 'set -- a b; set -- p$@q'		'2|pa|bq'
testcase 'set -- a b; set -- $@q'		'2|a|bq'
testcase 'set -- a b; set -- p$@'		'2|pa|b'
testcase 'set -- a b; set -- p$*q'		'2|pa|bq'
testcase 'set -- a b; set -- $*q'		'2|a|bq'
testcase 'set -- a b; set -- p$*'		'2|pa|b'
testcase 'set -- a b; set -- p$*q'		'2|pa|bq'
testcase 'set -- a b; set -- $*q'		'2|a|bq'
testcase 'set -- a b; set -- p$*'		'2|pa|b'
testcase 'set -- a b; set -- "p$@q"'		'2|pa|bq'
testcase 'set -- a b; set -- "$@q"'		'2|a|bq'
testcase 'set -- a b; set -- "p$@"'		'2|pa|b'
testcase 'set -- a b; set -- p"$@"q'		'2|pa|bq'
testcase 'set -- a b; set -- "$@"q'		'2|a|bq'
testcase 'set -- a b; set -- p"$@"'		'2|pa|b'
testcase 'set -- "" a b; set -- "p$@q"'		'3|p|a|bq'
testcase 'set -- "" a b; set -- "$@q"'		'3||a|bq'
testcase 'set -- "" a b; set -- "p$@"'		'3|p|a|b'
testcase 'set -- "" a b; set -- p"$@"q'		'3|p|a|bq'
testcase 'set -- "" a b; set -- "$@"q'		'3||a|bq'
testcase 'set -- "" a b; set -- p"$@"'		'3|p|a|b'
testcase 'set -- a; set -- p$@q'		'1|paq'
testcase 'set -- a; set -- $@q'			'1|aq'
testcase 'set -- a; set -- p$@'			'1|pa'
testcase 'set -- a; set -- p$@q'		'1|paq'
testcase 'set -- a; set -- $@q'			'1|aq'
testcase 'set -- a; set -- p$@'			'1|pa'
testcase 'set -- a; set -- p$*q'		'1|paq'
testcase 'set -- a; set -- $*q'			'1|aq'
testcase 'set -- a; set -- p$*'			'1|pa'
testcase 'set -- a; set -- p$*q'		'1|paq'
testcase 'set -- a; set -- $*q'			'1|aq'
testcase 'set -- a; set -- p$*'			'1|pa'
testcase 'set -- a; set -- "p$@q"'		'1|paq'
testcase 'set -- a; set -- "$@q"'		'1|aq'
testcase 'set -- a; set -- "p$@"'		'1|pa'
testcase 'set -- a; set -- p"$@"q'		'1|paq'
testcase 'set -- a; set -- "$@"q'		'1|aq'
testcase 'set -- a; set -- p"$@"'		'1|pa'

test "x$failures" = x