1 # $MirOS: src/bin/mksh/check.t,v 1.756 2016/11/11 23:31:31 tg Exp $
4 # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
5 # 2011, 2012, 2013, 2014, 2015, 2016
6 # mirabilos <m@mirbsd.org>
8 # Provided that these terms and disclaimer and all copyright notices
9 # are retained or reproduced in an accompanying document, permission
10 # is granted to deal in this work without restriction, including un‐
11 # limited rights to use, publicly perform, distribute, sell, modify,
12 # merge, give away, or sublicence.
14 # This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
15 # the utmost extent permitted by applicable law, neither express nor
16 # implied; without malicious intent or gross negligence. In no event
17 # may a licensor, author or contributor be held liable for indirect,
18 # direct, other damage, loss, or other issues arising in any way out
19 # of dealing in the work, even if advised of the possibility of such
20 # damage or existence of a defect, except proven that it results out
21 # of said person’s immediate fault when using the work as intended.
23 # You may also want to test IFS with the script at
24 # http://www.research.att.com/~gsf/public/ifs.sh
27 # http://svnweb.freebsd.org/base/head/bin/test/tests/legacy_test.sh?view=co&content-type=text%2Fplain
29 # Integrated testsuites from:
30 # (2013/12/02 20:39:44) http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
33 @(#)MIRBSD KSH R54 2016/11/11
35 Check version of shell.
39 category: shell:legacy-no
42 @(#)LEGACY KSH R54 2016/11/11
44 Check version of legacy shell.
47 name: KSH_VERSION-legacy
48 category: shell:legacy-yes
52 Regression test self-testing
60 Regression test self-testing
69 Regression test self-testing
70 env-setup: !ENV=fnord!
78 Ensure that the test run directory (default /tmp but can be changed
79 with check.pl flag -T or test.sh $TMPDIR) is not mounted noexec, as
80 we execute scripts from the scratch directory during several tests.
82 print '#!'"$__progname"'\necho tf' >lq
90 Just output the environment variables set (always fails)
97 Check some things in the LEGACY KSH
98 category: shell:legacy-yes
102 [[ "$(set +o) -o" = *"-o emacs -o"* ]] && echo 1=emacs
103 [[ "$(set +o) -o" = *"-o vi -o"* ]] && echo 1=vi
106 [[ "$(set +o) -o" = *"-o emacs -o"* ]] && echo 2=emacs
107 [[ "$(set +o) -o" = *"-o vi -o"* ]] && echo 2=vi
112 name: selftest-direct-builtin-call
114 Check that direct builtin calls work
116 ln -s "$__progname" cat || cp "$__progname" cat
117 ln -s "$__progname" echo || cp "$__progname" echo
118 ./echo -c 'echo foo' | ./cat -u
124 Check that recursion is detected/avoided in aliases.
129 expected-stderr-pattern:
130 /fooBar.*not found.*/
134 Check that recursion is detected/avoided in aliases.
141 expected-stderr-pattern:
142 /fooBar.*not found.*\n.*barFoo.*not found/
146 Check that recursion is detected/avoided in aliases.
160 Check that alias expansion isn't done on keywords (in keyword
165 while false; do echo hi ; done
172 Check that alias expansion done after alias with trailing space.
175 alias foo='bar stuff '
176 alias bar='Bar1 Bar2 '
185 Check that alias expansion done after alias with trailing space.
197 Check that alias expansion done after alias with trailing space
202 X Y in 'Y') echo is y ;; Z) echo is z ;; esac
208 Check that newlines in an alias don't cause the command to be lost.
228 Check that recursion is detected/avoided in aliases.
229 This check fails for slow machines or Cygwin, raise
230 the time-limit clause (e.g. to 7) if this occurs.
233 print '#!'"$__progname"'\necho tf' >lq
235 PATH=$PWD$PATHSEP$PATH
251 Check that recursion is detected/avoided in aliases.
252 Regression, introduced during an old bugfix.
254 alias foo='print hello '
255 alias bar='foo world'
262 Check that special argument handling still applies with escaped aliases
264 alias local='\typeset'
275 Check that arithmetic expressions are compound constructs
277 { ! (( 0$(cat >&2) )) <<<1; } <<<2
283 Check that only one side of ternary operator is evaluated
288 echo $((1 ? 20 : (x+=2)))
290 echo $((0 ? (y+=2) : 30))
300 Check that assignments not done on non-evaluated side of ternary
306 echo $((1 ? 20 : (x+=2)))
308 echo $((0 ? (y+=2) : 30))
318 Check that assignments not done on non-evaluated side of ternary
319 operator and this construct is parsed correctly (Debian #445651)
329 Check that preun/postun not done on non-evaluated side of ternary
332 (( m = n = 0, 1 ? n++ : m++ ? 2 : 3 ))
334 m=0; echo $(( 0 ? ++m : 2 )); echo $m
335 m=0; echo $(( 0 ? m++ : 2 )); echo $m
343 name: arith-lazy-5-arr-n
344 description: Check lazy evaluation with side effects
346 a=0; echo "$((0&&b[a++],a))"
350 name: arith-lazy-5-arr-p
351 description: Check lazy evaluation with side effects
353 a=0; echo "$((0&&(b[a++]),a))"
357 name: arith-lazy-5-str-n
358 description: Check lazy evaluation with side effects
360 a=0 b=a++; ((0&&b)); echo $a
364 name: arith-lazy-5-str-p
365 description: Check lazy evaluation with side effects
367 a=0 b=a++; ((0&&(b))); echo $a
371 name: arith-lazy-5-tern-l-n
372 description: Check lazy evaluation with side effects
374 a=0; echo "$((0?b[a++]:999,a))"
378 name: arith-lazy-5-tern-l-p
379 description: Check lazy evaluation with side effects
381 a=0; echo "$((0?(b[a++]):999,a))"
385 name: arith-lazy-5-tern-r-n
386 description: Check lazy evaluation with side effects
388 a=0; echo "$((1?999:b[a++],a))"
392 name: arith-lazy-5-tern-r-p
393 description: Check lazy evaluation with side effects
395 a=0; echo "$((1?999:(b[a++]),a))"
399 name: arith-ternary-prec-1
401 Check precedence of ternary operator vs assignment
405 expected-exit: e != 0
406 expected-stderr-pattern:
407 /.*:.*1 \? 20 : x\+=2.*lvalue.*\n$/
409 name: arith-ternary-prec-2
411 Check precedence of ternary operator vs assignment
414 echo $((0 ? x+=2 : 20))
420 Prove arithmetic expressions with embedded parameter
421 substitutions cannot be parsed ahead of time
425 print 2 $((2 * $a)) .
430 name: arith-div-assoc-1
432 Check associativity of division operator
438 name: arith-div-byzero
440 Check division by zero errors out
446 expected-stderr-pattern:
449 name: arith-div-intmin-by-minusone
451 Check division overflow wraps around silently
454 echo signed:$((-2147483648 / -1))r$((-2147483648 % -1)).
455 echo unsigned:$((# -2147483648 / -1))r$((# -2147483648 % -1)).
457 signed:-2147483648r0.
458 unsigned:0r2147483648.
460 name: arith-div-intmin-by-minusone-64
462 Check division overflow wraps around silently
465 echo signed:$((-9223372036854775808 / -1))r$((-9223372036854775808 % -1)).
466 echo unsigned:$((# -9223372036854775808 / -1))r$((# -9223372036854775808 % -1)).
468 signed:-9223372036854775808r0.
469 unsigned:0r9223372036854775808.
471 name: arith-assop-assoc-1
473 Check associativity of assignment-operator operator
475 typeset -i i=1 j=2 k=3
476 echo $((i += j += k))
482 name: arith-mandatory
484 Passing of this test is *mandatory* for a valid mksh executable!
485 category: shell:legacy-no
490 print -r -- $((x++)):$sari=$uari. #0
492 print -r -- $((x++)):$sari=$uari. #1
493 sari=2147483647 uari=2147483647
494 print -r -- $((x++)):$sari=$uari. #2
496 print -r -- $((x++)):$sari=$uari. #3
498 let 'sari *= 2' 'uari *= 2'
500 print -r -- $((x++)):$sari=$uari. #4
502 print -r -- $((x++)):$sari=$uari. #5
503 sari=-2147483648 uari=-2147483648
504 print -r -- $((x++)):$sari=$uari. #6
506 print -r -- $((x++)):$sari=$uari. #7
508 ((# uari = -5 >> 1 ))
509 print -r -- $((x++)):$sari=$uari. #8
512 print -r -- $((x++)):$sari=$uari. #9
516 2:2147483647=2147483647.
517 3:-2147483648=2147483648.
520 6:-2147483648=2147483648.
521 7:2147483647=2147483647.
525 name: arith-unsigned-1
527 Check if unsigned arithmetics work
531 echo x1 $((-1)) $((#-1))
535 vs=4123456789; vu=4123456789
537 (( vs %= 2147483647 ))
538 (( vu %= 2147483647 ))
540 vs=4123456789; vu=4123456789
541 (( # vs %= 2147483647 ))
542 (( # vu %= 2147483647 ))
544 # make sure the calculation does not change unsigned flag
545 vs=4123456789; vu=4123456789
548 echo x6 $((# vs % 2147483647)) $((# vu % 2147483647))
553 echo x7 ${va[#4123456789%2147483647]}
554 # make sure multiple calculations don't interfere with each other
555 let '# mca = -4 % -2' ' mcb = -4 % -2'
559 x2 -171510507 4123456789
560 x3 -171510507 4123456789
561 x4 1975973142 1975973142
562 x5 -171510507 4123456789
563 x6 1975973142 1975973142
567 name: arith-limit32-1
569 Check if arithmetics are 32 bit
573 echo x1 $((-1)) $((#-1))
577 vs=2147483647; vu=2147483647
581 vs=4294967295; vu=4294967295
589 x2 2147483647 2147483647
590 x3 -2147483648 2147483648
595 name: arith-limit64-1
597 Check if arithmetics are 64 bit
601 echo x1 $((-1)) $((#-1))
605 vs=9223372036854775807; vu=9223372036854775807
609 vs=18446744073709551615; vu=18446744073709551615
616 x1 -1 18446744073709551615
617 x2 9223372036854775807 9223372036854775807
618 x3 -9223372036854775808 9223372036854775808
619 x4 -1 18446744073709551615
625 Check that \newline is not collapsed after #
635 Check that \newline is not collapsed inside single quotes
647 Check that \newline is not collapsed inside single quotes
659 Check interaction of aliases, single quotes and here-documents
660 with backslash-newline
661 (don't know what POSIX has to say about this)
683 Check what happens with backslash at end of input
684 (the old Bourne shell trashes them; so do we)
693 # Places \newline should be collapsed
697 Check that \newline is collapsed before, in the middle of, and
709 Check that \newline is collapsed in $ sequences
733 Check that \newline is collapsed in $(..) and `...` sequences
758 Check that \newline is collapsed in $((..)) sequences
769 echo $((1+2+3+4+5+6)\
780 Check that \newline is collapsed in double quoted strings
795 Check that \newline is collapsed in here document delimiters
796 (ksh93 fails second part of this)
818 Check that \newline is collapsed in double-quoted here-document
837 Check that \newline is collapsed in various 2+ character tokens
882 Check that \ at the end of an alias is collapsed when followed
884 (don't know what POSIX has to say about this)
894 Check that \newline in a keyword is collapsed
904 # Places \newline should be collapsed (ksh extensions)
908 Check that \newline is collapsed in extended globbing
925 Check that \newline is collapsed in ((...)) expressions
940 See if break breaks out of loops
942 for i in a b c; do echo $i; break; echo bad-$i; done
944 for i in a b c; do echo $i; break 1; echo bad-$i; done
970 See if break breaks out of nested loops
987 What if break used outside of any loops
988 (ksh88,ksh93 don't print error messages here)
991 expected-stderr-pattern:
996 What if break N used when only N-1 loops
997 (ksh88,ksh93 don't print error messages here)
999 for i in a b c; do echo $i; break 2; echo bad-$i; done
1004 expected-stderr-pattern:
1009 Error if break argument isn't a number
1011 for i in a b c; do echo $i; break abc; echo more-$i; done
1015 expected-exit: e != 0
1016 expected-stderr-pattern:
1021 See if continue continues loops
1023 for i in a b c; do echo $i; continue; echo bad-$i ; done
1025 for i in a b c; do echo $i; continue 1; echo bad-$i; done
1061 See if continue breaks out of nested loops
1080 What if continue used outside of any loops
1081 (ksh88,ksh93 don't print error messages here)
1084 expected-stderr-pattern:
1089 What if continue N used when only N-1 loops
1090 (ksh88,ksh93 don't print error messages here)
1092 for i in a b c; do echo $i; continue 2; echo bad-$i; done
1099 expected-stderr-pattern:
1104 Error if continue argument isn't a number
1106 for i in a b c; do echo $i; continue abc; echo more-$i; done
1110 expected-exit: e != 0
1111 expected-stderr-pattern:
1116 Test someone's CD history package (uses arrays)
1118 # go to known place before doing anything
1132 if [ "$CDHISTFILE" -a -r "$CDHISTFILE" ] # if directory history exists
1136 while read -r t # read directory history file
1142 if [ "${CDHIST[0]}" != "$PWD" -a "$PWD" != "" ]
1144 _cdins # insert $PWD into cd history
1147 cdlen=${#CDHIST[*]} # number of elements in history
1151 if [ "$OLDPWD" = "" ] && ((cdlen>1))
1153 'print' ${CDHIST[1]}
1161 -l) # print directory list
1164 while (((i=i-1)>=0))
1167 'print' "$num ${CDHIST[i]}"
1171 -[0-9]|-[0-9][0-9]) # cd to dir in list
1172 if (((i=${1#-})<cdlen))
1174 'print' ${CDHIST[i]}
1182 -*) # cd to matched dir in list
1187 case ${CDHIST[i]} in
1189 'print' ${CDHIST[i]}
1209 _cdins # insert $PWD into cd history
1211 if [ "$CDHISTFILE" ]
1213 cdlen=${#CDHIST[*]} # number of elements in history
1218 'print' -r ${CDHIST[i]} # update directory history
1224 function _cdins # insert $PWD into cd history
1225 { # meant to be called only by _cd
1229 while ((i<${#CDHIST[*]})) # see if dir is already in list
1231 if [ "${CDHIST[$i]}" = "$PWD" ]
1238 if ((i>22)) # limit max size of list
1243 while (((i=i-1)>=0)) # bump old dirs in list
1245 CDHIST[i+1]=${CDHIST[i]}
1248 CDHIST[0]=$PWD # insert new directory in list
1276 Check package for cd -Pe
1278 # the mv command fails on Cygwin
1279 # Hurd aborts the testsuite (permission denied)
1280 # QNX does not find subdir to cd into
1281 category: !os:cygwin,!os:gnu,!os:msys,!os:nto,!os:os390,!nosymlink
1282 file-setup: file 644 "x"
1283 mkdir noread noread/target noread/target/subdir
1290 echo 1=$?,${PWD#$bwd/}
1291 epwd=$($TSHELL -c pwd 2>/dev/null)
1292 # This unexpectedly succeeds on GNU/Linux and MidnightBSD
1295 mv ../../noread ../../renamed
1297 echo 2=$?,${PWD#$bwd/}
1300 rm -rf noread link renamed
1302 export TSHELL="$__progname"
1309 2=0,noread/target/subdir
1313 2=1,noread/target/subdir
1317 Check that prompt not printed when processing ENV
1318 env-setup: !ENV=./foo!
1319 file-setup: file 644 "foo"
1334 Check that weird ${foo+bar} constructs are parsed correctly
1336 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
1337 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "<$x> "; done' >pfs
1339 (echo 1 ${IFS+'}'z}) 2>/dev/null || echo failed in 1
1340 (echo 2 "${IFS+'}'z}") 2>/dev/null || echo failed in 2
1341 (echo 3 "foo ${IFS+'bar} baz") 2>/dev/null || echo failed in 3
1342 (echo -n '4 '; ./pfn "foo ${IFS+"b c"} baz") 2>/dev/null || echo failed in 4
1343 (echo -n '5 '; ./pfn "foo ${IFS+b c} baz") 2>/dev/null || echo failed in 5
1344 (echo 6 ${IFS+"}"z}) 2>/dev/null || echo failed in 6
1345 (echo 7 "${IFS+"}"z}") 2>/dev/null || echo failed in 7
1346 (echo 8 "${IFS+\"}\"z}") 2>/dev/null || echo failed in 8
1347 (echo 9 "${IFS+\"\}\"z}") 2>/dev/null || echo failed in 9
1348 (echo 10 foo ${IFS+'bar} baz'}) 2>/dev/null || echo failed in 10
1349 (echo 11 "$(echo "${IFS+'}'z}")") 2>/dev/null || echo failed in 11
1350 (echo 12 "$(echo ${IFS+'}'z})") 2>/dev/null || echo failed in 12
1351 (echo 13 ${IFS+\}z}) 2>/dev/null || echo failed in 13
1352 (echo 14 "${IFS+\}z}") 2>/dev/null || echo failed in 14
1353 u=x; (echo -n '15 '; ./pfs "foo ${IFS+a"b$u{ {"{{\}b} c ${IFS+d{}} bar" ${IFS-e{}} baz; echo .) 2>/dev/null || echo failed in 15
1354 l=t; (echo 16 ${IFS+h`echo -n i ${IFS+$l}h`ere}) 2>/dev/null || echo failed in 16
1355 l=t; (echo 17 ${IFS+h$(echo -n i ${IFS+$l}h)ere}) 2>/dev/null || echo failed in 17
1356 l=t; (echo 18 "${IFS+h`echo -n i ${IFS+$l}h`ere}") 2>/dev/null || echo failed in 18
1357 l=t; (echo 19 "${IFS+h$(echo -n i ${IFS+$l}h)ere}") 2>/dev/null || echo failed in 19
1358 l=t; (echo 20 ${IFS+h`echo -n i "${IFS+$l}"h`ere}) 2>/dev/null || echo failed in 20
1359 l=t; (echo 21 ${IFS+h$(echo -n i "${IFS+$l}"h)ere}) 2>/dev/null || echo failed in 21
1360 l=t; (echo 22 "${IFS+h`echo -n i "${IFS+$l}"h`ere}") 2>/dev/null || echo failed in 22
1361 l=t; (echo 23 "${IFS+h$(echo -n i "${IFS+$l}"h)ere}") 2>/dev/null || echo failed in 23
1362 key=value; (echo -n '24 '; ./pfn "${IFS+'$key'}") 2>/dev/null || echo failed in 24
1363 key=value; (echo -n '25 '; ./pfn "${IFS+"'$key'"}") 2>/dev/null || echo failed in 25 # ksh93: “'$key'”
1364 key=value; (echo -n '26 '; ./pfn ${IFS+'$key'}) 2>/dev/null || echo failed in 26
1365 key=value; (echo -n '27 '; ./pfn ${IFS+"'$key'"}) 2>/dev/null || echo failed in 27
1366 (echo -n '28 '; ./pfn "${IFS+"'"x ~ x'}'x"'}"x}" #') 2>/dev/null || echo failed in 28
1367 u=x; (echo -n '29 '; ./pfs foo ${IFS+a"b$u{ {"{ {\}b} c ${IFS+d{}} bar ${IFS-e{}} baz; echo .) 2>/dev/null || echo failed in 29
1368 (echo -n '30 '; ./pfs ${IFS+foo 'b\
1369 ar' baz}; echo .) 2>/dev/null || (echo failed in 30; echo failed in 31)
1370 (echo -n '32 '; ./pfs ${IFS+foo "b\
1371 ar" baz}; echo .) 2>/dev/null || echo failed in 32
1372 (echo -n '33 '; ./pfs "${IFS+foo 'b\
1373 ar' baz}"; echo .) 2>/dev/null || echo failed in 33
1374 (echo -n '34 '; ./pfs "${IFS+foo "b\
1375 ar" baz}"; echo .) 2>/dev/null || echo failed in 34
1376 (echo -n '35 '; ./pfs ${v=a\ b} x ${v=c\ d}; echo .) 2>/dev/null || echo failed in 35
1377 (echo -n '36 '; ./pfs "${v=a\ b}" x "${v=c\ d}"; echo .) 2>/dev/null || echo failed in 36
1378 (echo -n '37 '; ./pfs ${v-a\ b} x ${v-c\ d}; echo .) 2>/dev/null || echo failed in 37
1379 (echo 38 ${IFS+x'a'y} / "${IFS+x'a'y}" .) 2>/dev/null || echo failed in 38
1380 foo="x'a'y"; (echo 39 ${foo%*'a'*} / "${foo%*'a'*}" .) 2>/dev/null || echo failed in 39
1381 foo="a b c"; (echo -n '40 '; ./pfs "${foo#a}"; echo .) 2>/dev/null || echo failed in 40
1382 (foo() { return 100; }; foo; echo 41 ${#+${#:+${#?}}\ \}\}\}}) 2>/dev/null || echo failed in 41
1398 15 <foo abx{ {{{}b c d{} bar> <}> <baz> .
1412 29 <foo> <abx{ {{> <{}b> <c> <d{}> <bar> <}> <baz> .
1415 32 <foo> <bar> <baz> .
1416 33 <foo 'bar' baz> .
1418 35 <a> <b> <x> <a> <b> .
1419 36 <a\ b> <x> <a\ b> .
1420 37 <a b> <x> <c d> .
1426 name: expand-unglob-dblq
1428 Check that regular "${foo+bar}" constructs are parsed correctly
1433 test x"$v" = x"-" && unset v
1434 (echo "$1 plus norm foo ${v+'bar'} baz")
1435 (echo "$1 dash norm foo ${v-'bar'} baz")
1436 (echo "$1 eqal norm foo ${v='bar'} baz")
1437 (echo "$1 qstn norm foo ${v?'bar'} baz") 2>/dev/null || \
1438 echo "$1 qstn norm -> error"
1439 (echo "$1 PLUS norm foo ${v:+'bar'} baz")
1440 (echo "$1 DASH norm foo ${v:-'bar'} baz")
1441 (echo "$1 EQAL norm foo ${v:='bar'} baz")
1442 (echo "$1 QSTN norm foo ${v:?'bar'} baz") 2>/dev/null || \
1443 echo "$1 QSTN norm -> error"
1447 test x"$v" = x"-" && unset v
1448 (echo "$1 plus parn foo ${v+(bar)} baz")
1449 (echo "$1 dash parn foo ${v-(bar)} baz")
1450 (echo "$1 eqal parn foo ${v=(bar)} baz")
1451 (echo "$1 qstn parn foo ${v?(bar)} baz") 2>/dev/null || \
1452 echo "$1 qstn parn -> error"
1453 (echo "$1 PLUS parn foo ${v:+(bar)} baz")
1454 (echo "$1 DASH parn foo ${v:-(bar)} baz")
1455 (echo "$1 EQAL parn foo ${v:=(bar)} baz")
1456 (echo "$1 QSTN parn foo ${v:?(bar)} baz") 2>/dev/null || \
1457 echo "$1 QSTN parn -> error"
1461 test x"$v" = x"-" && unset v
1462 (echo "$1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz")
1463 (echo "$1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz")
1464 (echo "$1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz")
1465 (echo "$1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz") 2>/dev/null || \
1466 echo "$1 qstn brac -> error"
1467 (echo "$1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz")
1468 (echo "$1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz")
1469 (echo "$1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz")
1470 (echo "$1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz") 2>/dev/null || \
1471 echo "$1 QSTN brac -> error"
1473 : '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' '}}}'
1485 1 dash norm foo 'bar' baz
1486 1 eqal norm foo 'bar' baz
1487 1 qstn norm -> error
1489 1 DASH norm foo 'bar' baz
1490 1 EQAL norm foo 'bar' baz
1491 1 QSTN norm -> error
1492 2 plus norm foo 'bar' baz
1497 2 DASH norm foo 'bar' baz
1498 2 EQAL norm foo 'bar' baz
1499 2 QSTN norm -> error
1500 3 plus norm foo 'bar' baz
1501 3 dash norm foo x baz
1502 3 eqal norm foo x baz
1503 3 qstn norm foo x baz
1504 3 PLUS norm foo 'bar' baz
1505 3 DASH norm foo x baz
1506 3 EQAL norm foo x baz
1507 3 QSTN norm foo x baz
1509 4 dash parn foo (bar) baz
1510 4 eqal parn foo (bar) baz
1511 4 qstn parn -> error
1513 4 DASH parn foo (bar) baz
1514 4 EQAL parn foo (bar) baz
1515 4 QSTN parn -> error
1516 5 plus parn foo (bar) baz
1521 5 DASH parn foo (bar) baz
1522 5 EQAL parn foo (bar) baz
1523 5 QSTN parn -> error
1524 6 plus parn foo (bar) baz
1525 6 dash parn foo x baz
1526 6 eqal parn foo x baz
1527 6 qstn parn foo x baz
1528 6 PLUS parn foo (bar) baz
1529 6 DASH parn foo x baz
1530 6 EQAL parn foo x baz
1531 6 QSTN parn foo x baz
1532 7 plus brac foo c } baz
1533 7 dash brac foo ax{{{}b c d{} baz
1534 7 eqal brac foo ax{{{}b c ax{{{}b} baz
1535 7 qstn brac -> error
1536 7 PLUS brac foo c } baz
1537 7 DASH brac foo ax{{{}b c d{} baz
1538 7 EQAL brac foo ax{{{}b c ax{{{}b} baz
1539 7 QSTN brac -> error
1540 8 plus brac foo ax{{{}b c d{} baz
1541 8 dash brac foo c } baz
1542 8 eqal brac foo c } baz
1543 8 qstn brac foo c } baz
1544 8 PLUS brac foo c } baz
1545 8 DASH brac foo ax{{{}b c d{} baz
1546 8 EQAL brac foo ax{{{}b c ax{{{}b} baz
1547 8 QSTN brac -> error
1548 9 plus brac foo ax{{{}b c d{} baz
1549 9 dash brac foo x c x} baz
1550 9 eqal brac foo x c x} baz
1551 9 qstn brac foo x c x} baz
1552 9 PLUS brac foo ax{{{}b c d{} baz
1553 9 DASH brac foo x c x} baz
1554 9 EQAL brac foo x c x} baz
1555 9 QSTN brac foo x c x} baz
1557 name: expand-unglob-unq
1559 Check that regular ${foo+bar} constructs are parsed correctly
1564 test x"$v" = x"-" && unset v
1565 (echo $1 plus norm foo ${v+'bar'} baz)
1566 (echo $1 dash norm foo ${v-'bar'} baz)
1567 (echo $1 eqal norm foo ${v='bar'} baz)
1568 (echo $1 qstn norm foo ${v?'bar'} baz) 2>/dev/null || \
1569 echo "$1 qstn norm -> error"
1570 (echo $1 PLUS norm foo ${v:+'bar'} baz)
1571 (echo $1 DASH norm foo ${v:-'bar'} baz)
1572 (echo $1 EQAL norm foo ${v:='bar'} baz)
1573 (echo $1 QSTN norm foo ${v:?'bar'} baz) 2>/dev/null || \
1574 echo "$1 QSTN norm -> error"
1578 test x"$v" = x"-" && unset v
1579 (echo $1 plus parn foo ${v+\(bar')'} baz)
1580 (echo $1 dash parn foo ${v-\(bar')'} baz)
1581 (echo $1 eqal parn foo ${v=\(bar')'} baz)
1582 (echo $1 qstn parn foo ${v?\(bar')'} baz) 2>/dev/null || \
1583 echo "$1 qstn parn -> error"
1584 (echo $1 PLUS parn foo ${v:+\(bar')'} baz)
1585 (echo $1 DASH parn foo ${v:-\(bar')'} baz)
1586 (echo $1 EQAL parn foo ${v:=\(bar')'} baz)
1587 (echo $1 QSTN parn foo ${v:?\(bar')'} baz) 2>/dev/null || \
1588 echo "$1 QSTN parn -> error"
1592 test x"$v" = x"-" && unset v
1593 (echo $1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz)
1594 (echo $1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz)
1595 (echo $1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz)
1596 (echo $1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz) 2>/dev/null || \
1597 echo "$1 qstn brac -> error"
1598 (echo $1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz)
1599 (echo $1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz)
1600 (echo $1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz)
1601 (echo $1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz) 2>/dev/null || \
1602 echo "$1 QSTN brac -> error"
1604 : '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' '}}}'
1616 1 dash norm foo bar baz
1617 1 eqal norm foo bar baz
1618 1 qstn norm -> error
1620 1 DASH norm foo bar baz
1621 1 EQAL norm foo bar baz
1622 1 QSTN norm -> error
1623 2 plus norm foo bar baz
1628 2 DASH norm foo bar baz
1629 2 EQAL norm foo bar baz
1630 2 QSTN norm -> error
1631 3 plus norm foo bar baz
1632 3 dash norm foo x baz
1633 3 eqal norm foo x baz
1634 3 qstn norm foo x baz
1635 3 PLUS norm foo bar baz
1636 3 DASH norm foo x baz
1637 3 EQAL norm foo x baz
1638 3 QSTN norm foo x baz
1640 4 dash parn foo (bar) baz
1641 4 eqal parn foo (bar) baz
1642 4 qstn parn -> error
1644 4 DASH parn foo (bar) baz
1645 4 EQAL parn foo (bar) baz
1646 4 QSTN parn -> error
1647 5 plus parn foo (bar) baz
1652 5 DASH parn foo (bar) baz
1653 5 EQAL parn foo (bar) baz
1654 5 QSTN parn -> error
1655 6 plus parn foo (bar) baz
1656 6 dash parn foo x baz
1657 6 eqal parn foo x baz
1658 6 qstn parn foo x baz
1659 6 PLUS parn foo (bar) baz
1660 6 DASH parn foo x baz
1661 6 EQAL parn foo x baz
1662 6 QSTN parn foo x baz
1663 7 plus brac foo c } baz
1664 7 dash brac foo ax{{{}b c d{} baz
1665 7 eqal brac foo ax{{{}b c ax{{{}b} baz
1666 7 qstn brac -> error
1667 7 PLUS brac foo c } baz
1668 7 DASH brac foo ax{{{}b c d{} baz
1669 7 EQAL brac foo ax{{{}b c ax{{{}b} baz
1670 7 QSTN brac -> error
1671 8 plus brac foo ax{{{}b c d{} baz
1672 8 dash brac foo c } baz
1673 8 eqal brac foo c } baz
1674 8 qstn brac foo c } baz
1675 8 PLUS brac foo c } baz
1676 8 DASH brac foo ax{{{}b c d{} baz
1677 8 EQAL brac foo ax{{{}b c ax{{{}b} baz
1678 8 QSTN brac -> error
1679 9 plus brac foo ax{{{}b c d{} baz
1680 9 dash brac foo x c x} baz
1681 9 eqal brac foo x c x} baz
1682 9 qstn brac foo x c x} baz
1683 9 PLUS brac foo ax{{{}b c d{} baz
1684 9 DASH brac foo x c x} baz
1685 9 EQAL brac foo x c x} baz
1686 9 QSTN brac foo x c x} baz
1688 name: expand-threecolons-dblq
1690 Check for a particular thing that used to segfault
1693 echo "${TEST:1:2:3}"
1694 echo $? but still living
1695 expected-stderr-pattern:
1699 name: expand-threecolons-unq
1701 Check for a particular thing that used to not error out
1705 echo $? but still living
1706 expected-stderr-pattern:
1710 name: expand-weird-1
1712 Check corner cases of trim expansion vs. $# vs. ${#var} vs. ${var?}
1714 set 1 2 3 4 5 6 7 8 9 10 11
1715 echo ${#} # value of $#
1716 echo ${##} # length of $#
1717 echo ${##1} # $# trimmed 1
1718 set 1 2 3 4 5 6 7 8 9 10 11 12
1732 name: expand-weird-2
1734 Check more substitution and extension corner cases
1736 :& set -C; pid=$$; sub=$!; flg=$-; set -- i; exec 3>x.tmp
1737 #echo "D: !=$! #=$# \$=$$ -=$- ?=$?"
1738 echo >&3 3 = s^${!-word} , ${#-word} , p^${$-word} , f^${--word} , ${?-word} .
1739 echo >&3 4 = ${!+word} , ${#+word} , ${$+word} , ${-+word} , ${?+word} .
1740 echo >&3 5 = s^${!=word} , ${#=word} , p^${$=word} , f^${-=word} , ${?=word} .
1741 echo >&3 6 = s^${!?word} , ${#?word} , p^${$?word} , f^${-?word} , ${??word} .
1742 echo >&3 7 = sl^${#!} , ${##} , pl^${#$} , fl^${#-} , ${#?} .
1743 echo >&3 8 = sw^${%!} , ${%#} , pw^${%$} , fw^${%-} , ${%?} .
1744 echo >&3 9 = ${!!} , s^${!#} , ${!$} , s^${!-} , s^${!?} .
1745 echo >&3 10 = s^${!#pattern} , ${##pattern} , p^${$#pattern} , f^${-#pattern} , ${?#pattern} .
1746 echo >&3 11 = s^${!%pattern} , ${#%pattern} , p^${$%pattern} , f^${-%pattern} , ${?%pattern} .
1747 echo >&3 12 = $# : ${##} , ${##1} .
1749 echo >&3 14 = $# : ${##} , ${##1} .
1751 echo >&3 16 = $# : ${##} , ${##1} .
1752 set -- 1 2 3 4 5 6 7 8 9 a b c d e
1753 echo >&3 18 = $# : ${##} , ${##1} .
1756 -e "s/ pl^${#pid} / PID /g" -e "s/ sl^${#sub} / SUB /g" -e "s/ fl^${#flg} / FLG /g" \
1757 -e "s/ pw^${%pid} / PID /g" -e "s/ sw^${%sub} / SUB /g" -e "s/ fw^${%flg} / FLG /g" \
1758 -e "s/ p^$pid / PID /g" -e "s/ s^$sub / SUB /g" -e "s/ f^$flg / FLG /g"
1760 3 = SUB , 1 , PID , FLG , 0 .
1761 4 = word , word , word , word , word .
1762 5 = SUB , 1 , PID , FLG , 0 .
1763 6 = SUB , 1 , PID , FLG , 0 .
1764 7 = SUB , 1 , PID , FLG , 1 .
1765 8 = SUB , 1 , PID , FLG , 1 .
1766 9 = ! , SUB , $ , SUB , SUB .
1767 10 = SUB , 1 , PID , FLG , 0 .
1768 11 = SUB , 1 , PID , FLG , 0 .
1774 name: expand-weird-3
1776 Check that trimming works with positional parameters (Debian #48453)
1787 name: expand-weird-4
1789 Check that tilde expansion is enabled in ${x#~}
1790 and cases that are modelled after it (${x/~/~})
1794 echo "<${a#~}> <${a#\~}> <${b:-~}> <${b:-\~}> <${c:=~}><$c> <${a/~}> <${a/x/~}> <${a/x/\~}>"
1796 <~/x> </x> <~> <\~> <~><~> <~/x> <~//etc> <~/~>
1800 Check corner case of ${!?} with ! being var vs. op
1804 expected-stderr-pattern: /not set/
1808 Check corner case of ${!var} vs. ${var op} with var=!
1814 # get an at least three-digit bg pid
1818 if [[ $x != +([0-9]) ]]; then
1819 echo >&2 "cannot test, pid '$x' not numeric"
1820 echo >&2 report this with as many details as possible
1823 [[ $x = [0-9][0-9][0-9]* ]] && break
1826 t=$!; [[ $t = $x ]]; echo 5 $? .
1827 t=${!#}; [[ $t = $x ]]; echo 6 $? .
1828 t=${!#[0-9]}; [[ $t = $y ]]; echo 7 $? .
1829 t=${!-foo}; [[ $t = $x ]]; echo 8 $? .
1830 t=${!?bar}; [[ $t = $x ]]; echo 9 $? .
1842 name: expand-number-1
1844 Check that positional arguments do not overflow
1846 echo "1 ${12345678901234567890} ."
1850 name: expand-slashes-1
1852 Check that side effects in substring replacement are handled correctly
1857 echo 1 ${foo//n$((n++))/[$((++i))]} .
1863 name: expand-slashes-2
1865 Check that side effects in substring replacement are handled correctly
1870 echo 1 ${foo@/n$((n++))/[$((++i))]} .
1876 name: expand-slashes-3
1878 Check that we can access the replaced string
1881 echo 1 ${foo@/n[12]/[$KSH_MATCH]} .
1883 1 [n1][n1][n1][n2]n3 .
1887 Check that globbing isn't done when glob has syntax error
1888 file-setup: file 644 "abcx"
1889 file-setup: file 644 "abcz"
1890 file-setup: file 644 "bbc"
1900 Check that globbing isn't done when glob has syntax error
1901 (AT&T ksh fails this test)
1902 file-setup: file 644 "abcx"
1903 file-setup: file 644 "abcz"
1904 file-setup: file 644 "bbc"
1910 name: eglob-infinite-plus
1912 Check that shell doesn't go into infinite loop expanding +(...)
1914 file-setup: file 644 "abc"
1929 Check that eglobbing isn't done on substitution results
1930 file-setup: file 644 "abc"
1937 name: eglob-nomatch-1
1939 Check that the pattern doesn't match
1941 echo 1: no-file+(a|b)stuff
1942 echo 2: no-file+(a*(c)|b)stuff
1943 echo 3: no-file+((((c)))|b)stuff
1945 1: no-file+(a|b)stuff
1946 2: no-file+(a*(c)|b)stuff
1947 3: no-file+((((c)))|b)stuff
1951 Check that the pattern matches correctly
1952 file-setup: file 644 "abd"
1953 file-setup: file 644 "acd"
1954 file-setup: file 644 "abac"
1958 echo 3: *(a(b|c)) # (...|...) can be used within X(..)
1959 echo 4: a[b*(foo|bar)]d # patterns not special inside [...]
1968 Simple negation tests
1970 case foo in !(foo|bar)) echo yes;; *) echo no;; esac
1971 case bar in !(foo|bar)) echo yes;; *) echo no;; esac
1980 case foo in *(a|b[)) echo yes;; *) echo no;; esac
1981 case foo in *(a|b[)|f*) echo yes;; *) echo no;; esac
1982 case '*(a|b[)' in *(a|b[)) echo yes;; *) echo no;; esac
1990 Eglobbing in trim expressions...
1991 (AT&T ksh fails this - docs say # matches shortest string, ## matches
2007 Check eglobbing works in trims...
2010 echo 1: ${x#*(a|b)cd}
2011 echo 2: "${x#*(a|b)cd}"
2012 echo 3: ${x#"*(a|b)cd"}
2022 Check eglobbing works in trims, for Korn Shell
2023 Ensure eglobbing does not work for reduced-feature /bin/sh
2029 echo "<${x%bar|baz},${y%bar|baz},${z%\?}>"
2030 echo "<${x%ba(r|z)},${y%ba(r|z)}>"
2032 echo "<${x%bar|baz},${y%bar|baz},${z%\?}>"
2038 <foobar,foobaz,fooba>
2041 name: eglob-substrpl-1
2043 Check eglobbing works in substs... and they work at all
2045 [[ -n $BASH_VERSION ]] && shopt -s extglob
2046 x=1222321_ab/cde_b/c_1221
2048 echo 1: ${x/2} . ${x/}
2055 echo 8: ${x//+(2)/4}
2056 echo 9: ${x/b/c/e/f}
2057 echo 10: ${x/b\/c/e/f}
2058 echo 11: ${x/b\/c/e\/f}
2059 echo 12: ${x/b\/c/e\\/f}
2060 echo 13: ${x/b\\/c/e\\/f}
2061 echo 14: ${x//b/c/e/f}
2062 echo 15: ${x//b\/c/e/f}
2063 echo 16: ${x//b\/c/e\/f}
2064 echo 17: ${x//b\/c/e\\/f}
2065 echo 18: ${x//b\\/c/e\\/f}
2066 echo 19: ${x/b\/*\/c/x}
2074 echo 27: ${x//\%1/9}
2075 echo 28: ${x//\\%1/9}
2077 echo 30: ${x//\\a/9}
2080 1: 122321_ab/cde_b/c_1221 . 1222321_ab/cde_b/c_1221
2081 2: 131_ab/cde_b/c_11
2082 3: 1321_ab/cde_b/c_1221
2083 4: 131_ab/cde_b/c_11
2084 5: 1422321_ab/cde_b/c_1221
2085 6: 1444341_ab/cde_b/c_1441
2086 7: 14321_ab/cde_b/c_1221
2087 8: 14341_ab/cde_b/c_141
2088 9: 1222321_ac/e/f/cde_b/c_1221
2089 10: 1222321_ae/fde_b/c_1221
2090 11: 1222321_ae/fde_b/c_1221
2091 12: 1222321_ae\/fde_b/c_1221
2092 13: 1222321_ab/cde_b/c_1221
2093 14: 1222321_ac/e/f/cde_c/e/f/c_1221
2094 15: 1222321_ae/fde_e/f_1221
2095 16: 1222321_ae/fde_e/f_1221
2096 17: 1222321_ae\/fde_e\/f_1221
2097 18: 1222321_ab/cde_b/c_1221
2099 20: 1222321_ab.cde_b/c_1221
2100 21: 1222321_ab.cde_b.c_1221
2101 22: 1222321_ab/cde_b/c_1221
2102 23: 9222321_ab/cde_b/c_1221
2103 24: 1222321_ab/cde_b/c_1221
2104 25: 1222321_ab/cde_b/c_1229
2105 26: 1222321_ab/cde_b/c_1221
2106 27: 1222321_ab/cde_b/c_1221
2107 28: 1222321_ab/cde_b/c_1221
2108 29: 1222321_9b/cde_b/c_1221
2109 30: 1222321_ab/cde_b/c_1221
2110 31: 1xyz22321_ab/cde_b/c_1221
2112 name: eglob-substrpl-2
2114 Check anchored substring replacement works, corner cases
2131 name: eglob-substrpl-3a
2133 Check substring replacement works with variables and slashes, too
2138 echo "${wd/#$pfx/~}"
2139 echo "${wd/#\$pfx/~}"
2140 echo "${wd/#"$pfx"/~}"
2141 echo "${wd/#'$pfx'/~}"
2142 echo "${wd/#"\$pfx"/~}"
2143 echo "${wd/#'\$pfx'/~}"
2152 name: eglob-substrpl-3b
2154 More of this, bash fails it (bash4 passes)
2159 echo "${wd/#$(echo /home/user)/~}"
2160 echo "${wd/#"$(echo /home/user)"/~}"
2161 echo "${wd/#'$(echo /home/user)'/~}"
2167 name: eglob-substrpl-3c
2169 Even more weird cases
2174 echo 1: ${wd/#$pfx/~}
2175 echo 2: ${wd/#\$pfx/~}
2176 echo 3: ${wd/#"$pfx"/~}
2177 echo 4: ${wd/#'$pfx'/~}
2178 echo 5: ${wd/#"\$pfx"/~}
2179 echo 6: ${wd/#'\$pfx'/~}
2180 ts='a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)'
2183 [[ -n $BASH_VERSION ]] && shopt -s extglob
2184 echo 7: ${ts/a\/b/$tr}
2185 echo 8: ${ts/a\/b/\$tr}
2186 echo 9: ${ts/$tp/$tr}
2187 echo 10: ${ts/\$tp/$tr}
2188 echo 11: ${ts/\\$tp/$tr}
2189 echo 12: ${ts/$tp/c/d}
2190 echo 13: ${ts/$tp/c\/d}
2191 echo 14: ${ts/$tp/c\\/d}
2192 echo 15: ${ts/+(a\/b)/$tr}
2193 echo 16: ${ts/+(a\/b)/\$tr}
2194 echo 17: ${ts/+($tp)/$tr}
2195 echo 18: ${ts/+($tp)/c/d}
2196 echo 19: ${ts/+($tp)/c\/d}
2197 echo 20: ${ts//a\/b/$tr}
2198 echo 21: ${ts//a\/b/\$tr}
2199 echo 22: ${ts//$tp/$tr}
2200 echo 23: ${ts//$tp/c/d}
2201 echo 24: ${ts//$tp/c\/d}
2202 echo 25: ${ts//+(a\/b)/$tr}
2203 echo 26: ${ts//+(a\/b)/\$tr}
2204 echo 27: ${ts//+($tp)/$tr}
2205 echo 28: ${ts//+($tp)/c/d}
2206 echo 29: ${ts//+($tp)/c\/d}
2208 echo 30: ${ts/$tp/$tr}
2209 echo 31: ${ts//$tp/$tr}
2217 7: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2218 8: $tra/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2219 9: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2220 10: a/ba/bc/d$tp_a/b$tp_*(a/b)_*($tp)
2221 11: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2222 12: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2223 13: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2224 14: c\/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2225 15: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2226 16: $tr$tp$tp_a/b$tp_*(a/b)_*($tp)
2227 17: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2228 18: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2229 19: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2230 20: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2231 21: $tr$tr$tp$tp_$tr$tp_*($tr)_*($tp)
2232 22: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2233 23: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2234 24: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2235 25: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2236 26: $tr$tp$tp_$tr$tp_*($tr)_*($tp)
2237 27: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2238 28: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2239 29: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2240 30: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2241 31: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2242 # This is what GNU bash does:
2243 # 30: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2244 # 31: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2248 UTF-8 mode differences for eglobbing
2253 print 2: ${s/b???d/x} .
2256 print 4: ${s/b??d/x} .
2258 print 5: ${x%?} ${x%%?} .
2260 print 6: ${x#?} ${x##?} .
2262 print 7: ${x%?} ${x%%?} .
2264 print 8: ${x%?} ${x%%?} .
2266 print 9: ${x%?} ${x%%?} .
2280 Check that globbing isn't done when glob has syntax error
2281 file-setup: dir 755 "[x"
2282 file-setup: file 644 "[x/foo"
2294 Check that symbolic links aren't stat()'d
2295 # breaks on Dell UNIX 4.0 R2.2 (SVR4) where unlink also fails
2296 # breaks on FreeMiNT (cannot unlink dangling symlinks)
2297 # breaks on MSYS, OS/2 (do not support symlinks)
2298 category: !os:mint,!os:msys,!os:svr4.0,!nosymlink
2299 file-setup: dir 755 "dir"
2300 file-setup: symlink 644 "dir/abc"
2312 file-setup: file 644 ".bc"
2313 file-setup: file 644 "abc"
2314 file-setup: file 644 "bbc"
2315 file-setup: file 644 "cbc"
2316 file-setup: file 644 "-bc"
2339 (AT&T ksh fails this; POSIX says invalid)
2340 file-setup: file 644 "abc"
2348 Check that globbing matches the right things...
2349 # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
2350 # breaks on Cygwin 1.7 (files are now UTF-16 or something)
2351 # breaks on QNX 6.4.1 (says RT)
2352 category: !os:cygwin,!os:darwin,!os:msys,!os:nto,!os:os2
2354 file-setup: file 644 "aÂc"
2362 Results unspecified according to POSIX
2363 file-setup: file 644 ".bc"
2371 Results unspecified according to POSIX
2372 (AT&T ksh treats this like [a-cc-e]*)
2373 file-setup: file 644 "abc"
2374 file-setup: file 644 "bbc"
2375 file-setup: file 644 "cbc"
2376 file-setup: file 644 "dbc"
2377 file-setup: file 644 "ebc"
2378 file-setup: file 644 "-bc"
2386 Check against a regression from fixing IFS-subst-2
2389 print -r "before='$x'"
2391 print -r "after ='$x'"
2398 Check ordering/content of redundent here documents.
2410 Check quoted here-doc is protected.
2429 Check that newline isn't needed after heredoc-delimiter marker.
2441 Check that an error occurs if the heredoc-delimiter is missing.
2446 expected-exit: e > 0
2447 expected-stderr-pattern: /.*/
2451 Check that an error occurs if the heredoc-delimiter is missing.
2457 expected-exit: e > 0
2458 expected-stderr-pattern: /.*/
2462 Check that an error occurs if the heredoc is missing.
2465 expected-exit: e > 0
2466 expected-stderr-pattern: /.*/
2470 Check that an error occurs if the heredoc is missing.
2474 expected-exit: e > 0
2475 expected-stderr-pattern: /.*/
2479 Check that backslash quotes a $, ` and \ and kills a \newline
2486 th\`echo not-run\`ere
2487 th\\`echo is-run`ere
2504 Check that \newline in initial here-delim word doesn't imply
2519 Check that double quoted $ expressions in here delimiters are
2520 not expanded and match the delimiter.
2521 POSIX says only quote removal is applied to the delimiter.
2538 Check that double quoted escaped $ expressions in here
2539 delimiters are not expanded and match the delimiter.
2540 POSIX says only quote removal is applied to the delimiter
2541 (\ counts as a quote).
2562 Check that here strings work.
2566 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo
2567 "$__progname" -c "tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo"
2568 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$bar"
2569 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<'$bar'
2570 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$bar
2571 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<-foo
2572 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$(echo "foo bar")"
2573 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"A $(echo "foo bar") B"
2574 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$b\$b$bar
2590 Check that a corner case of here strings works like bash
2595 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
2602 Check that a corner case of here strings works like ksh93, zsh
2607 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
2614 Check another corner case of here strings
2616 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<< bar
2622 Check here string related regression with multiple iops
2624 echo $(tr r z <<<'bar' 2>/dev/null)
2630 Check long here strings
2638 Check direct here document assignment
2652 fnd=$(typeset -f foo)
2660 # rather nonsensical, but…
2663 vf=<<<$'=f $x \x40='
2665 print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} ve={$ve} vf={$vf} |"
2673 print -r -- "| ${v//$'\n'/^} |"
2693 Check here documents with no or empty delimiter
2710 fnd=$(typeset -f foo)
2718 print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} |"
2722 print -r -- "| vc={$vc} vd={$vd} |"
2730 print -r -- "| ${v//$'\n'/^} |"
2765 Check here documents can use $* and $@; note shells vary:
2766 • pdksh 5.2.14 acts the same
2767 • dash has 1 and 2 the same but 3 lacks the space
2768 • ksh93, bash4 differ in 2 by using space ipv colon
2810 Check that using multiple here documents works
2813 echo "got $(cat) on stdin"
2814 echo "got $(cat <&4) on fd#4"
2815 echo "got $(cat <&5) on fd#5"
2818 foo 4<<-a <<-b 5<<-c
2829 [[ $x = "$y" ]]; echo $?
2835 foo 4<<-a <<-b 5<<-c
2848 name: heredoc-comsub-1
2850 Tests for here documents in COMSUB, taken from Austin ML
2857 = here is the text =
2859 name: heredoc-comsub-2
2861 Tests for here documents in COMSUB, taken from Austin ML
2863 unbalanced=$(cat <<EOF
2864 this paren ) is a problem
2866 echo = $unbalanced =
2868 = this paren ) is a problem =
2870 name: heredoc-comsub-3
2872 Tests for here documents in COMSUB, taken from Austin ML
2874 balanced=$(cat <<EOF
2875 these parens ( ) are not a problem
2879 = these parens ( ) are not a problem =
2881 name: heredoc-comsub-4
2883 Tests for here documents in COMSUB, taken from Austin ML
2885 balanced=$(cat <<EOF
2886 these parens \( ) are a problem
2890 = these parens \( ) are a problem =
2892 name: heredoc-comsub-5
2894 Check heredoc and COMSUB mixture in input
2896 prefix() { sed -e "s/^/$1:/"; }
2897 XXX() { echo x-en; }
2898 YYY() { echo y-es; }
2900 prefix A <<XXX && echo "$(prefix B <<XXX
2903 echo line 2)" && prefix C <<YYY
2918 name: heredoc-comsub-6
2920 Check here documents and here strings can be used
2921 without a specific command, like $(<…) (extension)
2929 $foo) is not a problem
2938 bar) is not a problem>
2940 name: heredoc-subshell-1
2942 Tests for here documents in subshells, taken from Austin ML
2952 name: heredoc-subshell-2
2954 Tests for here documents in subshells, taken from Austin ML
2965 name: heredoc-subshell-3
2967 Tests for here documents in subshells, taken from Austin ML
2977 name: heredoc-weird-1
2979 Tests for here documents, taken from Austin ML
2980 Documents current state in mksh, *NOT* necessarily correct!
2993 name: heredoc-weird-2
2995 Tests for here documents, taken from Austin ML
3005 name: heredoc-weird-4
3007 Tests for here documents, taken from Austin ML
3008 Documents current state in mksh, *NOT* necessarily correct!
3019 name: heredoc-weird-5
3021 Tests for here documents, taken from Austin ML
3022 Documents current state in mksh, *NOT* necessarily correct!
3034 name: heredoc-tmpfile-1
3036 Check that heredoc temp files aren't removed too soon or too late.
3037 Heredoc in simple command.
3058 name: heredoc-tmpfile-2
3060 Check that heredoc temp files aren't removed too soon or too late.
3061 Heredoc in function, multiple calls to function.
3080 name: heredoc-tmpfile-3
3082 Check that heredoc temp files aren't removed too soon or too late.
3083 Heredoc in function in loop, multiple calls to function.
3110 name: heredoc-tmpfile-4
3112 Check that heredoc temp files aren't removed too soon or too late.
3113 Backgrounded simple command with here doc
3127 name: heredoc-tmpfile-5
3129 Check that heredoc temp files aren't removed too soon or too late.
3130 Backgrounded subshell command with here doc
3135 sleep 1 # so parent exits
3151 name: heredoc-tmpfile-6
3153 Check that heredoc temp files aren't removed too soon or too late.
3154 Heredoc in pipeline.
3158 cat <<- EOF | sed "s/hi/HI/"
3168 name: heredoc-tmpfile-7
3170 Check that heredoc temp files aren't removed too soon or too late.
3171 Heredoc in backgrounded pipeline.
3175 cat <<- EOF | sed 's/hi/HI/' &
3185 name: heredoc-tmpfile-8
3187 Check that heredoc temp files aren't removed too soon or too
3188 late. Heredoc in function, backgrounded call to function.
3189 This check can fail on slow machines (<100 MHz), or Cygwin,
3194 # Background eval so main shell doesn't do parsing
3202 # sleep so eval can die
3216 name: heredoc-quoting-unsubst
3218 Check for correct handling of quoted characters in
3219 here documents without substitution (marker is quoted).
3223 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
3226 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
3228 name: heredoc-quoting-subst
3230 Check for correct handling of quoted characters in
3231 here documents with substitution (marker is not quoted).
3235 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
3238 x " \" \ \ $ $ baz `echo baz` bar $foo x
3240 name: single-quotes-in-braces
3242 Check that single quotes inside unquoted {} are treated as quotes
3245 echo ${foo:+'blah $foo'}
3249 name: single-quotes-in-quoted-braces
3251 Check that single quotes inside quoted {} are treated as
3255 echo "${foo:+'blah $foo'}"
3259 name: single-quotes-in-braces-nested
3261 Check that single quotes inside unquoted {} are treated as quotes,
3262 even if that's inside a double-quoted command expansion
3265 echo "$( echo ${foo:+'blah $foo'})"
3269 name: single-quotes-in-brace-pattern
3271 Check that single quotes inside {} pattern are treated as quotes
3274 echo ${foo%'2'*} "${foo%'2'*}" ${foo%2'*'} "${foo%2'*'}"
3278 name: single-quotes-in-heredoc-braces
3280 Check that single quotes inside {} in heredoc are treated
3290 name: single-quotes-in-nested-braces
3292 Check that single quotes inside nested unquoted {} are
3296 echo ${foo:+${foo:+'blah $foo'}}
3300 name: single-quotes-in-nested-quoted-braces
3302 Check that single quotes inside nested quoted {} are treated
3306 echo "${foo:+${foo:+'blah $foo'}}"
3310 name: single-quotes-in-nested-braces-nested
3312 Check that single quotes inside nested unquoted {} are treated
3313 as quotes, even if that's inside a double-quoted command expansion
3316 echo "$( echo ${foo:+${foo:+'blah $foo'}})"
3320 name: single-quotes-in-nested-brace-pattern
3322 Check that single quotes inside nested {} pattern are treated as quotes
3325 echo ${foo:+${foo%'2'*}} "${foo:+${foo%'2'*}}" ${foo:+${foo%2'*'}} "${foo:+${foo%2'*'}}"
3329 name: single-quotes-in-heredoc-nested-braces
3331 Check that single quotes inside nested {} in heredoc are treated
3336 ${foo:+${foo:+'blah $foo'}}
3343 See if we can test history at all
3346 env-setup: !ENV=./Env!HISTFILE=hist.file!
3347 file-setup: file 644 "Env"
3355 expected-stderr-pattern:
3360 Verify duplicates and spaces are not entered
3363 env-setup: !ENV=./Env!HISTFILE=hist.file!
3364 file-setup: file 644 "Env"
3376 expected-stderr-pattern:
3379 name: history-unlink
3381 Check if broken HISTFILEs do not cause trouble
3384 env-setup: !ENV=./Env!HISTFILE=foo/hist.file!
3385 file-setup: file 644 "Env"
3387 file-setup: dir 755 "foo"
3388 file-setup: file 644 "foo/hist.file"
3391 perl-setup: chmod(0555, "foo");
3399 expected-stderr-pattern:
3400 /(.*can't unlink HISTFILE.*\n)?X*$/
3402 name: history-multiline
3404 Check correct multiline history, Debian #783978
3407 env-setup: !ENV=./Env!
3408 file-setup: file 644 "Env"
3430 expected-stderr-pattern:
3433 name: history-e-minus-1
3435 Check if more recent command is executed
3438 env-setup: !ENV=./Env!HISTFILE=hist.file!
3439 file-setup: file 644 "Env"
3449 expected-stderr-pattern:
3450 /^X*echo there\nX*$/
3452 name: history-e-minus-2
3454 Check that repeated command is printed before command
3458 env-setup: !ENV=./Env!HISTFILE=hist.file!
3459 file-setup: file 644 "Env"
3466 expected-stdout-pattern:
3467 /X*hi\nX*there\nX*echo there\nthere\nX*/
3468 expected-stderr-pattern:
3471 name: history-e-minus-3
3473 fc -e - fails when there is no history
3474 (ksh93 has a bug that causes this to fail)
3475 (ksh88 loops on this)
3478 env-setup: !ENV=./Env!HISTFILE=hist.file!
3479 file-setup: file 644 "Env"
3486 expected-stderr-pattern:
3487 /^X*.*:.*history.*\nX*$/
3489 name: history-e-minus-4
3491 Check if "fc -e -" command output goes to stdout.
3494 env-setup: !ENV=./Env!HISTFILE=hist.file!
3495 file-setup: file 644 "Env"
3499 fc -e - | (read x; echo "A $x")
3505 expected-stderr-pattern:
3508 name: history-e-minus-5
3510 fc is replaced in history by new command.
3513 env-setup: !ENV=./Env!HISTFILE=hist.file!
3514 file-setup: file 644 "Env"
3530 expected-stderr-pattern:
3531 /^X*echo ghi jkl\nX*$/
3533 name: history-list-1
3535 List lists correct range
3536 (ksh88 fails 'cause it lists the fc command)
3539 env-setup: !ENV=./Env!HISTFILE=hist.file!
3540 file-setup: file 644 "Env"
3553 expected-stderr-pattern:
3556 name: history-list-2
3558 Lists oldest history if given pre-historic number
3559 (ksh93 has a bug that causes this to fail)
3560 (ksh88 fails 'cause it lists the fc command)
3563 env-setup: !ENV=./Env!HISTFILE=hist.file!
3564 file-setup: file 644 "Env"
3578 expected-stderr-pattern:
3581 name: history-list-3
3583 Can give number 'options' to fc
3586 env-setup: !ENV=./Env!HISTFILE=hist.file!
3587 file-setup: file 644 "Env"
3602 expected-stderr-pattern:
3605 name: history-list-4
3607 -1 refers to previous command
3610 env-setup: !ENV=./Env!HISTFILE=hist.file!
3611 file-setup: file 644 "Env"
3625 expected-stderr-pattern:
3628 name: history-list-5
3630 List command stays in history
3633 env-setup: !ENV=./Env!HISTFILE=hist.file!
3634 file-setup: file 644 "Env"
3651 expected-stderr-pattern:
3654 name: history-list-6
3656 HISTSIZE limits about of history kept.
3657 (ksh88 fails 'cause it lists the fc command)
3660 env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3!
3661 file-setup: file 644 "Env"
3678 expected-stderr-pattern:
3681 name: history-list-7
3683 fc allows too old/new errors in range specification
3686 env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3!
3687 file-setup: file 644 "Env"
3705 expected-stderr-pattern:
3708 name: history-list-r-1
3710 test -r flag in history
3713 env-setup: !ENV=./Env!HISTFILE=hist.file!
3714 file-setup: file 644 "Env"
3732 expected-stderr-pattern:
3735 name: history-list-r-2
3737 If first is newer than last, -r is implied.
3740 env-setup: !ENV=./Env!HISTFILE=hist.file!
3741 file-setup: file 644 "Env"
3759 expected-stderr-pattern:
3762 name: history-list-r-3
3764 If first is newer than last, -r is cancelled.
3767 env-setup: !ENV=./Env!HISTFILE=hist.file!
3768 file-setup: file 644 "Env"
3786 expected-stderr-pattern:
3789 name: history-subst-1
3794 env-setup: !ENV=./Env!HISTFILE=hist.file!
3795 file-setup: file 644 "Env"
3800 fc -e - abc=AB 'echo a'
3805 expected-stderr-pattern:
3806 /^X*echo AB def\nX*$/
3808 name: history-subst-2
3810 Does subst find previous command?
3813 env-setup: !ENV=./Env!HISTFILE=hist.file!
3814 file-setup: file 644 "Env"
3819 fc -e - jkl=XYZQRT 'echo g'
3824 expected-stderr-pattern:
3825 /^X*echo ghi XYZQRT\nX*$/
3827 name: history-subst-3
3829 Does subst find previous command when no arguments given
3832 env-setup: !ENV=./Env!HISTFILE=hist.file!
3833 file-setup: file 644 "Env"
3843 expected-stderr-pattern:
3844 /^X*echo ghi XYZQRT\nX*$/
3846 name: history-subst-4
3848 Global substitutions work
3849 (ksh88 and ksh93 do not have -g option)
3852 env-setup: !ENV=./Env!HISTFILE=hist.file!
3853 file-setup: file 644 "Env"
3856 echo abc def asjj sadjhasdjh asdjhasd
3859 abc def asjj sadjhasdjh asdjhasd
3860 FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd
3861 expected-stderr-pattern:
3862 /^X*echo FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd\nX*$/
3864 name: history-subst-5
3866 Make sure searches don't find current (fc) command
3867 (ksh88/ksh93 don't have the ? prefix thing so they fail this test)
3870 env-setup: !ENV=./Env!HISTFILE=hist.file!
3871 file-setup: file 644 "Env"
3876 fc -e - abc=AB \?abc
3881 expected-stderr-pattern:
3882 /^X*echo AB def\nX*$/
3884 name: history-ed-1-old
3886 Basic (ed) editing works (assumes you have generic ed editor
3887 that prints no prompts). This is for oldish ed(1) which write
3888 the character count to stdout.
3893 env-setup: !ENV=./Env!HISTFILE=hist.file!
3894 file-setup: file 644 "Env"
3907 expected-stderr-pattern:
3908 /^X*echo FOOBAR def\nX*$/
3910 name: history-ed-2-old
3912 Correct command is edited when number given
3917 env-setup: !ENV=./Env!HISTFILE=hist.file!
3918 file-setup: file 644 "Env"
3926 s/is here/is changed/
3937 expected-stderr-pattern:
3938 /^X*echo line 2 is changed\nX*$/
3940 name: history-ed-3-old
3942 Newly created multi line commands show up as single command
3944 (ksh88 fails 'cause it lists the fc command)
3949 env-setup: !ENV=./Env!HISTFILE=hist.file!
3950 file-setup: file 644 "Env"
3971 expected-stderr-pattern:
3972 /^X*echo FOOBAR def\necho a new line\nX*$/
3976 Basic (ed) editing works (assumes you have generic ed editor
3977 that prints no prompts). This is for newish ed(1) and stderr.
3978 category: !no-stderr-ed
3982 env-setup: !ENV=./Env!HISTFILE=hist.file!
3983 file-setup: file 644 "Env"
3994 expected-stderr-pattern:
3995 /^X*13\n16\necho FOOBAR def\nX*$/
3999 Correct command is edited when number given
4000 category: !no-stderr-ed
4004 env-setup: !ENV=./Env!HISTFILE=hist.file!
4005 file-setup: file 644 "Env"
4013 s/is here/is changed/
4022 expected-stderr-pattern:
4023 /^X*20\n23\necho line 2 is changed\nX*$/
4027 Newly created multi line commands show up as single command
4029 category: !no-stderr-ed
4033 env-setup: !ENV=./Env!HISTFILE=hist.file!
4034 file-setup: file 644 "Env"
4053 expected-stderr-pattern:
4054 /^X*13\n32\necho FOOBAR def\necho a new line\nX*$/
4058 Simple test, default IFS
4060 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4076 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4093 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4106 name: IFS-space-colon-1
4108 Simple test, IFS=<white-space>:
4110 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4125 name: IFS-space-colon-2
4127 Simple test, IFS=<white-space>:
4128 AT&T ksh fails this, POSIX says the test is correct.
4130 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4137 name: IFS-space-colon-4
4139 Simple test, IFS=<white-space>:
4141 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4148 name: IFS-space-colon-5
4150 Simple test, IFS=<white-space>:
4151 Don't know what POSIX thinks of this. AT&T ksh does not do this.
4153 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4162 Simple test, IFS=<white-space>:
4164 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4167 echo -n '1:'; for i in $x ; do echo -n " [$i]" ; done ; echo
4168 echo -n '2:'; for i in :b:: ; do echo -n " [$i]" ; done ; echo
4172 echo -n '5:'; for i in $x ; do echo -n " [$i]" ; done ; echo
4175 echo -n '7:'; for i in $x ; do echo -n " [$i]" ; done ; echo
4177 echo -n '9:'; for i in ${FOO-`echo -n h:i`th:ere} ; do echo -n " [$i]" ; done ; echo
4178 showargs 10 ${FOO-`echo -n h:i`th:ere}
4179 showargs 11 "${FOO-`echo -n h:i`th:ere}"
4181 echo -n '12:'; for i in $x ; do echo -n " [$i]" ; done ; echo
4193 <10> <h> <ith> <ere> .
4196 <13> <A> <B> <> <D> .
4200 Check leading whitespace after trim does not make a field
4202 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4204 showargs 1 shift ${x#X}
4206 <1> <shift> <1> <2> .
4208 name: IFS-subst-3-arr
4210 Check leading IFS non-whitespace after trim does make a field
4211 but leading IFS whitespace does not, nor empty replacements
4213 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4216 showargs 1 ${-+:foo:bar}
4218 showargs 2 ${-+ foo bar}
4221 <1> <> <foo> <bar> .
4224 name: IFS-subst-3-ass
4226 Check non-field semantics
4228 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4231 showargs 1 x=${-+:foo:bar}
4233 showargs 2 x=${-+ foo bar}
4236 <1> <x=> <foo> <bar> .
4237 <2> <x=> <foo> <bar> .
4239 name: IFS-subst-3-lcl
4241 Check non-field semantics, smaller corner case (LP#1381965)
4246 expected-exit: e != 0
4247 expected-stderr-pattern:
4252 reported by mikeserv
4254 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4255 a='space divded argument
4258 IFS= ; q="$*" ; nq=$*
4259 pfn "$*" $* "$q" "$nq"
4260 [ "$q" = "$nq" ] && echo =true || echo =false
4262 <spacedivdedargument
4268 <spacedivdedargument
4270 <spacedivdedargument
4276 extended testsuite based on problem by mikeserv
4278 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4279 a='space divded argument
4282 IFS= ; q="$@" ; nq=$@
4283 pfn "$*" $* "$q" "$nq"
4284 [ "$q" = "$nq" ] && echo =true || echo =false
4286 <spacedivdedargument
4292 <space divded argument
4294 <space divded argument
4300 extended testsuite based on problem by mikeserv
4302 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4303 a='space divded argument
4305 IFS=\ ; set -- $a; IFS=
4310 print -nr -- '= qs '; pfn "$qs"
4311 print -nr -- '=nqs '; pfn "$nqs"
4312 print -nr -- '= qk '; pfn "$qk"
4313 print -nr -- '=nqk '; pfn "$nqk"
4314 print -nr -- '~ qs '; pfn "$*"
4315 print -nr -- '~nqs '; pfn $*
4316 print -nr -- '~ qk '; pfn "$@"
4317 print -nr -- '~nqk '; pfn $@
4319 = qs <spacedivdedargument
4321 =nqs <spacedivdedargument
4323 = qk <space divded argument
4325 =nqk <space divded argument
4327 ~ qs <spacedivdedargument
4344 extended testsuite based on problem by mikeserv
4346 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4347 a='space divded argument
4349 IFS=\ ; set -- $a; IFS=
4351 print -nr -- '= qs '; pfn "$qs"
4352 print -nr -- '~ qs '; pfn "$*"
4354 print -nr -- '=nqs '; pfn "$nqs"
4355 print -nr -- '~nqs '; pfn $*
4357 print -nr -- '= qk '; pfn "$qk"
4358 print -nr -- '~ qk '; pfn "$@"
4360 print -nr -- '=nqk '; pfn "$nqk"
4361 print -nr -- '~nqk '; pfn $@
4363 = qs <spacedivdedargument
4365 ~ qs <spacedivdedargument
4367 =nqs <spacedivdedargument
4373 = qk <space divded argument
4379 =nqk <space divded argument
4386 name: IFS-subst-4-4p
4388 extended testsuite based on problem by mikeserv
4390 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4391 a='space divded argument
4393 IFS=\ ; set -- $a; IFS=
4396 print -nr -- '= qs '; pfn "$qs"
4397 print -nr -- '~ qs '; pfn ${v:-"$*"}
4399 print -nr -- '=nqs '; pfn "$nqs"
4400 print -nr -- '~nqs '; pfn ${v:-$*}
4402 print -nr -- '= qk '; pfn "$qk"
4403 print -nr -- '~ qk '; pfn ${v:-"$@"}
4405 print -nr -- '=nqk '; pfn "$nqk"
4406 print -nr -- '~nqk '; pfn ${v:-$@}
4408 = qs <spacedivdedargument
4410 ~ qs <spacedivdedargument
4412 =nqs <spacedivdedargument
4418 = qk <space divded argument
4424 =nqk <space divded argument
4433 extended testsuite based on problem by mikeserv
4435 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4436 a='space divded argument
4438 IFS=\ ; set -- $a; IFS=,
4440 print -nr -- '= qs '; pfn "$qs"
4441 print -nr -- '~ qs '; pfn "$*"
4443 print -nr -- '=nqs '; pfn "$nqs"
4444 print -nr -- '~nqs '; pfn $*
4446 print -nr -- '= qk '; pfn "$qk"
4447 print -nr -- '~ qk '; pfn "$@"
4449 print -nr -- '=nqk '; pfn "$nqk"
4450 print -nr -- '~nqk '; pfn $@
4452 = qs <space,divded,argument
4454 ~ qs <space,divded,argument
4456 =nqs <space,divded,argument
4462 = qk <space divded argument
4468 =nqk <space divded argument
4475 name: IFS-subst-4-5p
4477 extended testsuite based on problem by mikeserv
4479 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4480 a='space divded argument
4482 IFS=\ ; set -- $a; IFS=,
4485 print -nr -- '= qs '; pfn "$qs"
4486 print -nr -- '~ qs '; pfn ${v:-"$*"}
4488 print -nr -- '=nqs '; pfn "$nqs"
4489 print -nr -- '~nqs '; pfn ${v:-$*}
4491 print -nr -- '= qk '; pfn "$qk"
4492 print -nr -- '~ qk '; pfn ${v:-"$@"}
4494 print -nr -- '=nqk '; pfn "$nqk"
4495 print -nr -- '~nqk '; pfn ${v:-$@}
4497 = qs <space,divded,argument
4499 ~ qs <space,divded,argument
4501 =nqs <space,divded,argument
4507 = qk <space divded argument
4513 =nqk <space divded argument
4522 extended testsuite based on IFS-subst-3
4523 differs slightly from ksh93:
4524 - omit trailing field in a3zna, a7ina (unquoted $@ expansion)
4525 - has extra middle fields in b5ins, b7ina (IFS_NWS unquoted expansion)
4526 differs slightly from bash:
4527 - omit leading field in a5ins, a7ina (IFS_NWS unquoted expansion)
4528 differs slightly from zsh:
4529 - differs in assignment, not expansion; probably zsh bug
4530 - has extra middle fields in b5ins, b7ina (IFS_NWS unquoted expansion)
4531 'emulate sh' zsh has extra fields in
4532 - a5ins (IFS_NWS unquoted $*)
4533 - b5ins, matching mksh’s
4534 !!WARNING!! more to come: http://austingroupbugs.net/view.php?id=888
4536 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4537 IFS=; set -- "" 2 ""; pfb $*; x=$*; pfn "$x"'
4539 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4540 IFS=; set -- "" 2 ""; pfb "$*"; x="$*"; pfn "$x"'
4542 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4543 IFS=; set -- "" 2 ""; pfb $@; x=$@; pfn "$x"'
4545 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4546 IFS=; set -- "" 2 ""; pfb "$@"; x="$@"; pfn "$x"'
4548 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4549 IFS=,; set -- "" 2 ""; pfb $*; x=$*; pfn "$x"'
4551 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4552 IFS=,; set -- "" 2 ""; pfb "$*"; x="$*"; pfn "$x"'
4554 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4555 IFS=,; set -- "" 2 ""; pfb $@; x=$@; pfn "$x"'
4557 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4558 IFS=,; set -- "" 2 ""; pfb "$@"; x="$@"; pfn "$x"'
4560 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4561 IFS=; set -- A B "" "" C; pfb $*; x=$*; pfn "$x"'
4563 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4564 IFS=; set -- A B "" "" C; pfb "$*"; x="$*"; pfn "$x"'
4566 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4567 IFS=; set -- A B "" "" C; pfb $@; x=$@; pfn "$x"'
4569 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4570 IFS=; set -- A B "" "" C; pfb "$@"; x="$@"; pfn "$x"'
4572 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4573 IFS=,; set -- A B "" "" C; pfb $*; x=$*; pfn "$x"'
4575 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4576 IFS=,; set -- A B "" "" C; pfb "$*"; x="$*"; pfn "$x"'
4578 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4579 IFS=,; set -- A B "" "" C; pfb $@; x=$@; pfn "$x"'
4581 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4582 IFS=,; set -- A B "" "" C; pfb "$@"; x="$@"; pfn "$x"'
4660 Regression wrt. vector expansion in trim
4662 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4672 ksh93 bug wrt. vector expansion in trim
4674 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4678 showargs "$*" ${a##"$*"}
4684 http://austingroupbugs.net/view.php?id=221
4686 n() { echo "$#"; }; n "${foo-$@}"
4692 Scalar context for $*/$@ in [[ and case
4694 "$__progname" -c 'IFS=; set a b; [[ $* = "$1$2" ]]; echo 1 $?' sh a b
4695 "$__progname" -c 'IFS=; [[ $* = ab ]]; echo 2 "$?"' sh a b
4696 "$__progname" -c 'IFS=; [[ "$*" = ab ]]; echo 3 "$?"' sh a b
4697 "$__progname" -c 'IFS=; [[ $* = a ]]; echo 4 "$?"' sh a b
4698 "$__progname" -c 'IFS=; [[ "$*" = a ]]; echo 5 "$?"' sh a b
4699 "$__progname" -c 'IFS=; [[ "$@" = a ]]; echo 6 "$?"' sh a b
4700 "$__progname" -c 'IFS=; case "$@" in a) echo 7 a;; ab) echo 7 b;; a\ b) echo 7 ok;; esac' sh a b
4701 "$__progname" -c 'IFS=; case $* in a) echo 8 a;; ab) echo 8 ok;; esac' sh a b
4702 "$__progname" -c 'pfsp() { for s_arg in "$@"; do print -nr -- "<$s_arg> "; done; print .; }; IFS=; star=$* at="$@"; pfsp 9 "$star" "$at"' sh a b
4716 http://austingroupbugs.net/view.php?id=832
4718 ${ZSH_VERSION+false} || emulate sh
4719 ${BASH_VERSION+set -o posix}
4720 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4722 showargs $((1230456))
4726 name: integer-base-err-1
4728 Can't have 0 base (causes shell to exit)
4729 expected-exit: e != 0
4735 expected-stderr-pattern:
4738 name: integer-base-err-2
4740 Can't have multiple bases in a 'constant' (causes shell to exit)
4741 (ksh88 fails this test)
4742 expected-exit: e != 0
4748 expected-stderr-pattern:
4749 /^.*:.*2#110#11.*\n$/
4751 name: integer-base-err-3
4753 Syntax errors in expressions and effects on bases
4754 (interactive so errors don't cause exits)
4755 (ksh88 fails this test - shell exits, even with -i)
4759 PS1= # minimise prompt hassles
4766 expected-stderr-pattern:
4767 /^([#\$] )?.*:.*2+.*\n.*:.*2+.*\n$/
4772 name: integer-base-err-4
4774 Are invalid digits (according to base) errors?
4775 (ksh93 fails this test)
4776 expected-exit: e != 0
4780 expected-stderr-pattern:
4781 /^([#\$] )?.*:.*3#4.*\n$/
4783 name: integer-base-1
4785 Missing number after base is treated as 0.
4794 name: integer-base-2
4796 Check 'stickyness' of base in various situations
4847 name: integer-base-3
4849 More base parsing (hmm doesn't test much..)
4869 name: integer-base-4
4871 Check that things not declared as integers are not made integers,
4872 also, check if base is not reset by -i with no arguments.
4873 (ksh93 fails - prints 10#20 - go figure)
4877 typeset -i | grep '^xx='
4884 name: integer-base-5
4900 for l in 1 2+3 4; do echo $l; done
4912 name: integer-base-6
4914 Even more base stuff
4915 (ksh93 fails this test - prints 0)
4923 name: integer-base-7
4925 Check that non-integer parameters don't get bases assigned
4927 echo $(( zz = 8#100 ))
4933 name: integer-base-8
4935 Check that base-36 works (full span)
4937 echo 1:$((36#109AZ)).
4938 typeset -i36 x=1691675
4947 name: integer-base-check-flat
4949 Check behaviour does not match POSuX (except if set -o posix),
4950 because a not type-safe scripting language has *no* business
4951 interpreting the string "010" as octal number eight (dangerous).
4953 echo 1 "$("$__progname" -c 'echo :$((10))/$((010)),$((0x10)):')" .
4954 echo 2 "$("$__progname" -o posix -c 'echo :$((10))/$((010)),$((0x10)):')" .
4955 echo 3 "$("$__progname" -o sh -c 'echo :$((10))/$((010)),$((0x10)):')" .
4961 name: integer-base-check-numeric-from
4963 Check behaviour for base one to 36, and that 37 degrades to 10
4967 while (( ++i <= 37 )); do
4968 eval 'echo '$i':$(('$i'#10)).'
4970 echo 37:$($__progname -c 'echo $((37#10))').$?:
5011 name: integer-base-check-numeric-to
5013 Check behaviour for base one to 36, and that 37 degrades to 10
5016 while (( ++i <= 37 )); do
5017 typeset -Uui$i x=0x40
5018 eval "typeset -i10 y=$x"
5060 name: integer-arithmetic-span
5062 Check wraparound and size that is defined in mksh
5065 echo s:$((2147483647+1)).$(((2147483647*2)+1)).$(((2147483647*2)+2)).
5066 echo u:$((#2147483647+1)).$((#(2147483647*2)+1)).$((#(2147483647*2)+2)).
5069 u:2147483648.4294967295.0.
5071 name: integer-arithmetic-span-64
5073 Check wraparound and size that is defined in mksh
5076 echo s:$((9223372036854775807+1)).$(((9223372036854775807*2)+1)).$(((9223372036854775807*2)+2)).
5077 echo u:$((#9223372036854775807+1)).$((#(9223372036854775807*2)+1)).$((#(9223372036854775807*2)+2)).
5079 s:-9223372036854775808.-1.0.
5080 u:9223372036854775808.18446744073709551615.0.
5082 name: integer-size-FAIL-to-detect
5084 Notify the user that their ints are not 32 or 64 bit
5091 See if $LINENO is updated and can be modified.
5104 See if $LINENO is set for .'d files.
5105 file-setup: file 644 "dotfile"
5123 See if $LINENO is set for commands in a function.
5142 See if unsetting LINENO makes it non-magic.
5143 file-setup: file 644 "dotfile"
5166 name: lineno-unset-use
5168 See if unsetting LINENO makes it non-magic even
5170 file-setup: file 644 "dotfile"
5196 Check if LINENO is tracked in traps
5202 trap 'fail $LINENO' INT ERR
5210 Ensure unknown traps are not a syntax error
5213 trap "echo trap 1 executed" UNKNOWNSIGNAL || echo "foo"
5215 trap "echo trap 2 executed" UNKNOWNSIGNAL EXIT 999999 FNORD
5217 ) 2>&1 | sed "s
\ 1^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]
\ 1PROG
\ 1"
5219 PROG: trap: bad signal 'UNKNOWNSIGNAL'
5222 PROG: trap: bad signal 'UNKNOWNSIGNAL'
5223 PROG: trap: bad signal '999999'
5224 PROG: trap: bad signal 'FNORD'
5230 Simple test, default IFS
5235 echo 1: "x[$x] y[$y] z[$z]"
5236 echo 1a: ${z-z not set}
5246 Complex tests, IFS either colon (IFS-NWS) or backslash (tricky)
5249 showargs() { print -nr "$1"; shift; for s_arg in "$@"; do print -nr -- " [$s_arg]"; done; print; }
5250 (IFS=\\ a=\<\\\>; showargs 3 $a)
5251 (IFS=: b=\<:\>; showargs 4 $b)
5252 print -r '<\>' | (IFS=\\ read f g; showargs 5 "$f" "$g")
5253 print -r '<\\>' | (IFS=\\ read f g; showargs 6 "$f" "$g")
5254 print '<\\\n>' | (IFS=\\ read f g; showargs 7 "$f" "$g")
5255 print -r '<\>' | (IFS=\\ read f; showargs 8 "$f")
5256 print -r '<\\>' | (IFS=\\ read f; showargs 9 "$f")
5257 print '<\\\n>' | (IFS=\\ read f; showargs 10 "$f")
5258 print -r '<\>' | (IFS=\\ read -r f g; showargs 11 "$f" "$g")
5259 print -r '<\\>' | (IFS=\\ read -r f g; showargs 12 "$f" "$g")
5260 print '<\\\n>' | (IFS=\\ read -r f g; showargs 13 "$f" "$g")
5261 print -r '<\>' | (IFS=\\ read -r f; showargs 14 "$f")
5262 print -r '<\\>' | (IFS=\\ read -r f; showargs 15 "$f")
5263 print '<\\\n>' | (IFS=\\ read -r f; showargs 16 "$f")
5264 print -r '<:>' | (IFS=: read f g; showargs 17 "$f" "$g")
5265 print -r '<::>' | (IFS=: read f g; showargs 18 "$f" "$g")
5266 print '<:\n>' | (IFS=: read f g; showargs 19 "$f" "$g")
5267 print -r '<:>' | (IFS=: read f; showargs 20 "$f")
5268 print -r '<::>' | (IFS=: read f; showargs 21 "$f")
5269 print '<:\n>' | (IFS=: read f; showargs 22 "$f")
5270 print -r '<:>' | (IFS=: read -r f g; showargs 23 "$f" "$g")
5271 print -r '<::>' | (IFS=: read -r f g; showargs 24 "$f" "$g")
5272 print '<:\n>' | (IFS=: read -r f g; showargs 25 "$f" "$g")
5273 print -r '<:>' | (IFS=: read -r f; showargs 26 "$f")
5274 print -r '<::>' | (IFS=: read -r f; showargs 27 "$f")
5275 print '<:\n>' | (IFS=: read -r f; showargs 28 "$f")
5306 If no var specified, REPLY is used
5314 name: read-regress-1
5316 Check a regression of read
5317 file-setup: file 644 "foo"
5322 while read a b c; do
5326 echo "<$a|$b|$c><$d>"
5332 Check read with delimiters
5335 print -n 'foo bar\tbaz\nblah \0blub\tblech\nmyok meck \0'
5337 emit | while IFS= read -d "" foo; do print -r -- "<$foo>"; done
5338 emit | while read -d "" foo; do print -r -- "<$foo>"; done
5339 emit | while read -d "eh?" foo; do print -r -- "<$foo>"; done
5356 Check read with number of bytes specified, and -A
5358 print 'foo\nbar' >x1
5360 print 'foo\\ bar baz' >x3
5362 x1b=u; read -N-1 x1b <x1
5363 x2a=u; read x2a <x2; r2a=$?
5364 x2b=u; read -N2 x2c <x2; r2b=$?
5365 x2c=u; read -n2 x2c <x2; r2c=$?
5366 x3a=u; read -A x3a <x3
5367 print -r "x1a=<$x1a>"
5368 print -r "x1b=<$x1b>"
5369 print -r "x2a=$r2a<$x2a>"
5370 print -r "x2b=$r2b<$x2b>"
5371 print -r "x2c=$r2c<$x2c>"
5372 print -r "x3a=<${x3a[0]}|${x3a[1]}|${x3a[2]}>"
5384 Lex array code had problems with this.
5395 When PATH is set before running a command, the new path is
5396 not used in doing the path search
5397 $ echo echo hi > /tmp/q ; chmod a+rx /tmp/q
5401 in comexec() the two lines
5403 (void) typeset(*vp++, xxx, 0);
5404 need to be moved out of the switch to before findcom() is
5405 called - I don't know what this will break.
5407 : "${PWD:-`pwd 2> /dev/null`}"
5408 : "${PWD:?"PWD not set - cannot do test"}"
5410 cat > Y/xxxscript << EOF
5412 # Need to restore path so echo can be found (some shells don't have
5418 chmod a+rx Y/xxxscript
5419 export OLDPATH="$PATH"
5420 PATH=$PWD/Y xxxscript
5427 Parsing of $(..) expressions is non-optimal. It is
5428 impossible to have any parentheses inside the expression.
5430 $ ksh -c 'echo $(echo \( )'
5432 $ ksh -c 'echo $(echo "(" )'
5435 The solution is to hack the parsing clode in lex.c, the
5436 question is how to hack it: should any parentheses be
5437 escaped by a backslash, or should recursive parsing be done
5438 (so quotes could also be used to hide hem). The former is
5439 easier, the later better...
5449 Continue in a for loop does not work right:
5451 if [ $i = b ] ; then
5460 if [ $i = b ] ; then
5461 if [ $first = no ] ; then
5462 echo 'continue in for loop broken'
5463 break # hope break isn't broken too :-)
5478 should print 0 according to POSIX (dash, bash, ksh93, posh)
5479 but not 0 according to the getopt(1) manual page, ksh88, and
5480 Bourne sh (such as /bin/sh on Solaris).
5481 We honour POSIX except when -o sh is set.
5482 category: shell:legacy-no
5485 [[ -o posix ]]; FPOSIX=$((1-$?))
5486 [[ -o sh ]]; FSH=$((1-$?))
5487 echo -n "FPOSIX=$FPOSIX FSH=$FSH "
5511 name: regression-10-legacy
5516 should print 0 according to POSIX (dash, bash, ksh93, posh)
5517 but not 0 according to the getopt(1) manual page, ksh88, and
5518 Bourne sh (such as /bin/sh on Solaris).
5519 category: shell:legacy-yes
5522 [[ -o posix ]]; FPOSIX=$((1-$?))
5523 [[ -o sh ]]; FSH=$((1-$?))
5524 echo -n "FPOSIX=$FPOSIX FSH=$FSH "
5553 should echo blah but on some machines echos /foo/bar/blah.
5562 Both of the following echos produce the same output under sh/ksh.att:
5565 echo "`echo \"$x\"`"
5567 pdksh produces different output for the former (foo instead of foo\tbar)
5570 echo "`echo \"$x\"`"
5578 The following command hangs forever:
5579 $ (: ; cat /etc/termcap) | sleep 2
5580 This is because the shell forks a shell to run the (..) command
5581 and this shell has the pipe open. When the sleep dies, the cat
5582 doesn't get a SIGPIPE 'cause a process (ie, the second shell)
5583 still has the pipe open.
5585 NOTE: this test provokes a bizarre bug in ksh93 (shell starts reading
5586 commands from /etc/termcap..)
5589 echo A line of text that will be duplicated quite a number of times.> t1
5590 cat t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 > t2
5591 cat t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 > t1
5592 cat t1 t1 t1 t1 > t2
5593 (: ; cat t2 2>/dev/null) | sleep 1
5598 $ (foobar) 2> /dev/null
5599 generates no output under /bin/sh, but pdksh produces the error
5602 $ foobar 2> /dev/null
5603 generates an error under /bin/sh and pdksh, but AT&T ksh88 produces
5604 no error (redirected to /dev/null).
5606 (you/should/not/see/this/error/1) 2> /dev/null
5607 you/should/not/see/this/error/2 2> /dev/null
5614 generates a blank line under pdksh and sets the exit status to 0.
5615 AT&T ksh88 generates no output and sets the exit status to 1. Also,
5618 generates no output under AT&T ksh88 (pdksh generates a blank line
5621 whence does/not/exist > /dev/null
5623 echo 2: $(whence does/not/exist | wc -l)
5624 echo 3: $(whence does/not/exist cat | wc -l)
5632 ${var%%expr} seems to be broken in many places. On the mips
5634 $ read line < /etc/passwd
5642 change the value of line. On sun4s & pas, the echo ${line%%:*} doesn't
5643 work. Haven't checked elsewhere...
5650 root:asdjhasdasjhs:0:1:Root:/:/bin/sh
5653 root:asdjhasdasjhs:0:1:Root:/:/bin/sh
5659 should set the exit status to non-zero (sh and AT&T ksh88 do).
5660 XXX doting a non existent file is a fatal error for a script
5663 expected-exit: e != 0
5664 expected-stderr-pattern: /.?/
5668 Both of the following echos should produce the same thing, but don't:
5682 backslash does not work as expected in case labels:
5701 Quoting backquotes inside backquotes doesn't work:
5702 $ echo `echo hi \`echo there\` folks`
5703 asks for more info. sh and AT&T ksh88 both echo
5706 echo `echo hi \`echo there\` folks`
5712 )) is not treated `correctly':
5713 $ (echo hi ; (echo there ; echo folks))
5716 instead of (as sh and ksh.att)
5717 $ (echo hi ; (echo there ; echo folks))
5723 ( : ; ( : ; echo hi))
5729 Check reading stdin in a while loop. The read should only read
5730 a single line, not a whole stdio buffer; the cat should get
5733 (echo a; echo b) | while read x ; do
5742 Check reading stdin in a while loop. The read should read both
5743 lines, not just the first.
5746 while [ "$a" != xxx ] ; do
5749 cat /dev/null | sed 's/x/y/'
5763 should cause a script to exit.
5767 expected-exit: e != 0
5768 expected-stderr-pattern: /does\/not\/exist/
5772 variable assignements not detected well
5775 expected-exit: e != 0
5776 expected-stderr-pattern: /a\.x=1/
5780 alias expansion different from AT&T ksh88
5782 alias a='for ' b='i in'
5783 a b hi ; do echo $i ; done
5789 strange characters allowed inside ${...}
5792 expected-exit: e != 0
5793 expected-stderr-pattern: /.?/
5797 Does read handle partial lines correctly
5800 while [ "$a" != xxx ] ; do
5817 Does read set variables to null at eof?
5820 while [ "$a" != xxx ] ; do
5824 echo 1: ${x-x not set} ${y-y not set} ${z-z not set}
5825 echo 2: ${x:+x not null} ${y:+y not null} ${z:+z not null}
5835 Does umask print a leading 0 when umask is 3 digits?
5837 # on MiNT, the first umask call seems to fail
5839 # now, the test proper
5847 Tempory files used for here-docs in functions get trashed after
5848 the function is parsed (before it is executed)
5871 Command substitution breaks reading in while loop
5872 (test from <sjg@void.zen.oz.au>)
5874 (echo abcdef; echo; echo 123) |
5877 # the following line breaks it
5878 c=`echo $line | wc -c`
5888 Machines with broken times() (reported by <sjg@void.zen.oz.au>)
5889 time does not report correct real time
5892 expected-stderr-pattern: !/^\s*0\.0[\s\d]+real|^\s*real[\s]+0+\.0/
5896 set -e doesn't ignore exit codes for if/while/until/&&/||/!.
5899 if false; then echo hi ; fi
5902 while false; do echo hi; done
5909 Only posh and oksh(2013-07) say “hi” below; FreeBSD sh,
5910 GNU bash in POSIX mode, dash, ksh93, mksh don’t. All of
5911 them exit 0. The POSIX behaviour is needed by BSD make.
5914 echo `false; echo hi` $(<this-file-does-not-exist)
5919 expected-stderr-pattern: /this-file-does-not-exist/
5923 This used to cause a core dump
5924 env-setup: !RANDOM=12!
5932 foo should be set to bar (should not be empty)
5942 Can't use command line assignments to assign readonly parameters.
5944 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
5945 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
5946 done >env; chmod +x env; PATH=.$PATHSEP$PATH
5949 foo=stuff env | grep '^foo'
5950 expected-exit: e != 0
5951 expected-stderr-pattern:
5956 Can subshells be prefixed by redirections (historical shells allow
5959 < /dev/null (sed 's/^/X/')
5963 Parameter assignments with [] recognised correctly
5981 Check that alias expansion works in command substitutions and
5994 Check that aliases are fully read.
6007 Check that (here doc) temp files are not left behind after an exec.
6010 TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
6012 sed 's/^/X /' << E_O_F
6019 echo=echo; [ -x /bin/echo ] && echo=/bin/echo
6020 exec $echo subtest-1 hi
6022 echo subtest-1 foo/*
6023 TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
6024 echo=echo; [ -x /bin/echo ] && echo=/bin/echo
6025 sed 's/^/X /' << E_O_F; exec $echo subtest-2 hi
6031 echo subtest-2 foo/*
6043 Check that unset params with attributes are reported by set, those
6044 sans attributes are not.
6060 Check that aliases do not use continuation prompt after trailing
6062 file-setup: file 644 "envf"
6065 env-setup: !ENV=./envf!
6069 alias foo='echo hi ; '
6081 Check that set allows both +o and -o options on same command line.
6084 set -o noglob +o allexport
6091 Check that globbing works in pipelined commands
6092 file-setup: file 644 "envf"
6094 file-setup: file 644 "abc"
6096 env-setup: !ENV=./envf!
6102 sed 's/^/X /' < ab* | sed 's/^/Y /'
6114 Check that getopts works in functions
6117 echo bfunc: enter "(args: $*; OPTIND=$OPTIND)"
6118 while getopts B oc; do
6121 echo bfunc: B option
6124 echo bfunc: odd option "($oc)"
6132 echo kfunc: enter "(args: $*; OPTIND=$OPTIND)"
6133 while getopts K oc; do
6136 echo kfunc: K option
6139 echo bfunc: odd option "($oc)"
6147 echo "line 1: OPTIND=$OPTIND"
6149 echo "line 2: ret=$?, optc=$optc, OPTIND=$OPTIND"
6151 echo "line 3: OPTIND=$OPTIND"
6153 echo "line 4: ret=$?, optc=$optc, OPTIND=$OPTIND"
6155 echo "line 5: OPTIND=$OPTIND"
6157 echo "line 6: ret=$?, optc=$optc, OPTIND=$OPTIND"
6162 echo "line 10: OPTIND=$OPTIND"
6164 echo "line 20: ret=$?, optc=$optc, OPTIND=$OPTIND"
6166 echo "line 30: OPTIND=$OPTIND"
6168 echo "line 40: ret=$?, optc=$optc, OPTIND=$OPTIND"
6170 echo "line 50: OPTIND=$OPTIND"
6172 echo "line 60: ret=$?, optc=$optc, OPTIND=$OPTIND"
6175 line 2: ret=0, optc=f, OPTIND=2
6176 bfunc: enter (args: -BBB blah; OPTIND=2)
6181 line 4: ret=0, optc=b, OPTIND=3
6182 kfunc: enter (args: -KKK blah; OPTIND=1)
6188 line 6: ret=0, optc=k, OPTIND=4
6191 line 20: ret=0, optc=f, OPTIND=2
6192 bfunc: enter (args: -BBB blah; OPTIND=2)
6197 line 40: ret=1, optc=?, OPTIND=2
6198 kfunc: enter (args: -KKK blah; OPTIND=1)
6204 line 60: ret=1, optc=?, OPTIND=2
6208 Check that ; is not required before the then in if (( ... )) then ...
6222 Check ${foo:%bar} is allowed (ksh88 allows it...)
6245 Check if typeset output is correct for
6246 uninitialised array elements.
6250 typeset -i | grep xxx | sed 's/^/ /'
6252 typeset | grep xxx | sed 's/^/ /'
6256 typeset -i | grep xxx | sed 's/^/ /'
6258 typeset | grep xxx | sed 's/^/ /'
6272 Check if trap exit is ok (exit not mistaken for signal name)
6281 Check if ${#array[*]} is calculated correctly.
6291 Check if default exit status is previous command
6297 ( (exit 103) ; exit)
6306 Check if EXIT trap is executed for sub shells.
6308 trap 'echo parent exit' EXIT
6310 (echo A; echo A last)
6312 (echo C; trap 'echo sub exit' EXIT; echo C last)
6327 Check if test -nt/-ot succeeds if second(first) file is missing.
6330 test a -nt b && echo nt OK || echo nt BAD
6331 test b -ot a && echo ot OK || echo ot BAD
6338 Check if typeset, export, and readonly work
6350 integer FNORD_E FNORD_F FNORD_G FNORD_H
6351 export FNORD_C FNORD_D FNORD_G FNORD_H
6352 readonly FNORD_B FNORD_D FNORD_F FNORD_H
6398 typeset -x -r FNORD_D
6400 typeset -i -r FNORD_F
6401 typeset -i -x FNORD_G
6402 typeset -i -x -r FNORD_H
6405 typeset -r FNORD_B=2
6406 typeset -x FNORD_C=3
6407 typeset -x -r FNORD_D=4
6408 typeset -i FNORD_E=5
6409 typeset -i -r FNORD_F=6
6410 typeset -i -x FNORD_G=7
6411 typeset -i -x -r FNORD_H=8
6429 Check that we can redefine functions calling time builtin
6441 check for a regression with sleep builtin and signal mask
6447 while read -p line; do :; done
6454 Check that quoting is sane
6462 while IFS= read -pr line; do
6463 if [[ $line = *space* ]]; then
6469 for line in "${lines[@]}"; do
6478 Check that we can both break and use source on the same line
6480 for s in s; do break; done; print -s s
6484 Check that all common arithmetic operators work as expected
6486 echo 1 $(( a = 5 )) .
6487 echo 2 $(( ++a )) , $(( a++ )) , $(( a )) .
6488 echo 3 $(( --a )) , $(( a-- )) , $(( a )) .
6489 echo 4 $(( a == 5 )) , $(( a == 6 )) .
6490 echo 5 $(( a != 5 )) , $(( a != 6 )) .
6491 echo 6 $(( a *= 3 )) .
6492 echo 7 $(( a /= 5 )) .
6493 echo 8 $(( a %= 2 )) .
6494 echo 9 $(( a += 9 )) .
6495 echo 10 $(( a -= 4 )) .
6496 echo 11 $(( a <<= 1 )) .
6497 echo 12 $(( a >>= 1 )) .
6498 echo 13 $(( a &= 4 )) .
6499 echo 14 $(( a ^= a )) .
6500 echo 15 $(( a |= 5 )) .
6501 echo 16 $(( 5 << 1 )) .
6502 echo 17 $(( 5 >> 1 )) .
6503 echo 18 $(( 5 <= 6 )) , $(( 5 <= 5 )) , $(( 5 <= 4 )) .
6504 echo 19 $(( 5 >= 6 )) , $(( 5 >= 5 )) , $(( 5 >= 4 )) .
6505 echo 20 $(( 5 < 6 )) , $(( 5 < 5 )) , $(( 5 < 4 )) .
6506 echo 21 $(( 5 > 6 )) , $(( 5 > 5 )) , $(( 5 > 4 )) .
6507 echo 22 $(( 0 && 0 )) , $(( 0 && 1 )) , $(( 1 && 0 )) , $(( 1 && 1 )) .
6508 echo 23 $(( 0 || 0 )) , $(( 0 || 1 )) , $(( 1 || 0 )) , $(( 1 || 1 )) .
6509 echo 24 $(( 5 * 3 )) .
6510 echo 25 $(( 7 / 2 )) .
6511 echo 26 $(( 5 % 5 )) , $(( 5 % 4 )) , $(( 5 % 1 )) , $(( 5 % -1 )) , $(( 5 % -2 )) .
6512 echo 27 $(( 5 + 2 )) , $(( 5 + 0 )) , $(( 5 + -2 )) .
6513 echo 28 $(( 5 - 2 )) , $(( 5 - 0 )) , $(( 5 - -2 )) .
6514 echo 29 $(( 6 & 4 )) , $(( 6 & 8 )) .
6515 echo 30 $(( 4 ^ 2 )) , $(( 4 ^ 4 )) .
6516 echo 31 $(( 4 | 2 )) , $(( 4 | 4 )) , $(( 4 | 0 )) .
6517 echo 32 $(( 0 ? 1 : 2 )) , $(( 3 ? 4 : 5 )) .
6518 echo 33 $(( 5 , 2 , 3 )) .
6519 echo 34 $(( ~0 )) , $(( ~1 )) , $(( ~~1 )) , $(( ~~2 )) .
6520 echo 35 $(( !0 )) , $(( !1 )) , $(( !!1 )) , $(( !!2 )) .
6521 echo 36 $(( (5) )) .
6548 26 0 , 1 , 0 , 0 , 1 .
6556 34 -1 , -2 , 1 , 2 .
6562 Check that all non-lksh arithmetic operators work as expected
6563 category: shell:legacy-no
6566 echo 1 $(( a ^<= 1 )) , $(( b ^<= 1 )) .
6567 echo 2 $(( a ^>= 2 )) , $(( b ^>= 2 )) .
6568 echo 3 $(( 5 ^< 1 )) .
6569 echo 4 $(( 5 ^> 1 )) .
6572 2 -2147483646 , -1073741822 .
6578 Ensure readonly is honoured for assignments and unset
6580 "$__progname" -c 'u=x; echo $? $u .' || echo aborted, $?
6582 "$__progname" -c 'readonly u; u=x; echo $? $u .' || echo aborted, $?
6584 "$__progname" -c 'u=x; readonly u; unset u; echo $? $u .' || echo aborted, $?
6591 expected-stderr-pattern:
6596 http://austingroupbugs.net/view.php?id=367 for export
6598 "$__progname" -c 'readonly foo; export foo=a; echo $?' || echo aborted, $?
6601 expected-stderr-pattern:
6606 Check that getopts works as intended, for readonly-2b to be valid
6608 "$__progname" -c 'set -- -a b; getopts a c; echo $? $c .; getopts a c; echo $? $c .' || echo aborted, $?
6615 http://austingroupbugs.net/view.php?id=367 for getopts
6617 "$__progname" -c 'readonly c; set -- -a b; getopts a c; echo $? $c .' || echo aborted, $?
6620 expected-stderr-pattern:
6625 http://austingroupbugs.net/view.php?id=367 for read
6627 echo x | "$__progname" -c 'read s; echo $? $s .' || echo aborted, $?
6628 echo y | "$__progname" -c 'readonly s; read s; echo $? $s .' || echo aborted, $?
6632 expected-stderr-pattern:
6637 Do not permit bypassing readonly for first array item
6639 set -A arr -- foo bar
6642 print -r -- "${arr[@]}"
6643 expected-exit: e != 0
6644 expected-stderr-pattern:
6649 Check that lone ampersand is a syntax error
6652 expected-exit: e != 0
6653 expected-stderr-pattern:
6656 name: xxx-quoted-newline-1
6658 Check that \<newline> works inside of ${}
6666 name: xxx-quoted-newline-2
6668 Check that \<newline> works at the start of a here document
6677 name: xxx-quoted-newline-3
6679 Check that \<newline> works at the end of a here document
6688 name: xxx-multi-assignment-cmd
6690 Check that assignments in a command affect subsequent assignments
6699 name: xxx-multi-assignment-posix-cmd
6701 Check that the behaviour for multiple assignments with a
6702 command name matches POSIX. See:
6703 http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925
6705 X=a Y=b; X=$Y Y=$X "$__progname" -c 'echo 1 $X $Y .'; echo 2 $X $Y .
6707 X=a Y=${X=b} Z=$X "$__progname" -c 'echo 3 $Z .'
6709 X=a Y=${X=b} Z=$X; echo 4 $Z .
6716 name: xxx-multi-assignment-posix-nocmd
6718 Check that the behaviour for multiple assignments with no
6719 command name matches POSIX (Debian #334182). See:
6720 http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925
6722 X=a Y=b; X=$Y Y=$X; echo 1 $X $Y .
6726 name: xxx-multi-assignment-posix-subassign
6728 Check that the behaviour for multiple assignments matches POSIX:
6729 - The assignment words shall be expanded in the current execution
6731 - The assignments happen in the temporary execution environment.
6734 Z=a Y=${X:=b} sh -c 'echo +$X+ +$Y+ +$Z+'
6736 # Now for the special case:
6738 X= Y=${X:=b} sh -c 'echo +$X+ +$Y+'
6746 name: xxx-exec-environment-1
6748 Check to see if exec sets it's environment correctly
6750 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
6751 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
6752 done >env; chmod +x env; PATH=.$PATHSEP$PATH
6754 expected-stdout-pattern:
6757 name: xxx-exec-environment-2
6759 Check to make sure exec doesn't change environment if a program
6762 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
6763 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
6764 done >env; chmod +x env; PATH=.$PATHSEP$PATH
6766 FOO=bar exec; env >bar2
6769 name: exec-function-environment-1
6771 Check assignments in function calls and whether they affect
6772 the current execution environment (ksh93, SUSv4)
6774 f() { a=2; }; g() { b=3; echo y$c-; }; a=1 f; b=2; c=1 g
6780 name: xxx-what-do-you-call-this-1
6786 name: xxx-prefix-strip-1
6793 name: xxx-prefix-strip-2
6801 name: xxx-variable-syntax-1
6804 expected-stderr-pattern:
6808 name: xxx-variable-syntax-2
6812 expected-stderr-pattern:
6816 name: xxx-variable-syntax-3
6820 expected-stderr-pattern:
6824 name: xxx-variable-syntax-4
6826 Not all kinds of trims are currently impossible, check those who do
6829 echo "<$*> X${*:+ }X"
6859 name: xxx-substitution-eval-order
6861 Check order of evaluation of expressions
6864 set -A A abc def GHI j G k
6865 echo ${A[x=(i+=1)]#${A[y=(i+=2)]}}
6871 name: xxx-set-option-1
6873 Check option parsing in set
6875 set -vsA foo -- A 1 3 2
6884 Check that exec exits for built-ins
6892 expected-stderr-pattern: /.*/
6896 Check the return value of while loops
6897 XXX need to do same for for/select/until loops
6900 while [ $i != xxx ] ; do
6902 if [ $i = xxx ] ; then
6910 while [ $i != xxx ] ; do
6912 if [ $i = xxx ] ; then
6920 while [ $i != xxx ] ; do
6932 Check that blank lines don't clear $?
6945 expected-stderr-pattern: /.*/
6949 Check that $? is preserved in subshells, includes, traps.
6958 echo 'echo include: $?' > foo
6962 trap 'echo trap: $?' ERR
6972 name: xxx-clean-chars-1
6974 Check MAGIC character is stuffed correctly
6980 name: xxx-param-subst-qmark-1
6982 Check suppresion of error message with null string. According to
6983 POSIX, it shouldn't print the error as 'word' isn't ommitted.
6984 ksh88/93, Solaris /bin/sh and /usr/xpg4/bin/sh all print the error.
6990 expected-stderr-pattern: !/not set/
6992 name: xxx-param-subst-qmark-namespec
6994 Check special names are output correctly
6997 "$__progname" -c "$@" >o1 2>o2
7000 sed -e "s
\ 1^${__progname%.exe}\.*e*x*e*:
\ 1PROG:
\ 1" -e 's/^/STDOUT: /g' <o1
7001 sed -e "s
\ 1^${__progname%.exe}\.*e*x*e*:
\ 1PROG:
\ 1" -e 's/^/STDERR: /g' <o2
7008 doit -u 'echo ${*:?}' foo ""
7011 STDERR: PROG: ${1x}: bad substitution
7013 STDERR: PROG: ${1x}: bad substitution
7015 STDERR: PROG: 1: parameter null or not set
7017 STDERR: PROG: 19: parameter null or not set
7019 STDERR: PROG: !: parameter null or not set
7021 STDERR: foo: ${*:?}: bad substitution
7024 # fails due to weirdness of execv stuff
7025 category: !os:uwin-nt
7027 Check c flag is set.
7028 arguments: !-c!echo "[$-]"!
7029 expected-stdout-pattern: /^\[.*c.*\]$/
7031 name: tilde-expand-1
7033 Check tilde expansion after equal signs
7034 env-setup: !HOME=/sweet!
7036 echo ${A=a=}~ b=~ c=d~ ~
7038 command command export g=~ h=d~
7043 echo ${A=a=}~ b=~ c=d~ ~
7045 command command export g=~ h=d~
7049 a=/sweet b=/sweet c=d~ /sweet
7056 name: tilde-expand-2
7058 Check tilde expansion works
7059 env-setup: !HOME=/sweet!
7063 plus=$(print -r -- ~+)
7064 minus=$(print -r -- ~-)
7065 nix=$(print -r -- ~)
7066 [[ $plus = / ]]; echo one $? .
7067 [[ $minus = "$wd" ]]; echo two $? .
7068 [[ $nix = /sweet ]]; echo nix $? .
7076 Check some "exit on error" conditions
7078 print '#!'"$__progname"'\nexec "$1"' >env
7079 print '#!'"$__progname"'\nexit 1' >false
7083 env false && echo something
7093 Check some "exit on error" edge conditions (POSIXly)
7095 print '#!'"$__progname"'\nexec "$1"' >env
7096 print '#!'"$__progname"'\nexit 1' >false
7097 print '#!'"$__progname"'\nexit 0' >true
7102 env false && echo something
7114 pdksh regression which AT&T ksh does right
7115 TFM says: [set] -e | errexit
7116 Exit (after executing the ERR trap) ...
7118 trap 'echo EXIT' EXIT
7121 cd /XXXXX 2>/dev/null
7127 expected-exit: e != 0
7131 "set -e" test suite (POSIX)
7145 "set -e" test suite (POSIX)
7151 [ "$1" = "$E" ] && { shift ; continue 2 ; }
7168 "set -e" test suite (BSD make)
7172 print 'all:\n\t@echo eins\n\t@exit 42\n' >zd/a/Makefile
7173 print 'all:\n\t@echo zwei\n' >zd/b/Makefile
7176 for entry in a b; do ( set -e; if [[ -d $wd/zd/$entry.i386 ]]; then _newdir_="$entry.i386"; else _newdir_="$entry"; fi; if [[ -z $_THISDIR_ ]]; then _nextdir_="$_newdir_"; else _nextdir_="$_THISDIR_/$_newdir_"; fi; _makefile_spec_=; [[ ! -f $wd/zd/$_newdir_/Makefile.bsd-wrapper ]] || _makefile_spec_="-f Makefile.bsd-wrapper"; subskipdir=; for skipdir in ; do subentry=${skipdir#$entry}; if [[ $subentry != $skipdir ]]; then if [[ -z $subentry ]]; then echo "($_nextdir_ skipped)"; break; fi; subskipdir="$subskipdir ${subentry#/}"; fi; done; if [[ -z $skipdir || -n $subentry ]]; then echo "===> $_nextdir_"; cd $wd/zd/$_newdir_; make SKIPDIR="$subskipdir" $_makefile_spec_ _THISDIR_="$_nextdir_" all; fi; ) done 2>&1 | sed "s!$wd!WD!g"
7182 Stop in WD/zd/a (line 2 of Makefile).
7186 "set -e" regression (LP#1104543)
7190 [ -x $PWD/nonexistant ] && $PWD/nonexistant
7201 "set -e" regression (Debian #700526)
7204 _db_cmd() { return $1; }
7205 db_input() { _db_cmd 30; }
7206 db_go() { _db_cmd 0; }
7213 "set -e" versus bang pipelines
7226 SUSv4 says that the shell should exit with 126/127 in some situations
7230 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
7231 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
7233 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
7234 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
7236 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
7237 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
7248 Check eval vs substitution exit codes (ksh93 alike)
7260 eval "eval $(false)"
7263 eval 'eval '"$(false)"
7267 eval $(echo :; false)
7285 Check that "exit" with no arguments behaves SUSv4 conformant.
7287 trap 'echo hi; exit' EXIT
7295 Check that ERR and EXIT traps are run just like ksh93 does.
7296 GNU bash does not run ERtrap in ±e eval-undef but runs it
7297 twice (bug?) in +e eval-false, so does ksh93 (bug?), which
7298 also has a bug to continue execution (echoing "and out" and
7299 returning 0) in +e eval-undef.
7300 file-setup: file 644 "x"
7302 trap 'echo EXtrap' EXIT
7303 trap 'echo ERtrap' ERR
7308 file-setup: file 644 "xt"
7310 trap 'echo EXtrap' EXIT
7311 trap 'echo ERtrap' ERR
7316 file-setup: file 644 "xf"
7318 trap 'echo EXtrap' EXIT
7319 trap 'echo ERtrap' ERR
7321 echo 'and run false'
7324 file-setup: file 644 "xu"
7326 trap 'echo EXtrap' EXIT
7327 trap 'echo ERtrap' ERR
7329 echo 'and run ${v?}'
7339 -e 's/parameter not set/parameter null or not set/' \
7340 -e 's/[[]6]//' -e 's/: eval: line 1//' -e 's/: line 6//' \
7341 -e "s
\ 1^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]
\ 1PROG
\ 1"
7346 echo = eval-true $(<rc) .
7348 echo = eval-false $(<rc) .
7349 runtest x $xe '${v?}'
7350 echo = eval-undef $(<rc) .
7352 echo = noeval-true $(<rc) .
7354 echo = noeval-false $(<rc) .
7356 echo = noeval-undef $(<rc) .
7360 echo = eval-true $(<rc) .
7362 echo = eval-false $(<rc) .
7363 runtest x $xe '${v?}'
7364 echo = eval-undef $(<rc) .
7366 echo = noeval-true $(<rc) .
7368 echo = noeval-false $(<rc) .
7370 echo = noeval-undef $(<rc) .
7382 x: v: parameter null or not set
7395 xu: v: parameter null or not set
7409 x: v: parameter null or not set
7423 xu: v: parameter null or not set
7427 name: exit-trap-interactive
7429 Check that interactive shell doesn't exit via EXIT trap on syntax error
7434 echo 'After error 1'
7435 trap 'echo Exit trap' EXIT
7437 echo 'After error 2'
7438 trap 'echo Exit trap' EXIT
7445 expected-stderr-pattern:
7446 /syntax error: 'newline' unexpected/
7450 Check that test also can handle string1 < string2 etc.
7452 test 2005/10/08 '<' 2005/08/21 && echo ja || echo nein
7453 test 2005/08/21 \< 2005/10/08 && echo ja || echo nein
7454 test 2005/10/08 '>' 2005/08/21 && echo ja || echo nein
7455 test 2005/08/21 \> 2005/10/08 && echo ja || echo nein
7461 expected-stderr-pattern: !/unexpected op/
7463 name: test-precedence-1
7465 Check a weird precedence case (and POSIX echo)
7475 Test the test -o operator
7480 [[ -o $1 ]]; echo $?
7483 test -o $1 -o -o !$1; echo $?
7484 [ -o $1 -o -o !$1 ]; echo $?
7485 [[ -o $1 || -o !$1 ]]; echo $?
7486 test -o ?$1; echo $?
7488 echo 0y $(if_test utf8-mode) =
7489 echo 0n $(if_test utf8-hack) =
7490 echo 1= $(runtest utf8-hack) =
7491 echo 2= $(runtest !utf8-hack) =
7492 echo 3= $(runtest ?utf8-hack) =
7494 echo 1+ $(runtest utf8-mode) =
7495 echo 2+ $(runtest !utf8-mode) =
7496 echo 3+ $(runtest ?utf8-mode) =
7498 echo 1- $(runtest utf8-mode) =
7499 echo 2- $(runtest !utf8-mode) =
7500 echo 3- $(runtest ?utf8-mode) =
7501 echo = short flags =
7502 echo 0y $(if_test -U) =
7503 echo 0y $(if_test +U) =
7504 echo 0n $(if_test -_) =
7505 echo 0n $(if_test -U-) =
7506 echo 1= $(runtest -_) =
7507 echo 2= $(runtest !-_) =
7508 echo 3= $(runtest ?-_) =
7510 echo 1+ $(runtest -U) =
7511 echo 2+ $(runtest !-U) =
7512 echo 3+ $(runtest ?-U) =
7513 echo 1+ $(runtest +U) =
7514 echo 2+ $(runtest !+U) =
7515 echo 3+ $(runtest ?+U) =
7517 echo 1- $(runtest -U) =
7518 echo 2- $(runtest !-U) =
7519 echo 3- $(runtest ?-U) =
7520 echo 1- $(runtest +U) =
7521 echo 2- $(runtest !+U) =
7522 echo 3- $(runtest ?+U) =
7558 Check that the short form [ $x ] works
7562 rv=$?; echo $((++i)) $rv
7564 rv=$?; echo $((++i)) $rv
7566 rv=$?; echo $((++i)) $rv
7568 rv=$?; echo $((++i)) $rv
7571 rv=$?; echo $((++i)) $rv
7573 rv=$?; echo $((++i)) $rv
7575 rv=$?; echo $((++i)) $rv
7577 rv=$?; echo $((++i)) $rv
7580 rv=$?; echo $((++i)) $rv
7582 rv=$?; echo $((++i)) $rv
7584 rv=$?; echo $((++i)) $rv
7586 rv=$?; echo $((++i)) $rv
7603 Check that the short form [[ $x ]] works (ksh93 extension)
7607 rv=$?; echo $((++i)) $rv
7609 rv=$?; echo $((++i)) $rv
7611 rv=$?; echo $((++i)) $rv
7613 rv=$?; echo $((++i)) $rv
7616 rv=$?; echo $((++i)) $rv
7618 rv=$?; echo $((++i)) $rv
7620 rv=$?; echo $((++i)) $rv
7622 rv=$?; echo $((++i)) $rv
7625 rv=$?; echo $((++i)) $rv
7627 rv=$?; echo $((++i)) $rv
7629 rv=$?; echo $((++i)) $rv
7631 rv=$?; echo $((++i)) $rv
7648 Check numeric -eq works (R40d regression); spotted by Martijn Dekker
7653 (0) echo yepp 0 \#"$*" ;;
7654 (1) echo nope 1 \#"$*" ;;
7655 (2) echo terr 2 \#"$*" ;;
7656 (*) echo wtf\? $? \#"$*" ;;
7659 tst 1 'test 2 -eq 2'
7660 tst 2 'test 2 -eq 2a'
7661 tst 3 'test 2 -eq 3'
7662 tst 4 'test 2 -ne 2'
7663 tst 5 'test 2 -ne 2a'
7664 tst 6 'test 2 -ne 3'
7665 tst 7 'test \! 2 -eq 2'
7666 tst 8 'test \! 2 -eq 2a'
7667 tst 9 'test \! 2 -eq 3'
7669 yepp 0 #1 test 2 -eq 2
7670 terr 2 #2 test 2 -eq 2a
7671 nope 1 #3 test 2 -eq 3
7672 nope 1 #4 test 2 -ne 2
7673 terr 2 #5 test 2 -ne 2a
7674 yepp 0 #6 test 2 -ne 3
7675 nope 1 #7 test \! 2 -eq 2
7676 terr 2 #8 test \! 2 -eq 2a
7677 yepp 0 #9 test \! 2 -eq 3
7678 expected-stderr-pattern:
7683 Check that ~/.mkshrc works correctly.
7684 Part 1: verify user environment is not read (internal)
7692 Check that ~/.mkshrc works correctly.
7693 Part 2: verify mkshrc is not read (non-interactive shells)
7694 file-setup: file 644 ".mkshrc"
7696 env-setup: !HOME=.!ENV=!
7704 Check that ~/.mkshrc works correctly.
7705 Part 2: verify mkshrc can be read (interactive shells)
7706 file-setup: file 644 ".mkshrc"
7710 env-setup: !HOME=.!ENV=!PS1=!
7715 expected-stderr-pattern:
7720 Check that ~/.mkshrc works correctly.
7721 Part 3: verify mkshrc can be turned off
7722 file-setup: file 644 ".mkshrc"
7724 env-setup: !HOME=.!ENV=nonexistant!
7732 Check that sh mode turns braceexpand off
7733 and that that works correctly
7737 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
7738 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
7746 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
7747 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
7750 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
7751 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
7767 Check that posix or sh mode is *not* automatically turned on
7770 ln -s "$__progname" ksh || cp "$__progname" ksh
7771 ln -s "$__progname" sh || cp "$__progname" sh
7772 ln -s "$__progname" ./-ksh || cp "$__progname" ./-ksh
7773 ln -s "$__progname" ./-sh || cp "$__progname" ./-sh
7774 for shell in {,-}{,k}sh; do
7775 print -- $shell $(./$shell +l -c \
7776 '[[ $(set +o) == *"-o "@(sh|posix)@(| *) ]] && echo sh || echo nosh')
7786 Check that posix or sh mode *is* automatically turned on
7789 ln -s "$__progname" ksh || cp "$__progname" ksh
7790 ln -s "$__progname" sh || cp "$__progname" sh
7791 ln -s "$__progname" ./-ksh || cp "$__progname" ./-ksh
7792 ln -s "$__progname" ./-sh || cp "$__progname" ./-sh
7793 for shell in {,-}{,k}sh; do
7794 print -- $shell $(./$shell +l -c \
7795 '[[ $(set +o) == *"-o "@(sh|posix)@(| *) ]] && echo sh || echo nosh')
7805 pdksh bug: last command of a pipeline is executed in a
7806 subshell - make sure it still is, scripts depend on it
7807 file-setup: file 644 "abcx"
7808 file-setup: file 644 "abcy"
7811 echo a | while read d; do
7831 check that co-processes work with TCOMs, TPIPEs and TPARENs
7834 "$__progname" -c 'i=100; echo hi |& while read -p line; do echo "$((i++)) $line"; done'
7835 "$__progname" -c 'i=200; echo hi | cat |& while read -p line; do echo "$((i++)) $line"; done'
7836 "$__progname" -c 'i=300; (echo hi | cat) |& while read -p line; do echo "$((i++)) $line"; done'
7844 Check that PIPESTATUS does what it's supposed to
7846 echo 1 $PIPESTATUS .
7847 echo 2 ${PIPESTATUS[0]} .
7848 echo 3 ${PIPESTATUS[1]} .
7849 (echo x; exit 12) | (cat; exit 23) | (cat; exit 42)
7850 echo 5 $? , $PIPESTATUS , ${PIPESTATUS[0]} , ${PIPESTATUS[1]} , ${PIPESTATUS[2]} , ${PIPESTATUS[3]} .
7851 echo 6 ${PIPESTATUS[0]} .
7852 set | fgrep PIPESTATUS
7853 echo 8 $(set | fgrep PIPESTATUS) .
7859 5 42 , 12 , 12 , 23 , 42 , .
7862 8 PIPESTATUS[0]=0 PIPESTATUS[1]=0 .
7866 Check that "set -o pipefail" does what it's supposed to
7868 echo 1 "$("$__progname" -c '(exit 12) | (exit 23) | (exit 42); echo $?')" .
7869 echo 2 "$("$__progname" -c '! (exit 12) | (exit 23) | (exit 42); echo $?')" .
7870 echo 3 "$("$__progname" -o pipefail -c '(exit 12) | (exit 23) | (exit 42); echo $?')" .
7871 echo 4 "$("$__progname" -o pipefail -c '! (exit 12) | (exit 23) | (exit 42); echo $?')" .
7872 echo 5 "$("$__progname" -c '(exit 23) | (exit 42) | :; echo $?')" .
7873 echo 6 "$("$__progname" -c '! (exit 23) | (exit 42) | :; echo $?')" .
7874 echo 7 "$("$__progname" -o pipefail -c '(exit 23) | (exit 42) | :; echo $?')" .
7875 echo 8 "$("$__progname" -o pipefail -c '! (exit 23) | (exit 42) | :; echo $?')" .
7876 echo 9 "$("$__progname" -o pipefail -c 'x=$( (exit 23) | (exit 42) | :); echo $?')" .
7888 name: persist-history-1
7890 Check if persistent history saving works
7891 category: !no-histfile
7894 env-setup: !ENV=./Env!HISTFILE=hist.file!
7895 file-setup: file 644 "Env"
7899 expected-stdout-pattern:
7901 expected-stderr-pattern:
7906 Check that global does what typeset is supposed to do
7910 global -Uui16 arrfoo[*]
7912 echo before ${arrfoo[0]} .
7914 echo after ${arrfoo[0]} .
7917 echo inside before ${arrbar[0]} .
7919 echo inside changed ${arrbar[0]} .
7920 global -Uui16 arrbar[*]
7921 echo inside typeset ${arrbar[0]} .
7923 echo inside changed ${arrbar[0]} .
7925 echo before ${arrbar[0]} .
7927 echo after ${arrbar[0]} .
7934 inside typeset 16#61 .
7935 inside changed 16#30 .
7938 name: typeset-padding-1
7940 Check if left/right justification works as per TFM
7942 typeset -L10 ln=0hall0
7943 typeset -R10 rn=0hall0
7944 typeset -ZL10 lz=0hall0
7945 typeset -ZR10 rz=0hall0
7946 typeset -Z10 rx=" hallo "
7947 echo "<$ln> <$rn> <$lz> <$rz> <$rx>"
7949 <0hall0 > < 0hall0> <hall0 > <00000hall0> <0000 hallo>
7951 name: typeset-padding-2
7953 Check if base-!10 integers are padded right
7955 typeset -Uui16 -L9 ln=16#1
7956 typeset -Uui16 -R9 rn=16#1
7957 typeset -Uui16 -Z9 zn=16#1
7961 echo "<$ln> <$rn> <$zn> <$ls> <$rs> <$zs>"
7963 <16#1 > < 16#1> <16#000001> <16#1 > < 16#1> <0000016#1>
7967 Check that the UTF-8 Byte Order Mark is ignored as the first
7968 multibyte character of the shell input (with -c, from standard
7969 input, as file, or as eval argument), but nowhere else
7970 # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
7971 category: !os:darwin
7974 print '#!/bin/sh\necho ohne' >foo/fnord
7975 print '#!/bin/sh\necho mit' >foo/fnord
7976 print 'fnord\nfnord\nfnord\nfnord' >foo/bar
7977 print eval \''fnord\nfnord\nfnord\nfnord'\' >foo/zoo
7978 set -A anzahl -- foo/*
7979 echo got ${#anzahl[*]} files
7981 export PATH=$(pwd)/foo$PATHSEP$PATH
7982 "$__progname" -c 'fnord'
7984 "$__progname" -c 'fnord; fnord; fnord; fnord'
7986 "$__progname" foo/bar
7988 "$__progname" <foo/bar
7990 "$__progname" foo/zoo
7992 "$__progname" -c 'echo : $(fnord)'
8022 Check that we can execute BOM-shebangs (failures not fatal)
8023 XXX if the OS can already execute them, we lose
8024 note: cygwin execve(2) doesn't return to us with ENOEXEC, we lose
8025 note: Ultrix perl5 t4 returns 65280 (exit-code 255) and no text
8026 XXX fails when LD_PRELOAD is set with -e and Perl chokes it (ASan)
8028 category: !os:cygwin,!os:msys,!os:ultrix,!os:uwin-nt,!smksh
8029 env-setup: !FOO=BAR!
8031 print '#!'"$__progname"'\nprint "1 a=$ENV{FOO}";' >t1
8032 print '#!'"$__progname"'\nprint "2 a=$ENV{FOO}";' >t2
8033 print '#!'"$__perlname"'\nprint "3 a=$ENV{FOO}\n";' >t3
8034 print '#!'"$__perlname"'\nprint "4 a=$ENV{FOO}\n";' >t4
8041 1 a=/nonexistant{FOO}
8042 2 a=/nonexistant{FOO}
8045 expected-stderr-pattern:
8046 /(Unrecognized character .... ignored at \..t4 line 1)*/
8050 Check that the utf8-mode flag is not set at non-interactive startup
8052 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8!
8054 if [[ $- = *U* ]]; then
8064 Check that the utf8-mode flag is not set at non-interactive startup
8066 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.utf8!
8068 if [[ $- = *U* ]]; then
8078 Check that the utf8-mode flag is set at interactive startup.
8079 -DMKSH_ASSUME_UTF8=0 => expected failure, please ignore
8080 -DMKSH_ASSUME_UTF8=1 => not expected, please investigate
8081 -UMKSH_ASSUME_UTF8 => not expected, but if your OS is old,
8082 try passing HAVE_SETLOCALE_CTYPE=0 to Build.sh
8084 category: !os:hpux,!os:msys
8087 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8!
8089 if [[ $- = *U* ]]; then
8096 expected-stderr-pattern:
8101 Check that the utf8-mode flag is set at interactive startup
8102 Expected failure if -DMKSH_ASSUME_UTF8=0
8106 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.utf8!
8108 if [[ $- = *U* ]]; then
8115 expected-stderr-pattern:
8120 Ensure ±U on the command line is honoured
8121 (these two tests may pass falsely depending on CPPFLAGS)
8124 code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi'
8125 let i++; "$__progname" -U -c "$code"
8126 let i++; "$__progname" +U -c "$code"
8135 Ensure ±U on the command line is honoured, interactive shells
8139 code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi'
8140 let i++; "$__progname" -U -ic "$code"
8141 let i++; "$__progname" +U -ic "$code"
8150 Ensure trailing combining characters are not lost
8171 Check if built-in shell aliases are okay
8176 autoload='\typeset -fu'
8177 functions='\typeset -f'
8178 hash='\builtin alias -t'
8179 history='\builtin fc -l'
8180 integer='\typeset -i'
8183 nameref='\typeset -n'
8185 r='\builtin fc -e -'
8186 type='\builtin whence -v'
8190 Check if “set -o sh” does not influence built-in aliases
8196 autoload='\typeset -fu'
8197 functions='\typeset -f'
8198 hash='\builtin alias -t'
8199 history='\builtin fc -l'
8200 integer='\typeset -i'
8203 nameref='\typeset -n'
8205 r='\builtin fc -e -'
8206 type='\builtin whence -v'
8210 Check if running as sh does not influence built-in aliases
8213 ./sh -c 'alias; typeset -f'
8216 autoload='\typeset -fu'
8217 functions='\typeset -f'
8218 hash='\builtin alias -t'
8219 history='\builtin fc -l'
8220 integer='\typeset -i'
8223 nameref='\typeset -n'
8225 r='\builtin fc -e -'
8226 type='\builtin whence -v'
8228 name: aliases-cmdline
8230 Check that aliases work from the command line (Debian #517009)
8231 Note that due to the nature of the lexing process, defining
8232 aliases in COMSUBs then immediately using them, and things
8233 like 'alias foo=bar && foo', still fail.
8235 "$__progname" -c $'alias a="echo OK"\na'
8239 name: aliases-funcdef-1
8241 Check if POSIX functions take precedences over aliases
8243 alias foo='echo makro'
8251 name: aliases-funcdef-2
8253 Check if POSIX functions take precedences over aliases
8255 alias foo='echo makro'
8263 name: aliases-funcdef-3
8265 Check if aliases take precedences over Korn functions
8267 alias foo='echo makro'
8275 name: aliases-funcdef-4
8277 Functions should only take over if actually being defined
8288 Check if Korn Shell arrays work as expected
8291 set -A foo -- a \$v "$v" '$v' b
8292 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
8298 Check if bash-style arrays work as expected
8301 foo=(a \$v "$v" '$v' b)
8302 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
8308 Check if bash-style arrays work as expected, with newlines
8310 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "$x|"; done' >pfp
8312 test -n "$ZSH_VERSION" && setopt KSH_ARRAYS
8318 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
8323 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
8328 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
8330 7|a|bc|d|$v|e f|$v|g|
8331 7|a|bc|d|$v|e f|$v|g|
8332 6|abc\|d|$v|e f|$v|g||
8336 Check if array bounds are uint32_t
8343 echo ${foo[4294967295]} g ${foo[*]}
8350 Check if Korn Shell arrays with specified indices work as expected
8353 set -A foo -- [1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b
8354 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|"
8355 # we don't want this at all:
8357 set -A arr "[5]=meh"
8358 echo "<${arr[0]}><${arr[5]}>"
8360 5|[1]=$v|[2]=c d|[4]=$v|[0]=a|[5]=b||
8365 Check if bash-style arrays with specified indices work as expected
8366 (taken out temporarily to fix arrays-4; see also arrays-9a comment)
8370 foo=([1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b)
8371 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|"
8372 x=([128]=foo bar baz)
8375 # Check that we do not break this by globbing
8380 echo "<${arr[0]}><${arr[5]}>"
8389 Check if we can get the array keys (indices) for indexed arrays,
8395 echo -n "$((i++))<$x>"
8406 echo a $(of ${foo[*]}) = $(of ${bar[*]}) a
8407 echo b $(of "${foo[*]}") = $(of "${bar[*]}") b
8408 echo c $(of ${foo[@]}) = $(of ${bar[@]}) c
8409 echo d $(of "${foo[@]}") = $(of "${bar[@]}") d
8410 echo e $(of ${!foo[*]}) = $(of ${!bar[*]}) e
8411 echo f $(of "${!foo[*]}") = $(of "${!bar[*]}") f
8412 echo g $(of ${!foo[@]}) = $(of ${!bar[@]}) g
8413 echo h $(of "${!foo[@]}") = $(of "${!bar[@]}") h
8421 a 0<zwei>1<eins>2<drei> = a
8422 b 0<zwei eins drei> = 0<> b
8423 c 0<zwei>1<eins>2<drei> = c
8424 d 0<zwei>1<eins>2<drei> = d
8432 Check if we can get the array keys (indices) for indexed arrays,
8433 Korn shell style, in some corner cases
8436 echo !arz[0]: ${!arz[0]}
8437 echo !arz[1]: ${!arz[1]}
8440 echo !arz[0]: ${!arz[0]}
8441 echo !arz[1]: ${!arz[1]}
8444 echo !arz[0]: ${!arz[0]}
8445 echo !arz[1]: ${!arz[1]}
8459 Check some behavioural rules for arrays.
8497 typeset -Z3 aa ab ac ad ae af ag
8542 Check that we can concatenate arrays
8544 unset foo; foo=(bar); foo+=(baz); echo 1 ${!foo[*]} : ${foo[*]} .
8545 unset foo; foo=(foo bar); foo+=(baz); echo 2 ${!foo[*]} : ${foo[*]} .
8546 # unset foo; foo=([2]=foo [0]=bar); foo+=(baz [5]=quux); echo 3 ${!foo[*]} : ${foo[*]} .
8549 2 0 1 2 : foo bar baz .
8550 # 3 0 2 3 5 : bar foo baz quux .
8554 Check that we can concatenate parameters too
8556 unset foo; foo=bar; foo+=baz; echo 1 $foo .
8557 unset foo; typeset -i16 foo=10; foo+=20; echo 2 $foo .
8562 name: arrassign-basic
8564 Check basic whitespace conserving properties of wdarrassign
8572 c+=("$(echo "c d")")
8574 echo ".a:${a[0]}.${a[1]}.${a[2]}.${a[3]}:"
8575 echo ".b:${b[0]}.${b[1]}.${b[2]}.${b[3]}:"
8576 echo ".c:${c[0]}.${c[1]}.${c[2]}.${c[3]}:"
8577 echo ".d:${d[0]}.${d[1]}.${d[2]}.${d[3]}:"
8584 name: arrassign-fnc-none
8586 Check locality of array access inside a function
8590 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8593 if [[ -n $BASH_VERSION ]]; then
8599 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8603 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8605 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8607 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8608 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8610 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8612 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8625 name: arrassign-fnc-local
8627 Check locality of array access inside a function
8628 with the bash/mksh/ksh93 local/typeset keyword
8629 (note: ksh93 has no local; typeset works only in FKSH)
8634 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8637 if [[ -n $BASH_VERSION ]]; then
8644 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8648 if [[ -n $BASH_VERSION ]]; then
8654 echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8659 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8661 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8663 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8664 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8666 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8668 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8669 echo ".f0r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8671 echo ".f1r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8673 echo ".f2r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8691 name: arrassign-fnc-global
8693 Check locality of array access inside a function
8694 with the mksh-specific global keyword
8699 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8705 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8711 echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8716 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8718 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8720 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8721 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8723 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8725 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8726 echo ".f0r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8728 echo ".f1r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8730 echo ".f2r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8748 name: strassign-fnc-none
8750 Check locality of string access inside a function
8785 name: strassign-fnc-local
8787 Check locality of string access inside a function
8788 with the bash/mksh/ksh93 local/typeset keyword
8789 (note: ksh93 has no local; typeset works only in FKSH)
8843 name: strassign-fnc-global
8845 Check locality of string access inside a function
8846 with the mksh-specific global keyword
8900 name: unset-fnc-local-ksh
8902 Check that “unset” removes a previous “local”
8903 (ksh93 syntax compatible version); apparently,
8904 there are shells which fail this?
8930 name: unset-fnc-local-sh
8932 Check that “unset” removes a previous “local”
8933 (Debian Policy §10.4 sh version); apparently,
8934 there are shells which fail this?
8960 name: varexpand-substr-1
8962 Check if bash-style substring expansion works
8963 when using positive numerics
8966 typeset -i y=123456789
8967 typeset -i 16 z=123456789 # 16#75bcd15
8968 echo a t${x:2:2} ${y:2:3} ${z:2:3} a
8969 echo b ${x::3} ${y::3} ${z::3} b
8970 echo c ${x:2:} ${y:2:} ${z:2:} c
8971 echo d ${x:2} ${y:2} ${z:2} d
8972 echo e ${x:2:6} ${y:2:6} ${z:2:7} e
8973 echo f ${x:2:7} ${y:2:7} ${z:2:8} f
8974 echo g ${x:2:8} ${y:2:8} ${z:2:9} g
8979 d cdefghi 3456789 #75bcd15 d
8980 e cdefgh 345678 #75bcd1 e
8981 f cdefghi 3456789 #75bcd15 f
8982 g cdefghi 3456789 #75bcd15 g
8984 name: varexpand-substr-2
8986 Check if bash-style substring expansion works
8987 when using negative numerics or expressions
8990 typeset -i y=123456789
8991 typeset -i 16 z=123456789 # 16#75bcd15
8993 echo a ${x:$n:3} ${y:$n:3} ${z:$n:3} a
8994 echo b ${x:(n):3} ${y:(n):3} ${z:(n):3} b
8995 echo c ${x:(-2):1} ${y:(-2):1} ${z:(-2):1} c
8996 echo d t${x: n:2} ${y: n:3} ${z: n:3} d
9003 name: varexpand-substr-3
9005 Check that some things that work in bash fail.
9006 This is by design. Oh and vice versa, nowadays.
9008 export x=abcdefghi n=2
9009 "$__progname" -c 'echo v${x:(n)}x'
9010 "$__progname" -c 'echo w${x: n}x'
9011 "$__progname" -c 'echo x${x:n}x'
9012 "$__progname" -c 'echo y${x:}x'
9013 "$__progname" -c 'echo z${x}x'
9014 # next fails only in bash
9015 "$__progname" -c 'x=abcdef;y=123;echo ${x:${y:2:1}:2}' >/dev/null 2>&1; echo $?
9021 expected-stderr-pattern:
9022 /x:n.*bad substitution.*\n.*bad substitution/
9024 name: varexpand-substr-4
9026 Check corner cases for substring expansion
9030 echo a ${x:(y == 1 ? 2 : 3):4} a
9034 name: varexpand-substr-5A
9036 Check that substring expansions work on characters
9040 echo a ${x::1} ${x: -1} a
9041 echo b ${x::3} ${x: -3} b
9042 echo c ${x:1:2} ${x: -3:2} c
9050 name: varexpand-substr-5W
9052 Check that substring expansions work on characters
9056 echo a ${x::1} ${x: -1} a
9057 echo b ${x::2} ${x: -2} b
9058 echo c ${x:1:1} ${x: -2:1} c
9066 name: varexpand-substr-6
9068 Check that string substitution works correctly
9073 echo a ${baz: foo: bar}
9074 echo b ${baz: foo: $bar}
9075 echo c ${baz: $foo: bar}
9076 echo d ${baz: $foo: $bar}
9083 name: varexpand-special-hash
9085 Check special ${var@x} expansion for x=hash
9090 print ${foo@#} ${bar@#} ${baz@#} .
9092 9B15FBFB CFBDD32B 00000000 .
9094 name: varexpand-special-quote
9096 Check special ${var@Q} expansion for quoted strings
9103 print -r -- "<i=$i j=$j k=$k>"
9104 s="u=${i@Q} v=${j@Q} w=${k@Q}"
9105 print -r -- "s=\"$s\""
9111 s="u=x v='a b' w=$'c\nd\240e\u20ACf'"
9114 typeset w=$'c\nd\240e\u20ACf'
9116 name: varexpand-null-1
9118 Ensure empty strings expand emptily
9120 print s ${a} . ${b} S
9121 print t ${a#?} . ${b%?} T
9122 print r ${a=} . ${b/c/d} R
9124 print s "${a}" . "${b}" S
9125 print t "${a#?}" . "${b%?}" T
9126 print r "${a=}" . "${b/c/d}" R
9136 name: varexpand-null-2
9138 Ensure empty strings, when quoted, are expanded as empty strings
9140 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "<$x> "; done' >pfs
9142 ./pfs 1 "${a}" 2 "${a#?}" + "${b%?}" 3 "${a=}" + "${b/c/d}"
9145 <1> <> <2> <> <+> <> <3> <> <+> <> .
9147 name: varexpand-null-3
9149 Ensure concatenating behaviour matches other shells
9151 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
9153 x=; showargs 1 "$x"$@
9154 set A; showargs 2 "${@:+}"
9188 name: varexpand-funny-chars
9190 Check some characters
9191 XXX \uEF80 is asymmetric, possibly buggy so we don’t check this
9193 x=$'<\x00>'; typeset -p x
9194 x=$'<\x01>'; typeset -p x
9195 x=$'<\u0000>'; typeset -p x
9196 x=$'<\u0001>'; typeset -p x
9203 name: print-funny-chars
9205 Check print builtin's capability to output designated characters
9208 print '<\0144\0344\xDB\u00DB\u20AC\uDB\x40>'
9214 # integer-base-one-3Ar
9215 typeset -Uui16 -Z11 pos=0
9216 typeset -Uui16 -Z5 hv=2147483647
9218 if read -arN -1 line; then
9221 while (( i < ${#line[*]} )); do
9223 if (( (pos & 15) == 0 )); then
9224 (( pos )) && print "$dasc|"
9225 print -n "${pos#16#} "
9228 print -n "${hv#16#} "
9229 if (( (hv < 32) || (hv > 126) )); then
9232 dasc=$dasc${line[i-1]#1#}
9234 (( (pos++ & 15) == 7 )) && print -n -- '- '
9237 while (( pos & 15 )); do
9239 (( (pos++ & 15) == 7 )) && print -n -- '- '
9241 (( hv == 2147483647 )) || print "$dasc|"
9244 00000000 3C 64 E4 DB C3 9B E2 82 - AC C3 9B 40 3E 0A 3C 00 |<d.........@>.<.|
9245 00000010 3E 0A 3C 01 3E 0A 3C 00 - 3E 0A 3C 01 3E 0A |>.<.>.<.>.<.>.|
9249 Check print builtin's \c escape
9251 print '\ca'; print b
9257 Check that CR+LF is not collapsed into LF as some MSYS shells wrongly do
9259 echo '#!'"$__progname" >foo
9261 print -n -- '220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT\r\n220->> Bitte keine Werbung einwerfen! <<\r\r\n220 Who do you wanna pretend to be today'
9266 ./foo | while IFS= read -r line; do
9267 print -r -- "{$line}"
9270 [220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT
\r
9271 220->> Bitte keine Werbung einwerfen! <<
\r\r
9272 220 Who do you wanna pretend to be today?
\r]
9273 {220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT
\r}
9274 {220->> Bitte keine Werbung einwerfen! <<
\r\r}
9275 {220 Who do you wanna pretend to be today?
\r}
9279 Check that CR+LF is shown and read as-is
9285 if test x"$KSH_VERSION" = x""; then #
\r
9286 printf '<%s>' "$x" #
\r
9288 print -nr -- "<$x>" #
\r
9291 echo "[$("$__progname" foo)]"
9292 "$__progname" foo | while IFS= read -r line; do
9293 print -r -- "{$line}"
9304 Check that LF-only is shown and read as-is
9310 if test x"$KSH_VERSION" = x""; then #
9311 printf '<%s>' "$x" #
9313 print -nr -- "<$x>" #
9316 echo "[$("$__progname" foo)]"
9317 "$__progname" foo | while IFS= read -r line; do
9318 print -r -- "{$line}"
9327 name: print-nul-chars
9329 Check handling of NUL characters for print and COMSUB
9332 print $(($(print '<\0>' | wc -c))) $(($(print "$x" | wc -c))) \
9334 expected-stdout-pattern:
9339 Check that print -A works as expected
9341 print -An 0x20AC 0xC3 0xBC 8#101
9343 print -A 0x20AC 0xC3 0xBC 8#102
9349 Check backslash expansion by the print builtin
9351 print '\ \!\"\#\$\%\&'\\\''\(\)\*\+\,\-\.\/\0\1\2\3\4\5\6\7\8' \
9352 '\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T' \
9353 '\U\V\W\X\Y\Z\[\\\]\^\_\`\a\b \d\e\f\g\h\i\j\k\l\m\n\o\p' \
9354 '\q\r\s\t\u\v\w\x\y\z\{\|\}\~' '\u20acd' '\U20acd' '\x123' \
9355 '\0x' '\0123' '\01234' | {
9356 # integer-base-one-3As
9357 typeset -Uui16 -Z11 pos=0
9358 typeset -Uui16 -Z5 hv=2147483647
9362 while IFS= read -r line; do
9364 while [[ -n $line ]]; do
9366 if (( (pos & 15) == 0 )); then
9367 (( pos )) && print "$dasc|"
9368 print -n "${pos#16#} "
9371 print -n "${hv#16#} "
9372 if (( (hv < 32) || (hv > 126) )); then
9375 dasc=$dasc${line::1}
9377 (( (pos++ & 15) == 7 )) && print -n -- '- '
9381 while (( pos & 15 )); do
9383 (( (pos++ & 15) == 7 )) && print -n -- '- '
9385 (( hv == 2147483647 )) || print "$dasc|"
9388 00000000 5C 20 5C 21 5C 22 5C 23 - 5C 24 5C 25 5C 26 5C 27 |\ \!\"\#\$\%\&\'|
9389 00000010 5C 28 5C 29 5C 2A 5C 2B - 5C 2C 5C 2D 5C 2E 5C 2F |\(\)\*\+\,\-\.\/|
9390 00000020 5C 31 5C 32 5C 33 5C 34 - 5C 35 5C 36 5C 37 5C 38 |\1\2\3\4\5\6\7\8|
9391 00000030 20 5C 39 5C 3A 5C 3B 5C - 3C 5C 3D 5C 3E 5C 3F 5C | \9\:\;\<\=\>\?\|
9392 00000040 40 5C 41 5C 42 5C 43 5C - 44 1B 5C 46 5C 47 5C 48 |@\A\B\C\D.\F\G\H|
9393 00000050 5C 49 5C 4A 5C 4B 5C 4C - 5C 4D 5C 4E 5C 4F 5C 50 |\I\J\K\L\M\N\O\P|
9394 00000060 5C 51 5C 52 5C 53 5C 54 - 20 5C 56 5C 57 5C 58 5C |\Q\R\S\T \V\W\X\|
9395 00000070 59 5C 5A 5C 5B 5C 5C 5D - 5C 5E 5C 5F 5C 60 07 08 |Y\Z\[\]\^\_\`..|
9396 00000080 20 20 5C 64 1B 0C 5C 67 - 5C 68 5C 69 5C 6A 5C 6B | \d..\g\h\i\j\k|
9397 00000090 5C 6C 5C 6D 0A 5C 6F 5C - 70 20 5C 71 0D 5C 73 09 |\l\m.\o\p \q.\s.|
9398 000000A0 0B 5C 77 5C 79 5C 7A 5C - 7B 5C 7C 5C 7D 5C 7E 20 |.\w\y\z\{\|\}\~ |
9399 000000B0 E2 82 AC 64 20 EF BF BD - 20 12 33 20 78 20 53 20 |...d ... .3 x S |
9400 000000C0 53 34 0A - |S4.|
9402 name: dollar-doublequoted-strings
9404 Check that a $ preceding "…" is ignored
9406 echo $"Localise me!"
9411 I do not take a $V for a V!
9416 I do not take a $V for a V!
9418 name: dollar-quoted-strings
9420 Check backslash expansion by $'…' strings
9422 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
9424 ./pfn $'\ \!\"\#\$\%\&\'\(\)\*\+\,\-\.\/ \1\2\3\4\5\6' \
9425 $'a\0b' $'a\01b' $'\7\8\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I' \
9426 $'\J\K\L\M\N\O\P\Q\R\S\T\U1\V\W\X\Y\Z\[\\\]\^\_\`\a\b\d\e' \
9427 $'\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u1\v\w\x1\y\z\{\|\}\~ $x' \
9428 $'\u20acd' $'\U20acd' $'\x123' $'fn\x0rd' $'\0234' $'\234' \
9429 $'\2345' $'\ca' $'\c!' $'\c?' $'\c€' $'a\
9431 # integer-base-one-3As
9432 typeset -Uui16 -Z11 pos=0
9433 typeset -Uui16 -Z5 hv=2147483647
9437 while IFS= read -r line; do
9439 while [[ -n $line ]]; do
9441 if (( (pos & 15) == 0 )); then
9442 (( pos )) && print "$dasc|"
9443 print -n "${pos#16#} "
9446 print -n "${hv#16#} "
9447 if (( (hv < 32) || (hv > 126) )); then
9450 dasc=$dasc${line::1}
9452 (( (pos++ & 15) == 7 )) && print -n -- '- '
9456 while (( pos & 15 )); do
9458 (( (pos++ & 15) == 7 )) && print -n -- '- '
9460 (( hv == 2147483647 )) || print "$dasc|"
9463 00000000 20 21 22 23 24 25 26 27 - 28 29 2A 2B 2C 2D 2E 2F | !"#$%&'()*+,-./|
9464 00000010 20 01 02 03 04 05 06 0A - 61 0A 61 01 62 0A 07 38 | .......a.a.b..8|
9465 00000020 39 3A 3B 3C 3D 3E 3F 40 - 41 42 43 44 1B 46 47 48 |9:;<=>?@ABCD.FGH|
9466 00000030 49 0A 4A 4B 4C 4D 4E 4F - 50 51 52 53 54 01 56 57 |I.JKLMNOPQRST.VW|
9467 00000040 58 59 5A 5B 5C 5D 5E 5F - 60 07 08 64 1B 0A 0C 67 |XYZ[\]^_`..d...g|
9468 00000050 68 69 6A 6B 6C 6D 0A 6F - 70 71 0D 73 09 01 0B 77 |hijklm.opq.s...w|
9469 00000060 01 79 7A 7B 7C 7D 7E 20 - 24 78 0A E2 82 AC 64 0A |.yz{|}~ $x....d.|
9470 00000070 EF BF BD 0A C4 A3 0A 66 - 6E 0A 13 34 0A 9C 0A 9C |.......fn..4....|
9471 00000080 35 0A 01 0A 01 0A 7F 0A - 02 82 AC 0A 61 0A 62 0A |5...........a.b.|
9473 name: dollar-quotes-in-heredocs-strings
9475 They are, however, not parsed in here documents, here strings
9476 (outside of string delimiters) or regular strings, but in
9477 parameter substitutions.
9480 dollar = strchr(s, '$'); /* ' */
9486 cat <<<"dollar = strchr(s, '$'); /* ' */"
9487 cat <<<'dollar = strchr(s, '\''$'\''); /* '\'' */'
9488 x="dollar = strchr(s, '$'); /* ' */"
9491 unset nl; print -r -- "x${nl:=$'\n'}y"
9497 # probably never reached for here strings?
9499 cat <<<"4 foo\\\"bar"
9501 # old scripts use this (e.g. ncurses)
9503 # make sure this works, outside of quotes
9506 dollar = strchr(s, '$'); /* ' */
9509 dollar = strchr(s, '$'); /* ' */
9510 dollar = strchr(s, '$'); /* ' */
9511 dollar = strchr(s, '$'); /* ' */
9523 name: dot-needs-argument
9525 check Debian #415167 solution: '.' without arguments should fail
9528 "$__progname" -c source
9529 expected-exit: e != 0
9530 expected-stderr-pattern:
9531 /\.: missing argument.*\n.*source: missing argument/
9533 name: dot-errorlevel
9535 Ensure dot resets $?
9544 name: alias-function-no-conflict
9546 make aliases not conflict with function definitions
9548 # POSIX function can be defined, but alias overrides it
9549 alias foo='echo bar'
9556 foo 2>/dev/null || echo rab
9557 # alias overrides ksh function
9558 alias korn='echo bar'
9564 # alias temporarily overrides POSIX function
9569 alias bla='echo bal'
9583 name: bash-function-parens
9585 ensure the keyword function is ignored when preceding
9586 POSIX style function declarations (bashism)
9589 echo '#!'"$__progname"
9591 echo ' echo "bar='\''$0'\'\"
9593 print -r -- "${2:-foo}"
9595 mk 'function foo' >f-korn
9597 mk 'function foo ()' >f-bash
9598 print '#!'"$__progname"'\nprint -r -- "${0%/f-argh}"' >f-argh
9601 x="korn: $(./f-korn)"; echo "${x/@("$u")/.}"
9602 x="dash: $(./f-dash)"; echo "${x/@("$u")/.}"
9603 x="bash: $(./f-bash)"; echo "${x/@("$u")/.}"
9606 dash: bar='./f-dash'
9607 bash: bar='./f-bash'
9609 name: integer-base-one-1
9611 check if the use of fake integer base 1 works
9614 typeset -Uui16 i0=1#ï i1=1#â
\82¬
9616 typeset -i1 o1a=0x263A
9617 typeset -Uui1 o0b=0x7E
9618 typeset -Uui1 o1b=0xFDD0
9619 integer px=0xCAFE 'p0=1# ' p1=1#… pl=1#f
9620 echo "in <$i0> <$i1>"
9621 echo "out <${o0a#1#}|${o0b#1#}> <${o1a#1#}|${o1b#1#}>"
9623 echo "pass <$px> <$p0> <$p1> <$pl> <${i0#1#}|${i1#1#}>"
9624 typeset -Uui16 tv1=1#~ tv2=1#
\7f tv3=1#
\80 tv4=1#
\81 tv5=1#À tv6=1#Á tv7=1#Â tv8=1#Â
\80
9625 echo "specX <${tv1#16#}> <${tv2#16#}> <${tv3#16#}> <${tv4#16#}> <${tv5#16#}> <${tv6#16#}> <${tv7#16#}> <${tv8#16#}>"
9626 typeset -i1 tv1 tv2 tv3 tv4 tv5 tv6 tv7 tv8
9627 echo "specW <${tv1#1#}> <${tv2#1#}> <${tv3#1#}> <${tv4#1#}> <${tv5#1#}> <${tv6#1#}> <${tv7#1#}> <${tv8#1#}>"
9628 typeset -i1 xs1=0xEF7F xs2=0xEF80 xs3=0xFDD0
9629 echo "specU <${xs1#1#}> <${xs2#1#}> <${xs3#1#}>"
9631 in <16#EFEF> <16#20AC>
9633 pass <16#cafe> <1# > <1#â
\80¦> <1#f> <ï|â
\82¬>
9634 specX <7E> <7F> <EF80> <EF81> <EFC0> <EFC1> <A0> <80>
9635 specW <~> <
\7f> <
\80> <
\81> <À> <Á> <Â > <Â
\80>
9636 specU <> <
\80> <ï·
\90>
9638 name: integer-base-one-2a
9640 check if the use of fake integer base 1 stops at correct characters
9645 expected-stderr-pattern:
9646 /1#foo: unexpected 'oo'/
9647 expected-exit: e != 0
9649 name: integer-base-one-2b
9651 check if the use of fake integer base 1 stops at correct characters
9656 expected-stderr-pattern:
9657 /1#À
\80: unexpected '
\80'/
9658 expected-exit: e != 0
9660 name: integer-base-one-2c1
9662 check if the use of fake integer base 1 stops at correct characters
9670 name: integer-base-one-2c2
9672 check if the use of fake integer base 1 stops at correct characters
9677 expected-stderr-pattern:
9678 /1#â
\80¦: unexpected '
\80'/
9679 expected-exit: e != 0
9681 name: integer-base-one-2d1
9683 check if the use of fake integer base 1 handles octets okay
9687 echo /$x/ # invalid utf-8
9691 name: integer-base-one-2d2
9693 check if the use of fake integer base 1 handles octets
9697 echo /$x/ # invalid 2-byte
9701 name: integer-base-one-2d3
9703 check if the use of fake integer base 1 handles octets
9707 echo /$x/ # invalid 2-byte
9711 name: integer-base-one-2d4
9713 check if the use of fake integer base 1 stops at invalid input
9716 typeset -i16 x=1#ï¿À
9717 echo /$x/ # invalid 3-byte
9718 expected-stderr-pattern:
9719 /1#ï¿À: unexpected '¿'/
9720 expected-exit: e != 0
9722 name: integer-base-one-2d5
9724 check if the use of fake integer base 1 stops at invalid input
9727 typeset -i16 x=1#À
\80
9728 echo /$x/ # non-minimalistic
9729 expected-stderr-pattern:
9730 /1#À
\80: unexpected '
\80'/
9731 expected-exit: e != 0
9733 name: integer-base-one-2d6
9735 check if the use of fake integer base 1 stops at invalid input
9738 typeset -i16 x=1#à
\80\80
9739 echo /$x/ # non-minimalistic
9740 expected-stderr-pattern:
9741 /1#à
\80\80: unexpected '
\80'/
9742 expected-exit: e != 0
9744 name: integer-base-one-3As
9746 some sample code for hexdumping
9747 not NUL safe; input lines must be NL terminated
9750 print 'Hello, World!\\\nこんにちは!'
9751 typeset -Uui16 i=0x100
9752 # change that to 0xFF once we can handle embedded
9753 # NUL characters in strings / here documents
9754 while (( i++ < 0x1FF )); do
9755 print -n "\x${i#16#1}"
9759 # integer-base-one-3As
9760 typeset -Uui16 -Z11 pos=0
9761 typeset -Uui16 -Z5 hv=2147483647
9765 while IFS= read -r line; do
9767 while [[ -n $line ]]; do
9769 if (( (pos & 15) == 0 )); then
9770 (( pos )) && print "$dasc|"
9771 print -n "${pos#16#} "
9774 print -n "${hv#16#} "
9775 if (( (hv < 32) || (hv > 126) )); then
9778 dasc=$dasc${line::1}
9780 (( (pos++ & 15) == 7 )) && print -n -- '- '
9784 while (( pos & 15 )); do
9786 (( (pos++ & 15) == 7 )) && print -n -- '- '
9788 (( hv == 2147483647 )) || print "$dasc|"
9791 00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..|
9792 00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................|
9793 00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................|
9794 00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................|
9795 00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.|
9796 00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>|
9797 00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN|
9798 00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^|
9799 00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn|
9800 00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~|
9801 000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................|
9802 000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................|
9803 000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................|
9804 000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................|
9805 000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................|
9806 000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................|
9807 00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................|
9808 00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................|
9809 00000120 FF 7A 0A - |.z.|
9811 name: integer-base-one-3Ws
9813 some sample code for hexdumping Unicode
9814 not NUL safe; input lines must be NL terminated
9818 print 'Hello, World!\\\nこんにちは!'
9819 typeset -Uui16 i=0x100
9820 # change that to 0xFF once we can handle embedded
9821 # NUL characters in strings / here documents
9822 while (( i++ < 0x1FF )); do
9823 print -n "\u${i#16#1}"
9826 print \\xff # invalid utf-8
9827 print \\xc2 # invalid 2-byte
9828 print \\xef\\xbf\\xc0 # invalid 3-byte
9829 print \\xc0\\x80 # non-minimalistic
9830 print \\xe0\\x80\\x80 # non-minimalistic
9831 print '�' # end of range
9832 print '\0z' # embedded NUL
9834 # integer-base-one-3Ws
9835 typeset -Uui16 -Z11 pos=0
9836 typeset -Uui16 -Z7 hv
9841 while IFS= read -r line; do
9844 while (( lpos < ${#line} )); do
9845 wc=1#${line:(lpos++):1}
9846 if (( (wc < 32) || \
9847 ((wc > 126) && (wc < 160)) )); then
9849 elif (( (wc & 0xFF80) == 0xEF80 )); then
9854 if (( (pos & 7) == 7 )); then
9857 elif (( (pos & 7) == 0 )); then
9858 (( pos )) && print "$dasc|"
9859 print -n "${pos#16#} "
9863 print -n "${hv#16#} "
9864 (( (pos++ & 7) == 3 )) && \
9869 while (( pos & 7 )); do
9871 (( (pos++ & 7) == 3 )) && print -n -- '- '
9873 (( hv == 2147483647 )) || print "$dasc|"
9876 00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W|
9877 00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.こ|
9878 00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |んにちは!...|
9879 00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........|
9880 00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........|
9881 00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........|
9882 00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"|
9883 00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*|
9884 00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012|
9885 00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:|
9886 00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB|
9887 00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ|
9888 00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR|
9889 00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ|
9890 00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab|
9891 00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij|
9892 00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr|
9893 00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz|
9894 00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....|
9895 00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........|
9896 000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........|
9897 000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........|
9898 000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |..... ¡¢|
9899 000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA |£¤¥¦§¨©ª|
9900 000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 |«¬®¯°±²|
9901 000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA |³´µ¶·¸¹º|
9902 000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 |»¼½¾¿ÀÁÂ|
9903 000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA |ÃÄÅÆÇÈÉÊ|
9904 000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 |ËÌÍÎÏÐÑÒ|
9905 000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA |ÓÔÕÖ×ØÙÚ|
9906 000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 |ÛÜÝÞßàáâ|
9907 000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA |ãäåæçèéê|
9908 00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 |ëìíîïðñò|
9909 00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA |óôõö÷øùú|
9910 00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |ûüýþÿ.�.|
9911 00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |�.���.��|
9912 00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |.���.���|
9913 00000128 EFBE EFEF EFBF EFBF - 000A 007A 000A |����.z.|
9915 name: integer-base-one-3Ar
9917 some sample code for hexdumping; NUL and binary safe
9920 print 'Hello, World!\\\nこんにちは!'
9921 typeset -Uui16 i=0x100
9922 # change that to 0xFF once we can handle embedded
9923 # NUL characters in strings / here documents
9924 while (( i++ < 0x1FF )); do
9925 print -n "\x${i#16#1}"
9929 # integer-base-one-3Ar
9930 typeset -Uui16 -Z11 pos=0
9931 typeset -Uui16 -Z5 hv=2147483647
9933 if read -arN -1 line; then
9936 while (( i < ${#line[*]} )); do
9938 if (( (pos & 15) == 0 )); then
9939 (( pos )) && print "$dasc|"
9940 print -n "${pos#16#} "
9943 print -n "${hv#16#} "
9944 if (( (hv < 32) || (hv > 126) )); then
9947 dasc=$dasc${line[i-1]#1#}
9949 (( (pos++ & 15) == 7 )) && print -n -- '- '
9952 while (( pos & 15 )); do
9954 (( (pos++ & 15) == 7 )) && print -n -- '- '
9956 (( hv == 2147483647 )) || print "$dasc|"
9959 00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..|
9960 00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................|
9961 00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................|
9962 00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................|
9963 00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.|
9964 00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>|
9965 00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN|
9966 00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^|
9967 00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn|
9968 00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~|
9969 000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................|
9970 000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................|
9971 000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................|
9972 000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................|
9973 000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................|
9974 000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................|
9975 00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................|
9976 00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................|
9977 00000120 FF 00 7A 0A - |..z.|
9979 name: integer-base-one-3Wr
9981 some sample code for hexdumping Unicode; NUL and binary safe
9985 print 'Hello, World!\\\nこんにちは!'
9986 typeset -Uui16 i=0x100
9987 # change that to 0xFF once we can handle embedded
9988 # NUL characters in strings / here documents
9989 while (( i++ < 0x1FF )); do
9990 print -n "\u${i#16#1}"
9993 print \\xff # invalid utf-8
9994 print \\xc2 # invalid 2-byte
9995 print \\xef\\xbf\\xc0 # invalid 3-byte
9996 print \\xc0\\x80 # non-minimalistic
9997 print \\xe0\\x80\\x80 # non-minimalistic
9998 print '�' # end of range
9999 print '\0z' # embedded NUL
10001 # integer-base-one-3Wr
10002 typeset -Uui16 -Z11 pos=0
10003 typeset -Uui16 -Z7 hv=2147483647
10005 if read -arN -1 line; then
10008 while (( i < ${#line[*]} )); do
10010 if (( (hv < 32) || \
10011 ((hv > 126) && (hv < 160)) )); then
10013 elif (( (hv & 0xFF80) == 0xEF80 )); then
10016 dch=${line[i-1]#1#}
10018 if (( (pos & 7) == 7 )); then
10021 elif (( (pos & 7) == 0 )); then
10022 (( pos )) && print "$dasc|"
10023 print -n "${pos#16#} "
10026 print -n "${hv#16#} "
10027 (( (pos++ & 7) == 3 )) && \
10032 while (( pos & 7 )); do
10034 (( (pos++ & 7) == 3 )) && print -n -- '- '
10036 (( hv == 2147483647 )) || print "$dasc|"
10039 00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W|
10040 00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.こ|
10041 00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |んにちは!...|
10042 00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........|
10043 00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........|
10044 00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........|
10045 00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"|
10046 00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*|
10047 00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012|
10048 00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:|
10049 00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB|
10050 00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ|
10051 00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR|
10052 00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ|
10053 00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab|
10054 00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij|
10055 00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr|
10056 00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz|
10057 00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....|
10058 00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........|
10059 000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........|
10060 000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........|
10061 000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |..... ¡¢|
10062 000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA |£¤¥¦§¨©ª|
10063 000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 |«¬®¯°±²|
10064 000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA |³´µ¶·¸¹º|
10065 000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 |»¼½¾¿ÀÁÂ|
10066 000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA |ÃÄÅÆÇÈÉÊ|
10067 000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 |ËÌÍÎÏÐÑÒ|
10068 000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA |ÓÔÕÖ×ØÙÚ|
10069 000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 |ÛÜÝÞßàáâ|
10070 000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA |ãäåæçèéê|
10071 00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 |ëìíîïðñò|
10072 00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA |óôõö÷øùú|
10073 00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |ûüýþÿ.�.|
10074 00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |�.���.��|
10075 00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |.���.���|
10076 00000128 EFBE EFEF EFBF EFBF - 000A 0000 007A 000A |����..z.|
10078 name: integer-base-one-4
10080 Check if ksh93-style base-one integers work
10085 (echo 2f $(('aa'))) 2>&1 | sed "s/^[^']*'/2p '/"
10093 2p 'aa': multi-character character constant
10099 name: integer-base-one-5A
10101 Check to see that we’re NUL and Unicode safe
10104 print 'a\0b\xfdz' >x
10110 16#61 16#0 16#62 16#FD 16#7A .
10112 name: integer-base-one-5W
10114 Check to see that we’re NUL and Unicode safe
10123 16#61 16#0 16#62 16#20AC 16#63 .
10127 Check if we can use a specific syntax idiom for ulimit
10128 category: !os:syllable
10130 if ! x=$(ulimit -d) || [[ $x = unknown ]]; then
10131 #echo expected to fail on this OS
10134 ulimit -dS $x && echo okay
10141 Check some of the most basic invariants of I/O redirection
10146 print -u2 e$((i++)).
10171 Check if GNU bash-like I/O redirection works
10172 Part 1: this is also supported by GNU bash
10173 category: shell:legacy-no
10176 function threeout {
10192 Check if GNU bash-like I/O redirection works
10193 Part 2: this is *not* supported by GNU bash
10194 category: shell:legacy-no
10197 function threeout {
10213 Check if GNU bash-like I/O redirection works
10214 Part 2: this is *not* supported by GNU bash
10215 category: shell:legacy-no
10218 function threeout {
10223 threeout 3>foo &>&3
10234 Check if GNU bash-like I/O redirection works
10235 Part 2: this is supported by GNU bash 4 only
10236 category: shell:legacy-no
10241 function threeout {
10258 Check if GNU bash-like I/O redirection fails correctly
10259 Part 1: this is also supported by GNU bash
10260 category: shell:legacy-no
10265 function threeout {
10276 expected-stderr-pattern: /.*: can't (create|overwrite) .*/
10280 Check if GNU bash-like I/O redirection fails correctly
10281 Part 2: this is *not* supported by GNU bash
10282 category: shell:legacy-no
10287 function threeout {
10303 Check if GNU bash-like I/O redirection works
10304 Part 4: this is also supported by GNU bash,
10305 but failed in some mksh versions
10306 category: shell:legacy-no
10309 function threeout {
10315 [[ -e bar ]] && threeout "$bf" &>foo
10328 name: bashiop-5-normal
10330 Check if GNU bash-like I/O redirection is only supported
10331 in !POSIX !sh mode as it breaks existing scripts' syntax
10332 category: shell:legacy-no
10334 :>x; echo 1 "$("$__progname" -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
10335 :>x; echo 2 "$("$__progname" -o posix -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
10336 :>x; echo 3 "$("$__progname" -o sh -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
10342 name: bashiop-5-legacy
10344 Check if GNU bash-like I/O redirection is not parsed
10345 in lksh as it breaks existing scripts' syntax
10346 category: shell:legacy-yes
10348 :>x; echo 1 "$("$__progname" -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
10349 :>x; echo 2 "$("$__progname" -o posix -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
10350 :>x; echo 3 "$("$__progname" -o sh -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
10361 for n in ${a#*=}; do echo 1hu ${n} .; done
10362 for n in "${a#*=}"; do echo 1hq ${n} .; done
10363 for n in ${a##*=}; do echo 2hu ${n} .; done
10364 for n in "${a##*=}"; do echo 2hq ${n} .; done
10365 for n in ${a%=*}; do echo 1pu ${n} .; done
10366 for n in "${a%=*}"; do echo 1pq ${n} .; done
10367 for n in ${a%%=*}; do echo 2pu ${n} .; done
10368 for n in "${a%%=*}"; do echo 2pq ${n} .; done
10375 name: oksh-and-list-error-1
10377 Test exit status of rightmost element in 2 element && list in -e mode
10380 echo "should not print"
10382 expected-exit: e != 0
10384 name: oksh-and-list-error-2
10386 Test exit status of rightmost element in 3 element && list in -e mode
10388 true && true && false
10389 echo "should not print"
10391 expected-exit: e != 0
10393 name: oksh-or-list-error-1
10395 Test exit status of || list in -e mode
10398 echo "should not print"
10400 expected-exit: e != 0
10402 name: oksh-longline-crash
10404 This used to cause a core dump
10407 deplibs="-lz -lpng /usr/local/lib/libjpeg.la -ltiff -lm -lX11 -lXext /usr/local/lib/libiconv.la -L/usr/local/lib -L/usr/ports/devel/gettext/w-gettext-0.10.40/gettext-0.10.40/intl/.libs /usr/local/lib/libintl.la /usr/local/lib/libglib.la /usr/local/lib/libgmodule.la -lintl -lm -lX11 -lXext -L/usr/X11R6/lib -lglib -lgmodule -L/usr/local/lib /usr/local/lib/libgdk.la -lintl -lm -lX11 -lXext -L/usr/X11R6/lib -lglib -lgmodule -L/usr/local/lib /usr/local/lib/libgtk.la -ltiff -ljpeg -lz -lpng -lm -lX11 -lXext -lintl -lglib -lgmodule -lgdk -lgtk -L/usr/X11R6/lib -lglib -lgmodule -L/usr/local/lib /usr/local/lib/libgdk_pixbuf.la -lz -lpng /usr/local/lib/libiconv.la -L/usr/local/lib -L/usr/ports/devel/gettext/w-gettext-0.10.40/gettext-0.10.40/intl/.libs /usr/local/lib/libintl.la /usr/local/lib/libglib.la -lm -lm /usr/local/lib/libaudiofile.la -lm -lm -laudiofile -L/usr/local/lib /usr/local/lib/libesd.la -lm -lz -L/usr/local/lib /usr/local/lib/libgnomesupport.la -lm -lz -lm -lglib -L/usr/local/lib /usr/local/lib/libgnome.la -lX11 -lXext /usr/local/lib/libiconv.la -L/usr/local/lib -L/usr/ports/devel/gettext/w-gettext-0.10.40/gettext-0.10.40/intl/.libs /usr/local/lib/libintl.la /usr/local/lib/libgmodule.la -lintl -lm -lX11 -lXext -L/usr/X11R6/lib -lglib -lgmodule -L/usr/local/lib /usr/local/lib/libgdk.la -lintl -lm -lX11 -lXext -L/usr/X11R6/lib -lglib -lgmodule -L/usr/local/lib /usr/local/lib/libgtk.la -lICE -lSM -lz -lpng /usr/local/lib/libungif.la /usr/local/lib/libjpeg.la -ltiff -lm -lz -lpng /usr/local/lib/libungif.la -lz /usr/local/lib/libjpeg.la -ltiff -L/usr/local/lib -L/usr/X11R6/lib /usr/local/lib/libgdk_imlib.la -lm -L/usr/local/lib /usr/local/lib/libart_lgpl.la -lm -lz -lm -lX11 -lXext -lintl -lglib -lgmodule -lgdk -lgtk -lICE -lSM -lm -lX11 -lXext -lintl -lglib -lgmodule -lgdk -lgtk -L/usr/X11R6/lib -lm -lz -lpng -lungif -lz -ljpeg -ltiff -ljpeg -lgdk_imlib -lglib -lm -laudiofile -lm -laudiofile -lesd -L/usr/local/lib /usr/local/lib/libgnomeui.la -lz -lz /usr/local/lib/libxml.la -lz -lz -lz /usr/local/lib/libxml.la -lm -lX11 -lXext /usr/local/lib/libiconv.la -L/usr/ports/devel/gettext/w-gettext-0.10.40/gettext-0.10.40/intl/.libs /usr/local/lib/libintl.la /usr/local/lib/libglib.la /usr/local/lib/libgmodule.la -lintl -lglib -lgmodule /usr/local/lib/libgdk.la /usr/local/lib/libgtk.la -L/usr/X11R6/lib -L/usr/local/lib /usr/local/lib/libglade.la -lz -lz -lz /usr/local/lib/libxml.la /usr/local/lib/libglib.la -lm -lm /usr/local/lib/libaudiofile.la -lm -lm -laudiofile /usr/local/lib/libesd.la -lm -lz /usr/local/lib/libgnomesupport.la -lm -lz -lm -lglib /usr/local/lib/libgnome.la -lX11 -lXext /usr/local/lib/libiconv.la -L/usr/ports/devel/gettext/w-gettext-0.10.40/gettext-0.10.40/intl/.libs /usr/local/lib/libintl.la /usr/local/lib/libgmodule.la -lintl -lm -lX11 -lXext -lglib -lgmodule /usr/local/lib/libgdk.la -lintl -lm -lX11 -lXext -lglib -lgmodule /usr/local/lib/libgtk.la -lICE -lSM -lz -lpng /usr/local/lib/libungif.la /usr/local/lib/libjpeg.la -ltiff -lm -lz -lz /usr/local/lib/libgdk_imlib.la /usr/local/lib/libart_lgpl.la -lm -lz -lm -lX11 -lXext -lintl -lglib -lgmodule -lgdk -lgtk -lm -lX11 -lXext -lintl -lglib -lgmodule -lgdk -lgtk -lm -lz -lungif -lz -ljpeg -ljpeg -lgdk_imlib -lglib -lm -laudiofile -lm -laudiofile -lesd /usr/local/lib/libgnomeui.la -L/usr/X11R6/lib -L/usr/local/lib /usr/local/lib/libglade-gnome.la /usr/local/lib/libglib.la -lm -lm /usr/local/lib/libaudiofile.la -lm -lm -laudiofile -L/usr/local/lib /usr/local/lib/libesd.la -lm -lz -L/usr/local/lib /usr/local/lib/libgnomesupport.la -lm -lz -lm -lglib -L/usr/local/lib /usr/local/lib/libgnome.la -lX11 -lXext /usr/local/lib/libiconv.la -L/usr/local/lib -L/usr/ports/devel/gettext/w-gettext-0.10.40/gettext-0.10.40/intl/.libs /usr/local/lib/libintl.la /usr/local/lib/libgmodule.la -lintl -lm -lX11 -lXext -L/usr/X11R6/lib -lglib -lgmodule -L/usr/local/lib /usr/local/lib/libgdk.la -lintl -lm -lX11 -lXext -L/usr/X11R6/lib -lglib -lgmodule -L/usr/local/lib /usr/local/lib/libgtk.la -lICE -lSM -lz -lpng /usr/local/lib/libungif.la /usr/local/lib/libjpeg.la -ltiff -lm -lz -lpng /usr/local/lib/libungif.la -lz /usr/local/lib/libjpeg.la -ltiff -L/usr/local/lib -L/usr/X11R6/lib /usr/local/lib/libgdk_imlib.la -lm -L/usr/local/lib /usr/local/lib/libart_lgpl.la -lm -lz -lm -lX11 -lXext -lintl -lglib -lgmodule -lgdk -lgtk -lICE -lSM -lm -lX11 -lXext -lintl -lglib -lgmodule -lgdk -lgtk -L/usr/X11R6/lib -lm -lz -lpng -lungif -lz -ljpeg -ltiff -ljpeg -lgdk_imlib -lglib -lm -laudiofile -lm -laudiofile -lesd -L/usr/local/lib /usr/local/lib/libgnomeui.la -L/usr/X11R6/lib -L/usr/local/lib"
10408 specialdeplibs="-lgnomeui -lart_lgpl -lgdk_imlib -ltiff -ljpeg -lungif -lpng -lz -lSM -lICE -lgtk -lgdk -lgmodule -lintl -lXext -lX11 -lgnome -lgnomesupport -lesd -laudiofile -lm -lglib"
10409 for deplib in $deplibs; do
10412 new_libs="$deplib $new_libs"
10415 case " $specialdeplibs " in
10417 new_libs="$deplib $new_libs";;
10423 name: oksh-seterror-1
10425 The -e flag should be ignored when executing a compound list
10426 followed by an if statement.
10428 if true; then false && false; fi
10431 expected-exit: e == 0
10433 name: oksh-seterror-2
10435 The -e flag should be ignored when executing a compound list
10436 followed by an if statement.
10438 if true; then if true; then false && false; fi; fi
10441 expected-exit: e == 0
10443 name: oksh-seterror-3
10445 The -e flag should be ignored when executing a compound list
10446 followed by an elif statement.
10448 if true; then :; elif true; then false && false; fi
10450 expected-exit: e == 0
10452 name: oksh-seterror-4
10454 The -e flag should be ignored when executing a pipeline
10463 expected-exit: e == 0
10465 name: oksh-seterror-5
10467 The -e flag should be ignored when executing a pipeline
10473 expected-exit: e == 0
10475 name: oksh-seterror-6
10477 When trapping ERR and EXIT, both traps should run in -e mode
10478 when an error occurs.
10480 trap 'echo EXIT' EXIT
10481 trap 'echo ERR' ERR
10487 expected-exit: e != 0
10492 name: oksh-seterror-7
10494 The -e flag within a command substitution should be honored
10496 echo $( set -e; false; echo foo )
10501 name: oksh-input-comsub
10503 A command substitution using input redirection should exit with
10504 failure if the input file does not exist.
10506 var=$(< non-existent)
10507 expected-exit: e != 0
10508 expected-stderr-pattern: /non-existent/
10510 name: oksh-empty-for-list
10512 A for list which expands to zero items should not execute the body.
10514 set foo bar baz ; for out in ; do echo $out ; done
10516 name: oksh-varfunction-mod1
10518 (Inspired by PR 2450 on OpenBSD.) Calling
10520 where f is a ksh style function, should not set FOO in the current
10521 env. If f is a Bourne style function, FOO should be set. Furthermore,
10522 the function should receive a correct value of FOO. However, differing
10523 from oksh, setting FOO in the function itself must change the value in
10524 setting FOO in the function itself should not change the value in
10525 global environment.
10527 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
10528 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
10529 done >env; chmod +x env; PATH=.$PATHSEP$PATH
10531 if [ x$FOO != xbar ]; then
10535 x=$(env | grep FOO)
10536 if [ "x$x" != "xFOO=bar" ]; then
10544 if [ x$FOO != xbar ]; then
10548 x=$(env | grep FOO)
10549 if [ "x$x" != "xFOO=bar" ]; then
10557 if [ $? != 0 ]; then
10560 if [ x$FOO != x ]; then
10564 if [ $? != 0 ]; then
10567 if [ x$FOO != xfoo ]; then
10572 if [ $? != 0 ]; then
10575 if [ x$FOO != xbarbar ]; then
10579 if [ $? != 0 ]; then
10582 if [ x$FOO != xfoo ]; then
10588 Verify that file descriptors > 2 are private for Korn shells
10589 AT&T ksh93 does this still, which means we must keep it as well
10590 XXX fails on some old Perl installations
10592 category: shell:legacy-no
10596 open(my \$fh, ">&", 9) or die "E: open \$!";
10597 syswrite(\$fh, "Fowl\\n", 5) or die "E: write \$!";
10602 expected-exit: e != 0
10603 expected-stderr-pattern:
10608 Verify that file descriptors > 2 are not private for POSIX shells
10609 See Debian Bug #154540, Closes: #499139
10610 XXX fails on some old Perl installations
10615 open(my \$fh, ">&", 9) or die "E: open \$!";
10616 syswrite(\$fh, "Fowl\\n", 5) or die "E: write \$!";
10619 test -n "$POSH_VERSION" || set -o posix
10627 Verify that file descriptors > 2 are not private for LEGACY KSH
10628 category: shell:legacy-yes
10632 open(my \$fh, ">&", 9) or die "E: open \$!";
10633 syswrite(\$fh, "Fowl\\n", 5) or die "E: write \$!";
10643 COMSUB are now parsed recursively, so this works
10644 see also regression-6: matching parenthesēs bug
10645 Fails on: pdksh bash2 bash3 zsh
10646 Passes on: bash4 ksh93 mksh(20110313+)
10648 echo 1 $(case 1 in (1) echo yes;; (2) echo no;; esac) .
10649 echo 2 $(case 1 in 1) echo yes;; 2) echo no;; esac) .
10650 TEST=1234; echo 3 ${TEST: $(case 1 in (1) echo 1;; (*) echo 2;; esac)} .
10651 TEST=5678; echo 4 ${TEST: $(case 1 in 1) echo 1;; *) echo 2;; esac)} .
10652 a=($(case 1 in (1) echo 1;; (*) echo 2;; esac)); echo 5 ${a[0]} .
10653 a=($(case 1 in 1) echo 1;; *) echo 2;; esac)); echo 6 ${a[0]} .
10664 COMSUB are now parsed recursively, so this works
10665 Fails on: pdksh bash2 bash3 bash4 zsh
10666 Passes on: ksh93 mksh(20110313+)
10668 echo 1 $(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10)) .
10669 echo 2 $(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20)) .
10670 (( a = $(case 1 in (1) echo 1;; (*) echo 2;; esac) )); echo 3 $a .
10671 (( a = $(case 1 in 1) echo 1;; *) echo 2;; esac) )); echo 4 $a .
10672 a=($(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10))); echo 5 ${a[0]} .
10673 a=($(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20))); echo 6 ${a[0]} .
10684 RedHat BZ#496791 – another case of missing recursion
10685 in parsing COMSUB expressions
10686 Fails on: pdksh bash2 bash3¹ bash4¹ zsh
10687 Passes on: ksh93 mksh(20110305+)
10688 ① bash[34] seem to choke on comment ending with backslash-newline
10690 # a comment with " ' \
10693 # a comment with " ' \
10701 Extended test for COMSUB explaining why a recursive parser
10702 is a must (a non-recursive parser cannot pass all three of
10703 these test cases, especially the ‘#’ is difficult)
10705 print '#!'"$__progname"'\necho 1234' >id; chmod +x id; PATH=.$PATHSEP$PATH
10706 echo $(typeset -i10 x=16#20; echo $x)
10707 echo $(typeset -Uui16 x=16#$(id -u)
10710 typeset -Uui16 a=36#foo; c=2
10711 typeset -Uui16 b=36 #foo; d=2
10720 Check the tree dump functions for !MKSH_SMALL functionality
10723 x() { case $1 in u) echo x ;;& *) echo $1 ;; esac; }
10739 Check COMSUB works with aliases (does not expand them twice)
10741 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
10743 alias echo='echo a'
10745 ./pfn "$(echo foo)"
10752 ./pfn "$(echo foo )"
10755 name: comsub-torture
10757 Check the tree dump functions work correctly
10759 if [[ -z $__progname ]]; then echo >&2 call me with __progname; exit 1; fi
10760 while IFS= read -r line; do
10761 if [[ $line = '#1' ]]; then
10764 elif [[ $line = EOFN* ]]; then
10765 fbody=$fbody$'\n'$line
10767 elif [[ $line != '#'* ]]; then
10768 fbody=$fbody$'\n\t'$line
10771 if (( lastf )); then
10772 x="inline_${nextf}() {"$fbody$'\n}\n'
10774 print -r -- "${x}typeset -f inline_$nextf" | "$__progname"
10775 x="function comsub_$nextf { x=\$("$fbody$'\n); }\n'
10777 print -r -- "${x}typeset -f comsub_$nextf" | "$__progname"
10778 x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n'
10780 print -r -- "${x}typeset -f reread_$nextf" | "$__progname"
10788 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
10789 #TPAREN_TPIPE_TLIST
10790 (echo $foo | tr -dc 0-9; echo)
10792 cmd && echo ja || echo nein
10794 select file in *; do echo "<$file>" ; break ; done
10796 time for i in {1,2,3} ; do echo $i ; done
10798 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
10799 #TIF_TBANG_TDBRACKET_TELIF
10800 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
10802 i=1; while (( i < 10 )); do echo $i; let ++i; done
10804 i=10; until (( !--i )) ; do echo $i; done
10807 #TFUNCT_TBRACE_TASYNC
10808 function korn { echo eins; echo zwei ; }
10809 bourne () { logger * & }
10812 #IOWRITE_IOCLOB_IOHERE_noIOSKIP
10816 #IOWRITE_noIOCLOB_IOHERE_IOSKIP
10821 sh 1<>/dev/console 0<&1 2>&1
10822 #COMSUB_EXPRSUB_FUNSUB_VALSUB
10823 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
10824 #QCHAR_OQUOTE_CQUOTE
10825 echo fo\ob\"a\`r\'b\$az
10826 echo "fo\ob\"a\`r\'b\$az"
10827 echo 'fo\ob\"a\`r'\''b\$az'
10828 #OSUBST_CSUBST_OPAT_SPAT_CPAT
10829 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
10832 note there must be no space between EOFN and )
10836 note the space between EOFN and ) is actually part of the here document marker
10839 x=$(sysctl -n kern.version | sed 1q)
10840 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
10841 ed -s /etc/motd 2>&1 <<-EOF
10848 EOF)" = @(?) ]] && rm -f /etc/motd
10849 if [[ ! -s /etc/motd ]]; then
10850 install -c -o root -g wheel -m 664 /dev/null /etc/motd
10851 print -- "$x\n" >/etc/motd
10861 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
10864 vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4"
10866 function comsub_TCOM { x=$(
10867 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
10869 function comsub_TCOM {
10870 x=$(vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" )
10872 function reread_TCOM { x=$((
10873 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
10875 function reread_TCOM {
10876 x=$(( vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" ) | tr u x )
10878 inline_TPAREN_TPIPE_TLIST() {
10879 (echo $foo | tr -dc 0-9; echo)
10881 inline_TPAREN_TPIPE_TLIST() {
10882 ( echo $foo | tr -dc 0-9
10885 function comsub_TPAREN_TPIPE_TLIST { x=$(
10886 (echo $foo | tr -dc 0-9; echo)
10888 function comsub_TPAREN_TPIPE_TLIST {
10889 x=$(( echo $foo | tr -dc 0-9 ; echo ) )
10891 function reread_TPAREN_TPIPE_TLIST { x=$((
10892 (echo $foo | tr -dc 0-9; echo)
10894 function reread_TPAREN_TPIPE_TLIST {
10895 x=$(( ( echo $foo | tr -dc 0-9 ; echo ) ) | tr u x )
10897 inline_TAND_TOR() {
10898 cmd && echo ja || echo nein
10900 inline_TAND_TOR() {
10901 cmd && echo ja || echo nein
10903 function comsub_TAND_TOR { x=$(
10904 cmd && echo ja || echo nein
10906 function comsub_TAND_TOR {
10907 x=$(cmd && echo ja || echo nein )
10909 function reread_TAND_TOR { x=$((
10910 cmd && echo ja || echo nein
10912 function reread_TAND_TOR {
10913 x=$(( cmd && echo ja || echo nein ) | tr u x )
10916 select file in *; do echo "<$file>" ; break ; done
10925 function comsub_TSELECT { x=$(
10926 select file in *; do echo "<$file>" ; break ; done
10928 function comsub_TSELECT {
10929 x=$(select file in * ; do echo "<$file>" ; break ; done )
10931 function reread_TSELECT { x=$((
10932 select file in *; do echo "<$file>" ; break ; done
10934 function reread_TSELECT {
10935 x=$(( select file in * ; do echo "<$file>" ; break ; done ) | tr u x )
10937 inline_TFOR_TTIME() {
10938 time for i in {1,2,3} ; do echo $i ; done
10940 inline_TFOR_TTIME() {
10941 time for i in {1,2,3}
10946 function comsub_TFOR_TTIME { x=$(
10947 time for i in {1,2,3} ; do echo $i ; done
10949 function comsub_TFOR_TTIME {
10950 x=$(time for i in {1,2,3} ; do echo $i ; done )
10952 function reread_TFOR_TTIME { x=$((
10953 time for i in {1,2,3} ; do echo $i ; done
10955 function reread_TFOR_TTIME {
10956 x=$(( time for i in {1,2,3} ; do echo $i ; done ) | tr u x )
10959 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
10970 echo kann net bis drei zählen
10974 function comsub_TCASE { x=$(
10975 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
10977 function comsub_TCASE {
10978 x=$(case $foo in (1) echo eins ;& (2) echo zwei ;| (*) echo kann net bis drei zählen ;; esac )
10980 function reread_TCASE { x=$((
10981 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
10983 function reread_TCASE {
10984 x=$(( case $foo in (1) echo eins ;& (2) echo zwei ;| (*) echo kann net bis drei zählen ;; esac ) | tr u x )
10986 inline_TIF_TBANG_TDBRACKET_TELIF() {
10987 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
10989 inline_TIF_TBANG_TDBRACKET_TELIF() {
11000 function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$(
11001 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
11003 function comsub_TIF_TBANG_TDBRACKET_TELIF {
11004 x=$(if ! [[ 1 = 1 ]] ; then echo eins ; elif [[ 1 = 2 ]] ; then echo zwei ; else echo drei ; fi )
11006 function reread_TIF_TBANG_TDBRACKET_TELIF { x=$((
11007 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
11009 function reread_TIF_TBANG_TDBRACKET_TELIF {
11010 x=$(( if ! [[ 1 = 1 ]] ; then echo eins ; elif [[ 1 = 2 ]] ; then echo zwei ; else echo drei ; fi ) | tr u x )
11013 i=1; while (( i < 10 )); do echo $i; let ++i; done
11025 function comsub_TWHILE { x=$(
11026 i=1; while (( i < 10 )); do echo $i; let ++i; done
11028 function comsub_TWHILE {
11029 x=$(i=1 ; while { \let] " i < 10 " ; } ; do echo $i ; let ++i ; done )
11031 function reread_TWHILE { x=$((
11032 i=1; while (( i < 10 )); do echo $i; let ++i; done
11034 function reread_TWHILE {
11035 x=$(( i=1 ; while { \let] " i < 10 " ; } ; do echo $i ; let ++i ; done ) | tr u x )
11038 i=10; until (( !--i )) ; do echo $i; done
11049 function comsub_TUNTIL { x=$(
11050 i=10; until (( !--i )) ; do echo $i; done
11052 function comsub_TUNTIL {
11053 x=$(i=10 ; until { \let] " !--i " ; } ; do echo $i ; done )
11055 function reread_TUNTIL { x=$((
11056 i=10; until (( !--i )) ; do echo $i; done
11058 function reread_TUNTIL {
11059 x=$(( i=10 ; until { \let] " !--i " ; } ; do echo $i ; done ) | tr u x )
11068 function comsub_TCOPROC { x=$(
11071 function comsub_TCOPROC {
11074 function reread_TCOPROC { x=$((
11077 function reread_TCOPROC {
11078 x=$(( cat * |& ls ) | tr u x )
11080 inline_TFUNCT_TBRACE_TASYNC() {
11081 function korn { echo eins; echo zwei ; }
11082 bourne () { logger * & }
11084 inline_TFUNCT_TBRACE_TASYNC() {
11093 function comsub_TFUNCT_TBRACE_TASYNC { x=$(
11094 function korn { echo eins; echo zwei ; }
11095 bourne () { logger * & }
11097 function comsub_TFUNCT_TBRACE_TASYNC {
11098 x=$(function korn { echo eins ; echo zwei ; } ; bourne() { logger * & } )
11100 function reread_TFUNCT_TBRACE_TASYNC { x=$((
11101 function korn { echo eins; echo zwei ; }
11102 bourne () { logger * & }
11104 function reread_TFUNCT_TBRACE_TASYNC {
11105 x=$(( function korn { echo eins ; echo zwei ; } ; bourne() { logger * & } ) | tr u x )
11107 inline_IOREAD_IOCAT() {
11110 inline_IOREAD_IOCAT() {
11113 function comsub_IOREAD_IOCAT { x=$(
11116 function comsub_IOREAD_IOCAT {
11117 x=$(tr x u <foo >>bar )
11119 function reread_IOREAD_IOCAT { x=$((
11122 function reread_IOREAD_IOCAT {
11123 x=$(( tr x u <foo >>bar ) | tr u x )
11125 inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
11130 inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
11136 function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$(
11141 function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
11142 x=$(cat >|bar <<"EOFN"
11147 function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$((
11152 function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
11153 x=$(( cat >|bar <<"EOFN"
11158 inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
11163 inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
11169 function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$(
11174 function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
11175 x=$(cat >bar <<-EOFI
11180 function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$((
11185 function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
11186 x=$(( cat >bar <<-EOFI
11191 inline_IORDWR_IODUP() {
11192 sh 1<>/dev/console 0<&1 2>&1
11194 inline_IORDWR_IODUP() {
11195 sh 1<>/dev/console <&1 2>&1
11197 function comsub_IORDWR_IODUP { x=$(
11198 sh 1<>/dev/console 0<&1 2>&1
11200 function comsub_IORDWR_IODUP {
11201 x=$(sh 1<>/dev/console <&1 2>&1 )
11203 function reread_IORDWR_IODUP { x=$((
11204 sh 1<>/dev/console 0<&1 2>&1
11206 function reread_IORDWR_IODUP {
11207 x=$(( sh 1<>/dev/console <&1 2>&1 ) | tr u x )
11209 inline_COMSUB_EXPRSUB_FUNSUB_VALSUB() {
11210 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
11212 inline_COMSUB_EXPRSUB_FUNSUB_VALSUB() {
11213 echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;}
11215 function comsub_COMSUB_EXPRSUB_FUNSUB_VALSUB { x=$(
11216 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
11218 function comsub_COMSUB_EXPRSUB_FUNSUB_VALSUB {
11219 x=$(echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;} )
11221 function reread_COMSUB_EXPRSUB_FUNSUB_VALSUB { x=$((
11222 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
11224 function reread_COMSUB_EXPRSUB_FUNSUB_VALSUB {
11225 x=$(( echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;} ) | tr u x )
11227 inline_QCHAR_OQUOTE_CQUOTE() {
11228 echo fo\ob\"a\`r\'b\$az
11229 echo "fo\ob\"a\`r\'b\$az"
11230 echo 'fo\ob\"a\`r'\''b\$az'
11232 inline_QCHAR_OQUOTE_CQUOTE() {
11233 echo fo\ob\"a\`r\'b\$az
11234 echo "fo\ob\"a\`r\'b\$az"
11235 echo "fo\\ob\\\"a\\\`r"\'"b\\\$az"
11237 function comsub_QCHAR_OQUOTE_CQUOTE { x=$(
11238 echo fo\ob\"a\`r\'b\$az
11239 echo "fo\ob\"a\`r\'b\$az"
11240 echo 'fo\ob\"a\`r'\''b\$az'
11242 function comsub_QCHAR_OQUOTE_CQUOTE {
11243 x=$(echo fo\ob\"a\`r\'b\$az ; echo "fo\ob\"a\`r\'b\$az" ; echo "fo\\ob\\\"a\\\`r"\'"b\\\$az" )
11245 function reread_QCHAR_OQUOTE_CQUOTE { x=$((
11246 echo fo\ob\"a\`r\'b\$az
11247 echo "fo\ob\"a\`r\'b\$az"
11248 echo 'fo\ob\"a\`r'\''b\$az'
11250 function reread_QCHAR_OQUOTE_CQUOTE {
11251 x=$(( echo fo\ob\"a\`r\'b\$az ; echo "fo\ob\"a\`r\'b\$az" ; echo "fo\\ob\\\"a\\\`r"\'"b\\\$az" ) | tr u x )
11253 inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() {
11254 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
11256 inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() {
11257 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
11259 function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$(
11260 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
11262 function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT {
11263 x=$([[ ${foo#bl\(u\)b} = @(bar|baz) ]] )
11265 function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$((
11266 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
11268 function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT {
11269 x=$(( [[ ${foo#bl\(u\)b} = @(bar|baz) ]] ) | tr u x )
11271 inline_heredoc_closed() {
11273 note there must be no space between EOFN and )
11276 inline_heredoc_closed() {
11278 note there must be no space between EOFN and )
11283 function comsub_heredoc_closed { x=$(
11285 note there must be no space between EOFN and )
11288 function comsub_heredoc_closed {
11290 note there must be no space between EOFN and )
11294 function reread_heredoc_closed { x=$((
11296 note there must be no space between EOFN and )
11299 function reread_heredoc_closed {
11300 x=$(( x=$(cat <<EOFN
11301 note there must be no space between EOFN and )
11303 ) ; echo $x ) | tr u x )
11305 inline_heredoc_space() {
11307 note the space between EOFN and ) is actually part of the here document marker
11310 inline_heredoc_space() {
11312 note the space between EOFN and ) is actually part of the here document marker
11317 function comsub_heredoc_space { x=$(
11319 note the space between EOFN and ) is actually part of the here document marker
11322 function comsub_heredoc_space {
11323 x=$(x=$(cat <<EOFN\
11324 note the space between EOFN and ) is actually part of the here document marker
11328 function reread_heredoc_space { x=$((
11330 note the space between EOFN and ) is actually part of the here document marker
11333 function reread_heredoc_space {
11334 x=$(( x=$(cat <<EOFN\
11335 note the space between EOFN and ) is actually part of the here document marker
11337 ) ; echo $x ) | tr u x )
11339 inline_patch_motd() {
11340 x=$(sysctl -n kern.version | sed 1q)
11341 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
11342 ed -s /etc/motd 2>&1 <<-EOF
11349 EOF)" = @(?) ]] && rm -f /etc/motd
11350 if [[ ! -s /etc/motd ]]; then
11351 install -c -o root -g wheel -m 664 /dev/null /etc/motd
11352 print -- "$x\n" >/etc/motd
11355 inline_patch_motd() {
11356 x=$(sysctl -n kern.version | sed 1q )
11357 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
11365 )" = @(?) ]] && rm -f /etc/motd
11366 if [[ ! -s /etc/motd ]]
11368 install -c -o root -g wheel -m 664 /dev/null /etc/motd
11369 print -- "$x\n" >/etc/motd
11372 function comsub_patch_motd { x=$(
11373 x=$(sysctl -n kern.version | sed 1q)
11374 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
11375 ed -s /etc/motd 2>&1 <<-EOF
11382 EOF)" = @(?) ]] && rm -f /etc/motd
11383 if [[ ! -s /etc/motd ]]; then
11384 install -c -o root -g wheel -m 664 /dev/null /etc/motd
11385 print -- "$x\n" >/etc/motd
11388 function comsub_patch_motd {
11389 x=$(x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
11397 )" = @(?) ]] && rm -f /etc/motd ; if [[ ! -s /etc/motd ]] ; then install -c -o root -g wheel -m 664 /dev/null /etc/motd ; print -- "$x\n" >/etc/motd ; fi )
11399 function reread_patch_motd { x=$((
11400 x=$(sysctl -n kern.version | sed 1q)
11401 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
11402 ed -s /etc/motd 2>&1 <<-EOF
11409 EOF)" = @(?) ]] && rm -f /etc/motd
11410 if [[ ! -s /etc/motd ]]; then
11411 install -c -o root -g wheel -m 664 /dev/null /etc/motd
11412 print -- "$x\n" >/etc/motd
11415 function reread_patch_motd {
11416 x=$(( x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
11424 )" = @(?) ]] && rm -f /etc/motd ; if [[ ! -s /etc/motd ]] ; then install -c -o root -g wheel -m 664 /dev/null /etc/motd ; print -- "$x\n" >/etc/motd ; fi ) | tr u x )
11426 inline_wdarrassign() {
11431 inline_wdarrassign() {
11439 function comsub_wdarrassign { x=$(
11444 function comsub_wdarrassign {
11445 x=$(case x in (x) a+=b ; \set -A c+ -- d e ;; esac )
11447 function reread_wdarrassign { x=$((
11452 function reread_wdarrassign {
11453 x=$(( case x in (x) a+=b ; \set -A c+ -- d e ;; esac ) | tr u x )
11456 name: comsub-torture-io
11458 Check the tree dump functions work correctly with I/O redirection
11460 if [[ -z $__progname ]]; then echo >&2 call me with __progname; exit 1; fi
11461 while IFS= read -r line; do
11462 if [[ $line = '#1' ]]; then
11465 elif [[ $line = EOFN* ]]; then
11466 fbody=$fbody$'\n'$line
11468 elif [[ $line != '#'* ]]; then
11469 fbody=$fbody$'\n\t'$line
11472 if (( lastf )); then
11473 x="inline_${nextf}() {"$fbody$'\n}\n'
11475 print -r -- "${x}typeset -f inline_$nextf" | "$__progname"
11476 x="function comsub_$nextf { x=\$("$fbody$'\n); }\n'
11478 print -r -- "${x}typeset -f comsub_$nextf" | "$__progname"
11479 x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n'
11481 print -r -- "${x}typeset -f reread_$nextf" | "$__progname"
11489 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
11490 #TPAREN_TPIPE_TLIST
11491 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
11493 cmd >&3 && >&3 echo ja || echo >&3 nein
11495 select file in *; do echo "<$file>" ; break >&3 ; done >&3
11497 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
11499 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
11500 #TIF_TBANG_TDBRACKET_TELIF
11501 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
11503 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
11505 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
11507 cat * >&3 |& >&3 ls
11508 #TFUNCT_TBRACE_TASYNC
11509 function korn { echo eins; echo >&3 zwei ; }
11510 bourne () { logger * >&3 & }
11512 echo $(true >&3) $((1+ 2))
11517 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
11520 vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" >&3
11522 function comsub_TCOM { x=$(
11523 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
11525 function comsub_TCOM {
11526 x=$(vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" >&3 )
11528 function reread_TCOM { x=$((
11529 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
11531 function reread_TCOM {
11532 x=$(( vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" >&3 ) | tr u x )
11534 inline_TPAREN_TPIPE_TLIST() {
11535 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
11537 inline_TPAREN_TPIPE_TLIST() {
11538 ( echo $foo | tr -dc 0-9 >&3
11541 function comsub_TPAREN_TPIPE_TLIST { x=$(
11542 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
11544 function comsub_TPAREN_TPIPE_TLIST {
11545 x=$(( echo $foo | tr -dc 0-9 >&3 ; echo >&3 ) >&3 )
11547 function reread_TPAREN_TPIPE_TLIST { x=$((
11548 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
11550 function reread_TPAREN_TPIPE_TLIST {
11551 x=$(( ( echo $foo | tr -dc 0-9 >&3 ; echo >&3 ) >&3 ) | tr u x )
11553 inline_TAND_TOR() {
11554 cmd >&3 && >&3 echo ja || echo >&3 nein
11556 inline_TAND_TOR() {
11557 cmd >&3 && echo ja >&3 || echo nein >&3
11559 function comsub_TAND_TOR { x=$(
11560 cmd >&3 && >&3 echo ja || echo >&3 nein
11562 function comsub_TAND_TOR {
11563 x=$(cmd >&3 && echo ja >&3 || echo nein >&3 )
11565 function reread_TAND_TOR { x=$((
11566 cmd >&3 && >&3 echo ja || echo >&3 nein
11568 function reread_TAND_TOR {
11569 x=$(( cmd >&3 && echo ja >&3 || echo nein >&3 ) | tr u x )
11572 select file in *; do echo "<$file>" ; break >&3 ; done >&3
11581 function comsub_TSELECT { x=$(
11582 select file in *; do echo "<$file>" ; break >&3 ; done >&3
11584 function comsub_TSELECT {
11585 x=$(select file in * ; do echo "<$file>" ; break >&3 ; done >&3 )
11587 function reread_TSELECT { x=$((
11588 select file in *; do echo "<$file>" ; break >&3 ; done >&3
11590 function reread_TSELECT {
11591 x=$(( select file in * ; do echo "<$file>" ; break >&3 ; done >&3 ) | tr u x )
11593 inline_TFOR_TTIME() {
11594 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
11596 inline_TFOR_TTIME() {
11602 function comsub_TFOR_TTIME { x=$(
11603 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
11605 function comsub_TFOR_TTIME {
11606 x=$(for i in {1,2,3} ; do time echo $i >&3 ; done >&3 )
11608 function reread_TFOR_TTIME { x=$((
11609 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
11611 function reread_TFOR_TTIME {
11612 x=$(( for i in {1,2,3} ; do time echo $i >&3 ; done >&3 ) | tr u x )
11615 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
11626 echo kann net bis drei zählen >&3
11630 function comsub_TCASE { x=$(
11631 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
11633 function comsub_TCASE {
11634 x=$(case $foo in (1) echo eins >&3 ;& (2) echo zwei >&3 ;| (*) echo kann net bis drei zählen >&3 ;; esac >&3 )
11636 function reread_TCASE { x=$((
11637 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
11639 function reread_TCASE {
11640 x=$(( case $foo in (1) echo eins >&3 ;& (2) echo zwei >&3 ;| (*) echo kann net bis drei zählen >&3 ;; esac >&3 ) | tr u x )
11642 inline_TIF_TBANG_TDBRACKET_TELIF() {
11643 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
11645 inline_TIF_TBANG_TDBRACKET_TELIF() {
11646 if ! [[ 1 = 1 ]] >&3
11649 elif [[ 1 = 2 ]] >&3
11656 function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$(
11657 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
11659 function comsub_TIF_TBANG_TDBRACKET_TELIF {
11660 x=$(if ! [[ 1 = 1 ]] >&3 ; then echo eins ; elif [[ 1 = 2 ]] >&3 ; then echo zwei ; else echo drei ; fi >&3 )
11662 function reread_TIF_TBANG_TDBRACKET_TELIF { x=$((
11663 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
11665 function reread_TIF_TBANG_TDBRACKET_TELIF {
11666 x=$(( if ! [[ 1 = 1 ]] >&3 ; then echo eins ; elif [[ 1 = 2 ]] >&3 ; then echo zwei ; else echo drei ; fi >&3 ) | tr u x )
11669 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
11681 function comsub_TWHILE { x=$(
11682 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
11684 function comsub_TWHILE {
11685 x=$(i=1 ; while { \let] " i < 10 " ; } >&3 ; do echo $i ; let ++i ; done >&3 )
11687 function reread_TWHILE { x=$((
11688 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
11690 function reread_TWHILE {
11691 x=$(( i=1 ; while { \let] " i < 10 " ; } >&3 ; do echo $i ; let ++i ; done >&3 ) | tr u x )
11694 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
11705 function comsub_TUNTIL { x=$(
11706 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
11708 function comsub_TUNTIL {
11709 x=$(i=10 ; until { \let] " !--i " ; } >&3 ; do echo $i ; done >&3 )
11711 function reread_TUNTIL { x=$((
11712 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
11714 function reread_TUNTIL {
11715 x=$(( i=10 ; until { \let] " !--i " ; } >&3 ; do echo $i ; done >&3 ) | tr u x )
11718 cat * >&3 |& >&3 ls
11724 function comsub_TCOPROC { x=$(
11725 cat * >&3 |& >&3 ls
11727 function comsub_TCOPROC {
11728 x=$(cat * >&3 |& ls >&3 )
11730 function reread_TCOPROC { x=$((
11731 cat * >&3 |& >&3 ls
11733 function reread_TCOPROC {
11734 x=$(( cat * >&3 |& ls >&3 ) | tr u x )
11736 inline_TFUNCT_TBRACE_TASYNC() {
11737 function korn { echo eins; echo >&3 zwei ; }
11738 bourne () { logger * >&3 & }
11740 inline_TFUNCT_TBRACE_TASYNC() {
11749 function comsub_TFUNCT_TBRACE_TASYNC { x=$(
11750 function korn { echo eins; echo >&3 zwei ; }
11751 bourne () { logger * >&3 & }
11753 function comsub_TFUNCT_TBRACE_TASYNC {
11754 x=$(function korn { echo eins ; echo zwei >&3 ; } ; bourne() { logger * >&3 & } )
11756 function reread_TFUNCT_TBRACE_TASYNC { x=$((
11757 function korn { echo eins; echo >&3 zwei ; }
11758 bourne () { logger * >&3 & }
11760 function reread_TFUNCT_TBRACE_TASYNC {
11761 x=$(( function korn { echo eins ; echo zwei >&3 ; } ; bourne() { logger * >&3 & } ) | tr u x )
11763 inline_COMSUB_EXPRSUB() {
11764 echo $(true >&3) $((1+ 2))
11766 inline_COMSUB_EXPRSUB() {
11767 echo $(true >&3 ) $((1+ 2))
11769 function comsub_COMSUB_EXPRSUB { x=$(
11770 echo $(true >&3) $((1+ 2))
11772 function comsub_COMSUB_EXPRSUB {
11773 x=$(echo $(true >&3 ) $((1+ 2)) )
11775 function reread_COMSUB_EXPRSUB { x=$((
11776 echo $(true >&3) $((1+ 2))
11778 function reread_COMSUB_EXPRSUB {
11779 x=$(( echo $(true >&3 ) $((1+ 2)) ) | tr u x )
11784 Check that non-subenvironment command substitution works
11804 You can now reliably use local and return in funsubs
11807 x=q; e=1; x=${ echo a; e=2; echo x$e;}; echo 1:y$x,$e,$?.
11808 x=q; e=1; x=${ echo a; typeset e=2; echo x$e;}; echo 2:y$x,$e,$?.
11809 x=q; e=1; x=${ echo a; typeset e=2; return 3; echo x$e;}; echo 3:y$x,$e,$?.
11817 Check that "value substitutions" work as advertised
11823 echo "before: x<$x> y<$y> z<$z> R<$REPLY>"
11826 echo "start: x<$x> y<$y> z<$z> R<$REPLY>"
11831 echo "end: x<$x> y<$y> z<$z> R<$REPLY>"
11833 echo "after: x<$x> y<$y> z<$z> R<$REPLY>"
11834 # ensure trailing newlines are kept
11835 t=${|REPLY=$'foo\n\n';}
11837 echo -n this used to segfault
11838 echo ${|true;}$(true).
11840 before: x<1> y<2> z<3> R<4>
11841 start: x<1> y<> z<3> R<>
11842 end: x<5> y<6> z<7> R<8>
11843 after: x<8> y<2> z<7> R<4>
11844 typeset t=$'foo\n\n'
11845 this used to segfault.
11847 name: event-subst-3
11849 Check that '!' substitution in noninteractive mode is ignored
11850 file-setup: file 755 "falsetto"
11854 file-setup: file 755 "!false"
11858 export PATH=.$PATHSEP$PATH
11866 ! false; then echo foo; else echo bar; fi
11875 name: event-subst-0
11877 Check that '!' substitution in interactive mode is ignored
11880 file-setup: file 755 "falsetto"
11884 file-setup: file 755 "!false"
11888 export PATH=.$PATHSEP$PATH
11896 ! false; then echo foo; else echo bar; fi
11904 expected-stderr-pattern:
11909 Check that "set -u" matches (future) SUSv4 requirement
11915 if [[ -n $v ]]; then
11950 (mypid=$$; try mypid)
11952 ) 2>&1 | sed -e 's/^[^]]*]//' -e 's/^[^:]*: *//'
11953 exit ${PIPESTATUS[0]}
11957 y: parameter not set
11961 y: parameter not set
11965 2: parameter not set
11967 1: parameter not set
11975 !: parameter not set
11986 Testsuite for nameref (bound variables)
12001 set|grep ^ir2|sed 's/^/s1: /'
12002 typeset|grep ' ir2'|sed -e 's/^/s2: /' -e 's/nameref/typeset -n/'
12003 set -A blub -- e1 e2 e3
12004 typeset -n ind=blub
12005 typeset -n ir2=blub[2]
12006 echo !ind[1]: ${!ind[1]}
12008 echo ind[1]: ${ind[1]}
12028 Testsuite for nameref (bound variables)
12029 Functions, argument given directly, after local
12032 typeset bar=lokal baz=auch
12064 Advanced testsuite for bound variables (ksh93 fails this)
12066 typeset -n foo=bar[i]
12067 set -A bar -- b c a
12068 for i in 0 1 2 3; do
12079 Ensure we don't run in an infinite loop
12083 typeset -n foo=fnord fnord=foo
12093 expected-stderr-pattern:
12094 /fnord: expression recurses on parameter/
12096 name: better-parens-1a
12098 Check support for ((…)) and $((…)) vs (…) and $(…)
12100 if ( (echo fubar)|tr u x); then
12109 name: better-parens-1b
12111 Check support for ((…)) and $((…)) vs (…) and $(…)
12113 echo $( (echo fubar)|tr u x) $?
12117 name: better-parens-1c
12119 Check support for ((…)) and $((…)) vs (…) and $(…)
12121 x=$( (echo fubar)|tr u x); echo $x $?
12125 name: better-parens-2a
12127 Check support for ((…)) and $((…)) vs (…) and $(…)
12129 if ((echo fubar)|tr u x); then
12138 name: better-parens-2b
12140 Check support for ((…)) and $((…)) vs (…) and $(…)
12142 echo $((echo fubar)|tr u x) $?
12146 name: better-parens-2c
12148 Check support for ((…)) and $((…)) vs (…) and $(…)
12150 x=$((echo fubar)|tr u x); echo $x $?
12154 name: better-parens-3a
12156 Check support for ((…)) and $((…)) vs (…) and $(…)
12158 if ( (echo fubar)|(tr u x)); then
12167 name: better-parens-3b
12169 Check support for ((…)) and $((…)) vs (…) and $(…)
12171 echo $( (echo fubar)|(tr u x)) $?
12175 name: better-parens-3c
12177 Check support for ((…)) and $((…)) vs (…) and $(…)
12179 x=$( (echo fubar)|(tr u x)); echo $x $?
12183 name: better-parens-4a
12185 Check support for ((…)) and $((…)) vs (…) and $(…)
12187 if ((echo fubar)|(tr u x)); then
12196 name: better-parens-4b
12198 Check support for ((…)) and $((…)) vs (…) and $(…)
12200 echo $((echo fubar)|(tr u x)) $?
12204 name: better-parens-4c
12206 Check support for ((…)) and $((…)) vs (…) and $(…)
12208 x=$((echo fubar)|(tr u x)); echo $x $?
12212 name: better-parens-5
12214 Another corner case
12216 ( (echo 'fo o$bar' "baz\$bla\"" m\$eh) | tr a A)
12217 ((echo 'fo o$bar' "baz\$bla\"" m\$eh) | tr a A)
12219 fo o$bAr bAz$blA" m$eh
12220 fo o$bAr bAz$blA" m$eh
12224 Test what the echo builtin does (mksh)
12226 echo -n 'foo\x40bar'
12233 Test what the echo builtin does (POSIX)
12234 Note: this follows Debian Policy 10.4 which mandates
12235 that -n shall be treated as an option, not XSI which
12236 mandates it shall be treated as string but escapes
12239 test -n "$POSH_VERSION" || set -o posix
12240 echo -n 'foo\x40bar'
12245 name: echo-test-3-mnbsd
12247 Test what the echo builtin does, and test a compatibility flag.
12250 "$__progname" -c 'echo -n 1=\\x40$1; echo -e \\x2E' -- foo bar
12251 "$__progname" -o posix -c 'echo -n 2=\\x40$1; echo -e \\x2E' -- foo bar
12252 "$__progname" -o sh -c 'echo -n 3=\\x40$1; echo -e \\x2E' -- foo bar
12258 name: echo-test-3-normal
12260 Test what the echo builtin does, and test a compatibility flag.
12261 category: !mnbsdash
12263 "$__progname" -c 'echo -n 1=\\x40$1; echo -e \\x2E' -- foo bar
12264 "$__progname" -o posix -c 'echo -n 2=\\x40$1; echo -e \\x2E' -- foo bar
12265 "$__progname" -o sh -c 'echo -n 3=\\x40$1; echo -e \\x2E' -- foo bar
12271 name: utilities-getopts-1
12273 getopts sets OPTIND correctly for unparsed option
12276 while getopts :a optc; do
12277 echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
12281 OPTARG=, OPTIND=2, optc=a.
12282 OPTARG=, OPTIND=3, optc=a.
12283 OPTARG=x, OPTIND=4, optc=?.
12286 name: utilities-getopts-2
12291 while getopts a: optc; do
12292 echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
12296 OPTARG=Mary, OPTIND=3, optc=a.
12297 OPTARG=, OPTIND=4, optc=?.
12299 expected-stderr-pattern: /.*-x.*option/
12301 name: utilities-getopts-3
12303 Check unsetting OPTARG
12306 getopts x:y opt && echo "${OPTARG-unset}"
12307 getopts x:y opt && echo "${OPTARG-unset}"
12314 Check the new wcswidth feature
12318 print octets: ${#s} .
12319 print 8-bit width: ${%s} .
12321 print characters: ${#s} .
12322 print columns: ${%s} .
12325 print octets: ${#s} .
12326 print 8-bit width: ${%s} .
12328 print characters: ${#s} .
12329 print columns: ${%s} .
12342 Check some corner cases
12358 Check some corner cases
12361 expected-stderr-pattern:
12367 Check some corner cases
12370 expected-stderr-pattern:
12376 Check some corner cases
12379 expected-stderr-pattern:
12385 Check some corner cases
12394 Check proper return values for realpath
12395 category: os:mirbsd
12408 x=$(realpath "$wd/$1" 2>&1); y=$?
12409 print $((++i)) "?$1" =${x##*$wd/} !$y
12435 chk lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself
12440 3 ?dir/file =dir/file !0
12441 4 ?dir/nix =dir/nix !0
12443 6 ?file/ =file/: Not a directory !20
12444 7 ?file/file =file/file: Not a directory !20
12445 8 ?file/nix =file/nix: Not a directory !20
12448 11 ?nix/file =nix/file: No such file or directory !2
12449 12 ?nix/nix =nix/nix: No such file or directory !2
12452 15 ?lndir/file =dir/file !0
12453 16 ?lndir/nix =dir/nix !0
12454 17 ?lnfile =file !0
12455 18 ?lnfile/ =lnfile/: Not a directory !20
12456 19 ?lnfile/file =lnfile/file: Not a directory !20
12457 20 ?lnfile/nix =lnfile/nix: Not a directory !20
12460 23 ?lnnix/file =lnnix/file: No such file or directory !2
12461 24 ?lnnix/nix =lnnix/nix: No such file or directory !2
12462 25 ?lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself =lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself/lnself: Too many levels of symbolic links !62
12466 Ensure that exactly two leading slashes are not collapsed
12467 POSIX guarantees this exception, e.g. for UNC paths on Cygwin
12468 category: os:mirbsd
12478 realpath /usr///bin
12487 realpath //usr/include/../bin
12504 Crashed during March 2011, fixed on vernal equinōx ☺
12505 category: os:mirbsd,os:openbsd
12507 export MALLOC_OPTIONS=FGJPRSX
12508 "$__progname" -c 'x=$(tr z r <<<baz); echo $x'
12514 Check test - bug#465250
12516 test \( ! -e \) ; echo $?
12522 Check test - bug#465250
12524 test \( -e \) ; echo $?
12530 Check test - bug#465250
12532 test ! -e ; echo $?
12538 Check test - bug#465250
12546 Check that zsh case variants work
12580 Check that case end tokens are not mixed up (Debian #220272)
12583 for value in 'x' '}' 'esac'; do
12584 print -n "$((++i))($value)bourne "
12589 print -n "$((++i))($value)korn "
12603 name: command-shift
12605 Check that 'command shift' works
12608 echo "before 0='$0' 1='$1' 2='$2'"
12610 echo "after 0='$0' 1='$1' 2='$2'"
12613 echo "before 0='$0' 1='$1' 2='$2'"
12615 echo "after 0='$0' 1='$1' 2='$2'"
12617 echo = without command
12619 echo = with command
12624 before 0='snc' 1='一' 2='二'
12625 after 0='snc' 1='二' 2=''
12627 before 0='swc' 1='一' 2='二'
12628 after 0='swc' 1='二' 2=''
12631 name: command-pvV-posix-priorities
12633 For POSIX compatibility, command -v should find aliases and reserved
12634 words, and command -p[vV] should find aliases, reserved words, and
12635 builtins over external commands.
12638 alias foo="bar baz"
12640 for word in 'if' 'foo' 'bar' 'set' 'true'; do
12642 command -pv "$word"
12644 command -pV "$word"
12649 if is a reserved word
12650 if is a reserved word
12651 alias foo='bar baz'
12652 alias foo='bar baz'
12653 foo is an alias for 'bar baz'
12654 foo is an alias for 'bar baz'
12661 set is a special shell builtin
12662 set is a special shell builtin
12665 true is a shell builtin
12666 true is a shell builtin
12668 name: whence-preserve-tradition
12670 This regression test is to ensure that the POSIX compatibility
12671 changes for 'command' (see previous test) do not affect traditional
12672 'whence' behaviour.
12673 category: os:mirbsd
12676 alias foo="bar baz"
12678 for word in 'if' 'foo' 'bar' 'set' 'true'; do
12686 if is a reserved word
12689 foo is an alias for 'bar baz'
12695 set is a special shell builtin
12699 true is a shell builtin
12700 true is a tracked alias for /bin/true
12704 Check that the compiler did not optimise-break them
12705 (lex.c has got a similar one in SHEREDELIM)
12710 while (( ++i < 256 )); do
12713 s+=$'\xC2\xA0\xE2\x82\xAC\xEF\xBF\xBD\xEF\xBF\xBE\xEF\xBF\xBF\xF0\x90\x80\x80.'
12716 typeset s=$'\001\002\003\004\005\006\a\b\t\n\v\f\r\016\017\020\021\022\023\024\025\026\027\030\031\032\E\034\035\036\037 !"#$%&\047()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\u00A0\u20AC\uFFFD\357\277\276\357\277\277\360\220\200\200.'
12718 name: stateptr-underflow
12720 This check overflows an Xrestpos stored in a short in R40
12723 function Lb64decode {
12724 [[ -o utf8-mode ]]; local u=$?
12727 [[ -n $s ]] || { s=$(cat;print x); s=${s%x}; }
12728 local -i i=0 n=${#s} p=0 v x
12731 while (( i < n )); do
12735 ([A-Z]) (( v = 1#$c - 65 )) ;;
12736 ([a-z]) (( v = 1#$c - 71 )) ;;
12737 ([0-9]) (( v = 1#$c + 4 )) ;;
12742 (( x = (x << 6) | v ))
12745 (1) (( o = (x >> 4) & 255 )) ;;
12746 (2) (( o = (x >> 2) & 255 )) ;;
12747 (3) (( o = x & 255 ))
12759 while (( ++i < 12120 )); do
12762 Lb64decode $s >/dev/null
12766 Check that "set -x" doesn't redirect too quickly
12768 print '#!'"$__progname" >bash
12770 echo 'GNU bash, version 2.05b.0(1)-release (i386-ecce-mirbsd10)
12771 Copyright (C) 2002 Free Software Foundation, Inc.'
12774 "$__progname" -xc 'foo=$(./bash --version 2>&1 | sed q); echo "=$foo="'
12776 =GNU bash, version 2.05b.0(1)-release (i386-ecce-mirbsd10)=
12777 expected-stderr-pattern:
12782 Check that "set -x" is off during PS4 expansion
12789 PS4='[(p:$-)$(f)] '
12791 set -x -o inherit-xtrace
12800 [(p:sh)(f1:sh)(f2:sh)] print '(o1:shx)'
12801 [(p:sh)(f1:sh)(f2:sh)] set +x
12805 Check that FKSH functions have their own shell flags
12806 category: shell:legacy-no
12808 [[ $KSH_VERSION = Version* ]] && set +B
12823 name: fksh-flags-legacy
12825 Check that even FKSH functions share the shell flags
12826 category: shell:legacy-yes
12828 [[ $KSH_VERSION = Version* ]] && set +B
12845 Check that !FKSH functions share the shell flags
12847 [[ $KSH_VERSION = Version* ]] && set +B