]>
Commit | Line | Data |
---|---|---|
deb63bfb | 1 | # $FreeBSD: head/bin/sh/tests/expansion/trim3.0 207127 2010-04-23 17:26:49Z jilles $ |
71aad674 A |
2 | |
3 | e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}' | |
4 | h='##' c='\\\\' | |
5 | failures='' | |
6 | ok='' | |
7 | ||
8 | testcase() { | |
9 | code="$1" | |
10 | expected="$2" | |
11 | oIFS="$IFS" | |
12 | eval "$code" | |
13 | IFS='|' | |
14 | result="$#|$*" | |
15 | IFS="$oIFS" | |
16 | if [ "x$result" = "x$expected" ]; then | |
17 | ok=x$ok | |
18 | else | |
19 | failures=x$failures | |
20 | echo "For $code, expected $expected actual $result" | |
21 | fi | |
22 | } | |
23 | ||
24 | # This doesn't make much sense, but it fails in dash so I'm adding it here: | |
25 | testcase 'set -- "${w%${w#???}}"' '1|a b' | |
26 | ||
27 | testcase 'set -- ${p#/et[}' '1|c]/' | |
28 | testcase 'set -- "${p#/et[}"' '1|c]/' | |
29 | testcase 'set -- "${p%${p#????}}"' '1|/et[' | |
30 | ||
31 | testcase 'set -- ${b%'\'}\''}' '1|{{(#)}' | |
32 | ||
33 | testcase 'set -- ${c#\\}' '1|\\\' | |
34 | testcase 'set -- ${c#\\\\}' '1|\\' | |
35 | testcase 'set -- ${c#\\\\\\}' '1|\' | |
36 | testcase 'set -- ${c#\\\\\\\\}' '0|' | |
37 | testcase 'set -- "${c#\\}"' '1|\\\' | |
38 | testcase 'set -- "${c#\\\\}"' '1|\\' | |
39 | testcase 'set -- "${c#\\\\\\}"' '1|\' | |
40 | testcase 'set -- "${c#\\\\\\\\}"' '1|' | |
41 | testcase 'set -- "${c#"$c"}"' '1|' | |
42 | testcase 'set -- ${c#"$c"}' '0|' | |
43 | testcase 'set -- "${c%"$c"}"' '1|' | |
44 | testcase 'set -- ${c%"$c"}' '0|' | |
45 | ||
46 | test "x$failures" = x |