3 e= q='?' a='*' t=texttext s='ast*que?non' p='/et[c]/' w='a b c' b='{{(#)}}'
16 if [ "x$result" = "x$expected" ]; then
20 echo "For $code, expected $expected actual $result"
24 testcase 'set -- a b' '2|a|b'
25 testcase 'set --' '0|'
26 testcase 'set -- ${e}' '0|'
27 testcase 'set -- "${e}"' '1|'
29 testcase 'set -- $p' '1|/etc/'
30 testcase 'set -- "$p"' '1|/et[c]/'
31 testcase 'set -- ${s+$p}' '1|/etc/'
32 testcase 'set -- "${s+$p}"' '1|/et[c]/'
33 testcase 'set -- ${s+"$p"}' '1|/et[c]/'
34 # Dquotes in dquotes is undefined for Bourne shell operators
35 #testcase 'set -- "${s+"$p"}"' '1|/et[c]/'
36 testcase 'set -- ${e:-$p}' '1|/etc/'
37 testcase 'set -- "${e:-$p}"' '1|/et[c]/'
38 testcase 'set -- ${e:-"$p"}' '1|/et[c]/'
39 # Dquotes in dquotes is undefined for Bourne shell operators
40 #testcase 'set -- "${e:-"$p"}"' '1|/et[c]/'
41 testcase 'set -- ${e:+"$e"}' '0|'
42 testcase 'set -- ${e:+$w"$e"}' '0|'
43 testcase 'set -- ${w:+"$w"}' '1|a b c'
44 testcase 'set -- ${w:+$w"$w"}' '3|a|b|ca b c'
46 # These two are known broken in FreeBSD /bin/sh
47 #testcase 'set -- ${s+a b}' '2|a|b'
48 #testcase 'set -- ${e:-a b}' '2|a|b'
49 testcase 'set -- "${s+a b}"' '1|a b'
50 testcase 'set -- "${e:-a b}"' '1|a b'
51 testcase 'set -- ${e:-\}}' '1|}'
52 # Currently broken in FreeBSD /bin/sh
53 #testcase 'set -- "${e:-\}}"' '1|}'
54 testcase 'set -- ${e:+{}}' '1|}'
55 testcase 'set -- "${e:+{}}"' '1|}'
57 testcase 'set -- ${e+x}${e+x}' '1|xx'
58 testcase 'set -- "${e+x}"${e+x}' '1|xx'
59 testcase 'set -- ${e+x}"${e+x}"' '1|xx'
60 testcase 'set -- "${e+x}${e+x}"' '1|xx'
61 testcase 'set -- "${e+x}""${e+x}"' '1|xx'
63 testcase 'set -- ${e:-${e:-$p}}' '1|/etc/'
64 testcase 'set -- "${e:-${e:-$p}}"' '1|/et[c]/'
65 testcase 'set -- ${e:-"${e:-$p}"}' '1|/et[c]/'
66 testcase 'set -- ${e:-${e:-"$p"}}' '1|/et[c]/'
67 testcase 'set -- ${e:-${e:-${e:-$w}}}' '3|a|b|c'
68 testcase 'set -- ${e:-${e:-${e:-"$w"}}}' '1|a b c'
69 testcase 'set -- ${e:-${e:-"${e:-$w}"}}' '1|a b c'
70 testcase 'set -- ${e:-"${e:-${e:-$w}}"}' '1|a b c'
71 testcase 'set -- "${e:-${e:-${e:-$w}}}"' '1|a b c'
73 testcase 'shift $#; set -- ${1+"$@"}' '0|'
74 testcase 'set -- ""; set -- ${1+"$@"}' '1|'
75 testcase 'set -- "" a; set -- ${1+"$@"}' '2||a'
76 testcase 'set -- a ""; set -- ${1+"$@"}' '2|a|'
77 testcase 'set -- a b; set -- ${1+"$@"}' '2|a|b'
78 testcase 'set -- a\ b; set -- ${1+"$@"}' '1|a b'
79 testcase 'set -- " " ""; set -- ${1+"$@"}' '2| |'