]> git.saurik.com Git - apple/shell_cmds.git/blob - sh/tests/parameters/positional2.0
shell_cmds-198.tar.gz
[apple/shell_cmds.git] / sh / tests / parameters / positional2.0
1 # $FreeBSD$
2
3 failures=''
4 ok=''
5
6 testcase() {
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
22 testcase 'set -- a b; set -- p$@q' '2|pa|bq'
23 testcase 'set -- a b; set -- $@q' '2|a|bq'
24 testcase 'set -- a b; set -- p$@' '2|pa|b'
25 testcase 'set -- a b; set -- p$@q' '2|pa|bq'
26 testcase 'set -- a b; set -- $@q' '2|a|bq'
27 testcase 'set -- a b; set -- p$@' '2|pa|b'
28 testcase 'set -- a b; set -- p$*q' '2|pa|bq'
29 testcase 'set -- a b; set -- $*q' '2|a|bq'
30 testcase 'set -- a b; set -- p$*' '2|pa|b'
31 testcase 'set -- a b; set -- p$*q' '2|pa|bq'
32 testcase 'set -- a b; set -- $*q' '2|a|bq'
33 testcase 'set -- a b; set -- p$*' '2|pa|b'
34 testcase 'set -- a b; set -- "p$@q"' '2|pa|bq'
35 testcase 'set -- a b; set -- "$@q"' '2|a|bq'
36 testcase 'set -- a b; set -- "p$@"' '2|pa|b'
37 testcase 'set -- a b; set -- p"$@"q' '2|pa|bq'
38 testcase 'set -- a b; set -- "$@"q' '2|a|bq'
39 testcase 'set -- a b; set -- p"$@"' '2|pa|b'
40 testcase 'set -- "" a b; set -- "p$@q"' '3|p|a|bq'
41 testcase 'set -- "" a b; set -- "$@q"' '3||a|bq'
42 testcase 'set -- "" a b; set -- "p$@"' '3|p|a|b'
43 testcase 'set -- "" a b; set -- p"$@"q' '3|p|a|bq'
44 testcase 'set -- "" a b; set -- "$@"q' '3||a|bq'
45 testcase 'set -- "" a b; set -- p"$@"' '3|p|a|b'
46 testcase 'set -- a; set -- p$@q' '1|paq'
47 testcase 'set -- a; set -- $@q' '1|aq'
48 testcase 'set -- a; set -- p$@' '1|pa'
49 testcase 'set -- a; set -- p$@q' '1|paq'
50 testcase 'set -- a; set -- $@q' '1|aq'
51 testcase 'set -- a; set -- p$@' '1|pa'
52 testcase 'set -- a; set -- p$*q' '1|paq'
53 testcase 'set -- a; set -- $*q' '1|aq'
54 testcase 'set -- a; set -- p$*' '1|pa'
55 testcase 'set -- a; set -- p$*q' '1|paq'
56 testcase 'set -- a; set -- $*q' '1|aq'
57 testcase 'set -- a; set -- p$*' '1|pa'
58 testcase 'set -- a; set -- "p$@q"' '1|paq'
59 testcase 'set -- a; set -- "$@q"' '1|aq'
60 testcase 'set -- a; set -- "p$@"' '1|pa'
61 testcase 'set -- a; set -- p"$@"q' '1|paq'
62 testcase 'set -- a; set -- "$@"q' '1|aq'
63 testcase 'set -- a; set -- p"$@"' '1|pa'
64
65 test "x$failures" = x