Lines Matching full:testing
3 [ -f testing.sh ] && . testing.sh
7 # testing "name" "command" "result" "infile" "stdin"
18 # Wrap txpect for shell testing
32 testing '-c "" exit status 0' '$SH -c "" && echo $?' '0\n' '' ''
33 testing '-c args' "\$SH -c 'echo \$0,\$1,\$2,\$3' one two three four five" \
35 testing '-c args2' "\$SH -c 'echo \${10}' a b c d e f g h i j k l" "k\n" "" ""
36 testing '-c arg split' \
39 testing '-c arg split2' \
42 testing '-c arg count' "$SH -c 'echo \$#' 9 8 7 6 1 2 3 4" "7\n" "" ""
43 testing 'trailing \' "$SH -c 'echo \'" '\\\n' '' ''
44 testing "trailing \\ in ''" "$SH -c \$'echo \\'one\\\\\\ntwo\\''" \
46 testing 'trailing \ in ""' "$SH -c \$'echo \"one\\\\\\ntwo\"'" 'onetwo\n' \
48 testing 'vanishing \' "$SH -c \$'echo \\\\\\n a'" 'a\n' '' ''
49 testing 'command\ arg' "$SH -c \$'echo\\\\\\n abc'" 'abc\n' '' ''
50 testing "exec3" '$C -c "{ exec readlink /proc/self/fd/0;} < /proc/self/exe"' \
52 testing 'arg shift' "$SH -c '"'for i in "" 2 1 1 1; do echo $? $1; shift $i; done'"' one two three …
54 testing '(subshell)' '$SH -c "(echo hello)"' 'hello\n' '' ''
55 testing 'syntax' '$SH -c "if true; then echo hello | fi" 2>/dev/null || echo x'\
57 testing 'syntax2' '$SH -c "for;i 0" 2>&1 | { grep -qi syntax && echo yes; }' \
62 testing 'non-absolute $_' "./bash -c 'echo \$_'" './bash\n' '' ''
65 testing 'exec exitval' "$SH -c 'exec echo hello' && echo \$?" "hello\n0\n" "" ""
66 testing 'simple script' '$SH input' 'input\n' 'echo $0' ''
67 testing 'simple script2' '$SH ./input two;echo $?' './input+two\n42\n' \
70 toyonly testing 'recursion guard' \
73 testing '$LINENO 1' "$SH input" "1\n" 'echo $LINENO' ''
77 $BROKEN testing 'simple script in $PATH' "PATH='$PWD/sub:$PATH' $SH script" \
81 testing "script file" "chmod +x input; ./input" "hello\n" "#!$C\necho hello" ""
82 testing 'IFS $*' "$SH -c 'IFS=xy; echo \"\$*\"' one two tyree" "twoxtyree\n" \
85 testing 'default exports' \
89 #testing "leading assignment fail" \
91 testing "lineno" "$SH input" "5 one\n6 one\n5 two\n6 two\n" \
93 testing "eval0" "$SH -c 'eval echo \$*' one two three" "two three\n" "" ""
101 testing 'return code' 'if false; then echo true; fi; echo $?' '0\n' '' ''
102 testing 'return code 2' 'if true; then false; fi; echo $?' '1\n' '' ''
103 testing 'return code 3' 'x=0; while [ $((x++)) -lt 2 ]; do echo $x; done; echo $?' '1\n2\n0\n' '' ''
104 testing 'return code 4' 'false; A=B; echo $?' '0\n' '' ''
105 testing 'local var +whiteout' \
108 testing 'escape passthrough' 'echo -e "a\nb\nc\td"' 'a\nb\nc\td\n' '' ''
110 testing 'trailing $ is literal' 'echo $' '$\n' '' ''
111 testing 'work after HERE' $'cat<<0;echo hello\npotato\n0' 'potato\nhello\n' '' ''
112 testing '<<\EOF' $'(cat<<EOF\n$PATH\nEOF\necho "$PATH") | sort -u | wc -l' \
114 testing "<<EOF''" $'(cat<<EOF\'\'\n$PATH\nEOF\necho "$PATH") | sort -u | wc -l'\
116 testing '<<\EOF' $'(cat<<\\EOF\n$PATH\nEOF\necho "$PATH") | sort -u | wc -l' \
118 testing '<< \' $'cat<<EOF\nabc\\\ndef\nEOF\n' 'abcdef\n' '' ''
119 testing '<< "\"' $'cat<<\\EOF\nabc\\\ndef\nEOF\n' 'abc\\\ndef\n' '' ''
120 testing '<<""' $'cat<<"";echo hello\npotato\n\necho huh' 'potato\nhello\nhuh\n'\
122 $BROKEN testing '<< trailing \' $'cat<<EOF 2>/dev/null\nabcde\nnext\\\nEOF\nEOF' \
124 $BROKEN testing '<< trailing \ 2' $'cat<<EOF\nabcde\nEO\\\nF\necho hello' \
126 testing '<< $(a)' $'cat<<$(a)\nx\n$(a)' 'x\n' '' ''
127 testing 'HERE straddle' $'cat<<EOF;if true\nhello\nEOF\nthen echo also; fi' \
129 $BROKEN testing '\\n in <<EOF' $'cat<<EO\\\nF\n$PATH\nEOF\n' "$PATH\n" "" ""
130 testing '\\n in <<EOF with ""' $'cat<<EO\\\nF""\n$PATH\nEOF\n' '$PATH\n' '' ''
131 $BROKEN testing '\\n in HERE terminator' $'cat<<EOF\nabc\nE\\\nOF\necho hello\n' \
134 testing "undelimited redirect doesn't eat prefix" './echo2</dev/null hello' \
137 testing 'prefix assignment is local' '{ echo $ABC; } {ABC}</dev/null; echo $3'\
139 testing 'double quotes' 'echo \x "\x" "\\" "\$" "\`"' 'x \x \ $ `\n' '' ''
140 testing 'quoted line escapes' $'echo "\\\none" \'\\\ntwo\'' 'one \\\ntwo\n' '' ''
141 testing 'escape makes argument' 'echo \ | wc -c' '2\n' '' ''
143 # TODO testing 'empty +() is literal' 'echo +()' '+()\n' '' ''
154 testing '$_ literal after exec' 'env >/dev/null; echo $_' 'env\n' '' ''
156 $BROKEN testing 'prefix is local for builtins' 'abc=123; abc=def unset abc; echo $abc' \
158 $BROKEN testing 'prefix localizes magic vars' \
161 testing '$NOTHING clears $_' 'true; $NOTHING; echo $_' '\n' '' ''
162 testing 'assignment with redirect is persistent, not prefix' \
164 $BROKEN testing '$_ with functions' 'true; x(){ echo $_;}; x abc; echo $_' \
168 testing 'cd in renamed dir' \
173 testing "smoketest" "echo hello" "hello\n" "" ""
174 testing "assignment" 'x=y; echo $x' 'y\n' '' ''
175 testing "+= assignment" 'x+=abc; y=def; y+=$x; echo $y' 'defabc\n' '' ''
176 testing "eval" "eval echo hello" "hello\n" "" ""
177 testing "eval2" "eval 'echo hello'; echo $?" "hello\n0\n" "" ""
178 testing "eval3" 'X="echo hello"; eval "$X"' "hello\n" "" ""
179 testing "eval4" 'eval printf '=%s=' \" hello \"' "= hello =" "" ""
180 NOSPACE=1 testing "eval5" 'eval echo \" hello \" | wc' ' 1 1 8' "" ""
181 $BROKEN testing 'eval6' $'false; eval \'echo $?\'' '1\n' '' ''
182 testing 'eval7' $'eval \'false\'; echo $?' '1\n' '' ''
183 testing 'eval8' $'false; eval ''; echo $?' '0\n' '' ''
184 $BROKEN testing 'eval9' $'A=echo; false; eval \'$A $?\'' '1\n' '' ''
185 testing "exec" "exec echo hello" "hello\n" "" ""
186 testing "exec2" "exec echo hello; echo $?" "hello\n" "" ""
189 testing "semicolon" "echo one;echo two" "one\ntwo\n" "" ""
190 testing "simple pipe" "echo hello | cat" "hello\n" "" ""
191 testing "&&" "true && echo hello" "hello\n" "" ""
192 testing "&&2" "false && echo hello" "" "" ""
193 testing "||" "true || echo hello" "" "" ""
194 testing "||2" "false || echo hello" "hello\n" "" ""
195 testing "&& ||" "true && false && potato || echo hello" "hello\n" "" ""
196 testing "&& after function" "x(){ false;};x && echo yes" "" "" ""
197 testing "|| after function" "x(){ false;};x || echo yes" "yes\n" "" ""
201 testing "redir1" "cat < input" "hello\n" "hello\n" ""
202 testing "redir2" "echo blah >out; cat out" "blah\n" "" ""
203 testing "redir3" "echo more >>out; cat out" "blah\nmore\n" "" ""
204 testing "redir4" "touch /not/exist 2>out||grep -o /not/exist out" \
206 testing "redir5" "ls out /not/exist &> out2 || wc -l < out2" "2\n" "" ""
207 testing "redir6" "ls out /not/exist &>>-abc || wc -l < ./-abc" "2\n" "" ""
208 testing "redir7" "ls out /not/exist |& wc -l" "2\n" "" ""
209 testing "redir8" 'echo -n $(<input)' "boing" "boing\n" ""
212 testing "redir10" 'echo hello 3<&3' "hello\n" "" ""
213 testing "redir11" 'if :;then echo one;fi {abc}<input; cat <&$abc' \
219 testing "tilde expansion" "echo ~" "$HOME\n" "" ""
220 testing "tilde2" "echo ~/dir" "$HOME/dir\n" "" ""
221 testing "bracket expansion" \
223 testing "brackets2" "echo {A{a,b}B{c,d}C,D}" "AaBcC AaBdC AbBcC AbBdC D\n" "" ""
224 testing "brackets3" 'echo {A"b,c"D}' "{Ab,cD}\n" "" ""
225 testing "brackets4" 'echo {A"bc",D}' "Abc D\n" "" ""
226 testing "brackets5" 'echo {A,B,C' "{A,B,C\n" "" ""
227 testing "brackets6" 'echo {{{{A,B},C}D},E}' "{AD} {BD} {CD} E\n" "" ""
228 testing "brackets7" 'echo {{{a,b},c,{d,e}},f}' "a b c d e f\n" "" ""
229 testing "brackets8" 'echo A{a{b,c{B,C}D}d{e,f},g{h,i}j}E' \
231 testing "brackets9" 'echo A{B{C,D}E{N,O},F{G,H}I}J{K,L}M' \
234 testing "bracket+tilde" "echo {~,~root}/pwd" "$HOME/pwd $EXPECT/pwd\n" "" ""
238 testing '${x#prefix}' 'x=abcde; echo ${x#abc}' 'de\n' '' ''
239 testing '${x#short} ${x##long}' 'x=banana; echo ${x#b*n} ${x##b*n}' \
241 toyonly testing '${x#utf8}' 'x=aそcde; echo ${x##a?c}' 'de\n' '' ''
242 testing '${x%y}' 'x=potato; echo ${x%t*o} ${x%%t*o}' 'pota po\n' '' ''
243 testing 'x=${x%y}' 'x=potato; x=${x%t*o}; echo $x' 'pota\n' '' ''
244 testing '${x%glob}' 'x=abc-def; echo ${x%-*f} ${x-*c}' 'abc abc-def\n' '' ''
245 testing 'x=${x//y}' 'x=potato; x=${x//ta}; echo $x' 'poto\n' '' ''
246 testing '${x^y}' 'x=aaaaa; echo ${x^a}' 'Aaaaa\n' '' ''
247 testing '${x^^y}' 'x=abccdec; echo ${x^^c}; x=abcdec; echo ${x^^c}' \
249 testing '${x,y}' 'x=BBB; echo ${x,B}' 'bBB\n' '' ''
250 testing '${x,,y}' 'x=POTATO; echo ${x,,} ${x,,?} ${x,,*} ${x,,T}' \
255 testing 'wildcards' 'echo w[v-x]w w[x-v]w abc/*/ghi' \
257 testing 'hidden wildcards' \
261 testing "backtick1" 'x=fred; echo `echo $x`' 'fred\n' "" ""
262 testing "backtick2" 'x=fred; echo `x=y; echo $x`; echo $x' 'y\nfred\n' "" ""
263 testing '$(( ) )' 'echo ab$((echo hello) | tr e x)cd' "abhxllocd\n" "" ""
264 $BROKEN testing '$((x=y)) lifetime' 'a=boing; echo $a $a$((a=4))$a $a' 'boing boing44 4\n' '' ''
266 testing 'quote' "echo \"'\"" "'\n" "" ""
268 testing "math" 'echo $((1+2))' '3\n' '' ''
269 testing "[oldmath]" 'echo $[1+2]' '3\n' '' ''
270 testing "math basic priority" 'echo $((1+2*3**4))' '163\n' '' ''
271 testing "math paren" 'echo $(((1+2)*3))' '9\n' '' ''
272 testing "math spaces" 'echo $(( ( 1 + 2 ) * 7 - 5 ** 2 ))' '-4\n' '' ''
273 testing "((<)) isn't redirect" '((1<2)) </dev/null && echo yes' 'yes\n' '' ''
274 testing "((>)) isn't redirect" '((1>2)) </dev/null || echo yes' 'yes\n' '' ''
275 testing "((not math) )" '((echo hello) )' 'hello\n' '' ''
276 testing "preincrement" 'echo $((++x)); echo $x' '1\n1\n' '' ''
277 testing "preincrement vs prefix plus" 'echo $((+++x)); echo $x' '1\n1\n' '' ''
278 testing "predecrement" 'echo $((--x)); echo $x' '-1\n-1\n' '' ''
279 testing "predecrement vs prefix minus" 'echo $((---x)); echo $x' '1\n-1\n' '' ''
280 testing "minus-minus-minus" 'echo $((x---7)); echo $x' '-7\n-1\n' '' ''
281 testing "x---y is x-- -y not x- --y" 'x=1 y=1; echo $((x---y)) $x $y' '0 0 1\n'\
283 $BROKEN testing "nesting ? :" \
286 testing "inherited assignment suppression" 'echo $((0 ? (x++) : 2)); echo $x' \
288 testing "boolean vs logical" 'echo $((2|4&&8))' '1\n' '' ''
289 testing "&& vs || priority" \
292 testing "|| vs && priority" \
301 testing "case" 'for i in A C J B; do case "$i" in A) echo got A ;; B) echo and B ;; C) echo then C …
303 testing 'case;;&' 'case wow in w?w) echo ok;;& wow) echo no; esac' 'ok\nno\n' \
305 testing "case newlines" \
308 testing "case block" \
310 testing 'loop in && ||' \
312 testing "continue" 'for i in a b c; do for j in d e f; do echo $i $j; continue 2; done; done' \
314 $BROKEN testing "piped loops that don't exit" \
320 testing "expand" 'echo $PWD' "$(pwd)\n" "" ""
321 testing "expand2" 'echo "$PWD"' "$(pwd)\n" "" ""
322 testing "expand3" 'echo "$"PWD' '$PWD\n' "" ""
323 testing "expand4" 'P=x; echo "$P"WD' 'xWD\n' "" ""
324 testing "dequote" "echo one 'two' ''three 'fo'ur '\\'" \
327 testing "leading variable assignment" 'abc=def env | grep ^abc=; echo $abc' \
329 testing "leading variable assignments" \
332 $BROKEN testing "leading assignment occurs after parsing" \
334 testing "leading assignment space" 'X="abc def"; Y=$X; echo "$Y"' \
336 testing "leading assignment space2" \
338 testing "leading assignment fail2" \
340 testing "leading assignment redirect" \
344 testing "{1..5}" "echo {1..5}" "1 2 3 4 5\n" "" ""
345 testing "{5..1}" "echo {5..1}" "5 4 3 2 1\n" "" ""
346 testing "{5..1..2}" "echo {5..1..2}" "5 3 1\n" "" ""
347 testing "{a..z..-3}" "echo {a..z..-3}" "a d g j m p s v y\n" "" ""
350 testing 'background curly block' \
355 $BROKEN testing 'background pipe block' \
358 $BROKEN testing 'background variable assignment' 'X=x; X=y & echo $X' 'x\n' '' ''
365 testing "IFS whitespace before/after" \
368 testing "quotes and whitespace" \
371 testing "quotes and whitespace2" \
374 testing "quotes and whitespace3" \
378 testing "IFS" 'IFS=x; A=abx; echo -n "$A"' "abx" "" ""
379 testing "IFS2" 'IFS=x; A=abx; echo -n $A' "ab" "" ""
380 testing "IFS3" 'IFS=x; echo "$(echo abx)"' "abx\n" "" ""
381 testing "IFS4" 'IFS=x; echo $(echo abx)y' "ab y\n" "" ""
382 testing "IFS5" 'IFS=xy; for i in abcxdefyghi; do echo =$i=; done' \
384 testing "curly bracket whitespace" 'for i in {$,} ""{$,}; do echo ="$i"=; done'\
387 testing 'empty $! is blank' 'echo $!' "\n" "" ""
388 $BROKEN testing '$! = jobs -p' 'true & [ $(jobs -p) = $! ] && echo yes' "yes\n" "" ""
390 testing '$*' 'cc(){ for i in $*;do echo =$i=;done;};cc "" "" "" "" ""' \
392 testing '$*2' 'cc(){ for i in "$*";do echo =$i=;done;};cc ""' \
394 testing '$*3... Flame. Flames. Flames, on the side of my face...' \
396 $BROKEN testing 'why... oh.' \
399 testing 'really?' 'cc() { for i in $*; do echo -$i-; done;}; cc "" "" ""' \
401 testing 'Sigh.' 'cc() { echo =$1$2=;}; cc "" ""' "==\n" "" ""
402 testing '$*4' 'cc(){ for i in "$*";do echo =$i=;done;};cc "" "" "" "" ""' \
404 testing '$*5' 'cc(){ for i in "$*";do echo =$i=;done;};cc "" "abc" ""' \
408 testing '$* + IFS' \
411 testing '$@' 'cc(){ for i in "$@";do echo =$i=;done;};cc "" "" "" "" ""' \
413 testing "IFS10" 'IFS=bcd; A=abcde; for i in $A; do echo =$i=; done' \
415 $BROKEN testing "IFS11" \
418 testing "IFS12" 'IFS=3;chicken(){ return 3;}; chicken;echo 3$?3' '3 3\n' "" ""
420 testing "IFS combinations" \
424 $BROKEN testing "! isn't special" "echo !" "!\n" "" ""
425 testing "! by itself" '!; echo $?' "1\n" "" ""
426 testing "! true" '! true; echo $?' "1\n" "" ""
427 testing "! ! true" '! ! true; echo $?' "0\n" "" ""
428 testing "! syntax err" '! echo 2>/dev/null < doesnotexist; echo $?' "0\n" "" ""
431 testing "case quoting" 'case a in "a") echo hello;; esac' 'hello\n' "" ""
433 testing "subshell splitting" 'for i in $(true); do echo =$i=; done' "" "" ""
434 testing "subshell split 2" 'for i in $(echo "one two thr"); do echo =$i=; done'\
438 testing "assignment nosplit" 'X="one two"; Y=$X; echo $Y' "one two\n" "" ""
439 testing "argument splitting" \
442 testing "assignment nosplit2" 'pop(){ X="$@";};pop one two three; echo $X' \
445 #testing "leading assignments don't affect current line" \
447 #testing "can't have space before first : but yes around arguments" \
450 testing "subshell exit err" '(exit 42); echo $?' "42\n" "" ""
453 #testing 'exec and $$' testing 'echo $$;exec readlink /proc/self'
456 testing "exec in paren" \
458 testing "exec in brackets" \
461 NOSPACE=1 testing "curly brackets and pipe" \
464 NOSPACE=1 testing "parentheses and pipe" \
467 $BROKEN testing "pipe into parentheses" \
471 $BROKEN testing "\$''" $'echo $\'abc\\\'def\\nghi\'' "abc'def\nghi\n" '' ''
472 testing "shift shift" 'shift; shift; shift; echo $? hello' "1 hello\n" "" ""
473 testing 'search cross $*' 'chicken() { echo ${*/b c/ghi}; }; chicken a b c d' \
475 testing 'eval $IFS' 'IFS=x; X=x; eval abc=a${X}b 2>/dev/null; echo $abc' \
477 $BROKEN testing '${@:3:5}' 'chicken() { for i in "${@:3:5}"; do echo =$i=; done; } ; chicken ab cd …
479 $BROKEN testing '${*:3:5}' 'chicken() { for i in "${*:3:5}"; do unset IFS; echo =$i=; done; } ; IFS…
481 testing 'sequence check' 'IFS=x; X=abxcd; echo ${X/bxc/g}' 'agd\n' '' ''
490 testing 'here0' 'cat<<<hello' 'hello\n' '' ''
495 testing 'here3' 'abc(){ cat <<< x"$@"yz;};abc one two "three four"' \
497 testing 'here4' 'for i in one two three; do cat <<< "ab${i}de"; done' \
499 testing 'here5' $'cat << EOF && cat << EOF2\nEOF2\nEOF\nEOF\nEOF2' \
502 testing 'here6' $'cat << EOF""\n$POTATO\nEOF' '$POTATO\n' '' ''
504 $BROKEN testing 'here7' 'ABC="abc def"; cat <<< $ABC' 'abc def\n' '' ''
506 testing 'here8' $'ABC="x y"\ncat << EOF\n~root/{"$ABC",def}\nEOF' \
508 testing '<<- eats leading tabs before expansion, but not after' \
511 testing '${var}' 'X=abcdef; echo ${X}' 'abcdef\n' '' ''
512 testing '${#}' 'X=abcdef; echo ${#X}' "6\n" "" ""
513 testing 'empty ${}' '{ echo ${};} 2>&1 | grep -o bad' 'bad\n' '' ''
516 $BROKEN testing '${$b}' '{ echo ${$b};} 2>&1 | grep -o bad' 'bad\n' '' ''
517 testing '${!PATH*}' 'echo ${!PATH*}' 'PATH\n' '' ''
518 testing '${!PATH@}' 'echo ${!PATH@}' 'PATH\n' '' ''
519 #testing '${!PATH[@]}' 'echo ${!PATH[@]}' '0\n' '' ''
520 testing '${!x}' 'X=abcdef Y=X; echo ${!Y}' 'abcdef\n' '' ''
521 testing '${!x@}' 'ABC=def; def=ghi; echo ${!ABC@}' 'ABC\n' '' ''
522 $BROKEN testing '${!x} err' '{ X=abcdef Y=X:2; echo ${!Y}; echo bang;} 2>/dev/null' \
524 testing '${!x*}' 'abcdef=1 abc=2 abcq=; echo "${!abc@}" | tr " " \\n | sort' \
526 testing '${!x*} none' 'echo "${!abc*}"' '\n' '' ''
527 $BROKEN testing '${!x*} err' '{ echo "${!abc*x}"; echo boing;} 2>/dev/null' '' '' ''
529 #testing '${!none@Q}' 'echo ${X@Q} ${!X@Q}; X=ABC; echo ${!X@Q}' '\n\n' '' ''
530 $BROKEN testing '${!x@Q}' 'ABC=123 X=ABC; echo ${!X@Q}' "'123'\n" '' ''
531 $BROKEN testing '${#@Q}' 'echo ${#@Q}' "'0'\n" '' ''
532 $BROKEN testing '${!*}' 'xx() { echo ${!*};}; fruit=123; xx fruit' '123\n' '' ''
533 $BROKEN testing '${!*} indirect' 'xx() { echo ${!a@Q};}; a=@; xx one two three' \
535 $BROKEN testing '${!x@ } match' \
538 #testing '${!x@ } no match no err' 'echo ${!ABC@ }def' 'def\n' '' ''
539 $BROKEN testing '${!x@ } no match no err2' 'ABC=def; echo ${!ABC@ }ghi' 'ghi\n' '' ''
540 toyonly testing '${#x::}' 'ABC=abcdefghijklmno; echo ${#ABC:1:2}' '5\n' '' ''
542 testing '$""' 'ABC=def; echo $"$ABC"' 'def\n' '' ''
543 testing '"$""" does not nest' 'echo "$"abc""' '$abc\n' '' ''
544 $BROKEN testing '${\}}' 'ABC=ab}cd; echo ${ABC/\}/x}' 'abxcd\n' '' ''
545 testing 'bad ${^}' '{ echo ${^};} 2>&1 | grep -o bad' 'bad\n' '' ''
547 testing '${::} both empty=0' 'ABC=def; echo ${ABC::}' '\n' '' ''
548 testing '${::} first empty' 'ABC=def; echo ${ABC: : 2 }' 'de\n' '' ''
549 testing '${::} second empty' 'ABC=def; echo ${ABC: 2 : }' '\n' '' ''
550 testing '${:}' 'ABC=def; echo ${ABC:1}' 'ef\n' '' ''
551 testing '${a: }' 'ABC=def; echo ${ABC: 1}' 'ef\n' '' ''
552 $BROKEN testing '${a :}' 'ABC=def; { echo ${ABC :1};} 2>&1 | grep -o bad' 'bad\n' '' ''
553 testing '${::}' 'ABC=defghi; echo ${ABC:1:2}' 'ef\n' '' ''
554 testing '${: : }' 'ABC=defghi; echo ${ABC: 1 : 2 }' 'ef\n' '' ''
555 testing '${::} indirect' \
558 testing '${::-}' 'ABC=defghi; echo ${ABC:1:-2}' 'efg\n' '' ''
559 testing '${:-:-}' 'ABC=defghi; echo ${ABC:-3:2}' 'defghi\n' '' ''
560 testing '${:-:-}2' 'echo ${ABC:-3:2}' '3:2\n' '' ''
561 testing '${: -:}' 'ABC=defghi; echo ${ABC: -3:2}' 'gh\n' '' ''
562 testing '${@%}' 'chicken() { for i in "${@%abc}"; do echo "=$i="; done;}; chicken 1abc 2abc 3abc' '…
563 testing '${*%}' 'chicken() { for i in "${*%abc}"; do echo "=$i="; done;}; chicken 1abc 2abc 3abc' '…
564 $BROKEN testing '${@@Q}' 'xx() { echo "${@@Q}"; }; xx one two three' \
572 testing "line continuation3" $'ec\\\nho hello' 'hello\n' '' ''
573 testing "line continuation4" $'if true | \\\n(true);then echo true;fi' 'true\n' '' ''
574 $BROKEN testing "line continuation5" $'XYZ=xyz; echo "abc$\\\nXYZ"' 'abcxyz\n' '' ''
577 $BROKEN testing 'SECONDS' 'readonly SECONDS=41; sleep 1; echo $SECONDS' '42\n' '' ''
578 # testing 'SECONDS2' 'readonly SECONDS; SECONDS=0; echo $SECONDS' '' '' '' #bash!
579 $BROKEN testing 'SECONDS2' 'SECONDS=123+456; echo $SECONDS' '0\n' '' '' #bash!!
580 testing '$LINENO 2' $'echo $LINENO\necho $LINENO' '1\n2\n' '' ''
581 testing '$EUID' 'echo $EUID' "$(id -u)\n" '' ''
582 testing '$UID' 'echo $UID' "$(id -ur)\n" '' ''
584 $BROKEN testing 'readonly leading assignment' \
587 $BROKEN testing 'readonly leading assignment2' \
589 $BROKEN testing 'readonly for' \
592 $BROKEN testing 'readonly {}<' \
594 testing '$_ 1' 'echo walrus; echo $_' 'walrus\nwalrus\n' '' ''
595 testing '$_ 2' 'unset _; echo $_' '_\n' '' ''
600 testing 'IFS wildcards' \
631 testing 'source file' 'source input' 'hello\n' 'echo hello \\\n' ''
632 testing '. file' '. input' 'hello\n' 'echo hello \\\n' ''
633 testing 'source no newline' 'source input' 'hello \\\n' 'echo hello \\' ''
634 testing 'source continues' 'echo hello; source <(echo false); echo $?' \
636 testing 'source returns' 'source <(echo return 37); echo $?' '37\n' '' ''
637 testing 'source is live' \
640 testing 'source is live in functions' \
643 testing 'subshell inheritance' \
646 $BROKEN testing 'semicolon vs newline' \
649 $BROKEN testing 'syntax err pops to source but encapsulating function continues' \
652 $BROKEN testing '"exit shell" means exit eval but encapsulating function continues' \
655 $BROKEN testing 'return needs function or source' \
657 testing 'return nests' 'y(){ x; return $((3+$?));};x(){ return 5; };y;echo $?' \
661 testing 'functions() {} in same PID' \
663 testing 'functions() () different PID' \
665 testing 'function() just wants any block span' \
668 testing 'function alternate syntax' \
671 testing 'function syntax 3' \
674 testing 'function nested parentheses' \
679 testing 'local replaces/preserves magic type' \
683 $BROKEN testing '$$ is parent shell' \
685 $BROKEN testing '$PPID is parent shell' \
687 $BROKEN testing '$BASHPID is current PID' \
690 testing 'unexport supports +=' 'export -n ABC+=DEF; declare -p ABC' \
692 $BROKEN testing 'unexport existing +=' \
696 $BROKEN testing '$!' '{ echo $BASHPID & echo $!; echo ${!};} | sort -u | wc -l' '1\n' \
701 testing 'NOP line clears $?' 'false;$NOTHING;echo $?' '0\n' '' ''
702 $BROKEN testing 'run "$@"' 'false;"$@";echo $?' '0\n' '' ''
705 testing '[[split1]]' 'A="1 -lt 2"; [[ $A ]] && echo yes' 'yes\n' '' ''
706 testing '[[split2]]' 'A="2 -lt 1"; [[ $A ]] && echo yes' 'yes\n' '' ''
707 testing '[[split3]]' \
711 testing '[[split4]]' \
714 $BROKEN testing '[[split5]]' \
718 testing '[[1>2]] is not a redirect' '[[ 1 >2 ]] || [ -e 2 ] || echo yup' \
720 testing "[[1 >0]] doesn't need that second space" \
722 testing '[[1<2]] is alphabetical, not numeric' '[[ 123 < 19 ]] && echo yes' \
724 testing '[[~]]' '[[ ~ == $HOME ]] && echo yes' 'yes\n' '' ''
727 testing 'quoting contexts nest' \
730 testing "\$'' suppresses variable expansion" \
733 testing 'if; is a syntax error but if $EMPTY; is not' \
812 # Testing shell corner cases _within_ a shell script is kind of hard.