xref: /freebsd/bin/sh/tests/parameters/positional2.0 (revision 0b3105a37d7adcadcb720112fed4dc4e8040be99)
1# $FreeBSD$
2
3failures=''
4ok=''
5
6testcase() {
7	code="$1"
8	expected="$2"
9	oIFS="$IFS"
10	eval "$code"
11	IFS='|'
12	result="$#|$*"
13	IFS="$oIFS"
14	if [ "x$result" = "x$expected" ]; then
15		ok=x$ok
16	else
17		failures=x$failures
18		echo "For $code, expected $expected actual $result"
19	fi
20}
21
22testcase 'set -- a b; set -- p$@q'		'2|pa|bq'
23testcase 'set -- a b; set -- $@q'		'2|a|bq'
24testcase 'set -- a b; set -- p$@'		'2|pa|b'
25testcase 'set -- a b; set -- p$@q'		'2|pa|bq'
26testcase 'set -- a b; set -- $@q'		'2|a|bq'
27testcase 'set -- a b; set -- p$@'		'2|pa|b'
28testcase 'set -- a b; set -- p$*q'		'2|pa|bq'
29testcase 'set -- a b; set -- $*q'		'2|a|bq'
30testcase 'set -- a b; set -- p$*'		'2|pa|b'
31testcase 'set -- a b; set -- p$*q'		'2|pa|bq'
32testcase 'set -- a b; set -- $*q'		'2|a|bq'
33testcase 'set -- a b; set -- p$*'		'2|pa|b'
34testcase 'set -- a b; set -- "p$@q"'		'2|pa|bq'
35testcase 'set -- a b; set -- "$@q"'		'2|a|bq'
36testcase 'set -- a b; set -- "p$@"'		'2|pa|b'
37testcase 'set -- a b; set -- p"$@"q'		'2|pa|bq'
38testcase 'set -- a b; set -- "$@"q'		'2|a|bq'
39testcase 'set -- a b; set -- p"$@"'		'2|pa|b'
40testcase 'set -- "" a b; set -- "p$@q"'		'3|p|a|bq'
41testcase 'set -- "" a b; set -- "$@q"'		'3||a|bq'
42testcase 'set -- "" a b; set -- "p$@"'		'3|p|a|b'
43testcase 'set -- "" a b; set -- p"$@"q'		'3|p|a|bq'
44testcase 'set -- "" a b; set -- "$@"q'		'3||a|bq'
45testcase 'set -- "" a b; set -- p"$@"'		'3|p|a|b'
46testcase 'set -- a; set -- p$@q'		'1|paq'
47testcase 'set -- a; set -- $@q'			'1|aq'
48testcase 'set -- a; set -- p$@'			'1|pa'
49testcase 'set -- a; set -- p$@q'		'1|paq'
50testcase 'set -- a; set -- $@q'			'1|aq'
51testcase 'set -- a; set -- p$@'			'1|pa'
52testcase 'set -- a; set -- p$*q'		'1|paq'
53testcase 'set -- a; set -- $*q'			'1|aq'
54testcase 'set -- a; set -- p$*'			'1|pa'
55testcase 'set -- a; set -- p$*q'		'1|paq'
56testcase 'set -- a; set -- $*q'			'1|aq'
57testcase 'set -- a; set -- p$*'			'1|pa'
58testcase 'set -- a; set -- "p$@q"'		'1|paq'
59testcase 'set -- a; set -- "$@q"'		'1|aq'
60testcase 'set -- a; set -- "p$@"'		'1|pa'
61testcase 'set -- a; set -- p"$@"q'		'1|paq'
62testcase 'set -- a; set -- "$@"q'		'1|aq'
63testcase 'set -- a; set -- p"$@"'		'1|pa'
64
65test "x$failures" = x
66