1 # $MirOS: src/bin/mksh/check.t,v 1.751 2016/08/12 16:48:02 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 R53 2016/08/12
35 Check version of shell.
39 category: shell:legacy-no
42 @(#)LEGACY KSH R53 2016/08/12
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-ternary-prec-1
345 Check precedence of ternary operator vs assignment
349 expected-exit: e != 0
350 expected-stderr-pattern:
351 /.*:.*1 \? 20 : x\+=2.*lvalue.*\n$/
353 name: arith-ternary-prec-2
355 Check precedence of ternary operator vs assignment
358 echo $((0 ? x+=2 : 20))
364 Prove arithmetic expressions with embedded parameter
365 substitutions cannot be parsed ahead of time
369 print 2 $((2 * $a)) .
374 name: arith-div-assoc-1
376 Check associativity of division operator
382 name: arith-div-byzero
384 Check division by zero errors out
390 expected-stderr-pattern:
393 name: arith-div-intmin-by-minusone
395 Check division overflow wraps around silently
398 echo signed:$((-2147483648 / -1))r$((-2147483648 % -1)).
399 echo unsigned:$((# -2147483648 / -1))r$((# -2147483648 % -1)).
401 signed:-2147483648r0.
402 unsigned:0r2147483648.
404 name: arith-div-intmin-by-minusone-64
406 Check division overflow wraps around silently
409 echo signed:$((-9223372036854775808 / -1))r$((-9223372036854775808 % -1)).
410 echo unsigned:$((# -9223372036854775808 / -1))r$((# -9223372036854775808 % -1)).
412 signed:-9223372036854775808r0.
413 unsigned:0r9223372036854775808.
415 name: arith-assop-assoc-1
417 Check associativity of assignment-operator operator
419 typeset -i i=1 j=2 k=3
420 echo $((i += j += k))
426 name: arith-mandatory
428 Passing of this test is *mandatory* for a valid mksh executable!
429 category: shell:legacy-no
434 print -r -- $((x++)):$sari=$uari. #0
436 print -r -- $((x++)):$sari=$uari. #1
437 sari=2147483647 uari=2147483647
438 print -r -- $((x++)):$sari=$uari. #2
440 print -r -- $((x++)):$sari=$uari. #3
442 let 'sari *= 2' 'uari *= 2'
444 print -r -- $((x++)):$sari=$uari. #4
446 print -r -- $((x++)):$sari=$uari. #5
447 sari=-2147483648 uari=-2147483648
448 print -r -- $((x++)):$sari=$uari. #6
450 print -r -- $((x++)):$sari=$uari. #7
452 ((# uari = -5 >> 1 ))
453 print -r -- $((x++)):$sari=$uari. #8
456 print -r -- $((x++)):$sari=$uari. #9
460 2:2147483647=2147483647.
461 3:-2147483648=2147483648.
464 6:-2147483648=2147483648.
465 7:2147483647=2147483647.
469 name: arith-unsigned-1
471 Check if unsigned arithmetics work
475 echo x1 $((-1)) $((#-1))
479 vs=4123456789; vu=4123456789
481 (( vs %= 2147483647 ))
482 (( vu %= 2147483647 ))
484 vs=4123456789; vu=4123456789
485 (( # vs %= 2147483647 ))
486 (( # vu %= 2147483647 ))
488 # make sure the calculation does not change unsigned flag
489 vs=4123456789; vu=4123456789
492 echo x6 $((# vs % 2147483647)) $((# vu % 2147483647))
497 echo x7 ${va[#4123456789%2147483647]}
498 # make sure multiple calculations don't interfere with each other
499 let '# mca = -4 % -2' ' mcb = -4 % -2'
503 x2 -171510507 4123456789
504 x3 -171510507 4123456789
505 x4 1975973142 1975973142
506 x5 -171510507 4123456789
507 x6 1975973142 1975973142
511 name: arith-limit32-1
513 Check if arithmetics are 32 bit
517 echo x1 $((-1)) $((#-1))
521 vs=2147483647; vu=2147483647
525 vs=4294967295; vu=4294967295
533 x2 2147483647 2147483647
534 x3 -2147483648 2147483648
539 name: arith-limit64-1
541 Check if arithmetics are 64 bit
545 echo x1 $((-1)) $((#-1))
549 vs=9223372036854775807; vu=9223372036854775807
553 vs=18446744073709551615; vu=18446744073709551615
560 x1 -1 18446744073709551615
561 x2 9223372036854775807 9223372036854775807
562 x3 -9223372036854775808 9223372036854775808
563 x4 -1 18446744073709551615
569 Check that \newline is not collapsed after #
579 Check that \newline is not collapsed inside single quotes
591 Check that \newline is not collapsed inside single quotes
603 Check interaction of aliases, single quotes and here-documents
604 with backslash-newline
605 (don't know what POSIX has to say about this)
627 Check what happens with backslash at end of input
628 (the old Bourne shell trashes them; so do we)
637 # Places \newline should be collapsed
641 Check that \newline is collapsed before, in the middle of, and
653 Check that \newline is collapsed in $ sequences
677 Check that \newline is collapsed in $(..) and `...` sequences
702 Check that \newline is collapsed in $((..)) sequences
713 echo $((1+2+3+4+5+6)\
724 Check that \newline is collapsed in double quoted strings
739 Check that \newline is collapsed in here document delimiters
740 (ksh93 fails second part of this)
762 Check that \newline is collapsed in double-quoted here-document
781 Check that \newline is collapsed in various 2+ character tokens
826 Check that \ at the end of an alias is collapsed when followed
828 (don't know what POSIX has to say about this)
838 Check that \newline in a keyword is collapsed
848 # Places \newline should be collapsed (ksh extensions)
852 Check that \newline is collapsed in extended globbing
869 Check that \newline is collapsed in ((...)) expressions
884 See if break breaks out of loops
886 for i in a b c; do echo $i; break; echo bad-$i; done
888 for i in a b c; do echo $i; break 1; echo bad-$i; done
914 See if break breaks out of nested loops
931 What if break used outside of any loops
932 (ksh88,ksh93 don't print error messages here)
935 expected-stderr-pattern:
940 What if break N used when only N-1 loops
941 (ksh88,ksh93 don't print error messages here)
943 for i in a b c; do echo $i; break 2; echo bad-$i; done
948 expected-stderr-pattern:
953 Error if break argument isn't a number
955 for i in a b c; do echo $i; break abc; echo more-$i; done
959 expected-exit: e != 0
960 expected-stderr-pattern:
965 See if continue continues loops
967 for i in a b c; do echo $i; continue; echo bad-$i ; done
969 for i in a b c; do echo $i; continue 1; echo bad-$i; done
1005 See if continue breaks out of nested loops
1024 What if continue used outside of any loops
1025 (ksh88,ksh93 don't print error messages here)
1028 expected-stderr-pattern:
1033 What if continue N used when only N-1 loops
1034 (ksh88,ksh93 don't print error messages here)
1036 for i in a b c; do echo $i; continue 2; echo bad-$i; done
1043 expected-stderr-pattern:
1048 Error if continue argument isn't a number
1050 for i in a b c; do echo $i; continue abc; echo more-$i; done
1054 expected-exit: e != 0
1055 expected-stderr-pattern:
1060 Test someone's CD history package (uses arrays)
1062 # go to known place before doing anything
1076 if [ "$CDHISTFILE" -a -r "$CDHISTFILE" ] # if directory history exists
1080 while read -r t # read directory history file
1086 if [ "${CDHIST[0]}" != "$PWD" -a "$PWD" != "" ]
1088 _cdins # insert $PWD into cd history
1091 cdlen=${#CDHIST[*]} # number of elements in history
1095 if [ "$OLDPWD" = "" ] && ((cdlen>1))
1097 'print' ${CDHIST[1]}
1105 -l) # print directory list
1108 while (((i=i-1)>=0))
1111 'print' "$num ${CDHIST[i]}"
1115 -[0-9]|-[0-9][0-9]) # cd to dir in list
1116 if (((i=${1#-})<cdlen))
1118 'print' ${CDHIST[i]}
1126 -*) # cd to matched dir in list
1131 case ${CDHIST[i]} in
1133 'print' ${CDHIST[i]}
1153 _cdins # insert $PWD into cd history
1155 if [ "$CDHISTFILE" ]
1157 cdlen=${#CDHIST[*]} # number of elements in history
1162 'print' -r ${CDHIST[i]} # update directory history
1168 function _cdins # insert $PWD into cd history
1169 { # meant to be called only by _cd
1173 while ((i<${#CDHIST[*]})) # see if dir is already in list
1175 if [ "${CDHIST[$i]}" = "$PWD" ]
1182 if ((i>22)) # limit max size of list
1187 while (((i=i-1)>=0)) # bump old dirs in list
1189 CDHIST[i+1]=${CDHIST[i]}
1192 CDHIST[0]=$PWD # insert new directory in list
1220 Check package for cd -Pe
1222 # the mv command fails on Cygwin
1223 # Hurd aborts the testsuite (permission denied)
1224 # QNX does not find subdir to cd into
1225 category: !os:cygwin,!os:gnu,!os:msys,!os:nto,!os:os390,!nosymlink
1226 file-setup: file 644 "x"
1227 mkdir noread noread/target noread/target/subdir
1234 echo 1=$?,${PWD#$bwd/}
1235 epwd=$($TSHELL -c pwd 2>/dev/null)
1236 # This unexpectedly succeeds on GNU/Linux and MidnightBSD
1239 mv ../../noread ../../renamed
1241 echo 2=$?,${PWD#$bwd/}
1244 rm -rf noread link renamed
1246 export TSHELL="$__progname"
1253 2=0,noread/target/subdir
1257 2=1,noread/target/subdir
1261 Check that prompt not printed when processing ENV
1262 env-setup: !ENV=./foo!
1263 file-setup: file 644 "foo"
1278 Check that weird ${foo+bar} constructs are parsed correctly
1280 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
1281 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "<$x> "; done' >pfs
1283 (echo 1 ${IFS+'}'z}) 2>/dev/null || echo failed in 1
1284 (echo 2 "${IFS+'}'z}") 2>/dev/null || echo failed in 2
1285 (echo 3 "foo ${IFS+'bar} baz") 2>/dev/null || echo failed in 3
1286 (echo -n '4 '; ./pfn "foo ${IFS+"b c"} baz") 2>/dev/null || echo failed in 4
1287 (echo -n '5 '; ./pfn "foo ${IFS+b c} baz") 2>/dev/null || echo failed in 5
1288 (echo 6 ${IFS+"}"z}) 2>/dev/null || echo failed in 6
1289 (echo 7 "${IFS+"}"z}") 2>/dev/null || echo failed in 7
1290 (echo 8 "${IFS+\"}\"z}") 2>/dev/null || echo failed in 8
1291 (echo 9 "${IFS+\"\}\"z}") 2>/dev/null || echo failed in 9
1292 (echo 10 foo ${IFS+'bar} baz'}) 2>/dev/null || echo failed in 10
1293 (echo 11 "$(echo "${IFS+'}'z}")") 2>/dev/null || echo failed in 11
1294 (echo 12 "$(echo ${IFS+'}'z})") 2>/dev/null || echo failed in 12
1295 (echo 13 ${IFS+\}z}) 2>/dev/null || echo failed in 13
1296 (echo 14 "${IFS+\}z}") 2>/dev/null || echo failed in 14
1297 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
1298 l=t; (echo 16 ${IFS+h`echo -n i ${IFS+$l}h`ere}) 2>/dev/null || echo failed in 16
1299 l=t; (echo 17 ${IFS+h$(echo -n i ${IFS+$l}h)ere}) 2>/dev/null || echo failed in 17
1300 l=t; (echo 18 "${IFS+h`echo -n i ${IFS+$l}h`ere}") 2>/dev/null || echo failed in 18
1301 l=t; (echo 19 "${IFS+h$(echo -n i ${IFS+$l}h)ere}") 2>/dev/null || echo failed in 19
1302 l=t; (echo 20 ${IFS+h`echo -n i "${IFS+$l}"h`ere}) 2>/dev/null || echo failed in 20
1303 l=t; (echo 21 ${IFS+h$(echo -n i "${IFS+$l}"h)ere}) 2>/dev/null || echo failed in 21
1304 l=t; (echo 22 "${IFS+h`echo -n i "${IFS+$l}"h`ere}") 2>/dev/null || echo failed in 22
1305 l=t; (echo 23 "${IFS+h$(echo -n i "${IFS+$l}"h)ere}") 2>/dev/null || echo failed in 23
1306 key=value; (echo -n '24 '; ./pfn "${IFS+'$key'}") 2>/dev/null || echo failed in 24
1307 key=value; (echo -n '25 '; ./pfn "${IFS+"'$key'"}") 2>/dev/null || echo failed in 25 # ksh93: “'$key'”
1308 key=value; (echo -n '26 '; ./pfn ${IFS+'$key'}) 2>/dev/null || echo failed in 26
1309 key=value; (echo -n '27 '; ./pfn ${IFS+"'$key'"}) 2>/dev/null || echo failed in 27
1310 (echo -n '28 '; ./pfn "${IFS+"'"x ~ x'}'x"'}"x}" #') 2>/dev/null || echo failed in 28
1311 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
1312 (echo -n '30 '; ./pfs ${IFS+foo 'b\
1313 ar' baz}; echo .) 2>/dev/null || (echo failed in 30; echo failed in 31)
1314 (echo -n '32 '; ./pfs ${IFS+foo "b\
1315 ar" baz}; echo .) 2>/dev/null || echo failed in 32
1316 (echo -n '33 '; ./pfs "${IFS+foo 'b\
1317 ar' baz}"; echo .) 2>/dev/null || echo failed in 33
1318 (echo -n '34 '; ./pfs "${IFS+foo "b\
1319 ar" baz}"; echo .) 2>/dev/null || echo failed in 34
1320 (echo -n '35 '; ./pfs ${v=a\ b} x ${v=c\ d}; echo .) 2>/dev/null || echo failed in 35
1321 (echo -n '36 '; ./pfs "${v=a\ b}" x "${v=c\ d}"; echo .) 2>/dev/null || echo failed in 36
1322 (echo -n '37 '; ./pfs ${v-a\ b} x ${v-c\ d}; echo .) 2>/dev/null || echo failed in 37
1323 (echo 38 ${IFS+x'a'y} / "${IFS+x'a'y}" .) 2>/dev/null || echo failed in 38
1324 foo="x'a'y"; (echo 39 ${foo%*'a'*} / "${foo%*'a'*}" .) 2>/dev/null || echo failed in 39
1325 foo="a b c"; (echo -n '40 '; ./pfs "${foo#a}"; echo .) 2>/dev/null || echo failed in 40
1326 (foo() { return 100; }; foo; echo 41 ${#+${#:+${#?}}\ \}\}\}}) 2>/dev/null || echo failed in 41
1342 15 <foo abx{ {{{}b c d{} bar> <}> <baz> .
1356 29 <foo> <abx{ {{> <{}b> <c> <d{}> <bar> <}> <baz> .
1359 32 <foo> <bar> <baz> .
1360 33 <foo 'bar' baz> .
1362 35 <a> <b> <x> <a> <b> .
1363 36 <a\ b> <x> <a\ b> .
1364 37 <a b> <x> <c d> .
1370 name: expand-unglob-dblq
1372 Check that regular "${foo+bar}" constructs are parsed correctly
1377 test x"$v" = x"-" && unset v
1378 (echo "$1 plus norm foo ${v+'bar'} baz")
1379 (echo "$1 dash norm foo ${v-'bar'} baz")
1380 (echo "$1 eqal norm foo ${v='bar'} baz")
1381 (echo "$1 qstn norm foo ${v?'bar'} baz") 2>/dev/null || \
1382 echo "$1 qstn norm -> error"
1383 (echo "$1 PLUS norm foo ${v:+'bar'} baz")
1384 (echo "$1 DASH norm foo ${v:-'bar'} baz")
1385 (echo "$1 EQAL norm foo ${v:='bar'} baz")
1386 (echo "$1 QSTN norm foo ${v:?'bar'} baz") 2>/dev/null || \
1387 echo "$1 QSTN norm -> error"
1391 test x"$v" = x"-" && unset v
1392 (echo "$1 plus parn foo ${v+(bar)} baz")
1393 (echo "$1 dash parn foo ${v-(bar)} baz")
1394 (echo "$1 eqal parn foo ${v=(bar)} baz")
1395 (echo "$1 qstn parn foo ${v?(bar)} baz") 2>/dev/null || \
1396 echo "$1 qstn parn -> error"
1397 (echo "$1 PLUS parn foo ${v:+(bar)} baz")
1398 (echo "$1 DASH parn foo ${v:-(bar)} baz")
1399 (echo "$1 EQAL parn foo ${v:=(bar)} baz")
1400 (echo "$1 QSTN parn foo ${v:?(bar)} baz") 2>/dev/null || \
1401 echo "$1 QSTN parn -> error"
1405 test x"$v" = x"-" && unset v
1406 (echo "$1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz")
1407 (echo "$1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz")
1408 (echo "$1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz")
1409 (echo "$1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz") 2>/dev/null || \
1410 echo "$1 qstn brac -> error"
1411 (echo "$1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz")
1412 (echo "$1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz")
1413 (echo "$1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz")
1414 (echo "$1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz") 2>/dev/null || \
1415 echo "$1 QSTN brac -> error"
1417 : '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' '}}}'
1429 1 dash norm foo 'bar' baz
1430 1 eqal norm foo 'bar' baz
1431 1 qstn norm -> error
1433 1 DASH norm foo 'bar' baz
1434 1 EQAL norm foo 'bar' baz
1435 1 QSTN norm -> error
1436 2 plus norm foo 'bar' baz
1441 2 DASH norm foo 'bar' baz
1442 2 EQAL norm foo 'bar' baz
1443 2 QSTN norm -> error
1444 3 plus norm foo 'bar' baz
1445 3 dash norm foo x baz
1446 3 eqal norm foo x baz
1447 3 qstn norm foo x baz
1448 3 PLUS norm foo 'bar' baz
1449 3 DASH norm foo x baz
1450 3 EQAL norm foo x baz
1451 3 QSTN norm foo x baz
1453 4 dash parn foo (bar) baz
1454 4 eqal parn foo (bar) baz
1455 4 qstn parn -> error
1457 4 DASH parn foo (bar) baz
1458 4 EQAL parn foo (bar) baz
1459 4 QSTN parn -> error
1460 5 plus parn foo (bar) baz
1465 5 DASH parn foo (bar) baz
1466 5 EQAL parn foo (bar) baz
1467 5 QSTN parn -> error
1468 6 plus parn foo (bar) baz
1469 6 dash parn foo x baz
1470 6 eqal parn foo x baz
1471 6 qstn parn foo x baz
1472 6 PLUS parn foo (bar) baz
1473 6 DASH parn foo x baz
1474 6 EQAL parn foo x baz
1475 6 QSTN parn foo x baz
1476 7 plus brac foo c } baz
1477 7 dash brac foo ax{{{}b c d{} baz
1478 7 eqal brac foo ax{{{}b c ax{{{}b} baz
1479 7 qstn brac -> error
1480 7 PLUS brac foo c } baz
1481 7 DASH brac foo ax{{{}b c d{} baz
1482 7 EQAL brac foo ax{{{}b c ax{{{}b} baz
1483 7 QSTN brac -> error
1484 8 plus brac foo ax{{{}b c d{} baz
1485 8 dash brac foo c } baz
1486 8 eqal brac foo c } baz
1487 8 qstn brac foo c } baz
1488 8 PLUS brac foo c } baz
1489 8 DASH brac foo ax{{{}b c d{} baz
1490 8 EQAL brac foo ax{{{}b c ax{{{}b} baz
1491 8 QSTN brac -> error
1492 9 plus brac foo ax{{{}b c d{} baz
1493 9 dash brac foo x c x} baz
1494 9 eqal brac foo x c x} baz
1495 9 qstn brac foo x c x} baz
1496 9 PLUS brac foo ax{{{}b c d{} baz
1497 9 DASH brac foo x c x} baz
1498 9 EQAL brac foo x c x} baz
1499 9 QSTN brac foo x c x} baz
1501 name: expand-unglob-unq
1503 Check that regular ${foo+bar} constructs are parsed correctly
1508 test x"$v" = x"-" && unset v
1509 (echo $1 plus norm foo ${v+'bar'} baz)
1510 (echo $1 dash norm foo ${v-'bar'} baz)
1511 (echo $1 eqal norm foo ${v='bar'} baz)
1512 (echo $1 qstn norm foo ${v?'bar'} baz) 2>/dev/null || \
1513 echo "$1 qstn norm -> error"
1514 (echo $1 PLUS norm foo ${v:+'bar'} baz)
1515 (echo $1 DASH norm foo ${v:-'bar'} baz)
1516 (echo $1 EQAL norm foo ${v:='bar'} baz)
1517 (echo $1 QSTN norm foo ${v:?'bar'} baz) 2>/dev/null || \
1518 echo "$1 QSTN norm -> error"
1522 test x"$v" = x"-" && unset v
1523 (echo $1 plus parn foo ${v+\(bar')'} baz)
1524 (echo $1 dash parn foo ${v-\(bar')'} baz)
1525 (echo $1 eqal parn foo ${v=\(bar')'} baz)
1526 (echo $1 qstn parn foo ${v?\(bar')'} baz) 2>/dev/null || \
1527 echo "$1 qstn parn -> error"
1528 (echo $1 PLUS parn foo ${v:+\(bar')'} baz)
1529 (echo $1 DASH parn foo ${v:-\(bar')'} baz)
1530 (echo $1 EQAL parn foo ${v:=\(bar')'} baz)
1531 (echo $1 QSTN parn foo ${v:?\(bar')'} baz) 2>/dev/null || \
1532 echo "$1 QSTN parn -> error"
1536 test x"$v" = x"-" && unset v
1537 (echo $1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz)
1538 (echo $1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz)
1539 (echo $1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz)
1540 (echo $1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz) 2>/dev/null || \
1541 echo "$1 qstn brac -> error"
1542 (echo $1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz)
1543 (echo $1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz)
1544 (echo $1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz)
1545 (echo $1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz) 2>/dev/null || \
1546 echo "$1 QSTN brac -> error"
1548 : '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' '}}}'
1560 1 dash norm foo bar baz
1561 1 eqal norm foo bar baz
1562 1 qstn norm -> error
1564 1 DASH norm foo bar baz
1565 1 EQAL norm foo bar baz
1566 1 QSTN norm -> error
1567 2 plus norm foo bar baz
1572 2 DASH norm foo bar baz
1573 2 EQAL norm foo bar baz
1574 2 QSTN norm -> error
1575 3 plus norm foo bar baz
1576 3 dash norm foo x baz
1577 3 eqal norm foo x baz
1578 3 qstn norm foo x baz
1579 3 PLUS norm foo bar baz
1580 3 DASH norm foo x baz
1581 3 EQAL norm foo x baz
1582 3 QSTN norm foo x baz
1584 4 dash parn foo (bar) baz
1585 4 eqal parn foo (bar) baz
1586 4 qstn parn -> error
1588 4 DASH parn foo (bar) baz
1589 4 EQAL parn foo (bar) baz
1590 4 QSTN parn -> error
1591 5 plus parn foo (bar) baz
1596 5 DASH parn foo (bar) baz
1597 5 EQAL parn foo (bar) baz
1598 5 QSTN parn -> error
1599 6 plus parn foo (bar) baz
1600 6 dash parn foo x baz
1601 6 eqal parn foo x baz
1602 6 qstn parn foo x baz
1603 6 PLUS parn foo (bar) baz
1604 6 DASH parn foo x baz
1605 6 EQAL parn foo x baz
1606 6 QSTN parn foo x baz
1607 7 plus brac foo c } baz
1608 7 dash brac foo ax{{{}b c d{} baz
1609 7 eqal brac foo ax{{{}b c ax{{{}b} baz
1610 7 qstn brac -> error
1611 7 PLUS brac foo c } baz
1612 7 DASH brac foo ax{{{}b c d{} baz
1613 7 EQAL brac foo ax{{{}b c ax{{{}b} baz
1614 7 QSTN brac -> error
1615 8 plus brac foo ax{{{}b c d{} baz
1616 8 dash brac foo c } baz
1617 8 eqal brac foo c } baz
1618 8 qstn brac foo c } baz
1619 8 PLUS brac foo c } baz
1620 8 DASH brac foo ax{{{}b c d{} baz
1621 8 EQAL brac foo ax{{{}b c ax{{{}b} baz
1622 8 QSTN brac -> error
1623 9 plus brac foo ax{{{}b c d{} baz
1624 9 dash brac foo x c x} baz
1625 9 eqal brac foo x c x} baz
1626 9 qstn brac foo x c x} baz
1627 9 PLUS brac foo ax{{{}b c d{} baz
1628 9 DASH brac foo x c x} baz
1629 9 EQAL brac foo x c x} baz
1630 9 QSTN brac foo x c x} baz
1632 name: expand-threecolons-dblq
1634 Check for a particular thing that used to segfault
1637 echo "${TEST:1:2:3}"
1638 echo $? but still living
1639 expected-stderr-pattern:
1643 name: expand-threecolons-unq
1645 Check for a particular thing that used to not error out
1649 echo $? but still living
1650 expected-stderr-pattern:
1654 name: expand-weird-1
1656 Check corner cases of trim expansion vs. $# vs. ${#var} vs. ${var?}
1658 set 1 2 3 4 5 6 7 8 9 10 11
1659 echo ${#} # value of $#
1660 echo ${##} # length of $#
1661 echo ${##1} # $# trimmed 1
1662 set 1 2 3 4 5 6 7 8 9 10 11 12
1676 name: expand-weird-2
1678 Check more substitution and extension corner cases
1680 :& set -C; pid=$$; sub=$!; flg=$-; set -- i; exec 3>x.tmp
1681 #echo "D: !=$! #=$# \$=$$ -=$- ?=$?"
1682 echo >&3 3 = s^${!-word} , ${#-word} , p^${$-word} , f^${--word} , ${?-word} .
1683 echo >&3 4 = ${!+word} , ${#+word} , ${$+word} , ${-+word} , ${?+word} .
1684 echo >&3 5 = s^${!=word} , ${#=word} , p^${$=word} , f^${-=word} , ${?=word} .
1685 echo >&3 6 = s^${!?word} , ${#?word} , p^${$?word} , f^${-?word} , ${??word} .
1686 echo >&3 7 = sl^${#!} , ${##} , pl^${#$} , fl^${#-} , ${#?} .
1687 echo >&3 8 = sw^${%!} , ${%#} , pw^${%$} , fw^${%-} , ${%?} .
1688 echo >&3 9 = ${!!} , s^${!#} , ${!$} , s^${!-} , s^${!?} .
1689 echo >&3 10 = s^${!#pattern} , ${##pattern} , p^${$#pattern} , f^${-#pattern} , ${?#pattern} .
1690 echo >&3 11 = s^${!%pattern} , ${#%pattern} , p^${$%pattern} , f^${-%pattern} , ${?%pattern} .
1691 echo >&3 12 = $# : ${##} , ${##1} .
1693 echo >&3 14 = $# : ${##} , ${##1} .
1695 echo >&3 16 = $# : ${##} , ${##1} .
1696 set -- 1 2 3 4 5 6 7 8 9 a b c d e
1697 echo >&3 18 = $# : ${##} , ${##1} .
1700 -e "s/ pl^${#pid} / PID /g" -e "s/ sl^${#sub} / SUB /g" -e "s/ fl^${#flg} / FLG /g" \
1701 -e "s/ pw^${%pid} / PID /g" -e "s/ sw^${%sub} / SUB /g" -e "s/ fw^${%flg} / FLG /g" \
1702 -e "s/ p^$pid / PID /g" -e "s/ s^$sub / SUB /g" -e "s/ f^$flg / FLG /g"
1704 3 = SUB , 1 , PID , FLG , 0 .
1705 4 = word , word , word , word , word .
1706 5 = SUB , 1 , PID , FLG , 0 .
1707 6 = SUB , 1 , PID , FLG , 0 .
1708 7 = SUB , 1 , PID , FLG , 1 .
1709 8 = SUB , 1 , PID , FLG , 1 .
1710 9 = ! , SUB , $ , SUB , SUB .
1711 10 = SUB , 1 , PID , FLG , 0 .
1712 11 = SUB , 1 , PID , FLG , 0 .
1718 name: expand-weird-3
1720 Check that trimming works with positional parameters (Debian #48453)
1731 name: expand-weird-4
1733 Check that tilde expansion is enabled in ${x#~}
1734 and cases that are modelled after it (${x/~/~})
1738 echo "<${a#~}> <${a#\~}> <${b:-~}> <${b:-\~}> <${c:=~}><$c> <${a/~}> <${a/x/~}> <${a/x/\~}>"
1740 <~/x> </x> <~> <\~> <~><~> <~/x> <~//etc> <~/~>
1744 Check corner case of ${!?} with ! being var vs. op
1748 expected-stderr-pattern: /not set/
1752 Check corner case of ${!var} vs. ${var op} with var=!
1758 # get an at least three-digit bg pid
1762 if [[ $x != +([0-9]) ]]; then
1763 echo >&2 "cannot test, pid '$x' not numeric"
1764 echo >&2 report this with as many details as possible
1767 [[ $x = [0-9][0-9][0-9]* ]] && break
1770 t=$!; [[ $t = $x ]]; echo 5 $? .
1771 t=${!#}; [[ $t = $x ]]; echo 6 $? .
1772 t=${!#[0-9]}; [[ $t = $y ]]; echo 7 $? .
1773 t=${!-foo}; [[ $t = $x ]]; echo 8 $? .
1774 t=${!?bar}; [[ $t = $x ]]; echo 9 $? .
1786 name: expand-number-1
1788 Check that positional arguments do not overflow
1790 echo "1 ${12345678901234567890} ."
1794 name: expand-slashes-1
1796 Check that side effects in substring replacement are handled correctly
1801 echo 1 ${foo//n$((n++))/[$((++i))]} .
1807 name: expand-slashes-2
1809 Check that side effects in substring replacement are handled correctly
1814 echo 1 ${foo@/n$((n++))/[$((++i))]} .
1820 name: expand-slashes-3
1822 Check that we can access the replaced string
1825 echo 1 ${foo@/n[12]/[$KSH_MATCH]} .
1827 1 [n1][n1][n1][n2]n3 .
1831 Check that globbing isn't done when glob has syntax error
1832 file-setup: file 644 "abcx"
1833 file-setup: file 644 "abcz"
1834 file-setup: file 644 "bbc"
1844 Check that globbing isn't done when glob has syntax error
1845 (AT&T ksh fails this test)
1846 file-setup: file 644 "abcx"
1847 file-setup: file 644 "abcz"
1848 file-setup: file 644 "bbc"
1854 name: eglob-infinite-plus
1856 Check that shell doesn't go into infinite loop expanding +(...)
1858 file-setup: file 644 "abc"
1873 Check that eglobbing isn't done on substitution results
1874 file-setup: file 644 "abc"
1881 name: eglob-nomatch-1
1883 Check that the pattern doesn't match
1885 echo 1: no-file+(a|b)stuff
1886 echo 2: no-file+(a*(c)|b)stuff
1887 echo 3: no-file+((((c)))|b)stuff
1889 1: no-file+(a|b)stuff
1890 2: no-file+(a*(c)|b)stuff
1891 3: no-file+((((c)))|b)stuff
1895 Check that the pattern matches correctly
1896 file-setup: file 644 "abd"
1897 file-setup: file 644 "acd"
1898 file-setup: file 644 "abac"
1902 echo 3: *(a(b|c)) # (...|...) can be used within X(..)
1903 echo 4: a[b*(foo|bar)]d # patterns not special inside [...]
1912 Simple negation tests
1914 case foo in !(foo|bar)) echo yes;; *) echo no;; esac
1915 case bar in !(foo|bar)) echo yes;; *) echo no;; esac
1924 case foo in *(a|b[)) echo yes;; *) echo no;; esac
1925 case foo in *(a|b[)|f*) echo yes;; *) echo no;; esac
1926 case '*(a|b[)' in *(a|b[)) echo yes;; *) echo no;; esac
1934 Eglobbing in trim expressions...
1935 (AT&T ksh fails this - docs say # matches shortest string, ## matches
1951 Check eglobbing works in trims...
1954 echo 1: ${x#*(a|b)cd}
1955 echo 2: "${x#*(a|b)cd}"
1956 echo 3: ${x#"*(a|b)cd"}
1966 Check eglobbing works in trims, for Korn Shell
1967 Ensure eglobbing does not work for reduced-feature /bin/sh
1973 echo "<${x%bar|baz},${y%bar|baz},${z%\?}>"
1974 echo "<${x%ba(r|z)},${y%ba(r|z)}>"
1976 echo "<${x%bar|baz},${y%bar|baz},${z%\?}>"
1982 <foobar,foobaz,fooba>
1985 name: eglob-substrpl-1
1987 Check eglobbing works in substs... and they work at all
1989 [[ -n $BASH_VERSION ]] && shopt -s extglob
1990 x=1222321_ab/cde_b/c_1221
1992 echo 1: ${x/2} . ${x/}
1999 echo 8: ${x//+(2)/4}
2000 echo 9: ${x/b/c/e/f}
2001 echo 10: ${x/b\/c/e/f}
2002 echo 11: ${x/b\/c/e\/f}
2003 echo 12: ${x/b\/c/e\\/f}
2004 echo 13: ${x/b\\/c/e\\/f}
2005 echo 14: ${x//b/c/e/f}
2006 echo 15: ${x//b\/c/e/f}
2007 echo 16: ${x//b\/c/e\/f}
2008 echo 17: ${x//b\/c/e\\/f}
2009 echo 18: ${x//b\\/c/e\\/f}
2010 echo 19: ${x/b\/*\/c/x}
2018 echo 27: ${x//\%1/9}
2019 echo 28: ${x//\\%1/9}
2021 echo 30: ${x//\\a/9}
2024 1: 122321_ab/cde_b/c_1221 . 1222321_ab/cde_b/c_1221
2025 2: 131_ab/cde_b/c_11
2026 3: 1321_ab/cde_b/c_1221
2027 4: 131_ab/cde_b/c_11
2028 5: 1422321_ab/cde_b/c_1221
2029 6: 1444341_ab/cde_b/c_1441
2030 7: 14321_ab/cde_b/c_1221
2031 8: 14341_ab/cde_b/c_141
2032 9: 1222321_ac/e/f/cde_b/c_1221
2033 10: 1222321_ae/fde_b/c_1221
2034 11: 1222321_ae/fde_b/c_1221
2035 12: 1222321_ae\/fde_b/c_1221
2036 13: 1222321_ab/cde_b/c_1221
2037 14: 1222321_ac/e/f/cde_c/e/f/c_1221
2038 15: 1222321_ae/fde_e/f_1221
2039 16: 1222321_ae/fde_e/f_1221
2040 17: 1222321_ae\/fde_e\/f_1221
2041 18: 1222321_ab/cde_b/c_1221
2043 20: 1222321_ab.cde_b/c_1221
2044 21: 1222321_ab.cde_b.c_1221
2045 22: 1222321_ab/cde_b/c_1221
2046 23: 9222321_ab/cde_b/c_1221
2047 24: 1222321_ab/cde_b/c_1221
2048 25: 1222321_ab/cde_b/c_1229
2049 26: 1222321_ab/cde_b/c_1221
2050 27: 1222321_ab/cde_b/c_1221
2051 28: 1222321_ab/cde_b/c_1221
2052 29: 1222321_9b/cde_b/c_1221
2053 30: 1222321_ab/cde_b/c_1221
2054 31: 1xyz22321_ab/cde_b/c_1221
2056 name: eglob-substrpl-2
2058 Check anchored substring replacement works, corner cases
2075 name: eglob-substrpl-3a
2077 Check substring replacement works with variables and slashes, too
2082 echo "${wd/#$pfx/~}"
2083 echo "${wd/#\$pfx/~}"
2084 echo "${wd/#"$pfx"/~}"
2085 echo "${wd/#'$pfx'/~}"
2086 echo "${wd/#"\$pfx"/~}"
2087 echo "${wd/#'\$pfx'/~}"
2096 name: eglob-substrpl-3b
2098 More of this, bash fails it (bash4 passes)
2103 echo "${wd/#$(echo /home/user)/~}"
2104 echo "${wd/#"$(echo /home/user)"/~}"
2105 echo "${wd/#'$(echo /home/user)'/~}"
2111 name: eglob-substrpl-3c
2113 Even more weird cases
2118 echo 1: ${wd/#$pfx/~}
2119 echo 2: ${wd/#\$pfx/~}
2120 echo 3: ${wd/#"$pfx"/~}
2121 echo 4: ${wd/#'$pfx'/~}
2122 echo 5: ${wd/#"\$pfx"/~}
2123 echo 6: ${wd/#'\$pfx'/~}
2124 ts='a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)'
2127 [[ -n $BASH_VERSION ]] && shopt -s extglob
2128 echo 7: ${ts/a\/b/$tr}
2129 echo 8: ${ts/a\/b/\$tr}
2130 echo 9: ${ts/$tp/$tr}
2131 echo 10: ${ts/\$tp/$tr}
2132 echo 11: ${ts/\\$tp/$tr}
2133 echo 12: ${ts/$tp/c/d}
2134 echo 13: ${ts/$tp/c\/d}
2135 echo 14: ${ts/$tp/c\\/d}
2136 echo 15: ${ts/+(a\/b)/$tr}
2137 echo 16: ${ts/+(a\/b)/\$tr}
2138 echo 17: ${ts/+($tp)/$tr}
2139 echo 18: ${ts/+($tp)/c/d}
2140 echo 19: ${ts/+($tp)/c\/d}
2141 echo 20: ${ts//a\/b/$tr}
2142 echo 21: ${ts//a\/b/\$tr}
2143 echo 22: ${ts//$tp/$tr}
2144 echo 23: ${ts//$tp/c/d}
2145 echo 24: ${ts//$tp/c\/d}
2146 echo 25: ${ts//+(a\/b)/$tr}
2147 echo 26: ${ts//+(a\/b)/\$tr}
2148 echo 27: ${ts//+($tp)/$tr}
2149 echo 28: ${ts//+($tp)/c/d}
2150 echo 29: ${ts//+($tp)/c\/d}
2152 echo 30: ${ts/$tp/$tr}
2153 echo 31: ${ts//$tp/$tr}
2161 7: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2162 8: $tra/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2163 9: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2164 10: a/ba/bc/d$tp_a/b$tp_*(a/b)_*($tp)
2165 11: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2166 12: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2167 13: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2168 14: c\/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2169 15: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2170 16: $tr$tp$tp_a/b$tp_*(a/b)_*($tp)
2171 17: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2172 18: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2173 19: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2174 20: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2175 21: $tr$tr$tp$tp_$tr$tp_*($tr)_*($tp)
2176 22: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2177 23: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2178 24: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2179 25: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2180 26: $tr$tp$tp_$tr$tp_*($tr)_*($tp)
2181 27: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2182 28: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2183 29: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2184 30: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2185 31: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2186 # This is what GNU bash does:
2187 # 30: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2188 # 31: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2192 UTF-8 mode differences for eglobbing
2197 print 2: ${s/b???d/x} .
2200 print 4: ${s/b??d/x} .
2202 print 5: ${x%?} ${x%%?} .
2204 print 6: ${x#?} ${x##?} .
2206 print 7: ${x%?} ${x%%?} .
2208 print 8: ${x%?} ${x%%?} .
2210 print 9: ${x%?} ${x%%?} .
2224 Check that globbing isn't done when glob has syntax error
2225 file-setup: dir 755 "[x"
2226 file-setup: file 644 "[x/foo"
2238 Check that symbolic links aren't stat()'d
2239 # breaks on Dell UNIX 4.0 R2.2 (SVR4) where unlink also fails
2240 # breaks on FreeMiNT (cannot unlink dangling symlinks)
2241 # breaks on MSYS, OS/2 (do not support symlinks)
2242 category: !os:mint,!os:msys,!os:svr4.0,!nosymlink
2243 file-setup: dir 755 "dir"
2244 file-setup: symlink 644 "dir/abc"
2256 file-setup: file 644 ".bc"
2257 file-setup: file 644 "abc"
2258 file-setup: file 644 "bbc"
2259 file-setup: file 644 "cbc"
2260 file-setup: file 644 "-bc"
2283 (AT&T ksh fails this; POSIX says invalid)
2284 file-setup: file 644 "abc"
2292 Check that globbing matches the right things...
2293 # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
2294 # breaks on Cygwin 1.7 (files are now UTF-16 or something)
2295 # breaks on QNX 6.4.1 (says RT)
2296 category: !os:cygwin,!os:darwin,!os:msys,!os:nto,!os:os2
2298 file-setup: file 644 "aÂc"
2306 Results unspecified according to POSIX
2307 file-setup: file 644 ".bc"
2315 Results unspecified according to POSIX
2316 (AT&T ksh treats this like [a-cc-e]*)
2317 file-setup: file 644 "abc"
2318 file-setup: file 644 "bbc"
2319 file-setup: file 644 "cbc"
2320 file-setup: file 644 "dbc"
2321 file-setup: file 644 "ebc"
2322 file-setup: file 644 "-bc"
2330 Check against a regression from fixing IFS-subst-2
2333 print -r "before='$x'"
2335 print -r "after ='$x'"
2342 Check ordering/content of redundent here documents.
2354 Check quoted here-doc is protected.
2373 Check that newline isn't needed after heredoc-delimiter marker.
2385 Check that an error occurs if the heredoc-delimiter is missing.
2390 expected-exit: e > 0
2391 expected-stderr-pattern: /.*/
2395 Check that an error occurs if the heredoc-delimiter is missing.
2401 expected-exit: e > 0
2402 expected-stderr-pattern: /.*/
2406 Check that an error occurs if the heredoc is missing.
2409 expected-exit: e > 0
2410 expected-stderr-pattern: /.*/
2414 Check that an error occurs if the heredoc is missing.
2418 expected-exit: e > 0
2419 expected-stderr-pattern: /.*/
2423 Check that backslash quotes a $, ` and \ and kills a \newline
2430 th\`echo not-run\`ere
2431 th\\`echo is-run`ere
2448 Check that \newline in initial here-delim word doesn't imply
2463 Check that double quoted $ expressions in here delimiters are
2464 not expanded and match the delimiter.
2465 POSIX says only quote removal is applied to the delimiter.
2482 Check that double quoted escaped $ expressions in here
2483 delimiters are not expanded and match the delimiter.
2484 POSIX says only quote removal is applied to the delimiter
2485 (\ counts as a quote).
2506 Check that here strings work.
2510 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo
2511 "$__progname" -c "tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo"
2512 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$bar"
2513 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<'$bar'
2514 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$bar
2515 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<-foo
2516 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$(echo "foo bar")"
2517 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"A $(echo "foo bar") B"
2518 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$b\$b$bar
2534 Check that a corner case of here strings works like bash
2539 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
2546 Check that a corner case of here strings works like ksh93, zsh
2551 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
2558 Check another corner case of here strings
2560 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<< bar
2566 Check here string related regression with multiple iops
2568 echo $(tr r z <<<'bar' 2>/dev/null)
2574 Check long here strings
2582 Check direct here document assignment
2596 fnd=$(typeset -f foo)
2604 # rather nonsensical, but…
2607 vf=<<<$'=f $x \x40='
2609 print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} ve={$ve} vf={$vf} |"
2617 print -r -- "| ${v//$'\n'/^} |"
2637 Check here documents with no or empty delimiter
2654 fnd=$(typeset -f foo)
2662 print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} |"
2666 print -r -- "| vc={$vc} vd={$vd} |"
2674 print -r -- "| ${v//$'\n'/^} |"
2709 Check here documents can use $* and $@; note shells vary:
2710 • pdksh 5.2.14 acts the same
2711 • dash has 1 and 2 the same but 3 lacks the space
2712 • ksh93, bash4 differ in 2 by using space ipv colon
2754 Check that using multiple here documents works
2757 echo "got $(cat) on stdin"
2758 echo "got $(cat <&4) on fd#4"
2759 echo "got $(cat <&5) on fd#5"
2762 foo 4<<-a <<-b 5<<-c
2773 [[ $x = "$y" ]]; echo $?
2779 foo 4<<-a <<-b 5<<-c
2792 name: heredoc-comsub-1
2794 Tests for here documents in COMSUB, taken from Austin ML
2801 = here is the text =
2803 name: heredoc-comsub-2
2805 Tests for here documents in COMSUB, taken from Austin ML
2807 unbalanced=$(cat <<EOF
2808 this paren ) is a problem
2810 echo = $unbalanced =
2812 = this paren ) is a problem =
2814 name: heredoc-comsub-3
2816 Tests for here documents in COMSUB, taken from Austin ML
2818 balanced=$(cat <<EOF
2819 these parens ( ) are not a problem
2823 = these parens ( ) are not a problem =
2825 name: heredoc-comsub-4
2827 Tests for here documents in COMSUB, taken from Austin ML
2829 balanced=$(cat <<EOF
2830 these parens \( ) are a problem
2834 = these parens \( ) are a problem =
2836 name: heredoc-comsub-5
2838 Check heredoc and COMSUB mixture in input
2840 prefix() { sed -e "s/^/$1:/"; }
2841 XXX() { echo x-en; }
2842 YYY() { echo y-es; }
2844 prefix A <<XXX && echo "$(prefix B <<XXX
2847 echo line 2)" && prefix C <<YYY
2862 name: heredoc-comsub-6
2864 Check here documents and here strings can be used
2865 without a specific command, like $(<…) (extension)
2873 $foo) is not a problem
2882 bar) is not a problem>
2884 name: heredoc-subshell-1
2886 Tests for here documents in subshells, taken from Austin ML
2896 name: heredoc-subshell-2
2898 Tests for here documents in subshells, taken from Austin ML
2909 name: heredoc-subshell-3
2911 Tests for here documents in subshells, taken from Austin ML
2921 name: heredoc-weird-1
2923 Tests for here documents, taken from Austin ML
2924 Documents current state in mksh, *NOT* necessarily correct!
2937 name: heredoc-weird-2
2939 Tests for here documents, taken from Austin ML
2949 name: heredoc-weird-4
2951 Tests for here documents, taken from Austin ML
2952 Documents current state in mksh, *NOT* necessarily correct!
2963 name: heredoc-weird-5
2965 Tests for here documents, taken from Austin ML
2966 Documents current state in mksh, *NOT* necessarily correct!
2978 name: heredoc-tmpfile-1
2980 Check that heredoc temp files aren't removed too soon or too late.
2981 Heredoc in simple command.
3002 name: heredoc-tmpfile-2
3004 Check that heredoc temp files aren't removed too soon or too late.
3005 Heredoc in function, multiple calls to function.
3024 name: heredoc-tmpfile-3
3026 Check that heredoc temp files aren't removed too soon or too late.
3027 Heredoc in function in loop, multiple calls to function.
3054 name: heredoc-tmpfile-4
3056 Check that heredoc temp files aren't removed too soon or too late.
3057 Backgrounded simple command with here doc
3071 name: heredoc-tmpfile-5
3073 Check that heredoc temp files aren't removed too soon or too late.
3074 Backgrounded subshell command with here doc
3079 sleep 1 # so parent exits
3095 name: heredoc-tmpfile-6
3097 Check that heredoc temp files aren't removed too soon or too late.
3098 Heredoc in pipeline.
3102 cat <<- EOF | sed "s/hi/HI/"
3112 name: heredoc-tmpfile-7
3114 Check that heredoc temp files aren't removed too soon or too late.
3115 Heredoc in backgrounded pipeline.
3119 cat <<- EOF | sed 's/hi/HI/' &
3129 name: heredoc-tmpfile-8
3131 Check that heredoc temp files aren't removed too soon or too
3132 late. Heredoc in function, backgrounded call to function.
3133 This check can fail on slow machines (<100 MHz), or Cygwin,
3138 # Background eval so main shell doesn't do parsing
3146 # sleep so eval can die
3160 name: heredoc-quoting-unsubst
3162 Check for correct handling of quoted characters in
3163 here documents without substitution (marker is quoted).
3167 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
3170 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
3172 name: heredoc-quoting-subst
3174 Check for correct handling of quoted characters in
3175 here documents with substitution (marker is not quoted).
3179 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
3182 x " \" \ \ $ $ baz `echo baz` bar $foo x
3184 name: single-quotes-in-braces
3186 Check that single quotes inside unquoted {} are treated as quotes
3189 echo ${foo:+'blah $foo'}
3193 name: single-quotes-in-quoted-braces
3195 Check that single quotes inside quoted {} are treated as
3199 echo "${foo:+'blah $foo'}"
3203 name: single-quotes-in-braces-nested
3205 Check that single quotes inside unquoted {} are treated as quotes,
3206 even if that's inside a double-quoted command expansion
3209 echo "$( echo ${foo:+'blah $foo'})"
3213 name: single-quotes-in-brace-pattern
3215 Check that single quotes inside {} pattern are treated as quotes
3218 echo ${foo%'2'*} "${foo%'2'*}" ${foo%2'*'} "${foo%2'*'}"
3222 name: single-quotes-in-heredoc-braces
3224 Check that single quotes inside {} in heredoc are treated
3234 name: single-quotes-in-nested-braces
3236 Check that single quotes inside nested unquoted {} are
3240 echo ${foo:+${foo:+'blah $foo'}}
3244 name: single-quotes-in-nested-quoted-braces
3246 Check that single quotes inside nested quoted {} are treated
3250 echo "${foo:+${foo:+'blah $foo'}}"
3254 name: single-quotes-in-nested-braces-nested
3256 Check that single quotes inside nested unquoted {} are treated
3257 as quotes, even if that's inside a double-quoted command expansion
3260 echo "$( echo ${foo:+${foo:+'blah $foo'}})"
3264 name: single-quotes-in-nested-brace-pattern
3266 Check that single quotes inside nested {} pattern are treated as quotes
3269 echo ${foo:+${foo%'2'*}} "${foo:+${foo%'2'*}}" ${foo:+${foo%2'*'}} "${foo:+${foo%2'*'}}"
3273 name: single-quotes-in-heredoc-nested-braces
3275 Check that single quotes inside nested {} in heredoc are treated
3280 ${foo:+${foo:+'blah $foo'}}
3287 See if we can test history at all
3290 env-setup: !ENV=./Env!HISTFILE=hist.file!
3291 file-setup: file 644 "Env"
3299 expected-stderr-pattern:
3304 Verify duplicates and spaces are not entered
3307 env-setup: !ENV=./Env!HISTFILE=hist.file!
3308 file-setup: file 644 "Env"
3320 expected-stderr-pattern:
3323 name: history-unlink
3325 Check if broken HISTFILEs do not cause trouble
3328 env-setup: !ENV=./Env!HISTFILE=foo/hist.file!
3329 file-setup: file 644 "Env"
3331 file-setup: dir 755 "foo"
3332 file-setup: file 644 "foo/hist.file"
3335 perl-setup: chmod(0555, "foo");
3343 expected-stderr-pattern:
3344 /(.*can't unlink HISTFILE.*\n)?X*$/
3346 name: history-multiline
3348 Check correct multiline history, Debian #783978
3351 env-setup: !ENV=./Env!
3352 file-setup: file 644 "Env"
3374 expected-stderr-pattern:
3377 name: history-e-minus-1
3379 Check if more recent command is executed
3382 env-setup: !ENV=./Env!HISTFILE=hist.file!
3383 file-setup: file 644 "Env"
3393 expected-stderr-pattern:
3394 /^X*echo there\nX*$/
3396 name: history-e-minus-2
3398 Check that repeated command is printed before command
3402 env-setup: !ENV=./Env!HISTFILE=hist.file!
3403 file-setup: file 644 "Env"
3410 expected-stdout-pattern:
3411 /X*hi\nX*there\nX*echo there\nthere\nX*/
3412 expected-stderr-pattern:
3415 name: history-e-minus-3
3417 fc -e - fails when there is no history
3418 (ksh93 has a bug that causes this to fail)
3419 (ksh88 loops on this)
3422 env-setup: !ENV=./Env!HISTFILE=hist.file!
3423 file-setup: file 644 "Env"
3430 expected-stderr-pattern:
3431 /^X*.*:.*history.*\nX*$/
3433 name: history-e-minus-4
3435 Check if "fc -e -" command output goes to stdout.
3438 env-setup: !ENV=./Env!HISTFILE=hist.file!
3439 file-setup: file 644 "Env"
3443 fc -e - | (read x; echo "A $x")
3449 expected-stderr-pattern:
3452 name: history-e-minus-5
3454 fc is replaced in history by new command.
3457 env-setup: !ENV=./Env!HISTFILE=hist.file!
3458 file-setup: file 644 "Env"
3474 expected-stderr-pattern:
3475 /^X*echo ghi jkl\nX*$/
3477 name: history-list-1
3479 List lists correct range
3480 (ksh88 fails 'cause it lists the fc command)
3483 env-setup: !ENV=./Env!HISTFILE=hist.file!
3484 file-setup: file 644 "Env"
3497 expected-stderr-pattern:
3500 name: history-list-2
3502 Lists oldest history if given pre-historic number
3503 (ksh93 has a bug that causes this to fail)
3504 (ksh88 fails 'cause it lists the fc command)
3507 env-setup: !ENV=./Env!HISTFILE=hist.file!
3508 file-setup: file 644 "Env"
3522 expected-stderr-pattern:
3525 name: history-list-3
3527 Can give number 'options' to fc
3530 env-setup: !ENV=./Env!HISTFILE=hist.file!
3531 file-setup: file 644 "Env"
3546 expected-stderr-pattern:
3549 name: history-list-4
3551 -1 refers to previous command
3554 env-setup: !ENV=./Env!HISTFILE=hist.file!
3555 file-setup: file 644 "Env"
3569 expected-stderr-pattern:
3572 name: history-list-5
3574 List command stays in history
3577 env-setup: !ENV=./Env!HISTFILE=hist.file!
3578 file-setup: file 644 "Env"
3595 expected-stderr-pattern:
3598 name: history-list-6
3600 HISTSIZE limits about of history kept.
3601 (ksh88 fails 'cause it lists the fc command)
3604 env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3!
3605 file-setup: file 644 "Env"
3622 expected-stderr-pattern:
3625 name: history-list-7
3627 fc allows too old/new errors in range specification
3630 env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3!
3631 file-setup: file 644 "Env"
3649 expected-stderr-pattern:
3652 name: history-list-r-1
3654 test -r flag in history
3657 env-setup: !ENV=./Env!HISTFILE=hist.file!
3658 file-setup: file 644 "Env"
3676 expected-stderr-pattern:
3679 name: history-list-r-2
3681 If first is newer than last, -r is implied.
3684 env-setup: !ENV=./Env!HISTFILE=hist.file!
3685 file-setup: file 644 "Env"
3703 expected-stderr-pattern:
3706 name: history-list-r-3
3708 If first is newer than last, -r is cancelled.
3711 env-setup: !ENV=./Env!HISTFILE=hist.file!
3712 file-setup: file 644 "Env"
3730 expected-stderr-pattern:
3733 name: history-subst-1
3738 env-setup: !ENV=./Env!HISTFILE=hist.file!
3739 file-setup: file 644 "Env"
3744 fc -e - abc=AB 'echo a'
3749 expected-stderr-pattern:
3750 /^X*echo AB def\nX*$/
3752 name: history-subst-2
3754 Does subst find previous command?
3757 env-setup: !ENV=./Env!HISTFILE=hist.file!
3758 file-setup: file 644 "Env"
3763 fc -e - jkl=XYZQRT 'echo g'
3768 expected-stderr-pattern:
3769 /^X*echo ghi XYZQRT\nX*$/
3771 name: history-subst-3
3773 Does subst find previous command when no arguments given
3776 env-setup: !ENV=./Env!HISTFILE=hist.file!
3777 file-setup: file 644 "Env"
3787 expected-stderr-pattern:
3788 /^X*echo ghi XYZQRT\nX*$/
3790 name: history-subst-4
3792 Global substitutions work
3793 (ksh88 and ksh93 do not have -g option)
3796 env-setup: !ENV=./Env!HISTFILE=hist.file!
3797 file-setup: file 644 "Env"
3800 echo abc def asjj sadjhasdjh asdjhasd
3803 abc def asjj sadjhasdjh asdjhasd
3804 FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd
3805 expected-stderr-pattern:
3806 /^X*echo FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd\nX*$/
3808 name: history-subst-5
3810 Make sure searches don't find current (fc) command
3811 (ksh88/ksh93 don't have the ? prefix thing so they fail this test)
3814 env-setup: !ENV=./Env!HISTFILE=hist.file!
3815 file-setup: file 644 "Env"
3820 fc -e - abc=AB \?abc
3825 expected-stderr-pattern:
3826 /^X*echo AB def\nX*$/
3828 name: history-ed-1-old
3830 Basic (ed) editing works (assumes you have generic ed editor
3831 that prints no prompts). This is for oldish ed(1) which write
3832 the character count to stdout.
3837 env-setup: !ENV=./Env!HISTFILE=hist.file!
3838 file-setup: file 644 "Env"
3851 expected-stderr-pattern:
3852 /^X*echo FOOBAR def\nX*$/
3854 name: history-ed-2-old
3856 Correct command is edited when number given
3861 env-setup: !ENV=./Env!HISTFILE=hist.file!
3862 file-setup: file 644 "Env"
3870 s/is here/is changed/
3881 expected-stderr-pattern:
3882 /^X*echo line 2 is changed\nX*$/
3884 name: history-ed-3-old
3886 Newly created multi line commands show up as single command
3888 (ksh88 fails 'cause it lists the fc command)
3893 env-setup: !ENV=./Env!HISTFILE=hist.file!
3894 file-setup: file 644 "Env"
3915 expected-stderr-pattern:
3916 /^X*echo FOOBAR def\necho a new line\nX*$/
3920 Basic (ed) editing works (assumes you have generic ed editor
3921 that prints no prompts). This is for newish ed(1) and stderr.
3922 category: !no-stderr-ed
3926 env-setup: !ENV=./Env!HISTFILE=hist.file!
3927 file-setup: file 644 "Env"
3938 expected-stderr-pattern:
3939 /^X*13\n16\necho FOOBAR def\nX*$/
3943 Correct command is edited when number given
3944 category: !no-stderr-ed
3948 env-setup: !ENV=./Env!HISTFILE=hist.file!
3949 file-setup: file 644 "Env"
3957 s/is here/is changed/
3966 expected-stderr-pattern:
3967 /^X*20\n23\necho line 2 is changed\nX*$/
3971 Newly created multi line commands show up as single command
3973 category: !no-stderr-ed
3977 env-setup: !ENV=./Env!HISTFILE=hist.file!
3978 file-setup: file 644 "Env"
3997 expected-stderr-pattern:
3998 /^X*13\n32\necho FOOBAR def\necho a new line\nX*$/
4002 Simple test, default IFS
4004 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4020 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4037 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4050 name: IFS-space-colon-1
4052 Simple test, IFS=<white-space>:
4054 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4069 name: IFS-space-colon-2
4071 Simple test, IFS=<white-space>:
4072 AT&T ksh fails this, POSIX says the test is correct.
4074 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4081 name: IFS-space-colon-4
4083 Simple test, IFS=<white-space>:
4085 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4092 name: IFS-space-colon-5
4094 Simple test, IFS=<white-space>:
4095 Don't know what POSIX thinks of this. AT&T ksh does not do this.
4097 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4106 Simple test, IFS=<white-space>:
4108 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4111 echo -n '1:'; for i in $x ; do echo -n " [$i]" ; done ; echo
4112 echo -n '2:'; for i in :b:: ; do echo -n " [$i]" ; done ; echo
4116 echo -n '5:'; for i in $x ; do echo -n " [$i]" ; done ; echo
4119 echo -n '7:'; for i in $x ; do echo -n " [$i]" ; done ; echo
4121 echo -n '9:'; for i in ${FOO-`echo -n h:i`th:ere} ; do echo -n " [$i]" ; done ; echo
4122 showargs 10 ${FOO-`echo -n h:i`th:ere}
4123 showargs 11 "${FOO-`echo -n h:i`th:ere}"
4125 echo -n '12:'; for i in $x ; do echo -n " [$i]" ; done ; echo
4137 <10> <h> <ith> <ere> .
4140 <13> <A> <B> <> <D> .
4144 Check leading whitespace after trim does not make a field
4146 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4148 showargs 1 shift ${x#X}
4150 <1> <shift> <1> <2> .
4152 name: IFS-subst-3-arr
4154 Check leading IFS non-whitespace after trim does make a field
4155 but leading IFS whitespace does not, nor empty replacements
4157 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4160 showargs 1 ${-+:foo:bar}
4162 showargs 2 ${-+ foo bar}
4165 <1> <> <foo> <bar> .
4168 name: IFS-subst-3-ass
4170 Check non-field semantics
4172 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4175 showargs 1 x=${-+:foo:bar}
4177 showargs 2 x=${-+ foo bar}
4180 <1> <x=> <foo> <bar> .
4181 <2> <x=> <foo> <bar> .
4183 name: IFS-subst-3-lcl
4185 Check non-field semantics, smaller corner case (LP#1381965)
4190 expected-exit: e != 0
4191 expected-stderr-pattern:
4196 reported by mikeserv
4198 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4199 a='space divded argument
4202 IFS= ; q="$*" ; nq=$*
4203 pfn "$*" $* "$q" "$nq"
4204 [ "$q" = "$nq" ] && echo =true || echo =false
4206 <spacedivdedargument
4212 <spacedivdedargument
4214 <spacedivdedargument
4220 extended testsuite based on problem by mikeserv
4222 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4223 a='space divded argument
4226 IFS= ; q="$@" ; nq=$@
4227 pfn "$*" $* "$q" "$nq"
4228 [ "$q" = "$nq" ] && echo =true || echo =false
4230 <spacedivdedargument
4236 <space divded argument
4238 <space divded argument
4244 extended testsuite based on problem by mikeserv
4246 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4247 a='space divded argument
4249 IFS=\ ; set -- $a; IFS=
4254 print -nr -- '= qs '; pfn "$qs"
4255 print -nr -- '=nqs '; pfn "$nqs"
4256 print -nr -- '= qk '; pfn "$qk"
4257 print -nr -- '=nqk '; pfn "$nqk"
4258 print -nr -- '~ qs '; pfn "$*"
4259 print -nr -- '~nqs '; pfn $*
4260 print -nr -- '~ qk '; pfn "$@"
4261 print -nr -- '~nqk '; pfn $@
4263 = qs <spacedivdedargument
4265 =nqs <spacedivdedargument
4267 = qk <space divded argument
4269 =nqk <space divded argument
4271 ~ qs <spacedivdedargument
4288 extended testsuite based on problem by mikeserv
4290 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4291 a='space divded argument
4293 IFS=\ ; set -- $a; IFS=
4295 print -nr -- '= qs '; pfn "$qs"
4296 print -nr -- '~ qs '; pfn "$*"
4298 print -nr -- '=nqs '; pfn "$nqs"
4299 print -nr -- '~nqs '; pfn $*
4301 print -nr -- '= qk '; pfn "$qk"
4302 print -nr -- '~ qk '; pfn "$@"
4304 print -nr -- '=nqk '; pfn "$nqk"
4305 print -nr -- '~nqk '; pfn $@
4307 = qs <spacedivdedargument
4309 ~ qs <spacedivdedargument
4311 =nqs <spacedivdedargument
4317 = qk <space divded argument
4323 =nqk <space divded argument
4330 name: IFS-subst-4-4p
4332 extended testsuite based on problem by mikeserv
4334 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4335 a='space divded argument
4337 IFS=\ ; set -- $a; IFS=
4340 print -nr -- '= qs '; pfn "$qs"
4341 print -nr -- '~ qs '; pfn ${v:-"$*"}
4343 print -nr -- '=nqs '; pfn "$nqs"
4344 print -nr -- '~nqs '; pfn ${v:-$*}
4346 print -nr -- '= qk '; pfn "$qk"
4347 print -nr -- '~ qk '; pfn ${v:-"$@"}
4349 print -nr -- '=nqk '; pfn "$nqk"
4350 print -nr -- '~nqk '; pfn ${v:-$@}
4352 = qs <spacedivdedargument
4354 ~ qs <spacedivdedargument
4356 =nqs <spacedivdedargument
4362 = qk <space divded argument
4368 =nqk <space divded argument
4377 extended testsuite based on problem by mikeserv
4379 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4380 a='space divded argument
4382 IFS=\ ; set -- $a; IFS=,
4384 print -nr -- '= qs '; pfn "$qs"
4385 print -nr -- '~ qs '; pfn "$*"
4387 print -nr -- '=nqs '; pfn "$nqs"
4388 print -nr -- '~nqs '; pfn $*
4390 print -nr -- '= qk '; pfn "$qk"
4391 print -nr -- '~ qk '; pfn "$@"
4393 print -nr -- '=nqk '; pfn "$nqk"
4394 print -nr -- '~nqk '; pfn $@
4396 = qs <space,divded,argument
4398 ~ qs <space,divded,argument
4400 =nqs <space,divded,argument
4406 = qk <space divded argument
4412 =nqk <space divded argument
4419 name: IFS-subst-4-5p
4421 extended testsuite based on problem by mikeserv
4423 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4424 a='space divded argument
4426 IFS=\ ; set -- $a; IFS=,
4429 print -nr -- '= qs '; pfn "$qs"
4430 print -nr -- '~ qs '; pfn ${v:-"$*"}
4432 print -nr -- '=nqs '; pfn "$nqs"
4433 print -nr -- '~nqs '; pfn ${v:-$*}
4435 print -nr -- '= qk '; pfn "$qk"
4436 print -nr -- '~ qk '; pfn ${v:-"$@"}
4438 print -nr -- '=nqk '; pfn "$nqk"
4439 print -nr -- '~nqk '; pfn ${v:-$@}
4441 = qs <space,divded,argument
4443 ~ qs <space,divded,argument
4445 =nqs <space,divded,argument
4451 = qk <space divded argument
4457 =nqk <space divded argument
4466 extended testsuite based on IFS-subst-3
4467 differs slightly from ksh93:
4468 - omit trailing field in a3zna, a7ina (unquoted $@ expansion)
4469 - has extra middle fields in b5ins, b7ina (IFS_NWS unquoted expansion)
4470 differs slightly from bash:
4471 - omit leading field in a5ins, a7ina (IFS_NWS unquoted expansion)
4472 differs slightly from zsh:
4473 - differs in assignment, not expansion; probably zsh bug
4474 - has extra middle fields in b5ins, b7ina (IFS_NWS unquoted expansion)
4475 'emulate sh' zsh has extra fields in
4476 - a5ins (IFS_NWS unquoted $*)
4477 - b5ins, matching mksh’s
4478 !!WARNING!! more to come: http://austingroupbugs.net/view.php?id=888
4480 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4481 IFS=; set -- "" 2 ""; pfb $*; x=$*; pfn "$x"'
4483 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4484 IFS=; set -- "" 2 ""; pfb "$*"; x="$*"; pfn "$x"'
4486 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4487 IFS=; set -- "" 2 ""; pfb $@; x=$@; pfn "$x"'
4489 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4490 IFS=; set -- "" 2 ""; pfb "$@"; x="$@"; pfn "$x"'
4492 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4493 IFS=,; set -- "" 2 ""; pfb $*; x=$*; pfn "$x"'
4495 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4496 IFS=,; set -- "" 2 ""; pfb "$*"; x="$*"; pfn "$x"'
4498 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4499 IFS=,; set -- "" 2 ""; pfb $@; x=$@; pfn "$x"'
4501 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4502 IFS=,; set -- "" 2 ""; pfb "$@"; x="$@"; pfn "$x"'
4504 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4505 IFS=; set -- A B "" "" C; pfb $*; x=$*; pfn "$x"'
4507 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4508 IFS=; set -- A B "" "" C; pfb "$*"; x="$*"; pfn "$x"'
4510 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4511 IFS=; set -- A B "" "" C; pfb $@; x=$@; pfn "$x"'
4513 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4514 IFS=; set -- A B "" "" C; pfb "$@"; x="$@"; pfn "$x"'
4516 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4517 IFS=,; set -- A B "" "" C; pfb $*; x=$*; pfn "$x"'
4519 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4520 IFS=,; set -- A B "" "" C; pfb "$*"; x="$*"; pfn "$x"'
4522 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4523 IFS=,; set -- A B "" "" C; pfb $@; x=$@; pfn "$x"'
4525 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4526 IFS=,; set -- A B "" "" C; pfb "$@"; x="$@"; pfn "$x"'
4604 Regression wrt. vector expansion in trim
4606 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4616 ksh93 bug wrt. vector expansion in trim
4618 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4622 showargs "$*" ${a##"$*"}
4628 http://austingroupbugs.net/view.php?id=221
4630 n() { echo "$#"; }; n "${foo-$@}"
4636 Scalar context for $*/$@ in [[ and case
4638 "$__progname" -c 'IFS=; set a b; [[ $* = "$1$2" ]]; echo 1 $?' sh a b
4639 "$__progname" -c 'IFS=; [[ $* = ab ]]; echo 2 "$?"' sh a b
4640 "$__progname" -c 'IFS=; [[ "$*" = ab ]]; echo 3 "$?"' sh a b
4641 "$__progname" -c 'IFS=; [[ $* = a ]]; echo 4 "$?"' sh a b
4642 "$__progname" -c 'IFS=; [[ "$*" = a ]]; echo 5 "$?"' sh a b
4643 "$__progname" -c 'IFS=; [[ "$@" = a ]]; echo 6 "$?"' sh a b
4644 "$__progname" -c 'IFS=; case "$@" in a) echo 7 a;; ab) echo 7 b;; a\ b) echo 7 ok;; esac' sh a b
4645 "$__progname" -c 'IFS=; case $* in a) echo 8 a;; ab) echo 8 ok;; esac' sh a b
4646 "$__progname" -c 'pfsp() { for s_arg in "$@"; do print -nr -- "<$s_arg> "; done; print .; }; IFS=; star=$* at="$@"; pfsp 9 "$star" "$at"' sh a b
4660 http://austingroupbugs.net/view.php?id=832
4662 ${ZSH_VERSION+false} || emulate sh
4663 ${BASH_VERSION+set -o posix}
4664 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4666 showargs $((1230456))
4670 name: integer-base-err-1
4672 Can't have 0 base (causes shell to exit)
4673 expected-exit: e != 0
4679 expected-stderr-pattern:
4682 name: integer-base-err-2
4684 Can't have multiple bases in a 'constant' (causes shell to exit)
4685 (ksh88 fails this test)
4686 expected-exit: e != 0
4692 expected-stderr-pattern:
4693 /^.*:.*2#110#11.*\n$/
4695 name: integer-base-err-3
4697 Syntax errors in expressions and effects on bases
4698 (interactive so errors don't cause exits)
4699 (ksh88 fails this test - shell exits, even with -i)
4703 PS1= # minimise prompt hassles
4710 expected-stderr-pattern:
4711 /^([#\$] )?.*:.*2+.*\n.*:.*2+.*\n$/
4716 name: integer-base-err-4
4718 Are invalid digits (according to base) errors?
4719 (ksh93 fails this test)
4720 expected-exit: e != 0
4724 expected-stderr-pattern:
4725 /^([#\$] )?.*:.*3#4.*\n$/
4727 name: integer-base-1
4729 Missing number after base is treated as 0.
4738 name: integer-base-2
4740 Check 'stickyness' of base in various situations
4791 name: integer-base-3
4793 More base parsing (hmm doesn't test much..)
4813 name: integer-base-4
4815 Check that things not declared as integers are not made integers,
4816 also, check if base is not reset by -i with no arguments.
4817 (ksh93 fails - prints 10#20 - go figure)
4821 typeset -i | grep '^xx='
4828 name: integer-base-5
4844 for l in 1 2+3 4; do echo $l; done
4856 name: integer-base-6
4858 Even more base stuff
4859 (ksh93 fails this test - prints 0)
4867 name: integer-base-7
4869 Check that non-integer parameters don't get bases assigned
4871 echo $(( zz = 8#100 ))
4877 name: integer-base-8
4879 Check that base-36 works (full span)
4881 echo 1:$((36#109AZ)).
4882 typeset -i36 x=1691675
4891 name: integer-base-check-flat
4893 Check behaviour does not match POSuX (except if set -o posix),
4894 because a not type-safe scripting language has *no* business
4895 interpreting the string "010" as octal numer eight (dangerous).
4897 echo 1 "$("$__progname" -c 'echo :$((10))/$((010)),$((0x10)):')" .
4898 echo 2 "$("$__progname" -o posix -c 'echo :$((10))/$((010)),$((0x10)):')" .
4899 echo 3 "$("$__progname" -o sh -c 'echo :$((10))/$((010)),$((0x10)):')" .
4905 name: integer-base-check-numeric-from
4907 Check behaviour for base one to 36, and that 37 degrades to 10
4911 while (( ++i <= 37 )); do
4912 eval 'echo '$i':$(('$i'#10)).'
4914 echo 37:$($__progname -c 'echo $((37#10))').$?:
4955 name: integer-base-check-numeric-to
4957 Check behaviour for base one to 36, and that 37 degrades to 10
4960 while (( ++i <= 37 )); do
4961 typeset -Uui$i x=0x40
4962 eval "typeset -i10 y=$x"
5004 name: integer-arithmetic-span
5006 Check wraparound and size that is defined in mksh
5009 echo s:$((2147483647+1)).$(((2147483647*2)+1)).$(((2147483647*2)+2)).
5010 echo u:$((#2147483647+1)).$((#(2147483647*2)+1)).$((#(2147483647*2)+2)).
5013 u:2147483648.4294967295.0.
5015 name: integer-arithmetic-span-64
5017 Check wraparound and size that is defined in mksh
5020 echo s:$((9223372036854775807+1)).$(((9223372036854775807*2)+1)).$(((9223372036854775807*2)+2)).
5021 echo u:$((#9223372036854775807+1)).$((#(9223372036854775807*2)+1)).$((#(9223372036854775807*2)+2)).
5023 s:-9223372036854775808.-1.0.
5024 u:9223372036854775808.18446744073709551615.0.
5026 name: integer-size-FAIL-to-detect
5028 Notify the user that their ints are not 32 or 64 bit
5035 See if $LINENO is updated and can be modified.
5048 See if $LINENO is set for .'d files.
5049 file-setup: file 644 "dotfile"
5067 See if $LINENO is set for commands in a function.
5086 See if unsetting LINENO makes it non-magic.
5087 file-setup: file 644 "dotfile"
5110 name: lineno-unset-use
5112 See if unsetting LINENO makes it non-magic even
5114 file-setup: file 644 "dotfile"
5140 Check if LINENO is tracked in traps
5146 trap 'fail $LINENO' INT ERR
5154 Ensure unknown traps are not a syntax error
5157 trap "echo trap 1 executed" UNKNOWNSIGNAL || echo "foo"
5159 trap "echo trap 2 executed" UNKNOWNSIGNAL EXIT 999999 FNORD
5161 ) 2>&1 | sed "s
\ 1^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]
\ 1PROG
\ 1"
5163 PROG: trap: bad signal 'UNKNOWNSIGNAL'
5166 PROG: trap: bad signal 'UNKNOWNSIGNAL'
5167 PROG: trap: bad signal '999999'
5168 PROG: trap: bad signal 'FNORD'
5174 Simple test, default IFS
5179 echo 1: "x[$x] y[$y] z[$z]"
5180 echo 1a: ${z-z not set}
5190 Complex tests, IFS either colon (IFS-NWS) or backslash (tricky)
5193 showargs() { print -nr "$1"; shift; for s_arg in "$@"; do print -nr -- " [$s_arg]"; done; print; }
5194 (IFS=\\ a=\<\\\>; showargs 3 $a)
5195 (IFS=: b=\<:\>; showargs 4 $b)
5196 print -r '<\>' | (IFS=\\ read f g; showargs 5 "$f" "$g")
5197 print -r '<\\>' | (IFS=\\ read f g; showargs 6 "$f" "$g")
5198 print '<\\\n>' | (IFS=\\ read f g; showargs 7 "$f" "$g")
5199 print -r '<\>' | (IFS=\\ read f; showargs 8 "$f")
5200 print -r '<\\>' | (IFS=\\ read f; showargs 9 "$f")
5201 print '<\\\n>' | (IFS=\\ read f; showargs 10 "$f")
5202 print -r '<\>' | (IFS=\\ read -r f g; showargs 11 "$f" "$g")
5203 print -r '<\\>' | (IFS=\\ read -r f g; showargs 12 "$f" "$g")
5204 print '<\\\n>' | (IFS=\\ read -r f g; showargs 13 "$f" "$g")
5205 print -r '<\>' | (IFS=\\ read -r f; showargs 14 "$f")
5206 print -r '<\\>' | (IFS=\\ read -r f; showargs 15 "$f")
5207 print '<\\\n>' | (IFS=\\ read -r f; showargs 16 "$f")
5208 print -r '<:>' | (IFS=: read f g; showargs 17 "$f" "$g")
5209 print -r '<::>' | (IFS=: read f g; showargs 18 "$f" "$g")
5210 print '<:\n>' | (IFS=: read f g; showargs 19 "$f" "$g")
5211 print -r '<:>' | (IFS=: read f; showargs 20 "$f")
5212 print -r '<::>' | (IFS=: read f; showargs 21 "$f")
5213 print '<:\n>' | (IFS=: read f; showargs 22 "$f")
5214 print -r '<:>' | (IFS=: read -r f g; showargs 23 "$f" "$g")
5215 print -r '<::>' | (IFS=: read -r f g; showargs 24 "$f" "$g")
5216 print '<:\n>' | (IFS=: read -r f g; showargs 25 "$f" "$g")
5217 print -r '<:>' | (IFS=: read -r f; showargs 26 "$f")
5218 print -r '<::>' | (IFS=: read -r f; showargs 27 "$f")
5219 print '<:\n>' | (IFS=: read -r f; showargs 28 "$f")
5250 If no var specified, REPLY is used
5258 name: read-regress-1
5260 Check a regression of read
5261 file-setup: file 644 "foo"
5266 while read a b c; do
5270 echo "<$a|$b|$c><$d>"
5276 Check read with delimiters
5279 print -n 'foo bar\tbaz\nblah \0blub\tblech\nmyok meck \0'
5281 emit | while IFS= read -d "" foo; do print -r -- "<$foo>"; done
5282 emit | while read -d "" foo; do print -r -- "<$foo>"; done
5283 emit | while read -d "eh?" foo; do print -r -- "<$foo>"; done
5300 Check read with number of bytes specified, and -A
5302 print 'foo\nbar' >x1
5304 print 'foo\\ bar baz' >x3
5306 x1b=u; read -N-1 x1b <x1
5307 x2a=u; read x2a <x2; r2a=$?
5308 x2b=u; read -N2 x2c <x2; r2b=$?
5309 x2c=u; read -n2 x2c <x2; r2c=$?
5310 x3a=u; read -A x3a <x3
5311 print -r "x1a=<$x1a>"
5312 print -r "x1b=<$x1b>"
5313 print -r "x2a=$r2a<$x2a>"
5314 print -r "x2b=$r2b<$x2b>"
5315 print -r "x2c=$r2c<$x2c>"
5316 print -r "x3a=<${x3a[0]}|${x3a[1]}|${x3a[2]}>"
5328 Lex array code had problems with this.
5339 When PATH is set before running a command, the new path is
5340 not used in doing the path search
5341 $ echo echo hi > /tmp/q ; chmod a+rx /tmp/q
5345 in comexec() the two lines
5347 (void) typeset(*vp++, xxx, 0);
5348 need to be moved out of the switch to before findcom() is
5349 called - I don't know what this will break.
5351 : "${PWD:-`pwd 2> /dev/null`}"
5352 : "${PWD:?"PWD not set - cannot do test"}"
5354 cat > Y/xxxscript << EOF
5356 # Need to restore path so echo can be found (some shells don't have
5362 chmod a+rx Y/xxxscript
5363 export OLDPATH="$PATH"
5364 PATH=$PWD/Y xxxscript
5371 Parsing of $(..) expressions is non-optimal. It is
5372 impossible to have any parentheses inside the expression.
5374 $ ksh -c 'echo $(echo \( )'
5376 $ ksh -c 'echo $(echo "(" )'
5379 The solution is to hack the parsing clode in lex.c, the
5380 question is how to hack it: should any parentheses be
5381 escaped by a backslash, or should recursive parsing be done
5382 (so quotes could also be used to hide hem). The former is
5383 easier, the later better...
5393 Continue in a for loop does not work right:
5395 if [ $i = b ] ; then
5404 if [ $i = b ] ; then
5405 if [ $first = no ] ; then
5406 echo 'continue in for loop broken'
5407 break # hope break isn't broken too :-)
5422 should print 0 according to POSIX (dash, bash, ksh93, posh)
5423 but not 0 according to the getopt(1) manual page, ksh88, and
5424 Bourne sh (such as /bin/sh on Solaris).
5425 We honour POSIX except when -o sh is set.
5426 category: shell:legacy-no
5429 [[ -o posix ]]; FPOSIX=$((1-$?))
5430 [[ -o sh ]]; FSH=$((1-$?))
5431 echo -n "FPOSIX=$FPOSIX FSH=$FSH "
5455 name: regression-10-legacy
5460 should print 0 according to POSIX (dash, bash, ksh93, posh)
5461 but not 0 according to the getopt(1) manual page, ksh88, and
5462 Bourne sh (such as /bin/sh on Solaris).
5463 category: shell:legacy-yes
5466 [[ -o posix ]]; FPOSIX=$((1-$?))
5467 [[ -o sh ]]; FSH=$((1-$?))
5468 echo -n "FPOSIX=$FPOSIX FSH=$FSH "
5497 should echo blah but on some machines echos /foo/bar/blah.
5506 Both of the following echos produce the same output under sh/ksh.att:
5509 echo "`echo \"$x\"`"
5511 pdksh produces different output for the former (foo instead of foo\tbar)
5514 echo "`echo \"$x\"`"
5522 The following command hangs forever:
5523 $ (: ; cat /etc/termcap) | sleep 2
5524 This is because the shell forks a shell to run the (..) command
5525 and this shell has the pipe open. When the sleep dies, the cat
5526 doesn't get a SIGPIPE 'cause a process (ie, the second shell)
5527 still has the pipe open.
5529 NOTE: this test provokes a bizarre bug in ksh93 (shell starts reading
5530 commands from /etc/termcap..)
5533 echo A line of text that will be duplicated quite a number of times.> t1
5534 cat t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 > t2
5535 cat t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 > t1
5536 cat t1 t1 t1 t1 > t2
5537 (: ; cat t2 2>/dev/null) | sleep 1
5542 $ (foobar) 2> /dev/null
5543 generates no output under /bin/sh, but pdksh produces the error
5546 $ foobar 2> /dev/null
5547 generates an error under /bin/sh and pdksh, but AT&T ksh88 produces
5548 no error (redirected to /dev/null).
5550 (you/should/not/see/this/error/1) 2> /dev/null
5551 you/should/not/see/this/error/2 2> /dev/null
5558 generates a blank line under pdksh and sets the exit status to 0.
5559 AT&T ksh88 generates no output and sets the exit status to 1. Also,
5562 generates no output under AT&T ksh88 (pdksh generates a blank line
5565 whence does/not/exist > /dev/null
5567 echo 2: $(whence does/not/exist | wc -l)
5568 echo 3: $(whence does/not/exist cat | wc -l)
5576 ${var%%expr} seems to be broken in many places. On the mips
5578 $ read line < /etc/passwd
5586 change the value of line. On sun4s & pas, the echo ${line%%:*} doesn't
5587 work. Haven't checked elsewhere...
5594 root:asdjhasdasjhs:0:1:Root:/:/bin/sh
5597 root:asdjhasdasjhs:0:1:Root:/:/bin/sh
5603 should set the exit status to non-zero (sh and AT&T ksh88 do).
5604 XXX doting a non existent file is a fatal error for a script
5607 expected-exit: e != 0
5608 expected-stderr-pattern: /.?/
5612 Both of the following echos should produce the same thing, but don't:
5626 backslash does not work as expected in case labels:
5645 Quoting backquotes inside backquotes doesn't work:
5646 $ echo `echo hi \`echo there\` folks`
5647 asks for more info. sh and AT&T ksh88 both echo
5650 echo `echo hi \`echo there\` folks`
5656 )) is not treated `correctly':
5657 $ (echo hi ; (echo there ; echo folks))
5660 instead of (as sh and ksh.att)
5661 $ (echo hi ; (echo there ; echo folks))
5667 ( : ; ( : ; echo hi))
5673 Check reading stdin in a while loop. The read should only read
5674 a single line, not a whole stdio buffer; the cat should get
5677 (echo a; echo b) | while read x ; do
5686 Check reading stdin in a while loop. The read should read both
5687 lines, not just the first.
5690 while [ "$a" != xxx ] ; do
5693 cat /dev/null | sed 's/x/y/'
5707 should cause a script to exit.
5711 expected-exit: e != 0
5712 expected-stderr-pattern: /does\/not\/exist/
5716 variable assignements not detected well
5719 expected-exit: e != 0
5720 expected-stderr-pattern: /a\.x=1/
5724 alias expansion different from AT&T ksh88
5726 alias a='for ' b='i in'
5727 a b hi ; do echo $i ; done
5733 strange characters allowed inside ${...}
5736 expected-exit: e != 0
5737 expected-stderr-pattern: /.?/
5741 Does read handle partial lines correctly
5744 while [ "$a" != xxx ] ; do
5761 Does read set variables to null at eof?
5764 while [ "$a" != xxx ] ; do
5768 echo 1: ${x-x not set} ${y-y not set} ${z-z not set}
5769 echo 2: ${x:+x not null} ${y:+y not null} ${z:+z not null}
5779 Does umask print a leading 0 when umask is 3 digits?
5781 # on MiNT, the first umask call seems to fail
5783 # now, the test proper
5791 Tempory files used for here-docs in functions get trashed after
5792 the function is parsed (before it is executed)
5815 Command substitution breaks reading in while loop
5816 (test from <sjg@void.zen.oz.au>)
5818 (echo abcdef; echo; echo 123) |
5821 # the following line breaks it
5822 c=`echo $line | wc -c`
5832 Machines with broken times() (reported by <sjg@void.zen.oz.au>)
5833 time does not report correct real time
5836 expected-stderr-pattern: !/^\s*0\.0[\s\d]+real|^\s*real[\s]+0+\.0/
5840 set -e doesn't ignore exit codes for if/while/until/&&/||/!.
5843 if false; then echo hi ; fi
5846 while false; do echo hi; done
5853 Only posh and oksh(2013-07) say “hi” below; FreeBSD sh,
5854 GNU bash in POSIX mode, dash, ksh93, mksh don’t. All of
5855 them exit 0. The POSIX behaviour is needed by BSD make.
5858 echo `false; echo hi` $(<this-file-does-not-exist)
5863 expected-stderr-pattern: /this-file-does-not-exist/
5867 This used to cause a core dump
5868 env-setup: !RANDOM=12!
5876 foo should be set to bar (should not be empty)
5886 Can't use command line assignments to assign readonly parameters.
5888 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
5889 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
5890 done >env; chmod +x env; PATH=.$PATHSEP$PATH
5893 foo=stuff env | grep '^foo'
5894 expected-exit: e != 0
5895 expected-stderr-pattern:
5900 Can subshells be prefixed by redirections (historical shells allow
5903 < /dev/null (sed 's/^/X/')
5907 Parameter assignments with [] recognised correctly
5925 Check that alias expansion works in command substitutions and
5938 Check that aliases are fully read.
5951 Check that (here doc) temp files are not left behind after an exec.
5954 TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
5956 sed 's/^/X /' << E_O_F
5963 echo=echo; [ -x /bin/echo ] && echo=/bin/echo
5964 exec $echo subtest-1 hi
5966 echo subtest-1 foo/*
5967 TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
5968 echo=echo; [ -x /bin/echo ] && echo=/bin/echo
5969 sed 's/^/X /' << E_O_F; exec $echo subtest-2 hi
5975 echo subtest-2 foo/*
5987 Check that unset params with attributes are reported by set, those
5988 sans attributes are not.
6004 Check that aliases do not use continuation prompt after trailing
6006 file-setup: file 644 "envf"
6009 env-setup: !ENV=./envf!
6013 alias foo='echo hi ; '
6025 Check that set allows both +o and -o options on same command line.
6028 set -o noglob +o allexport
6035 Check that globbing works in pipelined commands
6036 file-setup: file 644 "envf"
6038 file-setup: file 644 "abc"
6040 env-setup: !ENV=./envf!
6046 sed 's/^/X /' < ab* | sed 's/^/Y /'
6058 Check that getopts works in functions
6061 echo bfunc: enter "(args: $*; OPTIND=$OPTIND)"
6062 while getopts B oc; do
6065 echo bfunc: B option
6068 echo bfunc: odd option "($oc)"
6076 echo kfunc: enter "(args: $*; OPTIND=$OPTIND)"
6077 while getopts K oc; do
6080 echo kfunc: K option
6083 echo bfunc: odd option "($oc)"
6091 echo "line 1: OPTIND=$OPTIND"
6093 echo "line 2: ret=$?, optc=$optc, OPTIND=$OPTIND"
6095 echo "line 3: OPTIND=$OPTIND"
6097 echo "line 4: ret=$?, optc=$optc, OPTIND=$OPTIND"
6099 echo "line 5: OPTIND=$OPTIND"
6101 echo "line 6: ret=$?, optc=$optc, OPTIND=$OPTIND"
6106 echo "line 10: OPTIND=$OPTIND"
6108 echo "line 20: ret=$?, optc=$optc, OPTIND=$OPTIND"
6110 echo "line 30: OPTIND=$OPTIND"
6112 echo "line 40: ret=$?, optc=$optc, OPTIND=$OPTIND"
6114 echo "line 50: OPTIND=$OPTIND"
6116 echo "line 60: ret=$?, optc=$optc, OPTIND=$OPTIND"
6119 line 2: ret=0, optc=f, OPTIND=2
6120 bfunc: enter (args: -BBB blah; OPTIND=2)
6125 line 4: ret=0, optc=b, OPTIND=3
6126 kfunc: enter (args: -KKK blah; OPTIND=1)
6132 line 6: ret=0, optc=k, OPTIND=4
6135 line 20: ret=0, optc=f, OPTIND=2
6136 bfunc: enter (args: -BBB blah; OPTIND=2)
6141 line 40: ret=1, optc=?, OPTIND=2
6142 kfunc: enter (args: -KKK blah; OPTIND=1)
6148 line 60: ret=1, optc=?, OPTIND=2
6152 Check that ; is not required before the then in if (( ... )) then ...
6166 Check ${foo:%bar} is allowed (ksh88 allows it...)
6189 Check if typeset output is correct for
6190 uninitialised array elements.
6194 typeset -i | grep xxx | sed 's/^/ /'
6196 typeset | grep xxx | sed 's/^/ /'
6200 typeset -i | grep xxx | sed 's/^/ /'
6202 typeset | grep xxx | sed 's/^/ /'
6216 Check if trap exit is ok (exit not mistaken for signal name)
6225 Check if ${#array[*]} is calculated correctly.
6235 Check if default exit status is previous command
6241 ( (exit 103) ; exit)
6250 Check if EXIT trap is executed for sub shells.
6252 trap 'echo parent exit' EXIT
6254 (echo A; echo A last)
6256 (echo C; trap 'echo sub exit' EXIT; echo C last)
6271 Check if test -nt/-ot succeeds if second(first) file is missing.
6274 test a -nt b && echo nt OK || echo nt BAD
6275 test b -ot a && echo ot OK || echo ot BAD
6282 Check if typeset, export, and readonly work
6294 integer FNORD_E FNORD_F FNORD_G FNORD_H
6295 export FNORD_C FNORD_D FNORD_G FNORD_H
6296 readonly FNORD_B FNORD_D FNORD_F FNORD_H
6342 typeset -x -r FNORD_D
6344 typeset -i -r FNORD_F
6345 typeset -i -x FNORD_G
6346 typeset -i -x -r FNORD_H
6349 typeset -r FNORD_B=2
6350 typeset -x FNORD_C=3
6351 typeset -x -r FNORD_D=4
6352 typeset -i FNORD_E=5
6353 typeset -i -r FNORD_F=6
6354 typeset -i -x FNORD_G=7
6355 typeset -i -x -r FNORD_H=8
6373 Check that we can redefine functions calling time builtin
6385 check for a regression with sleep builtin and signal mask
6391 while read -p line; do :; done
6398 Check that quoting is sane
6406 while IFS= read -pr line; do
6407 if [[ $line = *space* ]]; then
6413 for line in "${lines[@]}"; do
6422 Check that we can both break and use source on the same line
6424 for s in s; do break; done; print -s s
6428 Check that all common arithmetic operators work as expected
6430 echo 1 $(( a = 5 )) .
6431 echo 2 $(( ++a )) , $(( a++ )) , $(( a )) .
6432 echo 3 $(( --a )) , $(( a-- )) , $(( a )) .
6433 echo 4 $(( a == 5 )) , $(( a == 6 )) .
6434 echo 5 $(( a != 5 )) , $(( a != 6 )) .
6435 echo 6 $(( a *= 3 )) .
6436 echo 7 $(( a /= 5 )) .
6437 echo 8 $(( a %= 2 )) .
6438 echo 9 $(( a += 9 )) .
6439 echo 10 $(( a -= 4 )) .
6440 echo 11 $(( a <<= 1 )) .
6441 echo 12 $(( a >>= 1 )) .
6442 echo 13 $(( a &= 4 )) .
6443 echo 14 $(( a ^= a )) .
6444 echo 15 $(( a |= 5 )) .
6445 echo 16 $(( 5 << 1 )) .
6446 echo 17 $(( 5 >> 1 )) .
6447 echo 18 $(( 5 <= 6 )) , $(( 5 <= 5 )) , $(( 5 <= 4 )) .
6448 echo 19 $(( 5 >= 6 )) , $(( 5 >= 5 )) , $(( 5 >= 4 )) .
6449 echo 20 $(( 5 < 6 )) , $(( 5 < 5 )) , $(( 5 < 4 )) .
6450 echo 21 $(( 5 > 6 )) , $(( 5 > 5 )) , $(( 5 > 4 )) .
6451 echo 22 $(( 0 && 0 )) , $(( 0 && 1 )) , $(( 1 && 0 )) , $(( 1 && 1 )) .
6452 echo 23 $(( 0 || 0 )) , $(( 0 || 1 )) , $(( 1 || 0 )) , $(( 1 || 1 )) .
6453 echo 24 $(( 5 * 3 )) .
6454 echo 25 $(( 7 / 2 )) .
6455 echo 26 $(( 5 % 5 )) , $(( 5 % 4 )) , $(( 5 % 1 )) , $(( 5 % -1 )) , $(( 5 % -2 )) .
6456 echo 27 $(( 5 + 2 )) , $(( 5 + 0 )) , $(( 5 + -2 )) .
6457 echo 28 $(( 5 - 2 )) , $(( 5 - 0 )) , $(( 5 - -2 )) .
6458 echo 29 $(( 6 & 4 )) , $(( 6 & 8 )) .
6459 echo 30 $(( 4 ^ 2 )) , $(( 4 ^ 4 )) .
6460 echo 31 $(( 4 | 2 )) , $(( 4 | 4 )) , $(( 4 | 0 )) .
6461 echo 32 $(( 0 ? 1 : 2 )) , $(( 3 ? 4 : 5 )) .
6462 echo 33 $(( 5 , 2 , 3 )) .
6463 echo 34 $(( ~0 )) , $(( ~1 )) , $(( ~~1 )) , $(( ~~2 )) .
6464 echo 35 $(( !0 )) , $(( !1 )) , $(( !!1 )) , $(( !!2 )) .
6465 echo 36 $(( (5) )) .
6492 26 0 , 1 , 0 , 0 , 1 .
6500 34 -1 , -2 , 1 , 2 .
6506 Check that all non-lksh arithmetic operators work as expected
6507 category: shell:legacy-no
6510 echo 1 $(( a ^<= 1 )) , $(( b ^<= 1 )) .
6511 echo 2 $(( a ^>= 2 )) , $(( b ^>= 2 )) .
6512 echo 3 $(( 5 ^< 1 )) .
6513 echo 4 $(( 5 ^> 1 )) .
6516 2 -2147483646 , -1073741822 .
6522 Ensure readonly is honoured for assignments and unset
6524 "$__progname" -c 'u=x; echo $? $u .' || echo aborted, $?
6526 "$__progname" -c 'readonly u; u=x; echo $? $u .' || echo aborted, $?
6528 "$__progname" -c 'u=x; readonly u; unset u; echo $? $u .' || echo aborted, $?
6535 expected-stderr-pattern:
6540 http://austingroupbugs.net/view.php?id=367 for export
6542 "$__progname" -c 'readonly foo; export foo=a; echo $?' || echo aborted, $?
6545 expected-stderr-pattern:
6550 Check that getopts works as intended, for readonly-2b to be valid
6552 "$__progname" -c 'set -- -a b; getopts a c; echo $? $c .; getopts a c; echo $? $c .' || echo aborted, $?
6559 http://austingroupbugs.net/view.php?id=367 for getopts
6561 "$__progname" -c 'readonly c; set -- -a b; getopts a c; echo $? $c .' || echo aborted, $?
6564 expected-stderr-pattern:
6569 http://austingroupbugs.net/view.php?id=367 for read
6571 echo x | "$__progname" -c 'read s; echo $? $s .' || echo aborted, $?
6572 echo y | "$__progname" -c 'readonly s; read s; echo $? $s .' || echo aborted, $?
6576 expected-stderr-pattern:
6581 Do not permit bypassing readonly for first array item
6583 set -A arr -- foo bar
6586 print -r -- "${arr[@]}"
6587 expected-exit: e != 0
6588 expected-stderr-pattern:
6593 Check that lone ampersand is a syntax error
6596 expected-exit: e != 0
6597 expected-stderr-pattern:
6600 name: xxx-quoted-newline-1
6602 Check that \<newline> works inside of ${}
6610 name: xxx-quoted-newline-2
6612 Check that \<newline> works at the start of a here document
6621 name: xxx-quoted-newline-3
6623 Check that \<newline> works at the end of a here document
6632 name: xxx-multi-assignment-cmd
6634 Check that assignments in a command affect subsequent assignments
6643 name: xxx-multi-assignment-posix-cmd
6645 Check that the behaviour for multiple assignments with a
6646 command name matches POSIX. See:
6647 http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925
6649 X=a Y=b; X=$Y Y=$X "$__progname" -c 'echo 1 $X $Y .'; echo 2 $X $Y .
6651 X=a Y=${X=b} Z=$X "$__progname" -c 'echo 3 $Z .'
6653 X=a Y=${X=b} Z=$X; echo 4 $Z .
6660 name: xxx-multi-assignment-posix-nocmd
6662 Check that the behaviour for multiple assignments with no
6663 command name matches POSIX (Debian #334182). See:
6664 http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925
6666 X=a Y=b; X=$Y Y=$X; echo 1 $X $Y .
6670 name: xxx-multi-assignment-posix-subassign
6672 Check that the behaviour for multiple assignments matches POSIX:
6673 - The assignment words shall be expanded in the current execution
6675 - The assignments happen in the temporary execution environment.
6678 Z=a Y=${X:=b} sh -c 'echo +$X+ +$Y+ +$Z+'
6680 # Now for the special case:
6682 X= Y=${X:=b} sh -c 'echo +$X+ +$Y+'
6690 name: xxx-exec-environment-1
6692 Check to see if exec sets it's environment correctly
6694 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
6695 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
6696 done >env; chmod +x env; PATH=.$PATHSEP$PATH
6698 expected-stdout-pattern:
6701 name: xxx-exec-environment-2
6703 Check to make sure exec doesn't change environment if a program
6706 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
6707 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
6708 done >env; chmod +x env; PATH=.$PATHSEP$PATH
6710 FOO=bar exec; env >bar2
6713 name: exec-function-environment-1
6715 Check assignments in function calls and whether they affect
6716 the current execution environment (ksh93, SUSv4)
6718 f() { a=2; }; g() { b=3; echo y$c-; }; a=1 f; b=2; c=1 g
6724 name: xxx-what-do-you-call-this-1
6730 name: xxx-prefix-strip-1
6737 name: xxx-prefix-strip-2
6745 name: xxx-variable-syntax-1
6748 expected-stderr-pattern:
6752 name: xxx-variable-syntax-2
6756 expected-stderr-pattern:
6760 name: xxx-variable-syntax-3
6764 expected-stderr-pattern:
6768 name: xxx-variable-syntax-4
6770 Not all kinds of trims are currently impossible, check those who do
6773 echo "<$*> X${*:+ }X"
6803 name: xxx-substitution-eval-order
6805 Check order of evaluation of expressions
6808 set -A A abc def GHI j G k
6809 echo ${A[x=(i+=1)]#${A[y=(i+=2)]}}
6815 name: xxx-set-option-1
6817 Check option parsing in set
6819 set -vsA foo -- A 1 3 2
6828 Check that exec exits for built-ins
6836 expected-stderr-pattern: /.*/
6840 Check the return value of while loops
6841 XXX need to do same for for/select/until loops
6844 while [ $i != xxx ] ; do
6846 if [ $i = xxx ] ; then
6854 while [ $i != xxx ] ; do
6856 if [ $i = xxx ] ; then
6864 while [ $i != xxx ] ; do
6876 Check that blank lines don't clear $?
6889 expected-stderr-pattern: /.*/
6893 Check that $? is preserved in subshells, includes, traps.
6902 echo 'echo include: $?' > foo
6906 trap 'echo trap: $?' ERR
6916 name: xxx-clean-chars-1
6918 Check MAGIC character is stuffed correctly
6924 name: xxx-param-subst-qmark-1
6926 Check suppresion of error message with null string. According to
6927 POSIX, it shouldn't print the error as 'word' isn't ommitted.
6928 ksh88/93, Solaris /bin/sh and /usr/xpg4/bin/sh all print the error.
6934 expected-stderr-pattern: !/not set/
6936 name: xxx-param-subst-qmark-namespec
6938 Check special names are output correctly
6941 "$__progname" -c "$@" >o1 2>o2
6944 sed -e "s
\ 1^${__progname%.exe}\.*e*x*e*:
\ 1PROG:
\ 1" -e 's/^/STDOUT: /g' <o1
6945 sed -e "s
\ 1^${__progname%.exe}\.*e*x*e*:
\ 1PROG:
\ 1" -e 's/^/STDERR: /g' <o2
6952 doit -u 'echo ${*:?}' foo ""
6955 STDERR: PROG: ${1x}: bad substitution
6957 STDERR: PROG: ${1x}: bad substitution
6959 STDERR: PROG: 1: parameter null or not set
6961 STDERR: PROG: 19: parameter null or not set
6963 STDERR: PROG: !: parameter null or not set
6965 STDERR: foo: ${*:?}: bad substitution
6968 # fails due to weirdness of execv stuff
6969 category: !os:uwin-nt
6971 Check c flag is set.
6972 arguments: !-c!echo "[$-]"!
6973 expected-stdout-pattern: /^\[.*c.*\]$/
6975 name: tilde-expand-1
6977 Check tilde expansion after equal signs
6978 env-setup: !HOME=/sweet!
6980 echo ${A=a=}~ b=~ c=d~ ~
6982 command command export g=~ h=d~
6987 echo ${A=a=}~ b=~ c=d~ ~
6989 command command export g=~ h=d~
6993 a=/sweet b=/sweet c=d~ /sweet
7000 name: tilde-expand-2
7002 Check tilde expansion works
7003 env-setup: !HOME=/sweet!
7007 plus=$(print -r -- ~+)
7008 minus=$(print -r -- ~-)
7009 nix=$(print -r -- ~)
7010 [[ $plus = / ]]; echo one $? .
7011 [[ $minus = "$wd" ]]; echo two $? .
7012 [[ $nix = /sweet ]]; echo nix $? .
7020 Check some "exit on error" conditions
7022 print '#!'"$__progname"'\nexec "$1"' >env
7023 print '#!'"$__progname"'\nexit 1' >false
7027 env false && echo something
7037 Check some "exit on error" edge conditions (POSIXly)
7039 print '#!'"$__progname"'\nexec "$1"' >env
7040 print '#!'"$__progname"'\nexit 1' >false
7041 print '#!'"$__progname"'\nexit 0' >true
7046 env false && echo something
7058 pdksh regression which AT&T ksh does right
7059 TFM says: [set] -e | errexit
7060 Exit (after executing the ERR trap) ...
7062 trap 'echo EXIT' EXIT
7065 cd /XXXXX 2>/dev/null
7071 expected-exit: e != 0
7075 "set -e" test suite (POSIX)
7089 "set -e" test suite (POSIX)
7095 [ "$1" = "$E" ] && { shift ; continue 2 ; }
7112 "set -e" test suite (BSD make)
7116 print 'all:\n\t@echo eins\n\t@exit 42\n' >zd/a/Makefile
7117 print 'all:\n\t@echo zwei\n' >zd/b/Makefile
7120 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"
7126 Stop in WD/zd/a (line 2 of Makefile).
7130 "set -e" regression (LP#1104543)
7134 [ -x $PWD/nonexistant ] && $PWD/nonexistant
7145 "set -e" regression (Debian #700526)
7148 _db_cmd() { return $1; }
7149 db_input() { _db_cmd 30; }
7150 db_go() { _db_cmd 0; }
7157 SUSv4 says that the shell should exit with 126/127 in some situations
7161 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
7162 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
7164 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
7165 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
7167 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
7168 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
7179 Check eval vs substitution exit codes (ksh93 alike)
7191 eval "eval $(false)"
7194 eval 'eval '"$(false)"
7198 eval $(echo :; false)
7216 Check that "exit" with no arguments behaves SUSv4 conformant.
7218 trap 'echo hi; exit' EXIT
7226 Check that ERR and EXIT traps are run just like ksh93 does.
7227 GNU bash does not run ERtrap in ±e eval-undef but runs it
7228 twice (bug?) in +e eval-false, so does ksh93 (bug?), which
7229 also has a bug to continue execution (echoing "and out" and
7230 returning 0) in +e eval-undef.
7231 file-setup: file 644 "x"
7233 trap 'echo EXtrap' EXIT
7234 trap 'echo ERtrap' ERR
7239 file-setup: file 644 "xt"
7241 trap 'echo EXtrap' EXIT
7242 trap 'echo ERtrap' ERR
7247 file-setup: file 644 "xf"
7249 trap 'echo EXtrap' EXIT
7250 trap 'echo ERtrap' ERR
7252 echo 'and run false'
7255 file-setup: file 644 "xu"
7257 trap 'echo EXtrap' EXIT
7258 trap 'echo ERtrap' ERR
7260 echo 'and run ${v?}'
7270 -e 's/parameter not set/parameter null or not set/' \
7271 -e 's/[[]6]//' -e 's/: eval: line 1//' -e 's/: line 6//' \
7272 -e "s
\ 1^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]
\ 1PROG
\ 1"
7277 echo = eval-true $(<rc) .
7279 echo = eval-false $(<rc) .
7280 runtest x $xe '${v?}'
7281 echo = eval-undef $(<rc) .
7283 echo = noeval-true $(<rc) .
7285 echo = noeval-false $(<rc) .
7287 echo = noeval-undef $(<rc) .
7291 echo = eval-true $(<rc) .
7293 echo = eval-false $(<rc) .
7294 runtest x $xe '${v?}'
7295 echo = eval-undef $(<rc) .
7297 echo = noeval-true $(<rc) .
7299 echo = noeval-false $(<rc) .
7301 echo = noeval-undef $(<rc) .
7313 x: v: parameter null or not set
7326 xu: v: parameter null or not set
7340 x: v: parameter null or not set
7354 xu: v: parameter null or not set
7358 name: exit-trap-interactive
7360 Check that interactive shell doesn't exit via EXIT trap on syntax error
7365 echo 'After error 1'
7366 trap 'echo Exit trap' EXIT
7368 echo 'After error 2'
7369 trap 'echo Exit trap' EXIT
7376 expected-stderr-pattern:
7377 /syntax error: 'newline' unexpected/
7381 Check that test also can handle string1 < string2 etc.
7383 test 2005/10/08 '<' 2005/08/21 && echo ja || echo nein
7384 test 2005/08/21 \< 2005/10/08 && echo ja || echo nein
7385 test 2005/10/08 '>' 2005/08/21 && echo ja || echo nein
7386 test 2005/08/21 \> 2005/10/08 && echo ja || echo nein
7392 expected-stderr-pattern: !/unexpected op/
7394 name: test-precedence-1
7396 Check a weird precedence case (and POSIX echo)
7406 Test the test -o operator
7411 [[ -o $1 ]]; echo $?
7414 test -o $1 -o -o !$1; echo $?
7415 [ -o $1 -o -o !$1 ]; echo $?
7416 [[ -o $1 || -o !$1 ]]; echo $?
7417 test -o ?$1; echo $?
7419 echo 0y $(if_test utf8-mode) =
7420 echo 0n $(if_test utf8-hack) =
7421 echo 1= $(runtest utf8-hack) =
7422 echo 2= $(runtest !utf8-hack) =
7423 echo 3= $(runtest ?utf8-hack) =
7425 echo 1+ $(runtest utf8-mode) =
7426 echo 2+ $(runtest !utf8-mode) =
7427 echo 3+ $(runtest ?utf8-mode) =
7429 echo 1- $(runtest utf8-mode) =
7430 echo 2- $(runtest !utf8-mode) =
7431 echo 3- $(runtest ?utf8-mode) =
7432 echo = short flags =
7433 echo 0y $(if_test -U) =
7434 echo 0y $(if_test +U) =
7435 echo 0n $(if_test -_) =
7436 echo 0n $(if_test -U-) =
7437 echo 1= $(runtest -_) =
7438 echo 2= $(runtest !-_) =
7439 echo 3= $(runtest ?-_) =
7441 echo 1+ $(runtest -U) =
7442 echo 2+ $(runtest !-U) =
7443 echo 3+ $(runtest ?-U) =
7444 echo 1+ $(runtest +U) =
7445 echo 2+ $(runtest !+U) =
7446 echo 3+ $(runtest ?+U) =
7448 echo 1- $(runtest -U) =
7449 echo 2- $(runtest !-U) =
7450 echo 3- $(runtest ?-U) =
7451 echo 1- $(runtest +U) =
7452 echo 2- $(runtest !+U) =
7453 echo 3- $(runtest ?+U) =
7489 Check that the short form [ $x ] works
7493 rv=$?; echo $((++i)) $rv
7495 rv=$?; echo $((++i)) $rv
7497 rv=$?; echo $((++i)) $rv
7499 rv=$?; echo $((++i)) $rv
7502 rv=$?; echo $((++i)) $rv
7504 rv=$?; echo $((++i)) $rv
7506 rv=$?; echo $((++i)) $rv
7508 rv=$?; echo $((++i)) $rv
7511 rv=$?; echo $((++i)) $rv
7513 rv=$?; echo $((++i)) $rv
7515 rv=$?; echo $((++i)) $rv
7517 rv=$?; echo $((++i)) $rv
7534 Check that the short form [[ $x ]] works (ksh93 extension)
7538 rv=$?; echo $((++i)) $rv
7540 rv=$?; echo $((++i)) $rv
7542 rv=$?; echo $((++i)) $rv
7544 rv=$?; echo $((++i)) $rv
7547 rv=$?; echo $((++i)) $rv
7549 rv=$?; echo $((++i)) $rv
7551 rv=$?; echo $((++i)) $rv
7553 rv=$?; echo $((++i)) $rv
7556 rv=$?; echo $((++i)) $rv
7558 rv=$?; echo $((++i)) $rv
7560 rv=$?; echo $((++i)) $rv
7562 rv=$?; echo $((++i)) $rv
7579 Check numeric -eq works (R40d regression); spotted by Martijn Dekker
7584 (0) echo yepp 0 \#"$*" ;;
7585 (1) echo nope 1 \#"$*" ;;
7586 (2) echo terr 2 \#"$*" ;;
7587 (*) echo wtf\? $? \#"$*" ;;
7590 tst 1 'test 2 -eq 2'
7591 tst 2 'test 2 -eq 2a'
7592 tst 3 'test 2 -eq 3'
7593 tst 4 'test 2 -ne 2'
7594 tst 5 'test 2 -ne 2a'
7595 tst 6 'test 2 -ne 3'
7596 tst 7 'test \! 2 -eq 2'
7597 tst 8 'test \! 2 -eq 2a'
7598 tst 9 'test \! 2 -eq 3'
7600 yepp 0 #1 test 2 -eq 2
7601 terr 2 #2 test 2 -eq 2a
7602 nope 1 #3 test 2 -eq 3
7603 nope 1 #4 test 2 -ne 2
7604 terr 2 #5 test 2 -ne 2a
7605 yepp 0 #6 test 2 -ne 3
7606 nope 1 #7 test \! 2 -eq 2
7607 terr 2 #8 test \! 2 -eq 2a
7608 yepp 0 #9 test \! 2 -eq 3
7609 expected-stderr-pattern:
7614 Check that ~/.mkshrc works correctly.
7615 Part 1: verify user environment is not read (internal)
7623 Check that ~/.mkshrc works correctly.
7624 Part 2: verify mkshrc is not read (non-interactive shells)
7625 file-setup: file 644 ".mkshrc"
7627 env-setup: !HOME=.!ENV=!
7635 Check that ~/.mkshrc works correctly.
7636 Part 2: verify mkshrc can be read (interactive shells)
7637 file-setup: file 644 ".mkshrc"
7641 env-setup: !HOME=.!ENV=!PS1=!
7646 expected-stderr-pattern:
7651 Check that ~/.mkshrc works correctly.
7652 Part 3: verify mkshrc can be turned off
7653 file-setup: file 644 ".mkshrc"
7655 env-setup: !HOME=.!ENV=nonexistant!
7663 Check that sh mode turns braceexpand off
7664 and that that works correctly
7668 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
7669 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
7677 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
7678 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
7681 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
7682 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
7698 Check that posix or sh mode is *not* automatically turned on
7701 ln -s "$__progname" ksh || cp "$__progname" ksh
7702 ln -s "$__progname" sh || cp "$__progname" sh
7703 ln -s "$__progname" ./-ksh || cp "$__progname" ./-ksh
7704 ln -s "$__progname" ./-sh || cp "$__progname" ./-sh
7705 for shell in {,-}{,k}sh; do
7706 print -- $shell $(./$shell +l -c \
7707 '[[ $(set +o) == *"-o "@(sh|posix)@(| *) ]] && echo sh || echo nosh')
7717 Check that posix or sh mode *is* automatically turned on
7720 ln -s "$__progname" ksh || cp "$__progname" ksh
7721 ln -s "$__progname" sh || cp "$__progname" sh
7722 ln -s "$__progname" ./-ksh || cp "$__progname" ./-ksh
7723 ln -s "$__progname" ./-sh || cp "$__progname" ./-sh
7724 for shell in {,-}{,k}sh; do
7725 print -- $shell $(./$shell +l -c \
7726 '[[ $(set +o) == *"-o "@(sh|posix)@(| *) ]] && echo sh || echo nosh')
7736 pdksh bug: last command of a pipeline is executed in a
7737 subshell - make sure it still is, scripts depend on it
7738 file-setup: file 644 "abcx"
7739 file-setup: file 644 "abcy"
7742 echo a | while read d; do
7762 check that co-processes work with TCOMs, TPIPEs and TPARENs
7765 "$__progname" -c 'i=100; echo hi |& while read -p line; do echo "$((i++)) $line"; done'
7766 "$__progname" -c 'i=200; echo hi | cat |& while read -p line; do echo "$((i++)) $line"; done'
7767 "$__progname" -c 'i=300; (echo hi | cat) |& while read -p line; do echo "$((i++)) $line"; done'
7775 Check that PIPESTATUS does what it's supposed to
7777 echo 1 $PIPESTATUS .
7778 echo 2 ${PIPESTATUS[0]} .
7779 echo 3 ${PIPESTATUS[1]} .
7780 (echo x; exit 12) | (cat; exit 23) | (cat; exit 42)
7781 echo 5 $? , $PIPESTATUS , ${PIPESTATUS[0]} , ${PIPESTATUS[1]} , ${PIPESTATUS[2]} , ${PIPESTATUS[3]} .
7782 echo 6 ${PIPESTATUS[0]} .
7783 set | fgrep PIPESTATUS
7784 echo 8 $(set | fgrep PIPESTATUS) .
7790 5 42 , 12 , 12 , 23 , 42 , .
7793 8 PIPESTATUS[0]=0 PIPESTATUS[1]=0 .
7797 Check that "set -o pipefail" does what it's supposed to
7799 echo 1 "$("$__progname" -c '(exit 12) | (exit 23) | (exit 42); echo $?')" .
7800 echo 2 "$("$__progname" -c '! (exit 12) | (exit 23) | (exit 42); echo $?')" .
7801 echo 3 "$("$__progname" -o pipefail -c '(exit 12) | (exit 23) | (exit 42); echo $?')" .
7802 echo 4 "$("$__progname" -o pipefail -c '! (exit 12) | (exit 23) | (exit 42); echo $?')" .
7803 echo 5 "$("$__progname" -c '(exit 23) | (exit 42) | :; echo $?')" .
7804 echo 6 "$("$__progname" -c '! (exit 23) | (exit 42) | :; echo $?')" .
7805 echo 7 "$("$__progname" -o pipefail -c '(exit 23) | (exit 42) | :; echo $?')" .
7806 echo 8 "$("$__progname" -o pipefail -c '! (exit 23) | (exit 42) | :; echo $?')" .
7807 echo 9 "$("$__progname" -o pipefail -c 'x=$( (exit 23) | (exit 42) | :); echo $?')" .
7819 name: persist-history-1
7821 Check if persistent history saving works
7822 category: !no-histfile
7825 env-setup: !ENV=./Env!HISTFILE=hist.file!
7826 file-setup: file 644 "Env"
7830 expected-stdout-pattern:
7832 expected-stderr-pattern:
7837 Check that global does what typeset is supposed to do
7841 global -Uui16 arrfoo[*]
7843 echo before ${arrfoo[0]} .
7845 echo after ${arrfoo[0]} .
7848 echo inside before ${arrbar[0]} .
7850 echo inside changed ${arrbar[0]} .
7851 global -Uui16 arrbar[*]
7852 echo inside typeset ${arrbar[0]} .
7854 echo inside changed ${arrbar[0]} .
7856 echo before ${arrbar[0]} .
7858 echo after ${arrbar[0]} .
7865 inside typeset 16#61 .
7866 inside changed 16#30 .
7869 name: typeset-padding-1
7871 Check if left/right justification works as per TFM
7873 typeset -L10 ln=0hall0
7874 typeset -R10 rn=0hall0
7875 typeset -ZL10 lz=0hall0
7876 typeset -ZR10 rz=0hall0
7877 typeset -Z10 rx=" hallo "
7878 echo "<$ln> <$rn> <$lz> <$rz> <$rx>"
7880 <0hall0 > < 0hall0> <hall0 > <00000hall0> <0000 hallo>
7882 name: typeset-padding-2
7884 Check if base-!10 integers are padded right
7886 typeset -Uui16 -L9 ln=16#1
7887 typeset -Uui16 -R9 rn=16#1
7888 typeset -Uui16 -Z9 zn=16#1
7892 echo "<$ln> <$rn> <$zn> <$ls> <$rs> <$zs>"
7894 <16#1 > < 16#1> <16#000001> <16#1 > < 16#1> <0000016#1>
7898 Check that the UTF-8 Byte Order Mark is ignored as the first
7899 multibyte character of the shell input (with -c, from standard
7900 input, as file, or as eval argument), but nowhere else
7901 # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
7902 category: !os:darwin
7905 print '#!/bin/sh\necho ohne' >foo/fnord
7906 print '#!/bin/sh\necho mit' >foo/fnord
7907 print 'fnord\nfnord\nfnord\nfnord' >foo/bar
7908 print eval \''fnord\nfnord\nfnord\nfnord'\' >foo/zoo
7909 set -A anzahl -- foo/*
7910 echo got ${#anzahl[*]} files
7912 export PATH=$(pwd)/foo$PATHSEP$PATH
7913 "$__progname" -c 'fnord'
7915 "$__progname" -c 'fnord; fnord; fnord; fnord'
7917 "$__progname" foo/bar
7919 "$__progname" <foo/bar
7921 "$__progname" foo/zoo
7923 "$__progname" -c 'echo : $(fnord)'
7953 Check that we can execute BOM-shebangs (failures not fatal)
7954 XXX if the OS can already execute them, we lose
7955 note: cygwin execve(2) doesn't return to us with ENOEXEC, we lose
7956 note: Ultrix perl5 t4 returns 65280 (exit-code 255) and no text
7957 XXX fails when LD_PRELOAD is set with -e and Perl chokes it (ASan)
7959 category: !os:cygwin,!os:msys,!os:ultrix,!os:uwin-nt,!smksh
7960 env-setup: !FOO=BAR!
7962 print '#!'"$__progname"'\nprint "1 a=$ENV{FOO}";' >t1
7963 print '#!'"$__progname"'\nprint "2 a=$ENV{FOO}";' >t2
7964 print '#!'"$__perlname"'\nprint "3 a=$ENV{FOO}\n";' >t3
7965 print '#!'"$__perlname"'\nprint "4 a=$ENV{FOO}\n";' >t4
7972 1 a=/nonexistant{FOO}
7973 2 a=/nonexistant{FOO}
7976 expected-stderr-pattern:
7977 /(Unrecognized character .... ignored at \..t4 line 1)*/
7981 Check that the utf8-mode flag is not set at non-interactive startup
7983 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8!
7985 if [[ $- = *U* ]]; then
7995 Check that the utf8-mode flag is not set at non-interactive startup
7997 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.utf8!
7999 if [[ $- = *U* ]]; then
8009 Check that the utf8-mode flag is set at interactive startup.
8010 -DMKSH_ASSUME_UTF8=0 => expected failure, please ignore
8011 -DMKSH_ASSUME_UTF8=1 => not expected, please investigate
8012 -UMKSH_ASSUME_UTF8 => not expected, but if your OS is old,
8013 try passing HAVE_SETLOCALE_CTYPE=0 to Build.sh
8015 category: !os:hpux,!os:msys
8018 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8!
8020 if [[ $- = *U* ]]; then
8027 expected-stderr-pattern:
8032 Check that the utf8-mode flag is set at interactive startup
8033 Expected failure if -DMKSH_ASSUME_UTF8=0
8037 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.utf8!
8039 if [[ $- = *U* ]]; then
8046 expected-stderr-pattern:
8051 Ensure ±U on the command line is honoured
8052 (these two tests may pass falsely depending on CPPFLAGS)
8055 code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi'
8056 let i++; "$__progname" -U -c "$code"
8057 let i++; "$__progname" +U -c "$code"
8066 Ensure ±U on the command line is honoured, interactive shells
8070 code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi'
8071 let i++; "$__progname" -U -ic "$code"
8072 let i++; "$__progname" +U -ic "$code"
8081 Ensure trailing combining characters are not lost
8102 Check if built-in shell aliases are okay
8107 autoload='\typeset -fu'
8108 functions='\typeset -f'
8109 hash='\builtin alias -t'
8110 history='\builtin fc -l'
8111 integer='\typeset -i'
8114 nameref='\typeset -n'
8116 r='\builtin fc -e -'
8117 type='\builtin whence -v'
8121 Check if “set -o sh” does not influence built-in aliases
8127 autoload='\typeset -fu'
8128 functions='\typeset -f'
8129 hash='\builtin alias -t'
8130 history='\builtin fc -l'
8131 integer='\typeset -i'
8134 nameref='\typeset -n'
8136 r='\builtin fc -e -'
8137 type='\builtin whence -v'
8141 Check if running as sh does not influence built-in aliases
8144 ./sh -c 'alias; typeset -f'
8147 autoload='\typeset -fu'
8148 functions='\typeset -f'
8149 hash='\builtin alias -t'
8150 history='\builtin fc -l'
8151 integer='\typeset -i'
8154 nameref='\typeset -n'
8156 r='\builtin fc -e -'
8157 type='\builtin whence -v'
8159 name: aliases-cmdline
8161 Check that aliases work from the command line (Debian #517009)
8162 Note that due to the nature of the lexing process, defining
8163 aliases in COMSUBs then immediately using them, and things
8164 like 'alias foo=bar && foo', still fail.
8166 "$__progname" -c $'alias a="echo OK"\na'
8170 name: aliases-funcdef-1
8172 Check if POSIX functions take precedences over aliases
8174 alias foo='echo makro'
8182 name: aliases-funcdef-2
8184 Check if POSIX functions take precedences over aliases
8186 alias foo='echo makro'
8194 name: aliases-funcdef-3
8196 Check if aliases take precedences over Korn functions
8198 alias foo='echo makro'
8206 name: aliases-funcdef-4
8208 Functions should only take over if actually being defined
8219 Check if Korn Shell arrays work as expected
8222 set -A foo -- a \$v "$v" '$v' b
8223 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
8229 Check if bash-style arrays work as expected
8232 foo=(a \$v "$v" '$v' b)
8233 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
8239 Check if bash-style arrays work as expected, with newlines
8241 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "$x|"; done' >pfp
8243 test -n "$ZSH_VERSION" && setopt KSH_ARRAYS
8249 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
8254 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
8259 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
8261 7|a|bc|d|$v|e f|$v|g|
8262 7|a|bc|d|$v|e f|$v|g|
8263 6|abc\|d|$v|e f|$v|g||
8267 Check if array bounds are uint32_t
8274 echo ${foo[4294967295]} g ${foo[*]}
8281 Check if Korn Shell arrays with specified indices work as expected
8284 set -A foo -- [1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b
8285 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|"
8286 # we don't want this at all:
8288 set -A arr "[5]=meh"
8289 echo "<${arr[0]}><${arr[5]}>"
8291 5|[1]=$v|[2]=c d|[4]=$v|[0]=a|[5]=b||
8296 Check if bash-style arrays with specified indices work as expected
8297 (taken out temporarily to fix arrays-4; see also arrays-9a comment)
8301 foo=([1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b)
8302 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|"
8303 x=([128]=foo bar baz)
8306 # Check that we do not break this by globbing
8311 echo "<${arr[0]}><${arr[5]}>"
8320 Check if we can get the array keys (indices) for indexed arrays,
8326 echo -n "$((i++))<$x>"
8337 echo a $(of ${foo[*]}) = $(of ${bar[*]}) a
8338 echo b $(of "${foo[*]}") = $(of "${bar[*]}") b
8339 echo c $(of ${foo[@]}) = $(of ${bar[@]}) c
8340 echo d $(of "${foo[@]}") = $(of "${bar[@]}") d
8341 echo e $(of ${!foo[*]}) = $(of ${!bar[*]}) e
8342 echo f $(of "${!foo[*]}") = $(of "${!bar[*]}") f
8343 echo g $(of ${!foo[@]}) = $(of ${!bar[@]}) g
8344 echo h $(of "${!foo[@]}") = $(of "${!bar[@]}") h
8352 a 0<zwei>1<eins>2<drei> = a
8353 b 0<zwei eins drei> = 0<> b
8354 c 0<zwei>1<eins>2<drei> = c
8355 d 0<zwei>1<eins>2<drei> = d
8363 Check if we can get the array keys (indices) for indexed arrays,
8364 Korn shell style, in some corner cases
8367 echo !arz[0]: ${!arz[0]}
8368 echo !arz[1]: ${!arz[1]}
8371 echo !arz[0]: ${!arz[0]}
8372 echo !arz[1]: ${!arz[1]}
8375 echo !arz[0]: ${!arz[0]}
8376 echo !arz[1]: ${!arz[1]}
8390 Check some behavioural rules for arrays.
8428 typeset -Z3 aa ab ac ad ae af ag
8473 Check that we can concatenate arrays
8475 unset foo; foo=(bar); foo+=(baz); echo 1 ${!foo[*]} : ${foo[*]} .
8476 unset foo; foo=(foo bar); foo+=(baz); echo 2 ${!foo[*]} : ${foo[*]} .
8477 # unset foo; foo=([2]=foo [0]=bar); foo+=(baz [5]=quux); echo 3 ${!foo[*]} : ${foo[*]} .
8480 2 0 1 2 : foo bar baz .
8481 # 3 0 2 3 5 : bar foo baz quux .
8485 Check that we can concatenate parameters too
8487 unset foo; foo=bar; foo+=baz; echo 1 $foo .
8488 unset foo; typeset -i16 foo=10; foo+=20; echo 2 $foo .
8493 name: arrassign-basic
8495 Check basic whitespace conserving properties of wdarrassign
8503 c+=("$(echo "c d")")
8505 echo ".a:${a[0]}.${a[1]}.${a[2]}.${a[3]}:"
8506 echo ".b:${b[0]}.${b[1]}.${b[2]}.${b[3]}:"
8507 echo ".c:${c[0]}.${c[1]}.${c[2]}.${c[3]}:"
8508 echo ".d:${d[0]}.${d[1]}.${d[2]}.${d[3]}:"
8515 name: arrassign-fnc-none
8517 Check locality of array access inside a function
8521 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8524 if [[ -n $BASH_VERSION ]]; then
8530 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8534 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8536 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8538 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8539 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8541 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8543 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8556 name: arrassign-fnc-local
8558 Check locality of array access inside a function
8559 with the bash/mksh/ksh93 local/typeset keyword
8560 (note: ksh93 has no local; typeset works only in FKSH)
8565 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8568 if [[ -n $BASH_VERSION ]]; then
8575 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8579 if [[ -n $BASH_VERSION ]]; then
8585 echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8590 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8592 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8594 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8595 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8597 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8599 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8600 echo ".f0r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8602 echo ".f1r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8604 echo ".f2r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8622 name: arrassign-fnc-global
8624 Check locality of array access inside a function
8625 with the mksh-specific global keyword
8630 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8636 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8642 echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8647 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8649 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8651 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8652 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8654 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8656 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8657 echo ".f0r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8659 echo ".f1r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8661 echo ".f2r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8679 name: strassign-fnc-none
8681 Check locality of string access inside a function
8716 name: strassign-fnc-local
8718 Check locality of string access inside a function
8719 with the bash/mksh/ksh93 local/typeset keyword
8720 (note: ksh93 has no local; typeset works only in FKSH)
8774 name: strassign-fnc-global
8776 Check locality of string access inside a function
8777 with the mksh-specific global keyword
8831 name: unset-fnc-local-ksh
8833 Check that “unset” removes a previous “local”
8834 (ksh93 syntax compatible version); apparently,
8835 there are shells which fail this?
8861 name: unset-fnc-local-sh
8863 Check that “unset” removes a previous “local”
8864 (Debian Policy §10.4 sh version); apparently,
8865 there are shells which fail this?
8891 name: varexpand-substr-1
8893 Check if bash-style substring expansion works
8894 when using positive numerics
8897 typeset -i y=123456789
8898 typeset -i 16 z=123456789 # 16#75bcd15
8899 echo a t${x:2:2} ${y:2:3} ${z:2:3} a
8900 echo b ${x::3} ${y::3} ${z::3} b
8901 echo c ${x:2:} ${y:2:} ${z:2:} c
8902 echo d ${x:2} ${y:2} ${z:2} d
8903 echo e ${x:2:6} ${y:2:6} ${z:2:7} e
8904 echo f ${x:2:7} ${y:2:7} ${z:2:8} f
8905 echo g ${x:2:8} ${y:2:8} ${z:2:9} g
8910 d cdefghi 3456789 #75bcd15 d
8911 e cdefgh 345678 #75bcd1 e
8912 f cdefghi 3456789 #75bcd15 f
8913 g cdefghi 3456789 #75bcd15 g
8915 name: varexpand-substr-2
8917 Check if bash-style substring expansion works
8918 when using negative numerics or expressions
8921 typeset -i y=123456789
8922 typeset -i 16 z=123456789 # 16#75bcd15
8924 echo a ${x:$n:3} ${y:$n:3} ${z:$n:3} a
8925 echo b ${x:(n):3} ${y:(n):3} ${z:(n):3} b
8926 echo c ${x:(-2):1} ${y:(-2):1} ${z:(-2):1} c
8927 echo d t${x: n:2} ${y: n:3} ${z: n:3} d
8934 name: varexpand-substr-3
8936 Check that some things that work in bash fail.
8937 This is by design. Oh and vice versa, nowadays.
8939 export x=abcdefghi n=2
8940 "$__progname" -c 'echo v${x:(n)}x'
8941 "$__progname" -c 'echo w${x: n}x'
8942 "$__progname" -c 'echo x${x:n}x'
8943 "$__progname" -c 'echo y${x:}x'
8944 "$__progname" -c 'echo z${x}x'
8945 # next fails only in bash
8946 "$__progname" -c 'x=abcdef;y=123;echo ${x:${y:2:1}:2}' >/dev/null 2>&1; echo $?
8952 expected-stderr-pattern:
8953 /x:n.*bad substitution.*\n.*bad substitution/
8955 name: varexpand-substr-4
8957 Check corner cases for substring expansion
8961 echo a ${x:(y == 1 ? 2 : 3):4} a
8965 name: varexpand-substr-5A
8967 Check that substring expansions work on characters
8971 echo a ${x::1} ${x: -1} a
8972 echo b ${x::3} ${x: -3} b
8973 echo c ${x:1:2} ${x: -3:2} c
8981 name: varexpand-substr-5W
8983 Check that substring expansions work on characters
8987 echo a ${x::1} ${x: -1} a
8988 echo b ${x::2} ${x: -2} b
8989 echo c ${x:1:1} ${x: -2:1} c
8997 name: varexpand-substr-6
8999 Check that string substitution works correctly
9004 echo a ${baz: foo: bar}
9005 echo b ${baz: foo: $bar}
9006 echo c ${baz: $foo: bar}
9007 echo d ${baz: $foo: $bar}
9014 name: varexpand-special-hash
9016 Check special ${var@x} expansion for x=hash
9021 print ${foo@#} ${bar@#} ${baz@#} .
9023 9B15FBFB CFBDD32B 00000000 .
9025 name: varexpand-special-quote
9027 Check special ${var@Q} expansion for quoted strings
9034 print -r -- "<i=$i j=$j k=$k>"
9035 s="u=${i@Q} v=${j@Q} w=${k@Q}"
9036 print -r -- "s=\"$s\""
9042 s="u=x v='a b' w=$'c\nd\240e\u20ACf'"
9045 typeset w=$'c\nd\240e\u20ACf'
9047 name: varexpand-null-1
9049 Ensure empty strings expand emptily
9051 print s ${a} . ${b} S
9052 print t ${a#?} . ${b%?} T
9053 print r ${a=} . ${b/c/d} R
9055 print s "${a}" . "${b}" S
9056 print t "${a#?}" . "${b%?}" T
9057 print r "${a=}" . "${b/c/d}" R
9067 name: varexpand-null-2
9069 Ensure empty strings, when quoted, are expanded as empty strings
9071 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "<$x> "; done' >pfs
9073 ./pfs 1 "${a}" 2 "${a#?}" + "${b%?}" 3 "${a=}" + "${b/c/d}"
9076 <1> <> <2> <> <+> <> <3> <> <+> <> .
9078 name: varexpand-null-3
9080 Ensure concatenating behaviour matches other shells
9082 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
9084 x=; showargs 1 "$x"$@
9085 set A; showargs 2 "${@:+}"
9119 name: varexpand-funny-chars
9121 Check some characters
9122 XXX \uEF80 is asymmetric, possibly buggy so we don’t check this
9124 x=$'<\x00>'; typeset -p x
9125 x=$'<\x01>'; typeset -p x
9126 x=$'<\u0000>'; typeset -p x
9127 x=$'<\u0001>'; typeset -p x
9134 name: print-funny-chars
9136 Check print builtin's capability to output designated characters
9139 print '<\0144\0344\xDB\u00DB\u20AC\uDB\x40>'
9145 # integer-base-one-3Ar
9146 typeset -Uui16 -Z11 pos=0
9147 typeset -Uui16 -Z5 hv=2147483647
9149 if read -arN -1 line; then
9152 while (( i < ${#line[*]} )); do
9154 if (( (pos & 15) == 0 )); then
9155 (( pos )) && print "$dasc|"
9156 print -n "${pos#16#} "
9159 print -n "${hv#16#} "
9160 if (( (hv < 32) || (hv > 126) )); then
9163 dasc=$dasc${line[i-1]#1#}
9165 (( (pos++ & 15) == 7 )) && print -n -- '- '
9168 while (( pos & 15 )); do
9170 (( (pos++ & 15) == 7 )) && print -n -- '- '
9172 (( hv == 2147483647 )) || print "$dasc|"
9175 00000000 3C 64 E4 DB C3 9B E2 82 - AC C3 9B 40 3E 0A 3C 00 |<d.........@>.<.|
9176 00000010 3E 0A 3C 01 3E 0A 3C 00 - 3E 0A 3C 01 3E 0A |>.<.>.<.>.<.>.|
9180 Check print builtin's \c escape
9182 print '\ca'; print b
9188 Check that CR+LF is not collapsed into LF as some MSYS shells wrongly do
9190 echo '#!'"$__progname" >foo
9192 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'
9197 ./foo | while IFS= read -r line; do
9198 print -r -- "{$line}"
9201 [220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT
\r
9202 220->> Bitte keine Werbung einwerfen! <<
\r\r
9203 220 Who do you wanna pretend to be today?
\r]
9204 {220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT
\r}
9205 {220->> Bitte keine Werbung einwerfen! <<
\r\r}
9206 {220 Who do you wanna pretend to be today?
\r}
9210 Check that CR+LF is shown and read as-is
9216 if test x"$KSH_VERSION" = x""; then #
\r
9217 printf '<%s>' "$x" #
\r
9219 print -nr -- "<$x>" #
\r
9222 echo "[$("$__progname" foo)]"
9223 "$__progname" foo | while IFS= read -r line; do
9224 print -r -- "{$line}"
9235 Check that LF-only is shown and read as-is
9241 if test x"$KSH_VERSION" = x""; then #
9242 printf '<%s>' "$x" #
9244 print -nr -- "<$x>" #
9247 echo "[$("$__progname" foo)]"
9248 "$__progname" foo | while IFS= read -r line; do
9249 print -r -- "{$line}"
9258 name: print-nul-chars
9260 Check handling of NUL characters for print and COMSUB
9263 print $(($(print '<\0>' | wc -c))) $(($(print "$x" | wc -c))) \
9265 expected-stdout-pattern:
9270 Check that print -A works as expected
9272 print -An 0x20AC 0xC3 0xBC 8#101
9274 print -A 0x20AC 0xC3 0xBC 8#102
9280 Check backslash expansion by the print builtin
9282 print '\ \!\"\#\$\%\&'\\\''\(\)\*\+\,\-\.\/\0\1\2\3\4\5\6\7\8' \
9283 '\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T' \
9284 '\U\V\W\X\Y\Z\[\\\]\^\_\`\a\b \d\e\f\g\h\i\j\k\l\m\n\o\p' \
9285 '\q\r\s\t\u\v\w\x\y\z\{\|\}\~' '\u20acd' '\U20acd' '\x123' \
9286 '\0x' '\0123' '\01234' | {
9287 # integer-base-one-3As
9288 typeset -Uui16 -Z11 pos=0
9289 typeset -Uui16 -Z5 hv=2147483647
9293 while IFS= read -r line; do
9295 while [[ -n $line ]]; do
9297 if (( (pos & 15) == 0 )); then
9298 (( pos )) && print "$dasc|"
9299 print -n "${pos#16#} "
9302 print -n "${hv#16#} "
9303 if (( (hv < 32) || (hv > 126) )); then
9306 dasc=$dasc${line::1}
9308 (( (pos++ & 15) == 7 )) && print -n -- '- '
9312 while (( pos & 15 )); do
9314 (( (pos++ & 15) == 7 )) && print -n -- '- '
9316 (( hv == 2147483647 )) || print "$dasc|"
9319 00000000 5C 20 5C 21 5C 22 5C 23 - 5C 24 5C 25 5C 26 5C 27 |\ \!\"\#\$\%\&\'|
9320 00000010 5C 28 5C 29 5C 2A 5C 2B - 5C 2C 5C 2D 5C 2E 5C 2F |\(\)\*\+\,\-\.\/|
9321 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|
9322 00000030 20 5C 39 5C 3A 5C 3B 5C - 3C 5C 3D 5C 3E 5C 3F 5C | \9\:\;\<\=\>\?\|
9323 00000040 40 5C 41 5C 42 5C 43 5C - 44 1B 5C 46 5C 47 5C 48 |@\A\B\C\D.\F\G\H|
9324 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|
9325 00000060 5C 51 5C 52 5C 53 5C 54 - 20 5C 56 5C 57 5C 58 5C |\Q\R\S\T \V\W\X\|
9326 00000070 59 5C 5A 5C 5B 5C 5C 5D - 5C 5E 5C 5F 5C 60 07 08 |Y\Z\[\]\^\_\`..|
9327 00000080 20 20 5C 64 1B 0C 5C 67 - 5C 68 5C 69 5C 6A 5C 6B | \d..\g\h\i\j\k|
9328 00000090 5C 6C 5C 6D 0A 5C 6F 5C - 70 20 5C 71 0D 5C 73 09 |\l\m.\o\p \q.\s.|
9329 000000A0 0B 5C 77 5C 79 5C 7A 5C - 7B 5C 7C 5C 7D 5C 7E 20 |.\w\y\z\{\|\}\~ |
9330 000000B0 E2 82 AC 64 20 EF BF BD - 20 12 33 20 78 20 53 20 |...d ... .3 x S |
9331 000000C0 53 34 0A - |S4.|
9333 name: dollar-doublequoted-strings
9335 Check that a $ preceding "…" is ignored
9337 echo $"Localise me!"
9342 I do not take a $V for a V!
9347 I do not take a $V for a V!
9349 name: dollar-quoted-strings
9351 Check backslash expansion by $'…' strings
9353 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
9355 ./pfn $'\ \!\"\#\$\%\&\'\(\)\*\+\,\-\.\/ \1\2\3\4\5\6' \
9356 $'a\0b' $'a\01b' $'\7\8\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I' \
9357 $'\J\K\L\M\N\O\P\Q\R\S\T\U1\V\W\X\Y\Z\[\\\]\^\_\`\a\b\d\e' \
9358 $'\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u1\v\w\x1\y\z\{\|\}\~ $x' \
9359 $'\u20acd' $'\U20acd' $'\x123' $'fn\x0rd' $'\0234' $'\234' \
9360 $'\2345' $'\ca' $'\c!' $'\c?' $'\c€' $'a\
9362 # integer-base-one-3As
9363 typeset -Uui16 -Z11 pos=0
9364 typeset -Uui16 -Z5 hv=2147483647
9368 while IFS= read -r line; do
9370 while [[ -n $line ]]; do
9372 if (( (pos & 15) == 0 )); then
9373 (( pos )) && print "$dasc|"
9374 print -n "${pos#16#} "
9377 print -n "${hv#16#} "
9378 if (( (hv < 32) || (hv > 126) )); then
9381 dasc=$dasc${line::1}
9383 (( (pos++ & 15) == 7 )) && print -n -- '- '
9387 while (( pos & 15 )); do
9389 (( (pos++ & 15) == 7 )) && print -n -- '- '
9391 (( hv == 2147483647 )) || print "$dasc|"
9394 00000000 20 21 22 23 24 25 26 27 - 28 29 2A 2B 2C 2D 2E 2F | !"#$%&'()*+,-./|
9395 00000010 20 01 02 03 04 05 06 0A - 61 0A 61 01 62 0A 07 38 | .......a.a.b..8|
9396 00000020 39 3A 3B 3C 3D 3E 3F 40 - 41 42 43 44 1B 46 47 48 |9:;<=>?@ABCD.FGH|
9397 00000030 49 0A 4A 4B 4C 4D 4E 4F - 50 51 52 53 54 01 56 57 |I.JKLMNOPQRST.VW|
9398 00000040 58 59 5A 5B 5C 5D 5E 5F - 60 07 08 64 1B 0A 0C 67 |XYZ[\]^_`..d...g|
9399 00000050 68 69 6A 6B 6C 6D 0A 6F - 70 71 0D 73 09 01 0B 77 |hijklm.opq.s...w|
9400 00000060 01 79 7A 7B 7C 7D 7E 20 - 24 78 0A E2 82 AC 64 0A |.yz{|}~ $x....d.|
9401 00000070 EF BF BD 0A C4 A3 0A 66 - 6E 0A 13 34 0A 9C 0A 9C |.......fn..4....|
9402 00000080 35 0A 01 0A 01 0A 7F 0A - 02 82 AC 0A 61 0A 62 0A |5...........a.b.|
9404 name: dollar-quotes-in-heredocs-strings
9406 They are, however, not parsed in here documents, here strings
9407 (outside of string delimiters) or regular strings, but in
9408 parameter substitutions.
9411 dollar = strchr(s, '$'); /* ' */
9417 cat <<<"dollar = strchr(s, '$'); /* ' */"
9418 cat <<<'dollar = strchr(s, '\''$'\''); /* '\'' */'
9419 x="dollar = strchr(s, '$'); /* ' */"
9422 unset nl; print -r -- "x${nl:=$'\n'}y"
9428 # probably never reached for here strings?
9430 cat <<<"4 foo\\\"bar"
9432 # old scripts use this (e.g. ncurses)
9434 # make sure this works, outside of quotes
9437 dollar = strchr(s, '$'); /* ' */
9440 dollar = strchr(s, '$'); /* ' */
9441 dollar = strchr(s, '$'); /* ' */
9442 dollar = strchr(s, '$'); /* ' */
9454 name: dot-needs-argument
9456 check Debian #415167 solution: '.' without arguments should fail
9459 "$__progname" -c source
9460 expected-exit: e != 0
9461 expected-stderr-pattern:
9462 /\.: missing argument.*\n.*source: missing argument/
9464 name: dot-errorlevel
9466 Ensure dot resets $?
9475 name: alias-function-no-conflict
9477 make aliases not conflict with function definitions
9479 # POSIX function can be defined, but alias overrides it
9480 alias foo='echo bar'
9487 foo 2>/dev/null || echo rab
9488 # alias overrides ksh function
9489 alias korn='echo bar'
9495 # alias temporarily overrides POSIX function
9500 alias bla='echo bal'
9514 name: bash-function-parens
9516 ensure the keyword function is ignored when preceding
9517 POSIX style function declarations (bashism)
9520 echo '#!'"$__progname"
9522 echo ' echo "bar='\''$0'\'\"
9524 print -r -- "${2:-foo}"
9526 mk 'function foo' >f-korn
9528 mk 'function foo ()' >f-bash
9529 print '#!'"$__progname"'\nprint -r -- "${0%/f-argh}"' >f-argh
9532 x="korn: $(./f-korn)"; echo "${x/@("$u")/.}"
9533 x="dash: $(./f-dash)"; echo "${x/@("$u")/.}"
9534 x="bash: $(./f-bash)"; echo "${x/@("$u")/.}"
9537 dash: bar='./f-dash'
9538 bash: bar='./f-bash'
9540 name: integer-base-one-1
9542 check if the use of fake integer base 1 works
9545 typeset -Uui16 i0=1#ï i1=1#â
\82¬
9547 typeset -i1 o1a=0x263A
9548 typeset -Uui1 o0b=0x7E
9549 typeset -Uui1 o1b=0xFDD0
9550 integer px=0xCAFE 'p0=1# ' p1=1#… pl=1#f
9551 echo "in <$i0> <$i1>"
9552 echo "out <${o0a#1#}|${o0b#1#}> <${o1a#1#}|${o1b#1#}>"
9554 echo "pass <$px> <$p0> <$p1> <$pl> <${i0#1#}|${i1#1#}>"
9555 typeset -Uui16 tv1=1#~ tv2=1#
\7f tv3=1#
\80 tv4=1#
\81 tv5=1#À tv6=1#Á tv7=1#Â tv8=1#Â
\80
9556 echo "specX <${tv1#16#}> <${tv2#16#}> <${tv3#16#}> <${tv4#16#}> <${tv5#16#}> <${tv6#16#}> <${tv7#16#}> <${tv8#16#}>"
9557 typeset -i1 tv1 tv2 tv3 tv4 tv5 tv6 tv7 tv8
9558 echo "specW <${tv1#1#}> <${tv2#1#}> <${tv3#1#}> <${tv4#1#}> <${tv5#1#}> <${tv6#1#}> <${tv7#1#}> <${tv8#1#}>"
9559 typeset -i1 xs1=0xEF7F xs2=0xEF80 xs3=0xFDD0
9560 echo "specU <${xs1#1#}> <${xs2#1#}> <${xs3#1#}>"
9562 in <16#EFEF> <16#20AC>
9564 pass <16#cafe> <1# > <1#â
\80¦> <1#f> <ï|â
\82¬>
9565 specX <7E> <7F> <EF80> <EF81> <EFC0> <EFC1> <A0> <80>
9566 specW <~> <
\7f> <
\80> <
\81> <À> <Á> <Â > <Â
\80>
9567 specU <> <
\80> <ï·
\90>
9569 name: integer-base-one-2a
9571 check if the use of fake integer base 1 stops at correct characters
9576 expected-stderr-pattern:
9577 /1#foo: unexpected 'oo'/
9578 expected-exit: e != 0
9580 name: integer-base-one-2b
9582 check if the use of fake integer base 1 stops at correct characters
9587 expected-stderr-pattern:
9588 /1#À
\80: unexpected '
\80'/
9589 expected-exit: e != 0
9591 name: integer-base-one-2c1
9593 check if the use of fake integer base 1 stops at correct characters
9601 name: integer-base-one-2c2
9603 check if the use of fake integer base 1 stops at correct characters
9608 expected-stderr-pattern:
9609 /1#â
\80¦: unexpected '
\80'/
9610 expected-exit: e != 0
9612 name: integer-base-one-2d1
9614 check if the use of fake integer base 1 handles octets okay
9618 echo /$x/ # invalid utf-8
9622 name: integer-base-one-2d2
9624 check if the use of fake integer base 1 handles octets
9628 echo /$x/ # invalid 2-byte
9632 name: integer-base-one-2d3
9634 check if the use of fake integer base 1 handles octets
9638 echo /$x/ # invalid 2-byte
9642 name: integer-base-one-2d4
9644 check if the use of fake integer base 1 stops at invalid input
9647 typeset -i16 x=1#ï¿À
9648 echo /$x/ # invalid 3-byte
9649 expected-stderr-pattern:
9650 /1#ï¿À: unexpected '¿'/
9651 expected-exit: e != 0
9653 name: integer-base-one-2d5
9655 check if the use of fake integer base 1 stops at invalid input
9658 typeset -i16 x=1#À
\80
9659 echo /$x/ # non-minimalistic
9660 expected-stderr-pattern:
9661 /1#À
\80: unexpected '
\80'/
9662 expected-exit: e != 0
9664 name: integer-base-one-2d6
9666 check if the use of fake integer base 1 stops at invalid input
9669 typeset -i16 x=1#à
\80\80
9670 echo /$x/ # non-minimalistic
9671 expected-stderr-pattern:
9672 /1#à
\80\80: unexpected '
\80'/
9673 expected-exit: e != 0
9675 name: integer-base-one-3As
9677 some sample code for hexdumping
9678 not NUL safe; input lines must be NL terminated
9681 print 'Hello, World!\\\nこんにちは!'
9682 typeset -Uui16 i=0x100
9683 # change that to 0xFF once we can handle embedded
9684 # NUL characters in strings / here documents
9685 while (( i++ < 0x1FF )); do
9686 print -n "\x${i#16#1}"
9690 # integer-base-one-3As
9691 typeset -Uui16 -Z11 pos=0
9692 typeset -Uui16 -Z5 hv=2147483647
9696 while IFS= read -r line; do
9698 while [[ -n $line ]]; do
9700 if (( (pos & 15) == 0 )); then
9701 (( pos )) && print "$dasc|"
9702 print -n "${pos#16#} "
9705 print -n "${hv#16#} "
9706 if (( (hv < 32) || (hv > 126) )); then
9709 dasc=$dasc${line::1}
9711 (( (pos++ & 15) == 7 )) && print -n -- '- '
9715 while (( pos & 15 )); do
9717 (( (pos++ & 15) == 7 )) && print -n -- '- '
9719 (( hv == 2147483647 )) || print "$dasc|"
9722 00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..|
9723 00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................|
9724 00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................|
9725 00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................|
9726 00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.|
9727 00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>|
9728 00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN|
9729 00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^|
9730 00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn|
9731 00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~|
9732 000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................|
9733 000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................|
9734 000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................|
9735 000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................|
9736 000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................|
9737 000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................|
9738 00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................|
9739 00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................|
9740 00000120 FF 7A 0A - |.z.|
9742 name: integer-base-one-3Ws
9744 some sample code for hexdumping Unicode
9745 not NUL safe; input lines must be NL terminated
9749 print 'Hello, World!\\\nこんにちは!'
9750 typeset -Uui16 i=0x100
9751 # change that to 0xFF once we can handle embedded
9752 # NUL characters in strings / here documents
9753 while (( i++ < 0x1FF )); do
9754 print -n "\u${i#16#1}"
9757 print \\xff # invalid utf-8
9758 print \\xc2 # invalid 2-byte
9759 print \\xef\\xbf\\xc0 # invalid 3-byte
9760 print \\xc0\\x80 # non-minimalistic
9761 print \\xe0\\x80\\x80 # non-minimalistic
9762 print '�' # end of range
9763 print '\0z' # embedded NUL
9765 # integer-base-one-3Ws
9766 typeset -Uui16 -Z11 pos=0
9767 typeset -Uui16 -Z7 hv
9772 while IFS= read -r line; do
9775 while (( lpos < ${#line} )); do
9776 wc=1#${line:(lpos++):1}
9777 if (( (wc < 32) || \
9778 ((wc > 126) && (wc < 160)) )); then
9780 elif (( (wc & 0xFF80) == 0xEF80 )); then
9785 if (( (pos & 7) == 7 )); then
9788 elif (( (pos & 7) == 0 )); then
9789 (( pos )) && print "$dasc|"
9790 print -n "${pos#16#} "
9794 print -n "${hv#16#} "
9795 (( (pos++ & 7) == 3 )) && \
9800 while (( pos & 7 )); do
9802 (( (pos++ & 7) == 3 )) && print -n -- '- '
9804 (( hv == 2147483647 )) || print "$dasc|"
9807 00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W|
9808 00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.こ|
9809 00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |んにちは!...|
9810 00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........|
9811 00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........|
9812 00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........|
9813 00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"|
9814 00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*|
9815 00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012|
9816 00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:|
9817 00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB|
9818 00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ|
9819 00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR|
9820 00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ|
9821 00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab|
9822 00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij|
9823 00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr|
9824 00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz|
9825 00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....|
9826 00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........|
9827 000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........|
9828 000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........|
9829 000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |..... ¡¢|
9830 000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA |£¤¥¦§¨©ª|
9831 000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 |«¬®¯°±²|
9832 000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA |³´µ¶·¸¹º|
9833 000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 |»¼½¾¿ÀÁÂ|
9834 000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA |ÃÄÅÆÇÈÉÊ|
9835 000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 |ËÌÍÎÏÐÑÒ|
9836 000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA |ÓÔÕÖ×ØÙÚ|
9837 000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 |ÛÜÝÞßàáâ|
9838 000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA |ãäåæçèéê|
9839 00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 |ëìíîïðñò|
9840 00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA |óôõö÷øùú|
9841 00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |ûüýþÿ.�.|
9842 00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |�.���.��|
9843 00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |.���.���|
9844 00000128 EFBE EFEF EFBF EFBF - 000A 007A 000A |����.z.|
9846 name: integer-base-one-3Ar
9848 some sample code for hexdumping; NUL and binary safe
9851 print 'Hello, World!\\\nこんにちは!'
9852 typeset -Uui16 i=0x100
9853 # change that to 0xFF once we can handle embedded
9854 # NUL characters in strings / here documents
9855 while (( i++ < 0x1FF )); do
9856 print -n "\x${i#16#1}"
9860 # integer-base-one-3Ar
9861 typeset -Uui16 -Z11 pos=0
9862 typeset -Uui16 -Z5 hv=2147483647
9864 if read -arN -1 line; then
9867 while (( i < ${#line[*]} )); do
9869 if (( (pos & 15) == 0 )); then
9870 (( pos )) && print "$dasc|"
9871 print -n "${pos#16#} "
9874 print -n "${hv#16#} "
9875 if (( (hv < 32) || (hv > 126) )); then
9878 dasc=$dasc${line[i-1]#1#}
9880 (( (pos++ & 15) == 7 )) && print -n -- '- '
9883 while (( pos & 15 )); do
9885 (( (pos++ & 15) == 7 )) && print -n -- '- '
9887 (( hv == 2147483647 )) || print "$dasc|"
9890 00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..|
9891 00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................|
9892 00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................|
9893 00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................|
9894 00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.|
9895 00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>|
9896 00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN|
9897 00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^|
9898 00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn|
9899 00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~|
9900 000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................|
9901 000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................|
9902 000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................|
9903 000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................|
9904 000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................|
9905 000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................|
9906 00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................|
9907 00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................|
9908 00000120 FF 00 7A 0A - |..z.|
9910 name: integer-base-one-3Wr
9912 some sample code for hexdumping Unicode; NUL and binary safe
9916 print 'Hello, World!\\\nこんにちは!'
9917 typeset -Uui16 i=0x100
9918 # change that to 0xFF once we can handle embedded
9919 # NUL characters in strings / here documents
9920 while (( i++ < 0x1FF )); do
9921 print -n "\u${i#16#1}"
9924 print \\xff # invalid utf-8
9925 print \\xc2 # invalid 2-byte
9926 print \\xef\\xbf\\xc0 # invalid 3-byte
9927 print \\xc0\\x80 # non-minimalistic
9928 print \\xe0\\x80\\x80 # non-minimalistic
9929 print '�' # end of range
9930 print '\0z' # embedded NUL
9932 # integer-base-one-3Wr
9933 typeset -Uui16 -Z11 pos=0
9934 typeset -Uui16 -Z7 hv=2147483647
9936 if read -arN -1 line; then
9939 while (( i < ${#line[*]} )); do
9941 if (( (hv < 32) || \
9942 ((hv > 126) && (hv < 160)) )); then
9944 elif (( (hv & 0xFF80) == 0xEF80 )); then
9949 if (( (pos & 7) == 7 )); then
9952 elif (( (pos & 7) == 0 )); then
9953 (( pos )) && print "$dasc|"
9954 print -n "${pos#16#} "
9957 print -n "${hv#16#} "
9958 (( (pos++ & 7) == 3 )) && \
9963 while (( pos & 7 )); do
9965 (( (pos++ & 7) == 3 )) && print -n -- '- '
9967 (( hv == 2147483647 )) || print "$dasc|"
9970 00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W|
9971 00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.こ|
9972 00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |んにちは!...|
9973 00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........|
9974 00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........|
9975 00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........|
9976 00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"|
9977 00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*|
9978 00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012|
9979 00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:|
9980 00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB|
9981 00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ|
9982 00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR|
9983 00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ|
9984 00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab|
9985 00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij|
9986 00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr|
9987 00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz|
9988 00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....|
9989 00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........|
9990 000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........|
9991 000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........|
9992 000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |..... ¡¢|
9993 000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA |£¤¥¦§¨©ª|
9994 000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 |«¬®¯°±²|
9995 000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA |³´µ¶·¸¹º|
9996 000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 |»¼½¾¿ÀÁÂ|
9997 000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA |ÃÄÅÆÇÈÉÊ|
9998 000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 |ËÌÍÎÏÐÑÒ|
9999 000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA |ÓÔÕÖ×ØÙÚ|
10000 000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 |ÛÜÝÞßàáâ|
10001 000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA |ãäåæçèéê|
10002 00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 |ëìíîïðñò|
10003 00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA |óôõö÷øùú|
10004 00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |ûüýþÿ.�.|
10005 00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |�.���.��|
10006 00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |.���.���|
10007 00000128 EFBE EFEF EFBF EFBF - 000A 0000 007A 000A |����..z.|
10009 name: integer-base-one-4
10011 Check if ksh93-style base-one integers work
10016 (echo 2f $(('aa'))) 2>&1 | sed "s/^[^']*'/2p '/"
10024 2p 'aa': multi-character character constant
10030 name: integer-base-one-5A
10032 Check to see that we’re NUL and Unicode safe
10035 print 'a\0b\xfdz' >x
10041 16#61 16#0 16#62 16#FD 16#7A .
10043 name: integer-base-one-5W
10045 Check to see that we’re NUL and Unicode safe
10054 16#61 16#0 16#62 16#20AC 16#63 .
10058 Check if we can use a specific syntax idiom for ulimit
10059 category: !os:syllable
10061 if ! x=$(ulimit -d) || [[ $x = unknown ]]; then
10062 #echo expected to fail on this OS
10065 ulimit -dS $x && echo okay
10072 Check some of the most basic invariants of I/O redirection
10077 print -u2 e$((i++)).
10102 Check if GNU bash-like I/O redirection works
10103 Part 1: this is also supported by GNU bash
10104 category: shell:legacy-no
10107 function threeout {
10123 Check if GNU bash-like I/O redirection works
10124 Part 2: this is *not* supported by GNU bash
10125 category: shell:legacy-no
10128 function threeout {
10144 Check if GNU bash-like I/O redirection works
10145 Part 2: this is *not* supported by GNU bash
10146 category: shell:legacy-no
10149 function threeout {
10154 threeout 3>foo &>&3
10165 Check if GNU bash-like I/O redirection works
10166 Part 2: this is supported by GNU bash 4 only
10167 category: shell:legacy-no
10172 function threeout {
10189 Check if GNU bash-like I/O redirection fails correctly
10190 Part 1: this is also supported by GNU bash
10191 category: shell:legacy-no
10196 function threeout {
10207 expected-stderr-pattern: /.*: can't (create|overwrite) .*/
10211 Check if GNU bash-like I/O redirection fails correctly
10212 Part 2: this is *not* supported by GNU bash
10213 category: shell:legacy-no
10218 function threeout {
10234 Check if GNU bash-like I/O redirection works
10235 Part 4: this is also supported by GNU bash,
10236 but failed in some mksh versions
10237 category: shell:legacy-no
10240 function threeout {
10246 [[ -e bar ]] && threeout "$bf" &>foo
10259 name: bashiop-5-normal
10261 Check if GNU bash-like I/O redirection is only supported
10262 in !POSIX !sh mode as it breaks existing scripts' syntax
10263 category: shell:legacy-no
10265 :>x; echo 1 "$("$__progname" -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
10266 :>x; echo 2 "$("$__progname" -o posix -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
10267 :>x; echo 3 "$("$__progname" -o sh -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
10273 name: bashiop-5-legacy
10275 Check if GNU bash-like I/O redirection is not parsed
10276 in lksh as it breaks existing scripts' syntax
10277 category: shell:legacy-yes
10279 :>x; echo 1 "$("$__progname" -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
10280 :>x; echo 2 "$("$__progname" -o posix -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
10281 :>x; echo 3 "$("$__progname" -o sh -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
10292 for n in ${a#*=}; do echo 1hu ${n} .; done
10293 for n in "${a#*=}"; do echo 1hq ${n} .; done
10294 for n in ${a##*=}; do echo 2hu ${n} .; done
10295 for n in "${a##*=}"; do echo 2hq ${n} .; done
10296 for n in ${a%=*}; do echo 1pu ${n} .; done
10297 for n in "${a%=*}"; do echo 1pq ${n} .; done
10298 for n in ${a%%=*}; do echo 2pu ${n} .; done
10299 for n in "${a%%=*}"; do echo 2pq ${n} .; done
10306 name: oksh-and-list-error-1
10308 Test exit status of rightmost element in 2 element && list in -e mode
10311 echo "should not print"
10313 expected-exit: e != 0
10315 name: oksh-and-list-error-2
10317 Test exit status of rightmost element in 3 element && list in -e mode
10319 true && true && false
10320 echo "should not print"
10322 expected-exit: e != 0
10324 name: oksh-or-list-error-1
10326 Test exit status of || list in -e mode
10329 echo "should not print"
10331 expected-exit: e != 0
10333 name: oksh-longline-crash
10335 This used to cause a core dump
10338 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"
10339 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"
10340 for deplib in $deplibs; do
10343 new_libs="$deplib $new_libs"
10346 case " $specialdeplibs " in
10348 new_libs="$deplib $new_libs";;
10354 name: oksh-seterror-1
10356 The -e flag should be ignored when executing a compound list
10357 followed by an if statement.
10359 if true; then false && false; fi
10362 expected-exit: e == 0
10364 name: oksh-seterror-2
10366 The -e flag should be ignored when executing a compound list
10367 followed by an if statement.
10369 if true; then if true; then false && false; fi; fi
10372 expected-exit: e == 0
10374 name: oksh-seterror-3
10376 The -e flag should be ignored when executing a compound list
10377 followed by an elif statement.
10379 if true; then :; elif true; then false && false; fi
10381 expected-exit: e == 0
10383 name: oksh-seterror-4
10385 The -e flag should be ignored when executing a pipeline
10394 expected-exit: e == 0
10396 name: oksh-seterror-5
10398 The -e flag should be ignored when executing a pipeline
10404 expected-exit: e == 0
10406 name: oksh-seterror-6
10408 When trapping ERR and EXIT, both traps should run in -e mode
10409 when an error occurs.
10411 trap 'echo EXIT' EXIT
10412 trap 'echo ERR' ERR
10418 expected-exit: e != 0
10423 name: oksh-seterror-7
10425 The -e flag within a command substitution should be honored
10427 echo $( set -e; false; echo foo )
10432 name: oksh-input-comsub
10434 A command substitution using input redirection should exit with
10435 failure if the input file does not exist.
10437 var=$(< non-existent)
10438 expected-exit: e != 0
10439 expected-stderr-pattern: /non-existent/
10441 name: oksh-empty-for-list
10443 A for list which expands to zero items should not execute the body.
10445 set foo bar baz ; for out in ; do echo $out ; done
10447 name: oksh-varfunction-mod1
10449 (Inspired by PR 2450 on OpenBSD.) Calling
10451 where f is a ksh style function, should not set FOO in the current
10452 env. If f is a Bourne style function, FOO should be set. Furthermore,
10453 the function should receive a correct value of FOO. However, differing
10454 from oksh, setting FOO in the function itself must change the value in
10455 setting FOO in the function itself should not change the value in
10456 global environment.
10458 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
10459 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
10460 done >env; chmod +x env; PATH=.$PATHSEP$PATH
10462 if [ x$FOO != xbar ]; then
10466 x=$(env | grep FOO)
10467 if [ "x$x" != "xFOO=bar" ]; then
10475 if [ x$FOO != xbar ]; then
10479 x=$(env | grep FOO)
10480 if [ "x$x" != "xFOO=bar" ]; then
10488 if [ $? != 0 ]; then
10491 if [ x$FOO != x ]; then
10495 if [ $? != 0 ]; then
10498 if [ x$FOO != xfoo ]; then
10503 if [ $? != 0 ]; then
10506 if [ x$FOO != xbarbar ]; then
10510 if [ $? != 0 ]; then
10513 if [ x$FOO != xfoo ]; then
10519 Verify that file descriptors > 2 are private for Korn shells
10520 AT&T ksh93 does this still, which means we must keep it as well
10521 XXX fails on some old Perl installations
10523 category: shell:legacy-no
10527 open(my \$fh, ">&", 9) or die "E: open \$!";
10528 syswrite(\$fh, "Fowl\\n", 5) or die "E: write \$!";
10533 expected-exit: e != 0
10534 expected-stderr-pattern:
10539 Verify that file descriptors > 2 are not private for POSIX shells
10540 See Debian Bug #154540, Closes: #499139
10541 XXX fails on some old Perl installations
10546 open(my \$fh, ">&", 9) or die "E: open \$!";
10547 syswrite(\$fh, "Fowl\\n", 5) or die "E: write \$!";
10550 test -n "$POSH_VERSION" || set -o posix
10558 Verify that file descriptors > 2 are not private for LEGACY KSH
10559 category: shell:legacy-yes
10563 open(my \$fh, ">&", 9) or die "E: open \$!";
10564 syswrite(\$fh, "Fowl\\n", 5) or die "E: write \$!";
10574 COMSUB are now parsed recursively, so this works
10575 see also regression-6: matching parenthesēs bug
10576 Fails on: pdksh bash2 bash3 zsh
10577 Passes on: bash4 ksh93 mksh(20110313+)
10579 echo 1 $(case 1 in (1) echo yes;; (2) echo no;; esac) .
10580 echo 2 $(case 1 in 1) echo yes;; 2) echo no;; esac) .
10581 TEST=1234; echo 3 ${TEST: $(case 1 in (1) echo 1;; (*) echo 2;; esac)} .
10582 TEST=5678; echo 4 ${TEST: $(case 1 in 1) echo 1;; *) echo 2;; esac)} .
10583 a=($(case 1 in (1) echo 1;; (*) echo 2;; esac)); echo 5 ${a[0]} .
10584 a=($(case 1 in 1) echo 1;; *) echo 2;; esac)); echo 6 ${a[0]} .
10595 COMSUB are now parsed recursively, so this works
10596 Fails on: pdksh bash2 bash3 bash4 zsh
10597 Passes on: ksh93 mksh(20110313+)
10599 echo 1 $(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10)) .
10600 echo 2 $(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20)) .
10601 (( a = $(case 1 in (1) echo 1;; (*) echo 2;; esac) )); echo 3 $a .
10602 (( a = $(case 1 in 1) echo 1;; *) echo 2;; esac) )); echo 4 $a .
10603 a=($(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10))); echo 5 ${a[0]} .
10604 a=($(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20))); echo 6 ${a[0]} .
10615 RedHat BZ#496791 – another case of missing recursion
10616 in parsing COMSUB expressions
10617 Fails on: pdksh bash2 bash3¹ bash4¹ zsh
10618 Passes on: ksh93 mksh(20110305+)
10619 ① bash[34] seem to choke on comment ending with backslash-newline
10621 # a comment with " ' \
10624 # a comment with " ' \
10632 Extended test for COMSUB explaining why a recursive parser
10633 is a must (a non-recursive parser cannot pass all three of
10634 these test cases, especially the ‘#’ is difficult)
10636 print '#!'"$__progname"'\necho 1234' >id; chmod +x id; PATH=.$PATHSEP$PATH
10637 echo $(typeset -i10 x=16#20; echo $x)
10638 echo $(typeset -Uui16 x=16#$(id -u)
10641 typeset -Uui16 a=36#foo; c=2
10642 typeset -Uui16 b=36 #foo; d=2
10651 Check the tree dump functions for !MKSH_SMALL functionality
10654 x() { case $1 in u) echo x ;;& *) echo $1 ;; esac; }
10670 Check COMSUB works with aliases (does not expand them twice)
10672 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
10674 alias echo='echo a'
10676 ./pfn "$(echo foo)"
10683 ./pfn "$(echo foo )"
10686 name: comsub-torture
10688 Check the tree dump functions work correctly
10690 if [[ -z $__progname ]]; then echo >&2 call me with __progname; exit 1; fi
10691 while IFS= read -r line; do
10692 if [[ $line = '#1' ]]; then
10695 elif [[ $line = EOFN* ]]; then
10696 fbody=$fbody$'\n'$line
10698 elif [[ $line != '#'* ]]; then
10699 fbody=$fbody$'\n\t'$line
10702 if (( lastf )); then
10703 x="inline_${nextf}() {"$fbody$'\n}\n'
10705 print -r -- "${x}typeset -f inline_$nextf" | "$__progname"
10706 x="function comsub_$nextf { x=\$("$fbody$'\n); }\n'
10708 print -r -- "${x}typeset -f comsub_$nextf" | "$__progname"
10709 x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n'
10711 print -r -- "${x}typeset -f reread_$nextf" | "$__progname"
10719 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
10720 #TPAREN_TPIPE_TLIST
10721 (echo $foo | tr -dc 0-9; echo)
10723 cmd && echo ja || echo nein
10725 select file in *; do echo "<$file>" ; break ; done
10727 time for i in {1,2,3} ; do echo $i ; done
10729 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
10730 #TIF_TBANG_TDBRACKET_TELIF
10731 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
10733 i=1; while (( i < 10 )); do echo $i; let ++i; done
10735 i=10; until (( !--i )) ; do echo $i; done
10738 #TFUNCT_TBRACE_TASYNC
10739 function korn { echo eins; echo zwei ; }
10740 bourne () { logger * & }
10743 #IOWRITE_IOCLOB_IOHERE_noIOSKIP
10747 #IOWRITE_noIOCLOB_IOHERE_IOSKIP
10752 sh 1<>/dev/console 0<&1 2>&1
10753 #COMSUB_EXPRSUB_FUNSUB_VALSUB
10754 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
10755 #QCHAR_OQUOTE_CQUOTE
10756 echo fo\ob\"a\`r\'b\$az
10757 echo "fo\ob\"a\`r\'b\$az"
10758 echo 'fo\ob\"a\`r'\''b\$az'
10759 #OSUBST_CSUBST_OPAT_SPAT_CPAT
10760 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
10763 note there must be no space between EOFN and )
10767 note the space between EOFN and ) is actually part of the here document marker
10770 x=$(sysctl -n kern.version | sed 1q)
10771 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
10772 ed -s /etc/motd 2>&1 <<-EOF
10779 EOF)" = @(?) ]] && rm -f /etc/motd
10780 if [[ ! -s /etc/motd ]]; then
10781 install -c -o root -g wheel -m 664 /dev/null /etc/motd
10782 print -- "$x\n" >/etc/motd
10792 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
10795 vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4"
10797 function comsub_TCOM { x=$(
10798 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
10800 function comsub_TCOM {
10801 x=$(vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" )
10803 function reread_TCOM { x=$((
10804 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
10806 function reread_TCOM {
10807 x=$(( vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" ) | tr u x )
10809 inline_TPAREN_TPIPE_TLIST() {
10810 (echo $foo | tr -dc 0-9; echo)
10812 inline_TPAREN_TPIPE_TLIST() {
10813 ( echo $foo | tr -dc 0-9
10816 function comsub_TPAREN_TPIPE_TLIST { x=$(
10817 (echo $foo | tr -dc 0-9; echo)
10819 function comsub_TPAREN_TPIPE_TLIST {
10820 x=$(( echo $foo | tr -dc 0-9 ; echo ) )
10822 function reread_TPAREN_TPIPE_TLIST { x=$((
10823 (echo $foo | tr -dc 0-9; echo)
10825 function reread_TPAREN_TPIPE_TLIST {
10826 x=$(( ( echo $foo | tr -dc 0-9 ; echo ) ) | tr u x )
10828 inline_TAND_TOR() {
10829 cmd && echo ja || echo nein
10831 inline_TAND_TOR() {
10832 cmd && echo ja || echo nein
10834 function comsub_TAND_TOR { x=$(
10835 cmd && echo ja || echo nein
10837 function comsub_TAND_TOR {
10838 x=$(cmd && echo ja || echo nein )
10840 function reread_TAND_TOR { x=$((
10841 cmd && echo ja || echo nein
10843 function reread_TAND_TOR {
10844 x=$(( cmd && echo ja || echo nein ) | tr u x )
10847 select file in *; do echo "<$file>" ; break ; done
10856 function comsub_TSELECT { x=$(
10857 select file in *; do echo "<$file>" ; break ; done
10859 function comsub_TSELECT {
10860 x=$(select file in * ; do echo "<$file>" ; break ; done )
10862 function reread_TSELECT { x=$((
10863 select file in *; do echo "<$file>" ; break ; done
10865 function reread_TSELECT {
10866 x=$(( select file in * ; do echo "<$file>" ; break ; done ) | tr u x )
10868 inline_TFOR_TTIME() {
10869 time for i in {1,2,3} ; do echo $i ; done
10871 inline_TFOR_TTIME() {
10872 time for i in {1,2,3}
10877 function comsub_TFOR_TTIME { x=$(
10878 time for i in {1,2,3} ; do echo $i ; done
10880 function comsub_TFOR_TTIME {
10881 x=$(time for i in {1,2,3} ; do echo $i ; done )
10883 function reread_TFOR_TTIME { x=$((
10884 time for i in {1,2,3} ; do echo $i ; done
10886 function reread_TFOR_TTIME {
10887 x=$(( time for i in {1,2,3} ; do echo $i ; done ) | tr u x )
10890 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
10901 echo kann net bis drei zählen
10905 function comsub_TCASE { x=$(
10906 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
10908 function comsub_TCASE {
10909 x=$(case $foo in (1) echo eins ;& (2) echo zwei ;| (*) echo kann net bis drei zählen ;; esac )
10911 function reread_TCASE { x=$((
10912 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
10914 function reread_TCASE {
10915 x=$(( case $foo in (1) echo eins ;& (2) echo zwei ;| (*) echo kann net bis drei zählen ;; esac ) | tr u x )
10917 inline_TIF_TBANG_TDBRACKET_TELIF() {
10918 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
10920 inline_TIF_TBANG_TDBRACKET_TELIF() {
10931 function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$(
10932 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
10934 function comsub_TIF_TBANG_TDBRACKET_TELIF {
10935 x=$(if ! [[ 1 = 1 ]] ; then echo eins ; elif [[ 1 = 2 ]] ; then echo zwei ; else echo drei ; fi )
10937 function reread_TIF_TBANG_TDBRACKET_TELIF { x=$((
10938 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
10940 function reread_TIF_TBANG_TDBRACKET_TELIF {
10941 x=$(( if ! [[ 1 = 1 ]] ; then echo eins ; elif [[ 1 = 2 ]] ; then echo zwei ; else echo drei ; fi ) | tr u x )
10944 i=1; while (( i < 10 )); do echo $i; let ++i; done
10956 function comsub_TWHILE { x=$(
10957 i=1; while (( i < 10 )); do echo $i; let ++i; done
10959 function comsub_TWHILE {
10960 x=$(i=1 ; while { \let] " i < 10 " ; } ; do echo $i ; let ++i ; done )
10962 function reread_TWHILE { x=$((
10963 i=1; while (( i < 10 )); do echo $i; let ++i; done
10965 function reread_TWHILE {
10966 x=$(( i=1 ; while { \let] " i < 10 " ; } ; do echo $i ; let ++i ; done ) | tr u x )
10969 i=10; until (( !--i )) ; do echo $i; done
10980 function comsub_TUNTIL { x=$(
10981 i=10; until (( !--i )) ; do echo $i; done
10983 function comsub_TUNTIL {
10984 x=$(i=10 ; until { \let] " !--i " ; } ; do echo $i ; done )
10986 function reread_TUNTIL { x=$((
10987 i=10; until (( !--i )) ; do echo $i; done
10989 function reread_TUNTIL {
10990 x=$(( i=10 ; until { \let] " !--i " ; } ; do echo $i ; done ) | tr u x )
10999 function comsub_TCOPROC { x=$(
11002 function comsub_TCOPROC {
11005 function reread_TCOPROC { x=$((
11008 function reread_TCOPROC {
11009 x=$(( cat * |& ls ) | tr u x )
11011 inline_TFUNCT_TBRACE_TASYNC() {
11012 function korn { echo eins; echo zwei ; }
11013 bourne () { logger * & }
11015 inline_TFUNCT_TBRACE_TASYNC() {
11024 function comsub_TFUNCT_TBRACE_TASYNC { x=$(
11025 function korn { echo eins; echo zwei ; }
11026 bourne () { logger * & }
11028 function comsub_TFUNCT_TBRACE_TASYNC {
11029 x=$(function korn { echo eins ; echo zwei ; } ; bourne() { logger * & } )
11031 function reread_TFUNCT_TBRACE_TASYNC { x=$((
11032 function korn { echo eins; echo zwei ; }
11033 bourne () { logger * & }
11035 function reread_TFUNCT_TBRACE_TASYNC {
11036 x=$(( function korn { echo eins ; echo zwei ; } ; bourne() { logger * & } ) | tr u x )
11038 inline_IOREAD_IOCAT() {
11041 inline_IOREAD_IOCAT() {
11044 function comsub_IOREAD_IOCAT { x=$(
11047 function comsub_IOREAD_IOCAT {
11048 x=$(tr x u <foo >>bar )
11050 function reread_IOREAD_IOCAT { x=$((
11053 function reread_IOREAD_IOCAT {
11054 x=$(( tr x u <foo >>bar ) | tr u x )
11056 inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
11061 inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
11067 function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$(
11072 function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
11073 x=$(cat >|bar <<"EOFN"
11078 function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$((
11083 function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
11084 x=$(( cat >|bar <<"EOFN"
11089 inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
11094 inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
11100 function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$(
11105 function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
11106 x=$(cat >bar <<-EOFI
11111 function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$((
11116 function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
11117 x=$(( cat >bar <<-EOFI
11122 inline_IORDWR_IODUP() {
11123 sh 1<>/dev/console 0<&1 2>&1
11125 inline_IORDWR_IODUP() {
11126 sh 1<>/dev/console <&1 2>&1
11128 function comsub_IORDWR_IODUP { x=$(
11129 sh 1<>/dev/console 0<&1 2>&1
11131 function comsub_IORDWR_IODUP {
11132 x=$(sh 1<>/dev/console <&1 2>&1 )
11134 function reread_IORDWR_IODUP { x=$((
11135 sh 1<>/dev/console 0<&1 2>&1
11137 function reread_IORDWR_IODUP {
11138 x=$(( sh 1<>/dev/console <&1 2>&1 ) | tr u x )
11140 inline_COMSUB_EXPRSUB_FUNSUB_VALSUB() {
11141 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
11143 inline_COMSUB_EXPRSUB_FUNSUB_VALSUB() {
11144 echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;}
11146 function comsub_COMSUB_EXPRSUB_FUNSUB_VALSUB { x=$(
11147 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
11149 function comsub_COMSUB_EXPRSUB_FUNSUB_VALSUB {
11150 x=$(echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;} )
11152 function reread_COMSUB_EXPRSUB_FUNSUB_VALSUB { x=$((
11153 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
11155 function reread_COMSUB_EXPRSUB_FUNSUB_VALSUB {
11156 x=$(( echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;} ) | tr u x )
11158 inline_QCHAR_OQUOTE_CQUOTE() {
11159 echo fo\ob\"a\`r\'b\$az
11160 echo "fo\ob\"a\`r\'b\$az"
11161 echo 'fo\ob\"a\`r'\''b\$az'
11163 inline_QCHAR_OQUOTE_CQUOTE() {
11164 echo fo\ob\"a\`r\'b\$az
11165 echo "fo\ob\"a\`r\'b\$az"
11166 echo "fo\\ob\\\"a\\\`r"\'"b\\\$az"
11168 function comsub_QCHAR_OQUOTE_CQUOTE { x=$(
11169 echo fo\ob\"a\`r\'b\$az
11170 echo "fo\ob\"a\`r\'b\$az"
11171 echo 'fo\ob\"a\`r'\''b\$az'
11173 function comsub_QCHAR_OQUOTE_CQUOTE {
11174 x=$(echo fo\ob\"a\`r\'b\$az ; echo "fo\ob\"a\`r\'b\$az" ; echo "fo\\ob\\\"a\\\`r"\'"b\\\$az" )
11176 function reread_QCHAR_OQUOTE_CQUOTE { x=$((
11177 echo fo\ob\"a\`r\'b\$az
11178 echo "fo\ob\"a\`r\'b\$az"
11179 echo 'fo\ob\"a\`r'\''b\$az'
11181 function reread_QCHAR_OQUOTE_CQUOTE {
11182 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 )
11184 inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() {
11185 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
11187 inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() {
11188 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
11190 function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$(
11191 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
11193 function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT {
11194 x=$([[ ${foo#bl\(u\)b} = @(bar|baz) ]] )
11196 function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$((
11197 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
11199 function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT {
11200 x=$(( [[ ${foo#bl\(u\)b} = @(bar|baz) ]] ) | tr u x )
11202 inline_heredoc_closed() {
11204 note there must be no space between EOFN and )
11207 inline_heredoc_closed() {
11209 note there must be no space between EOFN and )
11214 function comsub_heredoc_closed { x=$(
11216 note there must be no space between EOFN and )
11219 function comsub_heredoc_closed {
11221 note there must be no space between EOFN and )
11225 function reread_heredoc_closed { x=$((
11227 note there must be no space between EOFN and )
11230 function reread_heredoc_closed {
11231 x=$(( x=$(cat <<EOFN
11232 note there must be no space between EOFN and )
11234 ) ; echo $x ) | tr u x )
11236 inline_heredoc_space() {
11238 note the space between EOFN and ) is actually part of the here document marker
11241 inline_heredoc_space() {
11243 note the space between EOFN and ) is actually part of the here document marker
11248 function comsub_heredoc_space { x=$(
11250 note the space between EOFN and ) is actually part of the here document marker
11253 function comsub_heredoc_space {
11254 x=$(x=$(cat <<EOFN\
11255 note the space between EOFN and ) is actually part of the here document marker
11259 function reread_heredoc_space { x=$((
11261 note the space between EOFN and ) is actually part of the here document marker
11264 function reread_heredoc_space {
11265 x=$(( x=$(cat <<EOFN\
11266 note the space between EOFN and ) is actually part of the here document marker
11268 ) ; echo $x ) | tr u x )
11270 inline_patch_motd() {
11271 x=$(sysctl -n kern.version | sed 1q)
11272 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
11273 ed -s /etc/motd 2>&1 <<-EOF
11280 EOF)" = @(?) ]] && rm -f /etc/motd
11281 if [[ ! -s /etc/motd ]]; then
11282 install -c -o root -g wheel -m 664 /dev/null /etc/motd
11283 print -- "$x\n" >/etc/motd
11286 inline_patch_motd() {
11287 x=$(sysctl -n kern.version | sed 1q )
11288 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
11296 )" = @(?) ]] && rm -f /etc/motd
11297 if [[ ! -s /etc/motd ]]
11299 install -c -o root -g wheel -m 664 /dev/null /etc/motd
11300 print -- "$x\n" >/etc/motd
11303 function comsub_patch_motd { x=$(
11304 x=$(sysctl -n kern.version | sed 1q)
11305 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
11306 ed -s /etc/motd 2>&1 <<-EOF
11313 EOF)" = @(?) ]] && rm -f /etc/motd
11314 if [[ ! -s /etc/motd ]]; then
11315 install -c -o root -g wheel -m 664 /dev/null /etc/motd
11316 print -- "$x\n" >/etc/motd
11319 function comsub_patch_motd {
11320 x=$(x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
11328 )" = @(?) ]] && 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 )
11330 function reread_patch_motd { x=$((
11331 x=$(sysctl -n kern.version | sed 1q)
11332 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
11333 ed -s /etc/motd 2>&1 <<-EOF
11340 EOF)" = @(?) ]] && rm -f /etc/motd
11341 if [[ ! -s /etc/motd ]]; then
11342 install -c -o root -g wheel -m 664 /dev/null /etc/motd
11343 print -- "$x\n" >/etc/motd
11346 function reread_patch_motd {
11347 x=$(( x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
11355 )" = @(?) ]] && 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 )
11357 inline_wdarrassign() {
11362 inline_wdarrassign() {
11370 function comsub_wdarrassign { x=$(
11375 function comsub_wdarrassign {
11376 x=$(case x in (x) a+=b ; \set -A c+ -- d e ;; esac )
11378 function reread_wdarrassign { x=$((
11383 function reread_wdarrassign {
11384 x=$(( case x in (x) a+=b ; \set -A c+ -- d e ;; esac ) | tr u x )
11387 name: comsub-torture-io
11389 Check the tree dump functions work correctly with I/O redirection
11391 if [[ -z $__progname ]]; then echo >&2 call me with __progname; exit 1; fi
11392 while IFS= read -r line; do
11393 if [[ $line = '#1' ]]; then
11396 elif [[ $line = EOFN* ]]; then
11397 fbody=$fbody$'\n'$line
11399 elif [[ $line != '#'* ]]; then
11400 fbody=$fbody$'\n\t'$line
11403 if (( lastf )); then
11404 x="inline_${nextf}() {"$fbody$'\n}\n'
11406 print -r -- "${x}typeset -f inline_$nextf" | "$__progname"
11407 x="function comsub_$nextf { x=\$("$fbody$'\n); }\n'
11409 print -r -- "${x}typeset -f comsub_$nextf" | "$__progname"
11410 x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n'
11412 print -r -- "${x}typeset -f reread_$nextf" | "$__progname"
11420 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
11421 #TPAREN_TPIPE_TLIST
11422 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
11424 cmd >&3 && >&3 echo ja || echo >&3 nein
11426 select file in *; do echo "<$file>" ; break >&3 ; done >&3
11428 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
11430 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
11431 #TIF_TBANG_TDBRACKET_TELIF
11432 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
11434 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
11436 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
11438 cat * >&3 |& >&3 ls
11439 #TFUNCT_TBRACE_TASYNC
11440 function korn { echo eins; echo >&3 zwei ; }
11441 bourne () { logger * >&3 & }
11443 echo $(true >&3) $((1+ 2))
11448 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
11451 vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" >&3
11453 function comsub_TCOM { x=$(
11454 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
11456 function comsub_TCOM {
11457 x=$(vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" >&3 )
11459 function reread_TCOM { x=$((
11460 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
11462 function reread_TCOM {
11463 x=$(( vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" >&3 ) | tr u x )
11465 inline_TPAREN_TPIPE_TLIST() {
11466 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
11468 inline_TPAREN_TPIPE_TLIST() {
11469 ( echo $foo | tr -dc 0-9 >&3
11472 function comsub_TPAREN_TPIPE_TLIST { x=$(
11473 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
11475 function comsub_TPAREN_TPIPE_TLIST {
11476 x=$(( echo $foo | tr -dc 0-9 >&3 ; echo >&3 ) >&3 )
11478 function reread_TPAREN_TPIPE_TLIST { x=$((
11479 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
11481 function reread_TPAREN_TPIPE_TLIST {
11482 x=$(( ( echo $foo | tr -dc 0-9 >&3 ; echo >&3 ) >&3 ) | tr u x )
11484 inline_TAND_TOR() {
11485 cmd >&3 && >&3 echo ja || echo >&3 nein
11487 inline_TAND_TOR() {
11488 cmd >&3 && echo ja >&3 || echo nein >&3
11490 function comsub_TAND_TOR { x=$(
11491 cmd >&3 && >&3 echo ja || echo >&3 nein
11493 function comsub_TAND_TOR {
11494 x=$(cmd >&3 && echo ja >&3 || echo nein >&3 )
11496 function reread_TAND_TOR { x=$((
11497 cmd >&3 && >&3 echo ja || echo >&3 nein
11499 function reread_TAND_TOR {
11500 x=$(( cmd >&3 && echo ja >&3 || echo nein >&3 ) | tr u x )
11503 select file in *; do echo "<$file>" ; break >&3 ; done >&3
11512 function comsub_TSELECT { x=$(
11513 select file in *; do echo "<$file>" ; break >&3 ; done >&3
11515 function comsub_TSELECT {
11516 x=$(select file in * ; do echo "<$file>" ; break >&3 ; done >&3 )
11518 function reread_TSELECT { x=$((
11519 select file in *; do echo "<$file>" ; break >&3 ; done >&3
11521 function reread_TSELECT {
11522 x=$(( select file in * ; do echo "<$file>" ; break >&3 ; done >&3 ) | tr u x )
11524 inline_TFOR_TTIME() {
11525 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
11527 inline_TFOR_TTIME() {
11533 function comsub_TFOR_TTIME { x=$(
11534 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
11536 function comsub_TFOR_TTIME {
11537 x=$(for i in {1,2,3} ; do time echo $i >&3 ; done >&3 )
11539 function reread_TFOR_TTIME { x=$((
11540 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
11542 function reread_TFOR_TTIME {
11543 x=$(( for i in {1,2,3} ; do time echo $i >&3 ; done >&3 ) | tr u x )
11546 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
11557 echo kann net bis drei zählen >&3
11561 function comsub_TCASE { x=$(
11562 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
11564 function comsub_TCASE {
11565 x=$(case $foo in (1) echo eins >&3 ;& (2) echo zwei >&3 ;| (*) echo kann net bis drei zählen >&3 ;; esac >&3 )
11567 function reread_TCASE { x=$((
11568 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
11570 function reread_TCASE {
11571 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 )
11573 inline_TIF_TBANG_TDBRACKET_TELIF() {
11574 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
11576 inline_TIF_TBANG_TDBRACKET_TELIF() {
11577 if ! [[ 1 = 1 ]] >&3
11580 elif [[ 1 = 2 ]] >&3
11587 function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$(
11588 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
11590 function comsub_TIF_TBANG_TDBRACKET_TELIF {
11591 x=$(if ! [[ 1 = 1 ]] >&3 ; then echo eins ; elif [[ 1 = 2 ]] >&3 ; then echo zwei ; else echo drei ; fi >&3 )
11593 function reread_TIF_TBANG_TDBRACKET_TELIF { x=$((
11594 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
11596 function reread_TIF_TBANG_TDBRACKET_TELIF {
11597 x=$(( if ! [[ 1 = 1 ]] >&3 ; then echo eins ; elif [[ 1 = 2 ]] >&3 ; then echo zwei ; else echo drei ; fi >&3 ) | tr u x )
11600 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
11612 function comsub_TWHILE { x=$(
11613 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
11615 function comsub_TWHILE {
11616 x=$(i=1 ; while { \let] " i < 10 " ; } >&3 ; do echo $i ; let ++i ; done >&3 )
11618 function reread_TWHILE { x=$((
11619 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
11621 function reread_TWHILE {
11622 x=$(( i=1 ; while { \let] " i < 10 " ; } >&3 ; do echo $i ; let ++i ; done >&3 ) | tr u x )
11625 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
11636 function comsub_TUNTIL { x=$(
11637 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
11639 function comsub_TUNTIL {
11640 x=$(i=10 ; until { \let] " !--i " ; } >&3 ; do echo $i ; done >&3 )
11642 function reread_TUNTIL { x=$((
11643 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
11645 function reread_TUNTIL {
11646 x=$(( i=10 ; until { \let] " !--i " ; } >&3 ; do echo $i ; done >&3 ) | tr u x )
11649 cat * >&3 |& >&3 ls
11655 function comsub_TCOPROC { x=$(
11656 cat * >&3 |& >&3 ls
11658 function comsub_TCOPROC {
11659 x=$(cat * >&3 |& ls >&3 )
11661 function reread_TCOPROC { x=$((
11662 cat * >&3 |& >&3 ls
11664 function reread_TCOPROC {
11665 x=$(( cat * >&3 |& ls >&3 ) | tr u x )
11667 inline_TFUNCT_TBRACE_TASYNC() {
11668 function korn { echo eins; echo >&3 zwei ; }
11669 bourne () { logger * >&3 & }
11671 inline_TFUNCT_TBRACE_TASYNC() {
11680 function comsub_TFUNCT_TBRACE_TASYNC { x=$(
11681 function korn { echo eins; echo >&3 zwei ; }
11682 bourne () { logger * >&3 & }
11684 function comsub_TFUNCT_TBRACE_TASYNC {
11685 x=$(function korn { echo eins ; echo zwei >&3 ; } ; bourne() { logger * >&3 & } )
11687 function reread_TFUNCT_TBRACE_TASYNC { x=$((
11688 function korn { echo eins; echo >&3 zwei ; }
11689 bourne () { logger * >&3 & }
11691 function reread_TFUNCT_TBRACE_TASYNC {
11692 x=$(( function korn { echo eins ; echo zwei >&3 ; } ; bourne() { logger * >&3 & } ) | tr u x )
11694 inline_COMSUB_EXPRSUB() {
11695 echo $(true >&3) $((1+ 2))
11697 inline_COMSUB_EXPRSUB() {
11698 echo $(true >&3 ) $((1+ 2))
11700 function comsub_COMSUB_EXPRSUB { x=$(
11701 echo $(true >&3) $((1+ 2))
11703 function comsub_COMSUB_EXPRSUB {
11704 x=$(echo $(true >&3 ) $((1+ 2)) )
11706 function reread_COMSUB_EXPRSUB { x=$((
11707 echo $(true >&3) $((1+ 2))
11709 function reread_COMSUB_EXPRSUB {
11710 x=$(( echo $(true >&3 ) $((1+ 2)) ) | tr u x )
11715 Check that non-subenvironment command substitution works
11735 You can now reliably use local and return in funsubs
11738 x=q; e=1; x=${ echo a; e=2; echo x$e;}; echo 1:y$x,$e,$?.
11739 x=q; e=1; x=${ echo a; typeset e=2; echo x$e;}; echo 2:y$x,$e,$?.
11740 x=q; e=1; x=${ echo a; typeset e=2; return 3; echo x$e;}; echo 3:y$x,$e,$?.
11748 Check that "value substitutions" work as advertised
11754 echo "before: x<$x> y<$y> z<$z> R<$REPLY>"
11757 echo "begin: x<$x> y<$y> z<$z> R<$REPLY>"
11762 echo "end: x<$x> y<$y> z<$z> R<$REPLY>"
11764 echo "after: x<$x> y<$y> z<$z> R<$REPLY>"
11765 # ensure trailing newlines are kept
11766 t=${|REPLY=$'foo\n\n';}
11768 echo -n this used to segfault
11769 echo ${|true;}$(true).
11771 before: x<1> y<2> z<3> R<4>
11772 begin: x<1> y<> z<3> R<>
11773 end: x<5> y<6> z<7> R<8>
11774 after: x<8> y<2> z<7> R<4>
11775 typeset t=$'foo\n\n'
11776 this used to segfault.
11778 name: event-subst-3
11780 Check that '!' substitution in noninteractive mode is ignored
11781 file-setup: file 755 "falsetto"
11785 file-setup: file 755 "!false"
11789 export PATH=.$PATHSEP$PATH
11797 ! false; then echo foo; else echo bar; fi
11806 name: event-subst-0
11808 Check that '!' substitution in interactive mode is ignored
11811 file-setup: file 755 "falsetto"
11815 file-setup: file 755 "!false"
11819 export PATH=.$PATHSEP$PATH
11827 ! false; then echo foo; else echo bar; fi
11835 expected-stderr-pattern:
11840 Check that "set -u" matches (future) SUSv4 requirement
11846 if [[ -n $v ]]; then
11881 (mypid=$$; try mypid)
11883 ) 2>&1 | sed -e 's/^[^]]*]//' -e 's/^[^:]*: *//'
11884 exit ${PIPESTATUS[0]}
11888 y: parameter not set
11892 y: parameter not set
11896 2: parameter not set
11898 1: parameter not set
11906 !: parameter not set
11917 Testsuite for nameref (bound variables)
11932 set|grep ^ir2|sed 's/^/s1: /'
11933 typeset|grep ' ir2'|sed -e 's/^/s2: /' -e 's/nameref/typeset -n/'
11934 set -A blub -- e1 e2 e3
11935 typeset -n ind=blub
11936 typeset -n ir2=blub[2]
11937 echo !ind[1]: ${!ind[1]}
11939 echo ind[1]: ${ind[1]}
11959 Testsuite for nameref (bound variables)
11960 Functions, argument given directly, after local
11963 typeset bar=lokal baz=auch
11995 Advanced testsuite for bound variables (ksh93 fails this)
11997 typeset -n foo=bar[i]
11998 set -A bar -- b c a
11999 for i in 0 1 2 3; do
12010 Ensure we don't run in an infinite loop
12014 typeset -n foo=fnord fnord=foo
12024 expected-stderr-pattern:
12025 /fnord: expression recurses on parameter/
12027 name: better-parens-1a
12029 Check support for ((…)) and $((…)) vs (…) and $(…)
12031 if ( (echo fubar)|tr u x); then
12040 name: better-parens-1b
12042 Check support for ((…)) and $((…)) vs (…) and $(…)
12044 echo $( (echo fubar)|tr u x) $?
12048 name: better-parens-1c
12050 Check support for ((…)) and $((…)) vs (…) and $(…)
12052 x=$( (echo fubar)|tr u x); echo $x $?
12056 name: better-parens-2a
12058 Check support for ((…)) and $((…)) vs (…) and $(…)
12060 if ((echo fubar)|tr u x); then
12069 name: better-parens-2b
12071 Check support for ((…)) and $((…)) vs (…) and $(…)
12073 echo $((echo fubar)|tr u x) $?
12077 name: better-parens-2c
12079 Check support for ((…)) and $((…)) vs (…) and $(…)
12081 x=$((echo fubar)|tr u x); echo $x $?
12085 name: better-parens-3a
12087 Check support for ((…)) and $((…)) vs (…) and $(…)
12089 if ( (echo fubar)|(tr u x)); then
12098 name: better-parens-3b
12100 Check support for ((…)) and $((…)) vs (…) and $(…)
12102 echo $( (echo fubar)|(tr u x)) $?
12106 name: better-parens-3c
12108 Check support for ((…)) and $((…)) vs (…) and $(…)
12110 x=$( (echo fubar)|(tr u x)); echo $x $?
12114 name: better-parens-4a
12116 Check support for ((…)) and $((…)) vs (…) and $(…)
12118 if ((echo fubar)|(tr u x)); then
12127 name: better-parens-4b
12129 Check support for ((…)) and $((…)) vs (…) and $(…)
12131 echo $((echo fubar)|(tr u x)) $?
12135 name: better-parens-4c
12137 Check support for ((…)) and $((…)) vs (…) and $(…)
12139 x=$((echo fubar)|(tr u x)); echo $x $?
12143 name: better-parens-5
12145 Another corner case
12147 ( (echo 'fo o$bar' "baz\$bla\"" m\$eh) | tr a A)
12148 ((echo 'fo o$bar' "baz\$bla\"" m\$eh) | tr a A)
12150 fo o$bAr bAz$blA" m$eh
12151 fo o$bAr bAz$blA" m$eh
12155 Test what the echo builtin does (mksh)
12157 echo -n 'foo\x40bar'
12164 Test what the echo builtin does (POSIX)
12165 Note: this follows Debian Policy 10.4 which mandates
12166 that -n shall be treated as an option, not XSI which
12167 mandates it shall be treated as string but escapes
12170 test -n "$POSH_VERSION" || set -o posix
12171 echo -n 'foo\x40bar'
12176 name: echo-test-3-mnbsd
12178 Test what the echo builtin does, and test a compatibility flag.
12181 "$__progname" -c 'echo -n 1=\\x40$1; echo -e \\x2E' -- foo bar
12182 "$__progname" -o posix -c 'echo -n 2=\\x40$1; echo -e \\x2E' -- foo bar
12183 "$__progname" -o sh -c 'echo -n 3=\\x40$1; echo -e \\x2E' -- foo bar
12189 name: echo-test-3-normal
12191 Test what the echo builtin does, and test a compatibility flag.
12192 category: !mnbsdash
12194 "$__progname" -c 'echo -n 1=\\x40$1; echo -e \\x2E' -- foo bar
12195 "$__progname" -o posix -c 'echo -n 2=\\x40$1; echo -e \\x2E' -- foo bar
12196 "$__progname" -o sh -c 'echo -n 3=\\x40$1; echo -e \\x2E' -- foo bar
12202 name: utilities-getopts-1
12204 getopts sets OPTIND correctly for unparsed option
12207 while getopts :a optc; do
12208 echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
12212 OPTARG=, OPTIND=2, optc=a.
12213 OPTARG=, OPTIND=3, optc=a.
12214 OPTARG=x, OPTIND=4, optc=?.
12217 name: utilities-getopts-2
12222 while getopts a: optc; do
12223 echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
12227 OPTARG=Mary, OPTIND=3, optc=a.
12228 OPTARG=, OPTIND=4, optc=?.
12230 expected-stderr-pattern: /.*-x.*option/
12232 name: utilities-getopts-3
12234 Check unsetting OPTARG
12237 getopts x:y opt && echo "${OPTARG-unset}"
12238 getopts x:y opt && echo "${OPTARG-unset}"
12245 Check the new wcswidth feature
12249 print octets: ${#s} .
12250 print 8-bit width: ${%s} .
12252 print characters: ${#s} .
12253 print columns: ${%s} .
12256 print octets: ${#s} .
12257 print 8-bit width: ${%s} .
12259 print characters: ${#s} .
12260 print columns: ${%s} .
12273 Check some corner cases
12289 Check some corner cases
12292 expected-stderr-pattern:
12298 Check some corner cases
12301 expected-stderr-pattern:
12307 Check some corner cases
12310 expected-stderr-pattern:
12316 Check some corner cases
12325 Check proper return values for realpath
12326 category: os:mirbsd
12339 x=$(realpath "$wd/$1" 2>&1); y=$?
12340 print $((++i)) "?$1" =${x##*$wd/} !$y
12366 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
12371 3 ?dir/file =dir/file !0
12372 4 ?dir/nix =dir/nix !0
12374 6 ?file/ =file/: Not a directory !20
12375 7 ?file/file =file/file: Not a directory !20
12376 8 ?file/nix =file/nix: Not a directory !20
12379 11 ?nix/file =nix/file: No such file or directory !2
12380 12 ?nix/nix =nix/nix: No such file or directory !2
12383 15 ?lndir/file =dir/file !0
12384 16 ?lndir/nix =dir/nix !0
12385 17 ?lnfile =file !0
12386 18 ?lnfile/ =lnfile/: Not a directory !20
12387 19 ?lnfile/file =lnfile/file: Not a directory !20
12388 20 ?lnfile/nix =lnfile/nix: Not a directory !20
12391 23 ?lnnix/file =lnnix/file: No such file or directory !2
12392 24 ?lnnix/nix =lnnix/nix: No such file or directory !2
12393 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
12397 Ensure that exactly two leading slashes are not collapsed
12398 POSIX guarantees this exception, e.g. for UNC paths on Cygwin
12399 category: os:mirbsd
12409 realpath /usr///bin
12418 realpath //usr/include/../bin
12435 Crashed during March 2011, fixed on vernal equinōx ☺
12436 category: os:mirbsd,os:openbsd
12438 export MALLOC_OPTIONS=FGJPRSX
12439 "$__progname" -c 'x=$(tr z r <<<baz); echo $x'
12445 Check test - bug#465250
12447 test \( ! -e \) ; echo $?
12453 Check test - bug#465250
12455 test \( -e \) ; echo $?
12461 Check test - bug#465250
12463 test ! -e ; echo $?
12469 Check test - bug#465250
12477 Check that zsh case variants work
12511 Check that case end tokens are not mixed up (Debian #220272)
12514 for value in 'x' '}' 'esac'; do
12515 print -n "$((++i))($value)bourne "
12520 print -n "$((++i))($value)korn "
12534 name: command-shift
12536 Check that 'command shift' works
12539 echo "before 0='$0' 1='$1' 2='$2'"
12541 echo "after 0='$0' 1='$1' 2='$2'"
12544 echo "before 0='$0' 1='$1' 2='$2'"
12546 echo "after 0='$0' 1='$1' 2='$2'"
12548 echo = without command
12550 echo = with command
12555 before 0='snc' 1='一' 2='二'
12556 after 0='snc' 1='二' 2=''
12558 before 0='swc' 1='一' 2='二'
12559 after 0='swc' 1='二' 2=''
12562 name: command-pvV-posix-priorities
12564 For POSIX compatibility, command -v should find aliases and reserved
12565 words, and command -p[vV] should find aliases, reserved words, and
12566 builtins over external commands.
12569 alias foo="bar baz"
12571 for word in 'if' 'foo' 'bar' 'set' 'true'; do
12573 command -pv "$word"
12575 command -pV "$word"
12580 if is a reserved word
12581 if is a reserved word
12582 alias foo='bar baz'
12583 alias foo='bar baz'
12584 foo is an alias for 'bar baz'
12585 foo is an alias for 'bar baz'
12592 set is a special shell builtin
12593 set is a special shell builtin
12596 true is a shell builtin
12597 true is a shell builtin
12599 name: whence-preserve-tradition
12601 This regression test is to ensure that the POSIX compatibility
12602 changes for 'command' (see previous test) do not affect traditional
12603 'whence' behaviour.
12604 category: os:mirbsd
12607 alias foo="bar baz"
12609 for word in 'if' 'foo' 'bar' 'set' 'true'; do
12617 if is a reserved word
12620 foo is an alias for 'bar baz'
12626 set is a special shell builtin
12630 true is a shell builtin
12631 true is a tracked alias for /bin/true
12635 Check that the compiler did not optimise-break them
12636 (lex.c has got a similar one in SHEREDELIM)
12641 while (( ++i < 256 )); do
12644 s+=$'\xC2\xA0\xE2\x82\xAC\xEF\xBF\xBD\xEF\xBF\xBE\xEF\xBF\xBF\xF0\x90\x80\x80.'
12647 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.'
12649 name: stateptr-underflow
12651 This check overflows an Xrestpos stored in a short in R40
12654 function Lb64decode {
12655 [[ -o utf8-mode ]]; local u=$?
12658 [[ -n $s ]] || { s=$(cat;print x); s=${s%x}; }
12659 local -i i=0 n=${#s} p=0 v x
12662 while (( i < n )); do
12666 ([A-Z]) (( v = 1#$c - 65 )) ;;
12667 ([a-z]) (( v = 1#$c - 71 )) ;;
12668 ([0-9]) (( v = 1#$c + 4 )) ;;
12673 (( x = (x << 6) | v ))
12676 (1) (( o = (x >> 4) & 255 )) ;;
12677 (2) (( o = (x >> 2) & 255 )) ;;
12678 (3) (( o = x & 255 ))
12690 while (( ++i < 12120 )); do
12693 Lb64decode $s >/dev/null
12697 Check that "set -x" doesn't redirect too quickly
12699 print '#!'"$__progname" >bash
12701 echo 'GNU bash, version 2.05b.0(1)-release (i386-ecce-mirbsd10)
12702 Copyright (C) 2002 Free Software Foundation, Inc.'
12705 "$__progname" -xc 'foo=$(./bash --version 2>&1 | sed q); echo "=$foo="'
12707 =GNU bash, version 2.05b.0(1)-release (i386-ecce-mirbsd10)=
12708 expected-stderr-pattern:
12713 Check that "set -x" is off during PS4 expansion
12720 PS4='[(p:$-)$(f)] '
12722 set -x -o inherit-xtrace
12731 [(p:sh)(f1:sh)(f2:sh)] print '(o1:shx)'
12732 [(p:sh)(f1:sh)(f2:sh)] set +x
12736 Check that FKSH functions have their own shell flags
12737 category: shell:legacy-no
12739 [[ $KSH_VERSION = Version* ]] && set +B
12754 name: fksh-flags-legacy
12756 Check that even FKSH functions share the shell flags
12757 category: shell:legacy-yes
12759 [[ $KSH_VERSION = Version* ]] && set +B
12776 Check that !FKSH functions share the shell flags
12778 [[ $KSH_VERSION = Version* ]] && set +B