6 HOME=/usr/homes/chet # to make the check against new-exp.right work
8 recho "${undef-"foo bar"}" # should be foo bar
10 recho "${und="foo"}" # should be foo
19 expect $0: 'HOME: }: syntax error: operand expected (error token is "}")'
20 recho "${HOME:`echo }`}" # should be a math error -- bad substring substitution
24 x=${_ENV[(_$-=0)+(_=1)-_${-%%*i*}]} # memory leak
30 recho ${HOME:-`echo }`}
32 recho ${HOME:-`echo "}"`}
34 recho "${HOME:-`echo "}"`}"
36 recho "$(echo "${HOME}")"
38 recho "$(echo "$(echo ${HOME})")"
40 recho "$(echo "$(echo "${HOME}")")"
48 recho "${P#\*}" # should be @*
51 recho "$(echo ")")" # should be )
53 recho "$(echo "\")\"")" # should be ")"
57 recho -${foo}- # should be -abcd -
59 recho -${foo% *}- # should be -abcd -
61 recho -${foo%% *}- # should be -abcd-
72 echo -n $foo' ' ; echo foo
75 echo -n $foo" " ; echo foo
78 echo -n "$foo " ; echo foo
81 echo -e "$foo\c " ; echo foo
84 echo -e $foo"\c " ; echo foo
92 recho ${z:4:3} ${z:${#z}-3:3}
97 expect '<abcdefghijklmnop>'
100 expect '<abcdefghijklmnop>'
103 set 'ab cd' 'ef' 'gh ij' 'kl mn' 'op'
104 expect '<ab cd> <ef>'
107 expect '<gh ij> <kl mn>'
110 expect '<gh ij> <kl mn> <op>'
113 expect '<ab cd> <ef> <gh ij> <kl mn> <op>'
116 # indirect variable references
117 expect '<abcdefghijklmnop>'
129 expect '<abcdefghijklmnop>'
131 expect '<abcdefghijklmnop>'
140 expect $0: ABX: unbound variable
144 expect $0: '$6: cannot assign in this way'
149 # sed-like variable substitution
167 av=(abcd efgh ijkl mnop qrst uvwx)
176 recho ${av[1]/%ab/xx}
182 recho ${av[1]//??/za}
184 recho ${av[1]//#??/za}
186 recho ${av[1]//%??/za}
188 expect '<yyy> <yyy> <yyy> <yyy> <yyy> <yyy>'
190 expect '<yyy> <yyy> <yyy> <yyy> <yyy> <yyy>'
191 recho ${av[@]/#*/yyy}
192 expect '<yyy> <yyy> <yyy> <yyy> <yyy> <yyy>'
193 recho ${av[@]/%*/yyy}
194 expect '<yyy> <efgh> <ijkl> <mnop> <qrst> <uvwx>'
195 recho ${av[@]/a*/yyy}
196 expect '<abxx> <efxx> <ijxx> <mnxx> <qrxx> <uvxx>'
197 recho ${av[@]/%??/xx}
199 set abcd efgh ijkl mnop qrst uvwx
203 expect '<xxcd> <xxgh> <xxkl> <xxop> <xxst> <xxwx>'
205 expect '<xxcd> <xxgh> <xxkl> <xxop> <xxst> <xxwx>'
211 expect '<zaza> <zaza> <zaza> <zaza> <zaza> <zaza>'
213 expect '<zacd> <zagh> <zakl> <zaop> <zast> <zawx>'
215 expect '<yyy> <yyy> <yyy> <yyy> <yyy> <yyy>'
217 expect '<yyy> <efgh> <ijkl> <mnop> <qrst> <uvwx>'
219 expect '<abcd> <efgh> <ijkl> <mnop> <qrst> <uvwyyy>'
225 expect this is a test of proc subst
226 cat <(echo this is a test of proc subst)
227 echo this is test 2 > /tmp/x
228 expect this is test 2
232 expect $0: '${#:-foo}: bad substitution'
234 expect $0: '${#:}: bad substitution'
258 recho ${foo:-"$zbcd"}
280 # this disagrees with sh and ksh, but I think it is right according
283 recho "${foo:-"$z1"}"
286 expect '<ab> <cd> <ef> <gh>'
288 expect '<ab> <cd> <ef> <gh>'
290 expect '<ab> <cd> <ef> <gh>'
297 recho ${foo:-$xxx"$@"}
299 recho "${foo:-$xxx$@}"
301 recho "${foo:-$xxx"$@"}"
319 AB='abcdefghijklmnopqrstuvwxyz'
348 set $'\1' $'\2' $'\177'
371 expect $0: 'ABXD: parameter unset'
372 recho ${ABXD:?"parameter unset"}