1 # $MirOS: src/bin/mksh/check.t,v 1.667.2.3 2015/03/01 15:42:51 tg Exp $
4 # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
5 # 2011, 2012, 2013, 2014, 2015
6 # Thorsten Glaser <tg@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://openbsd.cs.toronto.edu/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
33 @(#)MIRBSD KSH R50 2015/03/01
35 Check version of shell.
39 category: shell:legacy-no
42 @(#)LEGACY KSH R50 2015/03/01
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
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 only one side of ternary operator is evaluated
267 echo $((1 ? 20 : (x+=2)))
269 echo $((0 ? (y+=2) : 30))
279 Check that assignments not done on non-evaluated side of ternary
285 echo $((1 ? 20 : (x+=2)))
287 echo $((0 ? (y+=2) : 30))
297 Check that assignments not done on non-evaluated side of ternary
298 operator and this construct is parsed correctly (Debian #445651)
308 Check that preun/postun not done on non-evaluated side of ternary
311 (( m = n = 0, 1 ? n++ : m++ ? 2 : 3 ))
313 m=0; echo $(( 0 ? ++m : 2 )); echo $m
314 m=0; echo $(( 0 ? m++ : 2 )); echo $m
322 name: arith-ternary-prec-1
324 Check precedence of ternary operator vs assignment
328 expected-exit: e != 0
329 expected-stderr-pattern:
330 /.*:.*1 \? 20 : x\+=2.*lvalue.*\n$/
332 name: arith-ternary-prec-2
334 Check precedence of ternary operator vs assignment
337 echo $((0 ? x+=2 : 20))
341 name: arith-div-assoc-1
343 Check associativity of division operator
349 name: arith-div-byzero
351 Check division by zero errors out
357 expected-stderr-pattern:
360 name: arith-div-intmin-by-minusone
362 Check division overflow wraps around silently
365 echo signed:$((-2147483648 / -1))r$((-2147483648 % -1)).
366 echo unsigned:$((# -2147483648 / -1))r$((# -2147483648 % -1)).
368 signed:-2147483648r0.
369 unsigned:0r2147483648.
371 name: arith-div-intmin-by-minusone-64
373 Check division overflow wraps around silently
376 echo signed:$((-9223372036854775808 / -1))r$((-9223372036854775808 % -1)).
377 echo unsigned:$((# -9223372036854775808 / -1))r$((# -9223372036854775808 % -1)).
379 signed:-9223372036854775808r0.
380 unsigned:0r9223372036854775808.
382 name: arith-assop-assoc-1
384 Check associativity of assignment-operator operator
386 typeset -i i=1 j=2 k=3
387 echo $((i += j += k))
393 name: arith-mandatory
395 Passing of this test is *mandatory* for a valid mksh executable!
396 category: shell:legacy-no
401 print -r -- $((x++)):$sari=$uari. #0
403 print -r -- $((x++)):$sari=$uari. #1
404 sari=2147483647 uari=2147483647
405 print -r -- $((x++)):$sari=$uari. #2
407 print -r -- $((x++)):$sari=$uari. #3
409 let 'sari *= 2' 'uari *= 2'
411 print -r -- $((x++)):$sari=$uari. #4
413 print -r -- $((x++)):$sari=$uari. #5
414 sari=-2147483648 uari=-2147483648
415 print -r -- $((x++)):$sari=$uari. #6
417 print -r -- $((x++)):$sari=$uari. #7
419 ((# uari = -5 >> 1 ))
420 print -r -- $((x++)):$sari=$uari. #8
423 print -r -- $((x++)):$sari=$uari. #9
427 2:2147483647=2147483647.
428 3:-2147483648=2147483648.
431 6:-2147483648=2147483648.
432 7:2147483647=2147483647.
436 name: arith-unsigned-1
438 Check if unsigned arithmetics work
442 echo x1 $((-1)) $((#-1))
446 vs=4123456789; vu=4123456789
448 (( vs %= 2147483647 ))
449 (( vu %= 2147483647 ))
451 vs=4123456789; vu=4123456789
452 (( # vs %= 2147483647 ))
453 (( # vu %= 2147483647 ))
455 # make sure the calculation does not change unsigned flag
456 vs=4123456789; vu=4123456789
459 echo x6 $((# vs % 2147483647)) $((# vu % 2147483647))
464 echo x7 ${va[#4123456789%2147483647]}
467 x2 -171510507 4123456789
468 x3 -171510507 4123456789
469 x4 1975973142 1975973142
470 x5 -171510507 4123456789
471 x6 1975973142 1975973142
474 name: arith-limit32-1
476 Check if arithmetics are 32 bit
480 echo x1 $((-1)) $((#-1))
484 vs=2147483647; vu=2147483647
488 vs=4294967295; vu=4294967295
496 x2 2147483647 2147483647
497 x3 -2147483648 2147483648
502 name: arith-limit64-1
504 Check if arithmetics are 64 bit
508 echo x1 $((-1)) $((#-1))
512 vs=9223372036854775807; vu=9223372036854775807
516 vs=18446744073709551615; vu=18446744073709551615
523 x1 -1 18446744073709551615
524 x2 9223372036854775807 9223372036854775807
525 x3 -9223372036854775808 9223372036854775808
526 x4 -1 18446744073709551615
532 Check that \newline is not collapsed after #
542 Check that \newline is not collapsed inside single quotes
554 Check that \newline is not collapsed inside single quotes
566 Check interaction of aliases, single quotes and here-documents
567 with backslash-newline
568 (don't know what POSIX has to say about this)
590 Check what happens with backslash at end of input
591 (the old Bourne shell trashes them; so do we)
600 # Places \newline should be collapsed
604 Check that \newline is collapsed before, in the middle of, and
616 Check that \newline is collapsed in $ sequences
640 Check that \newline is collapsed in $(..) and `...` sequences
665 Check that \newline is collapsed in $((..)) sequences
676 echo $((1+2+3+4+5+6)\
687 Check that \newline is collapsed in double quoted strings
702 Check that \newline is collapsed in here document delimiters
703 (ksh93 fails second part of this)
725 Check that \newline is collapsed in double-quoted here-document
744 Check that \newline is collapsed in various 2+ character tokens
789 Check that \ at the end of an alias is collapsed when followed
791 (don't know what POSIX has to say about this)
801 Check that \newline in a keyword is collapsed
811 # Places \newline should be collapsed (ksh extensions)
815 Check that \newline is collapsed in extended globbing
832 Check that \newline is collapsed in ((...)) expressions
847 See if break breaks out of loops
849 for i in a b c; do echo $i; break; echo bad-$i; done
851 for i in a b c; do echo $i; break 1; echo bad-$i; done
877 See if break breaks out of nested loops
894 What if break used outside of any loops
895 (ksh88,ksh93 don't print error messages here)
898 expected-stderr-pattern:
903 What if break N used when only N-1 loops
904 (ksh88,ksh93 don't print error messages here)
906 for i in a b c; do echo $i; break 2; echo bad-$i; done
911 expected-stderr-pattern:
916 Error if break argument isn't a number
918 for i in a b c; do echo $i; break abc; echo more-$i; done
922 expected-exit: e != 0
923 expected-stderr-pattern:
928 See if continue continues loops
930 for i in a b c; do echo $i; continue; echo bad-$i ; done
932 for i in a b c; do echo $i; continue 1; echo bad-$i; done
968 See if continue breaks out of nested loops
987 What if continue used outside of any loops
988 (ksh88,ksh93 don't print error messages here)
991 expected-stderr-pattern:
996 What if continue N used when only N-1 loops
997 (ksh88,ksh93 don't print error messages here)
999 for i in a b c; do echo $i; continue 2; echo bad-$i; done
1006 expected-stderr-pattern:
1011 Error if continue argument isn't a number
1013 for i in a b c; do echo $i; continue abc; echo more-$i; done
1017 expected-exit: e != 0
1018 expected-stderr-pattern:
1023 Test someone's CD history package (uses arrays)
1025 # go to known place before doing anything
1039 if [ "$CDHISTFILE" -a -r "$CDHISTFILE" ] # if directory history exists
1043 while read -r t # read directory history file
1049 if [ "${CDHIST[0]}" != "$PWD" -a "$PWD" != "" ]
1051 _cdins # insert $PWD into cd history
1054 cdlen=${#CDHIST[*]} # number of elements in history
1058 if [ "$OLDPWD" = "" ] && ((cdlen>1))
1060 'print' ${CDHIST[1]}
1068 -l) # print directory list
1071 while (((i=i-1)>=0))
1074 'print' "$num ${CDHIST[i]}"
1078 -[0-9]|-[0-9][0-9]) # cd to dir in list
1079 if (((i=${1#-})<cdlen))
1081 'print' ${CDHIST[i]}
1089 -*) # cd to matched dir in list
1094 case ${CDHIST[i]} in
1096 'print' ${CDHIST[i]}
1116 _cdins # insert $PWD into cd history
1118 if [ "$CDHISTFILE" ]
1120 cdlen=${#CDHIST[*]} # number of elements in history
1125 'print' -r ${CDHIST[i]} # update directory history
1131 function _cdins # insert $PWD into cd history
1132 { # meant to be called only by _cd
1136 while ((i<${#CDHIST[*]})) # see if dir is already in list
1138 if [ "${CDHIST[$i]}" = "$PWD" ]
1145 if ((i>22)) # limit max size of list
1150 while (((i=i-1)>=0)) # bump old dirs in list
1152 CDHIST[i+1]=${CDHIST[i]}
1155 CDHIST[0]=$PWD # insert new directory in list
1183 Check package for cd -Pe
1185 # the mv command fails on Cygwin
1186 # Hurd aborts the testsuite (permission denied)
1187 # QNX does not find subdir to cd into
1188 category: !os:cygwin,!os:gnu,!os:msys,!os:nto,!nosymlink
1189 file-setup: file 644 "x"
1190 mkdir noread noread/target noread/target/subdir
1197 echo 1=$?,${PWD#$bwd/}
1198 epwd=$($TSHELL -c pwd 2>/dev/null)
1199 # This unexpectedly succeeds on GNU/Linux and MidnightBSD
1202 mv ../../noread ../../renamed
1204 echo 2=$?,${PWD#$bwd/}
1207 rm -rf noread link renamed
1209 export TSHELL="$__progname"
1216 2=0,noread/target/subdir
1220 2=1,noread/target/subdir
1224 Check that prompt not printed when processing ENV
1225 env-setup: !ENV=./foo!
1226 file-setup: file 644 "foo"
1241 Check that weird ${foo+bar} constructs are parsed correctly
1243 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
1244 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "<$x> "; done' >pfs
1246 (echo 1 ${IFS+'}'z}) 2>/dev/null || echo failed in 1
1247 (echo 2 "${IFS+'}'z}") 2>/dev/null || echo failed in 2
1248 (echo 3 "foo ${IFS+'bar} baz") 2>/dev/null || echo failed in 3
1249 (echo -n '4 '; ./pfn "foo ${IFS+"b c"} baz") 2>/dev/null || echo failed in 4
1250 (echo -n '5 '; ./pfn "foo ${IFS+b c} baz") 2>/dev/null || echo failed in 5
1251 (echo 6 ${IFS+"}"z}) 2>/dev/null || echo failed in 6
1252 (echo 7 "${IFS+"}"z}") 2>/dev/null || echo failed in 7
1253 (echo 8 "${IFS+\"}\"z}") 2>/dev/null || echo failed in 8
1254 (echo 9 "${IFS+\"\}\"z}") 2>/dev/null || echo failed in 9
1255 (echo 10 foo ${IFS+'bar} baz'}) 2>/dev/null || echo failed in 10
1256 (echo 11 "$(echo "${IFS+'}'z}")") 2>/dev/null || echo failed in 11
1257 (echo 12 "$(echo ${IFS+'}'z})") 2>/dev/null || echo failed in 12
1258 (echo 13 ${IFS+\}z}) 2>/dev/null || echo failed in 13
1259 (echo 14 "${IFS+\}z}") 2>/dev/null || echo failed in 14
1260 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
1261 l=t; (echo 16 ${IFS+h`echo -n i ${IFS+$l}h`ere}) 2>/dev/null || echo failed in 16
1262 l=t; (echo 17 ${IFS+h$(echo -n i ${IFS+$l}h)ere}) 2>/dev/null || echo failed in 17
1263 l=t; (echo 18 "${IFS+h`echo -n i ${IFS+$l}h`ere}") 2>/dev/null || echo failed in 18
1264 l=t; (echo 19 "${IFS+h$(echo -n i ${IFS+$l}h)ere}") 2>/dev/null || echo failed in 19
1265 l=t; (echo 20 ${IFS+h`echo -n i "${IFS+$l}"h`ere}) 2>/dev/null || echo failed in 20
1266 l=t; (echo 21 ${IFS+h$(echo -n i "${IFS+$l}"h)ere}) 2>/dev/null || echo failed in 21
1267 l=t; (echo 22 "${IFS+h`echo -n i "${IFS+$l}"h`ere}") 2>/dev/null || echo failed in 22
1268 l=t; (echo 23 "${IFS+h$(echo -n i "${IFS+$l}"h)ere}") 2>/dev/null || echo failed in 23
1269 key=value; (echo -n '24 '; ./pfn "${IFS+'$key'}") 2>/dev/null || echo failed in 24
1270 key=value; (echo -n '25 '; ./pfn "${IFS+"'$key'"}") 2>/dev/null || echo failed in 25 # ksh93: “'$key'”
1271 key=value; (echo -n '26 '; ./pfn ${IFS+'$key'}) 2>/dev/null || echo failed in 26
1272 key=value; (echo -n '27 '; ./pfn ${IFS+"'$key'"}) 2>/dev/null || echo failed in 27
1273 (echo -n '28 '; ./pfn "${IFS+"'"x ~ x'}'x"'}"x}" #') 2>/dev/null || echo failed in 28
1274 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
1275 (echo -n '30 '; ./pfs ${IFS+foo 'b\
1276 ar' baz}; echo .) 2>/dev/null || (echo failed in 30; echo failed in 31)
1277 (echo -n '32 '; ./pfs ${IFS+foo "b\
1278 ar" baz}; echo .) 2>/dev/null || echo failed in 32
1279 (echo -n '33 '; ./pfs "${IFS+foo 'b\
1280 ar' baz}"; echo .) 2>/dev/null || echo failed in 33
1281 (echo -n '34 '; ./pfs "${IFS+foo "b\
1282 ar" baz}"; echo .) 2>/dev/null || echo failed in 34
1283 (echo -n '35 '; ./pfs ${v=a\ b} x ${v=c\ d}; echo .) 2>/dev/null || echo failed in 35
1284 (echo -n '36 '; ./pfs "${v=a\ b}" x "${v=c\ d}"; echo .) 2>/dev/null || echo failed in 36
1285 (echo -n '37 '; ./pfs ${v-a\ b} x ${v-c\ d}; echo .) 2>/dev/null || echo failed in 37
1286 (echo 38 ${IFS+x'a'y} / "${IFS+x'a'y}" .) 2>/dev/null || echo failed in 38
1287 foo="x'a'y"; (echo 39 ${foo%*'a'*} / "${foo%*'a'*}" .) 2>/dev/null || echo failed in 39
1288 foo="a b c"; (echo -n '40 '; ./pfs "${foo#a}"; echo .) 2>/dev/null || echo failed in 40
1304 15 <foo abx{ {{{}b c d{} bar> <}> <baz> .
1318 29 <foo> <abx{ {{> <{}b> <c> <d{}> <bar> <}> <baz> .
1321 32 <foo> <bar> <baz> .
1322 33 <foo 'bar' baz> .
1324 35 <a> <b> <x> <a> <b> .
1325 36 <a\ b> <x> <a\ b> .
1326 37 <a b> <x> <c d> .
1331 name: expand-unglob-dblq
1333 Check that regular "${foo+bar}" constructs are parsed correctly
1338 test x"$v" = x"-" && unset v
1339 (echo "$1 plus norm foo ${v+'bar'} baz")
1340 (echo "$1 dash norm foo ${v-'bar'} baz")
1341 (echo "$1 eqal norm foo ${v='bar'} baz")
1342 (echo "$1 qstn norm foo ${v?'bar'} baz") 2>/dev/null || \
1343 echo "$1 qstn norm -> error"
1344 (echo "$1 PLUS norm foo ${v:+'bar'} baz")
1345 (echo "$1 DASH norm foo ${v:-'bar'} baz")
1346 (echo "$1 EQAL norm foo ${v:='bar'} baz")
1347 (echo "$1 QSTN norm foo ${v:?'bar'} baz") 2>/dev/null || \
1348 echo "$1 QSTN norm -> error"
1352 test x"$v" = x"-" && unset v
1353 (echo "$1 plus parn foo ${v+(bar)} baz")
1354 (echo "$1 dash parn foo ${v-(bar)} baz")
1355 (echo "$1 eqal parn foo ${v=(bar)} baz")
1356 (echo "$1 qstn parn foo ${v?(bar)} baz") 2>/dev/null || \
1357 echo "$1 qstn parn -> error"
1358 (echo "$1 PLUS parn foo ${v:+(bar)} baz")
1359 (echo "$1 DASH parn foo ${v:-(bar)} baz")
1360 (echo "$1 EQAL parn foo ${v:=(bar)} baz")
1361 (echo "$1 QSTN parn foo ${v:?(bar)} baz") 2>/dev/null || \
1362 echo "$1 QSTN parn -> error"
1366 test x"$v" = x"-" && unset v
1367 (echo "$1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz")
1368 (echo "$1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz")
1369 (echo "$1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz")
1370 (echo "$1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz") 2>/dev/null || \
1371 echo "$1 qstn brac -> error"
1372 (echo "$1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz")
1373 (echo "$1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz")
1374 (echo "$1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz")
1375 (echo "$1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz") 2>/dev/null || \
1376 echo "$1 QSTN brac -> error"
1389 1 dash norm foo 'bar' baz
1390 1 eqal norm foo 'bar' baz
1391 1 qstn norm -> error
1393 1 DASH norm foo 'bar' baz
1394 1 EQAL norm foo 'bar' baz
1395 1 QSTN norm -> error
1396 2 plus norm foo 'bar' baz
1401 2 DASH norm foo 'bar' baz
1402 2 EQAL norm foo 'bar' baz
1403 2 QSTN norm -> error
1404 3 plus norm foo 'bar' baz
1405 3 dash norm foo x baz
1406 3 eqal norm foo x baz
1407 3 qstn norm foo x baz
1408 3 PLUS norm foo 'bar' baz
1409 3 DASH norm foo x baz
1410 3 EQAL norm foo x baz
1411 3 QSTN norm foo x baz
1413 4 dash parn foo (bar) baz
1414 4 eqal parn foo (bar) baz
1415 4 qstn parn -> error
1417 4 DASH parn foo (bar) baz
1418 4 EQAL parn foo (bar) baz
1419 4 QSTN parn -> error
1420 5 plus parn foo (bar) baz
1425 5 DASH parn foo (bar) baz
1426 5 EQAL parn foo (bar) baz
1427 5 QSTN parn -> error
1428 6 plus parn foo (bar) baz
1429 6 dash parn foo x baz
1430 6 eqal parn foo x baz
1431 6 qstn parn foo x baz
1432 6 PLUS parn foo (bar) baz
1433 6 DASH parn foo x baz
1434 6 EQAL parn foo x baz
1435 6 QSTN parn foo x baz
1436 7 plus brac foo c } baz
1437 7 dash brac foo ax{{{}b c d{} baz
1438 7 eqal brac foo ax{{{}b c ax{{{}b} baz
1439 7 qstn brac -> error
1440 7 PLUS brac foo c } baz
1441 7 DASH brac foo ax{{{}b c d{} baz
1442 7 EQAL brac foo ax{{{}b c ax{{{}b} baz
1443 7 QSTN brac -> error
1444 8 plus brac foo ax{{{}b c d{} baz
1445 8 dash brac foo c } baz
1446 8 eqal brac foo c } baz
1447 8 qstn brac foo c } baz
1448 8 PLUS brac foo c } baz
1449 8 DASH brac foo ax{{{}b c d{} baz
1450 8 EQAL brac foo ax{{{}b c ax{{{}b} baz
1451 8 QSTN brac -> error
1452 9 plus brac foo ax{{{}b c d{} baz
1453 9 dash brac foo x c x} baz
1454 9 eqal brac foo x c x} baz
1455 9 qstn brac foo x c x} baz
1456 9 PLUS brac foo ax{{{}b c d{} baz
1457 9 DASH brac foo x c x} baz
1458 9 EQAL brac foo x c x} baz
1459 9 QSTN brac foo x c x} baz
1461 name: expand-unglob-unq
1463 Check that regular ${foo+bar} constructs are parsed correctly
1468 test x"$v" = x"-" && unset v
1469 (echo $1 plus norm foo ${v+'bar'} baz)
1470 (echo $1 dash norm foo ${v-'bar'} baz)
1471 (echo $1 eqal norm foo ${v='bar'} baz)
1472 (echo $1 qstn norm foo ${v?'bar'} baz) 2>/dev/null || \
1473 echo "$1 qstn norm -> error"
1474 (echo $1 PLUS norm foo ${v:+'bar'} baz)
1475 (echo $1 DASH norm foo ${v:-'bar'} baz)
1476 (echo $1 EQAL norm foo ${v:='bar'} baz)
1477 (echo $1 QSTN norm foo ${v:?'bar'} baz) 2>/dev/null || \
1478 echo "$1 QSTN norm -> error"
1482 test x"$v" = x"-" && unset v
1483 (echo $1 plus parn foo ${v+\(bar')'} baz)
1484 (echo $1 dash parn foo ${v-\(bar')'} baz)
1485 (echo $1 eqal parn foo ${v=\(bar')'} baz)
1486 (echo $1 qstn parn foo ${v?\(bar')'} baz) 2>/dev/null || \
1487 echo "$1 qstn parn -> error"
1488 (echo $1 PLUS parn foo ${v:+\(bar')'} baz)
1489 (echo $1 DASH parn foo ${v:-\(bar')'} baz)
1490 (echo $1 EQAL parn foo ${v:=\(bar')'} baz)
1491 (echo $1 QSTN parn foo ${v:?\(bar')'} baz) 2>/dev/null || \
1492 echo "$1 QSTN parn -> error"
1496 test x"$v" = x"-" && unset v
1497 (echo $1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz)
1498 (echo $1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz)
1499 (echo $1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz)
1500 (echo $1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz) 2>/dev/null || \
1501 echo "$1 qstn brac -> error"
1502 (echo $1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz)
1503 (echo $1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz)
1504 (echo $1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz)
1505 (echo $1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz) 2>/dev/null || \
1506 echo "$1 QSTN brac -> error"
1519 1 dash norm foo bar baz
1520 1 eqal norm foo bar baz
1521 1 qstn norm -> error
1523 1 DASH norm foo bar baz
1524 1 EQAL norm foo bar baz
1525 1 QSTN norm -> error
1526 2 plus norm foo bar baz
1531 2 DASH norm foo bar baz
1532 2 EQAL norm foo bar baz
1533 2 QSTN norm -> error
1534 3 plus norm foo bar baz
1535 3 dash norm foo x baz
1536 3 eqal norm foo x baz
1537 3 qstn norm foo x baz
1538 3 PLUS norm foo bar baz
1539 3 DASH norm foo x baz
1540 3 EQAL norm foo x baz
1541 3 QSTN norm foo x baz
1543 4 dash parn foo (bar) baz
1544 4 eqal parn foo (bar) baz
1545 4 qstn parn -> error
1547 4 DASH parn foo (bar) baz
1548 4 EQAL parn foo (bar) baz
1549 4 QSTN parn -> error
1550 5 plus parn foo (bar) baz
1555 5 DASH parn foo (bar) baz
1556 5 EQAL parn foo (bar) baz
1557 5 QSTN parn -> error
1558 6 plus parn foo (bar) baz
1559 6 dash parn foo x baz
1560 6 eqal parn foo x baz
1561 6 qstn parn foo x baz
1562 6 PLUS parn foo (bar) baz
1563 6 DASH parn foo x baz
1564 6 EQAL parn foo x baz
1565 6 QSTN parn foo x baz
1566 7 plus brac foo c } baz
1567 7 dash brac foo ax{{{}b c d{} baz
1568 7 eqal brac foo ax{{{}b c ax{{{}b} baz
1569 7 qstn brac -> error
1570 7 PLUS brac foo c } baz
1571 7 DASH brac foo ax{{{}b c d{} baz
1572 7 EQAL brac foo ax{{{}b c ax{{{}b} baz
1573 7 QSTN brac -> error
1574 8 plus brac foo ax{{{}b c d{} baz
1575 8 dash brac foo c } baz
1576 8 eqal brac foo c } baz
1577 8 qstn brac foo c } baz
1578 8 PLUS brac foo c } baz
1579 8 DASH brac foo ax{{{}b c d{} baz
1580 8 EQAL brac foo ax{{{}b c ax{{{}b} baz
1581 8 QSTN brac -> error
1582 9 plus brac foo ax{{{}b c d{} baz
1583 9 dash brac foo x c x} baz
1584 9 eqal brac foo x c x} baz
1585 9 qstn brac foo x c x} baz
1586 9 PLUS brac foo ax{{{}b c d{} baz
1587 9 DASH brac foo x c x} baz
1588 9 EQAL brac foo x c x} baz
1589 9 QSTN brac foo x c x} baz
1591 name: expand-threecolons-dblq
1593 Check for a particular thing that used to segfault
1596 echo "${TEST:1:2:3}"
1597 echo $? but still living
1598 expected-stderr-pattern:
1602 name: expand-threecolons-unq
1604 Check for a particular thing that used to not error out
1608 echo $? but still living
1609 expected-stderr-pattern:
1613 name: expand-weird-1
1615 Check corner case of trim expansion vs. $# vs. ${#var}
1617 set 1 2 3 4 5 6 7 8 9 10 11
1618 echo ${#} # value of $#
1619 echo ${##} # length of $#
1620 echo ${##1} # $# trimmed 1
1621 set 1 2 3 4 5 6 7 8 9 10 11 12
1629 name: expand-weird-2
1631 Check corner case of ${var?} vs. ${#var}
1641 name: expand-weird-3
1643 Check that trimming works with positional parameters (Debian #48453)
1654 name: expand-number-1
1656 Check that positional arguments do not overflow
1658 echo "1 ${12345678901234567890} ."
1664 Check that globbing isn't done when glob has syntax error
1665 file-setup: file 644 "abcx"
1666 file-setup: file 644 "abcz"
1667 file-setup: file 644 "bbc"
1677 Check that globbing isn't done when glob has syntax error
1678 (AT&T ksh fails this test)
1679 file-setup: file 644 "abcx"
1680 file-setup: file 644 "abcz"
1681 file-setup: file 644 "bbc"
1687 name: eglob-infinite-plus
1689 Check that shell doesn't go into infinite loop expanding +(...)
1691 file-setup: file 644 "abc"
1706 Check that eglobbing isn't done on substitution results
1707 file-setup: file 644 "abc"
1714 name: eglob-nomatch-1
1716 Check that the pattern doesn't match
1718 echo 1: no-file+(a|b)stuff
1719 echo 2: no-file+(a*(c)|b)stuff
1720 echo 3: no-file+((((c)))|b)stuff
1722 1: no-file+(a|b)stuff
1723 2: no-file+(a*(c)|b)stuff
1724 3: no-file+((((c)))|b)stuff
1728 Check that the pattern matches correctly
1729 file-setup: file 644 "abd"
1730 file-setup: file 644 "acd"
1731 file-setup: file 644 "abac"
1735 echo 3: *(a(b|c)) # (...|...) can be used within X(..)
1736 echo 4: a[b*(foo|bar)]d # patterns not special inside [...]
1745 Simple negation tests
1747 case foo in !(foo|bar)) echo yes;; *) echo no;; esac
1748 case bar in !(foo|bar)) echo yes;; *) echo no;; esac
1757 case foo in *(a|b[)) echo yes;; *) echo no;; esac
1758 case foo in *(a|b[)|f*) echo yes;; *) echo no;; esac
1759 case '*(a|b[)' in *(a|b[)) echo yes;; *) echo no;; esac
1767 Eglobbing in trim expressions...
1768 (AT&T ksh fails this - docs say # matches shortest string, ## matches
1784 Check eglobbing works in trims...
1787 echo 1: ${x#*(a|b)cd}
1788 echo 2: "${x#*(a|b)cd}"
1789 echo 3: ${x#"*(a|b)cd"}
1799 Check eglobbing works in trims, for Korn Shell
1800 Ensure eglobbing does not work for reduced-feature /bin/sh
1806 echo "<${x%bar|baz},${y%bar|baz},${z%\?}>"
1807 echo "<${x%ba(r|z)},${y%ba(r|z)}>"
1809 echo "<${x%bar|baz},${y%bar|baz},${z%\?}>"
1815 <foobar,foobaz,fooba>
1818 name: eglob-substrpl-1
1820 Check eglobbing works in substs... and they work at all
1822 [[ -n $BASH_VERSION ]] && shopt -s extglob
1823 x=1222321_ab/cde_b/c_1221
1832 echo 8: ${x//+(2)/4}
1833 echo 9: ${x/b/c/e/f}
1834 echo 10: ${x/b\/c/e/f}
1835 echo 11: ${x/b\/c/e\/f}
1836 echo 12: ${x/b\/c/e\\/f}
1837 echo 13: ${x/b\\/c/e\\/f}
1838 echo 14: ${x//b/c/e/f}
1839 echo 15: ${x//b\/c/e/f}
1840 echo 16: ${x//b\/c/e\/f}
1841 echo 17: ${x//b\/c/e\\/f}
1842 echo 18: ${x//b\\/c/e\\/f}
1843 echo 19: ${x/b\/*\/c/x}
1849 echo 25: ${x//\%1/9}
1850 echo 26: ${x//\\%1/9}
1852 echo 28: ${x//\\a/9}
1855 1: 122321_ab/cde_b/c_1221
1856 2: 131_ab/cde_b/c_11
1857 3: 1321_ab/cde_b/c_1221
1858 4: 131_ab/cde_b/c_11
1859 5: 1422321_ab/cde_b/c_1221
1860 6: 1444341_ab/cde_b/c_1441
1861 7: 14321_ab/cde_b/c_1221
1862 8: 14341_ab/cde_b/c_141
1863 9: 1222321_ac/e/f/cde_b/c_1221
1864 10: 1222321_ae/fde_b/c_1221
1865 11: 1222321_ae/fde_b/c_1221
1866 12: 1222321_ae\/fde_b/c_1221
1867 13: 1222321_ab/cde_b/c_1221
1868 14: 1222321_ac/e/f/cde_c/e/f/c_1221
1869 15: 1222321_ae/fde_e/f_1221
1870 16: 1222321_ae/fde_e/f_1221
1871 17: 1222321_ae\/fde_e\/f_1221
1872 18: 1222321_ab/cde_b/c_1221
1874 20: 1222321_ab.cde_b/c_1221
1875 21: 1222321_ab.cde_b.c_1221
1876 22: 1222321_ab/cde_b/c_1221
1877 23: 9222321_ab/cde_b/c_1221
1878 24: 1222321_ab/cde_b/c_1229
1879 25: 1222321_ab/cde_b/c_1229
1880 26: 1222321_ab/cde_b/c_1221
1881 27: 1222321_9b/cde_b/c_1221
1882 28: 1222321_9b/cde_b/c_1221
1883 29: 1xyz22321_ab/cde_b/c_1221
1885 name: eglob-substrpl-2
1887 Check anchored substring replacement works, corner cases
1904 name: eglob-substrpl-3a
1906 Check substring replacement works with variables and slashes, too
1910 echo "${wd/#$pfx/~}"
1911 echo "${wd/#\$pfx/~}"
1912 echo "${wd/#"$pfx"/~}"
1913 echo "${wd/#'$pfx'/~}"
1914 echo "${wd/#"\$pfx"/~}"
1915 echo "${wd/#'\$pfx'/~}"
1924 name: eglob-substrpl-3b
1926 More of this, bash fails it (bash4 passes)
1930 echo "${wd/#$(echo /home/user)/~}"
1931 echo "${wd/#"$(echo /home/user)"/~}"
1932 echo "${wd/#'$(echo /home/user)'/~}"
1938 name: eglob-substrpl-3c
1940 Even more weird cases
1944 echo 1: ${wd/#$pfx/~}
1945 echo 2: ${wd/#\$pfx/~}
1946 echo 3: ${wd/#"$pfx"/~}
1947 echo 4: ${wd/#'$pfx'/~}
1948 echo 5: ${wd/#"\$pfx"/~}
1949 echo 6: ${wd/#'\$pfx'/~}
1950 ts='a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)'
1953 [[ -n $BASH_VERSION ]] && shopt -s extglob
1954 echo 7: ${ts/a\/b/$tr}
1955 echo 8: ${ts/a\/b/\$tr}
1956 echo 9: ${ts/$tp/$tr}
1957 echo 10: ${ts/\$tp/$tr}
1958 echo 11: ${ts/\\$tp/$tr}
1959 echo 12: ${ts/$tp/c/d}
1960 echo 13: ${ts/$tp/c\/d}
1961 echo 14: ${ts/$tp/c\\/d}
1962 echo 15: ${ts/+(a\/b)/$tr}
1963 echo 16: ${ts/+(a\/b)/\$tr}
1964 echo 17: ${ts/+($tp)/$tr}
1965 echo 18: ${ts/+($tp)/c/d}
1966 echo 19: ${ts/+($tp)/c\/d}
1967 echo 25: ${ts//a\/b/$tr}
1968 echo 26: ${ts//a\/b/\$tr}
1969 echo 27: ${ts//$tp/$tr}
1970 echo 28: ${ts//$tp/c/d}
1971 echo 29: ${ts//$tp/c\/d}
1972 echo 30: ${ts//+(a\/b)/$tr}
1973 echo 31: ${ts//+(a\/b)/\$tr}
1974 echo 32: ${ts//+($tp)/$tr}
1975 echo 33: ${ts//+($tp)/c/d}
1976 echo 34: ${ts//+($tp)/c\/d}
1978 echo 40: ${ts/$tp/$tr}
1979 echo 41: ${ts//$tp/$tr}
1987 7: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1988 8: $tra/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1989 9: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1990 10: a/ba/bc/d$tp_a/b$tp_*(a/b)_*($tp)
1991 11: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1992 12: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1993 13: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1994 14: c\/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1995 15: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
1996 16: $tr$tp$tp_a/b$tp_*(a/b)_*($tp)
1997 17: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
1998 18: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
1999 19: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2000 25: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2001 26: $tr$tr$tp$tp_$tr$tp_*($tr)_*($tp)
2002 27: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2003 28: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2004 29: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2005 30: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2006 31: $tr$tp$tp_$tr$tp_*($tr)_*($tp)
2007 32: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2008 33: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2009 34: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2010 40: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2011 41: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2012 # This is what GNU bash does:
2013 # 40: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2014 # 41: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2018 UTF-8 mode differences for eglobbing
2023 print 2: ${s/b???d/x} .
2026 print 4: ${s/b??d/x} .
2028 print 5: ${x%?} ${x%%?} .
2030 print 6: ${x#?} ${x##?} .
2032 print 7: ${x%?} ${x%%?} .
2034 print 8: ${x%?} ${x%%?} .
2036 print 9: ${x%?} ${x%%?} .
2050 Check that globbing isn't done when glob has syntax error
2051 file-setup: dir 755 "[x"
2052 file-setup: file 644 "[x/foo"
2064 Check that symbolic links aren't stat()'d
2065 # breaks on FreeMiNT (cannot unlink dangling symlinks)
2066 # breaks on MSYS (does not support symlinks)
2067 # breaks on Dell UNIX 4.0 R2.2 (SVR4) where unlink also fails
2068 category: !os:mint,!os:msys,!os:svr4.0,!nosymlink
2069 file-setup: dir 755 "dir"
2070 file-setup: symlink 644 "dir/abc"
2082 file-setup: file 644 ".bc"
2083 file-setup: file 644 "abc"
2084 file-setup: file 644 "bbc"
2085 file-setup: file 644 "cbc"
2086 file-setup: file 644 "-bc"
2109 (AT&T ksh fails this; POSIX says invalid)
2110 file-setup: file 644 "abc"
2118 Check that globbing matches the right things...
2119 # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
2120 # breaks on Cygwin 1.7 (files are now UTF-16 or something)
2121 # breaks on QNX 6.4.1 (says RT)
2122 category: !os:cygwin,!os:darwin,!os:msys,!os:nto
2124 file-setup: file 644 "aÂc"
2132 Results unspecified according to POSIX
2133 file-setup: file 644 ".bc"
2141 Results unspecified according to POSIX
2142 (AT&T ksh treats this like [a-cc-e]*)
2143 file-setup: file 644 "abc"
2144 file-setup: file 644 "bbc"
2145 file-setup: file 644 "cbc"
2146 file-setup: file 644 "dbc"
2147 file-setup: file 644 "ebc"
2148 file-setup: file 644 "-bc"
2156 Check against a regression from fixing IFS-subst-2
2159 print -r "before='$x'"
2161 print -r "after ='$x'"
2168 Check ordering/content of redundent here documents.
2180 Check quoted here-doc is protected.
2199 Check that newline isn't needed after heredoc-delimiter marker.
2211 Check that an error occurs if the heredoc-delimiter is missing.
2216 expected-exit: e > 0
2217 expected-stderr-pattern: /.*/
2221 Check that backslash quotes a $, ` and \ and kills a \newline
2228 th\`echo not-run\`ere
2229 th\\`echo is-run`ere
2246 Check that \newline in initial here-delim word doesn't imply
2261 Check that double quoted $ expressions in here delimiters are
2262 not expanded and match the delimiter.
2263 POSIX says only quote removal is applied to the delimiter.
2280 Check that double quoted escaped $ expressions in here
2281 delimiters are not expanded and match the delimiter.
2282 POSIX says only quote removal is applied to the delimiter
2283 (\ counts as a quote).
2304 Check that here strings work.
2308 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo
2309 "$__progname" -c "tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo"
2310 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$bar"
2311 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<'$bar'
2312 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$bar
2313 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<-foo
2314 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$(echo "foo bar")"
2327 Check that a corner case of here strings works like bash
2332 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
2339 Check that a corner case of here strings works like ksh93, zsh
2344 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
2351 Check another corner case of here strings
2353 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<< bar
2359 Check here string related regression with multiple iops
2361 echo $(tr r z <<<'bar' 2>/dev/null)
2367 Check long here strings
2375 Check direct here document assignment
2389 fnd=$(typeset -f foo)
2397 # rather nonsensical, but…
2400 vf=<<<$'=f $x \x40='
2402 print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} ve={$ve} vf={$vf} |"
2410 print -r -- "| ${v//$'\n'/^} |"
2430 Check here documents with no or empty delimiter
2447 fnd=$(typeset -f foo)
2455 print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} |"
2463 print -r -- "| ${v//$'\n'/^} |"
2485 Check here documents can use $* and $@; note shells vary:
2486 • pdksh 5.2.14 acts the same
2487 • dash has 1 and 2 the same but 3 lacks the space
2488 • ksh93, bash4 differ in 2 by using space ipv colon
2528 name: heredoc-comsub-1
2530 Tests for here documents in COMSUB, taken from Austin ML
2537 = here is the text =
2539 name: heredoc-comsub-2
2541 Tests for here documents in COMSUB, taken from Austin ML
2543 unbalanced=$(cat <<EOF
2544 this paren ) is a problem
2546 echo = $unbalanced =
2548 = this paren ) is a problem =
2550 name: heredoc-comsub-3
2552 Tests for here documents in COMSUB, taken from Austin ML
2554 balanced=$(cat <<EOF
2555 these parens ( ) are not a problem
2559 = these parens ( ) are not a problem =
2561 name: heredoc-comsub-4
2563 Tests for here documents in COMSUB, taken from Austin ML
2565 balanced=$(cat <<EOF
2566 these parens \( ) are a problem
2570 = these parens \( ) are a problem =
2572 name: heredoc-subshell-1
2574 Tests for here documents in subshells, taken from Austin ML
2584 name: heredoc-subshell-2
2586 Tests for here documents in subshells, taken from Austin ML
2597 name: heredoc-subshell-3
2599 Tests for here documents in subshells, taken from Austin ML
2609 name: heredoc-weird-1
2611 Tests for here documents, taken from Austin ML
2612 Documents current state in mksh, *NOT* necessarily correct!
2625 name: heredoc-weird-2
2627 Tests for here documents, taken from Austin ML
2637 name: heredoc-weird-4
2639 Tests for here documents, taken from Austin ML
2640 Documents current state in mksh, *NOT* necessarily correct!
2651 name: heredoc-weird-5
2653 Tests for here documents, taken from Austin ML
2654 Documents current state in mksh, *NOT* necessarily correct!
2666 name: heredoc-tmpfile-1
2668 Check that heredoc temp files aren't removed too soon or too late.
2669 Heredoc in simple command.
2690 name: heredoc-tmpfile-2
2692 Check that heredoc temp files aren't removed too soon or too late.
2693 Heredoc in function, multiple calls to function.
2712 name: heredoc-tmpfile-3
2714 Check that heredoc temp files aren't removed too soon or too late.
2715 Heredoc in function in loop, multiple calls to function.
2742 name: heredoc-tmpfile-4
2744 Check that heredoc temp files aren't removed too soon or too late.
2745 Backgrounded simple command with here doc
2759 name: heredoc-tmpfile-5
2761 Check that heredoc temp files aren't removed too soon or too late.
2762 Backgrounded subshell command with here doc
2767 sleep 1 # so parent exits
2783 name: heredoc-tmpfile-6
2785 Check that heredoc temp files aren't removed too soon or too late.
2786 Heredoc in pipeline.
2790 cat <<- EOF | sed "s/hi/HI/"
2800 name: heredoc-tmpfile-7
2802 Check that heredoc temp files aren't removed too soon or too late.
2803 Heredoc in backgrounded pipeline.
2807 cat <<- EOF | sed 's/hi/HI/' &
2817 name: heredoc-tmpfile-8
2819 Check that heredoc temp files aren't removed too soon or too
2820 late. Heredoc in function, backgrounded call to function.
2821 This check can fail on slow machines (<100 MHz), or Cygwin,
2826 # Background eval so main shell doesn't do parsing
2834 # sleep so eval can die
2848 name: heredoc-quoting-unsubst
2850 Check for correct handling of quoted characters in
2851 here documents without substitution (marker is quoted).
2855 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
2858 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
2860 name: heredoc-quoting-subst
2862 Check for correct handling of quoted characters in
2863 here documents with substitution (marker is not quoted).
2867 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
2870 x " \" \ \ $ $ baz `echo baz` bar $foo x
2872 name: single-quotes-in-braces
2874 Check that single quotes inside unquoted {} are treated as quotes
2877 echo ${foo:+'blah $foo'}
2881 name: single-quotes-in-quoted-braces
2883 Check that single quotes inside quoted {} are treated as
2887 echo "${foo:+'blah $foo'}"
2891 name: single-quotes-in-braces-nested
2893 Check that single quotes inside unquoted {} are treated as quotes,
2894 even if that's inside a double-quoted command expansion
2897 echo "$( echo ${foo:+'blah $foo'})"
2901 name: single-quotes-in-brace-pattern
2903 Check that single quotes inside {} pattern are treated as quotes
2906 echo ${foo%'2'*} "${foo%'2'*}" ${foo%2'*'} "${foo%2'*'}"
2910 name: single-quotes-in-heredoc-braces
2912 Check that single quotes inside {} in heredoc are treated
2922 name: single-quotes-in-nested-braces
2924 Check that single quotes inside nested unquoted {} are
2928 echo ${foo:+${foo:+'blah $foo'}}
2932 name: single-quotes-in-nested-quoted-braces
2934 Check that single quotes inside nested quoted {} are treated
2938 echo "${foo:+${foo:+'blah $foo'}}"
2942 name: single-quotes-in-nested-braces-nested
2944 Check that single quotes inside nested unquoted {} are treated
2945 as quotes, even if that's inside a double-quoted command expansion
2948 echo "$( echo ${foo:+${foo:+'blah $foo'}})"
2952 name: single-quotes-in-nested-brace-pattern
2954 Check that single quotes inside nested {} pattern are treated as quotes
2957 echo ${foo:+${foo%'2'*}} "${foo:+${foo%'2'*}}" ${foo:+${foo%2'*'}} "${foo:+${foo%2'*'}}"
2961 name: single-quotes-in-heredoc-nested-braces
2963 Check that single quotes inside nested {} in heredoc are treated
2968 ${foo:+${foo:+'blah $foo'}}
2975 See if we can test history at all
2978 env-setup: !ENV=./Env!HISTFILE=hist.file!
2979 file-setup: file 644 "Env"
2987 expected-stderr-pattern:
2992 Verify duplicates and spaces are not entered
2995 env-setup: !ENV=./Env!HISTFILE=hist.file!
2996 file-setup: file 644 "Env"
3008 expected-stderr-pattern:
3011 name: history-unlink
3013 Check if broken HISTFILEs do not cause trouble
3016 env-setup: !ENV=./Env!HISTFILE=foo/hist.file!
3017 file-setup: file 644 "Env"
3019 file-setup: dir 755 "foo"
3020 file-setup: file 644 "foo/hist.file"
3023 perl-setup: chmod(0555, "foo");
3031 expected-stderr-pattern:
3032 /(.*can't unlink HISTFILE.*\n)?X*$/
3034 name: history-e-minus-1
3036 Check if more recent command is executed
3039 env-setup: !ENV=./Env!HISTFILE=hist.file!
3040 file-setup: file 644 "Env"
3050 expected-stderr-pattern:
3051 /^X*echo there\nX*$/
3053 name: history-e-minus-2
3055 Check that repeated command is printed before command
3059 env-setup: !ENV=./Env!HISTFILE=hist.file!
3060 file-setup: file 644 "Env"
3067 expected-stdout-pattern:
3068 /X*hi\nX*there\nX*echo there\nthere\nX*/
3069 expected-stderr-pattern:
3072 name: history-e-minus-3
3074 fc -e - fails when there is no history
3075 (ksh93 has a bug that causes this to fail)
3076 (ksh88 loops on this)
3079 env-setup: !ENV=./Env!HISTFILE=hist.file!
3080 file-setup: file 644 "Env"
3087 expected-stderr-pattern:
3088 /^X*.*:.*history.*\nX*$/
3090 name: history-e-minus-4
3092 Check if "fc -e -" command output goes to stdout.
3095 env-setup: !ENV=./Env!HISTFILE=hist.file!
3096 file-setup: file 644 "Env"
3100 fc -e - | (read x; echo "A $x")
3106 expected-stderr-pattern:
3109 name: history-e-minus-5
3111 fc is replaced in history by new command.
3114 env-setup: !ENV=./Env!HISTFILE=hist.file!
3115 file-setup: file 644 "Env"
3131 expected-stderr-pattern:
3132 /^X*echo ghi jkl\nX*$/
3134 name: history-list-1
3136 List lists correct range
3137 (ksh88 fails 'cause it lists the fc command)
3140 env-setup: !ENV=./Env!HISTFILE=hist.file!
3141 file-setup: file 644 "Env"
3154 expected-stderr-pattern:
3157 name: history-list-2
3159 Lists oldest history if given pre-historic number
3160 (ksh93 has a bug that causes this to fail)
3161 (ksh88 fails 'cause it lists the fc command)
3164 env-setup: !ENV=./Env!HISTFILE=hist.file!
3165 file-setup: file 644 "Env"
3179 expected-stderr-pattern:
3182 name: history-list-3
3184 Can give number 'options' to fc
3187 env-setup: !ENV=./Env!HISTFILE=hist.file!
3188 file-setup: file 644 "Env"
3203 expected-stderr-pattern:
3206 name: history-list-4
3208 -1 refers to previous command
3211 env-setup: !ENV=./Env!HISTFILE=hist.file!
3212 file-setup: file 644 "Env"
3226 expected-stderr-pattern:
3229 name: history-list-5
3231 List command stays in history
3234 env-setup: !ENV=./Env!HISTFILE=hist.file!
3235 file-setup: file 644 "Env"
3252 expected-stderr-pattern:
3255 name: history-list-6
3257 HISTSIZE limits about of history kept.
3258 (ksh88 fails 'cause it lists the fc command)
3261 env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3!
3262 file-setup: file 644 "Env"
3279 expected-stderr-pattern:
3282 name: history-list-7
3284 fc allows too old/new errors in range specification
3287 env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3!
3288 file-setup: file 644 "Env"
3306 expected-stderr-pattern:
3309 name: history-list-r-1
3311 test -r flag in history
3314 env-setup: !ENV=./Env!HISTFILE=hist.file!
3315 file-setup: file 644 "Env"
3333 expected-stderr-pattern:
3336 name: history-list-r-2
3338 If first is newer than last, -r is implied.
3341 env-setup: !ENV=./Env!HISTFILE=hist.file!
3342 file-setup: file 644 "Env"
3360 expected-stderr-pattern:
3363 name: history-list-r-3
3365 If first is newer than last, -r is cancelled.
3368 env-setup: !ENV=./Env!HISTFILE=hist.file!
3369 file-setup: file 644 "Env"
3387 expected-stderr-pattern:
3390 name: history-subst-1
3395 env-setup: !ENV=./Env!HISTFILE=hist.file!
3396 file-setup: file 644 "Env"
3401 fc -e - abc=AB 'echo a'
3406 expected-stderr-pattern:
3407 /^X*echo AB def\nX*$/
3409 name: history-subst-2
3411 Does subst find previous command?
3414 env-setup: !ENV=./Env!HISTFILE=hist.file!
3415 file-setup: file 644 "Env"
3420 fc -e - jkl=XYZQRT 'echo g'
3425 expected-stderr-pattern:
3426 /^X*echo ghi XYZQRT\nX*$/
3428 name: history-subst-3
3430 Does subst find previous command when no arguments given
3433 env-setup: !ENV=./Env!HISTFILE=hist.file!
3434 file-setup: file 644 "Env"
3444 expected-stderr-pattern:
3445 /^X*echo ghi XYZQRT\nX*$/
3447 name: history-subst-4
3449 Global substitutions work
3450 (ksh88 and ksh93 do not have -g option)
3453 env-setup: !ENV=./Env!HISTFILE=hist.file!
3454 file-setup: file 644 "Env"
3457 echo abc def asjj sadjhasdjh asdjhasd
3460 abc def asjj sadjhasdjh asdjhasd
3461 FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd
3462 expected-stderr-pattern:
3463 /^X*echo FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd\nX*$/
3465 name: history-subst-5
3467 Make sure searches don't find current (fc) command
3468 (ksh88/ksh93 don't have the ? prefix thing so they fail this test)
3471 env-setup: !ENV=./Env!HISTFILE=hist.file!
3472 file-setup: file 644 "Env"
3477 fc -e - abc=AB \?abc
3482 expected-stderr-pattern:
3483 /^X*echo AB def\nX*$/
3485 name: history-ed-1-old
3487 Basic (ed) editing works (assumes you have generic ed editor
3488 that prints no prompts). This is for oldish ed(1) which write
3489 the character count to stdout.
3494 env-setup: !ENV=./Env!HISTFILE=hist.file!
3495 file-setup: file 644 "Env"
3508 expected-stderr-pattern:
3509 /^X*echo FOOBAR def\nX*$/
3511 name: history-ed-2-old
3513 Correct command is edited when number given
3518 env-setup: !ENV=./Env!HISTFILE=hist.file!
3519 file-setup: file 644 "Env"
3527 s/is here/is changed/
3538 expected-stderr-pattern:
3539 /^X*echo line 2 is changed\nX*$/
3541 name: history-ed-3-old
3543 Newly created multi line commands show up as single command
3545 (NOTE: adjusted for COMPLEX HISTORY compile time option)
3546 (ksh88 fails 'cause it lists the fc command)
3551 env-setup: !ENV=./Env!HISTFILE=hist.file!
3552 file-setup: file 644 "Env"
3573 expected-stderr-pattern:
3574 /^X*echo FOOBAR def\necho a new line\nX*$/
3578 Basic (ed) editing works (assumes you have generic ed editor
3579 that prints no prompts). This is for newish ed(1) and stderr.
3580 category: !no-stderr-ed
3584 env-setup: !ENV=./Env!HISTFILE=hist.file!
3585 file-setup: file 644 "Env"
3596 expected-stderr-pattern:
3597 /^X*13\n16\necho FOOBAR def\nX*$/
3601 Correct command is edited when number given
3602 category: !no-stderr-ed
3606 env-setup: !ENV=./Env!HISTFILE=hist.file!
3607 file-setup: file 644 "Env"
3615 s/is here/is changed/
3624 expected-stderr-pattern:
3625 /^X*20\n23\necho line 2 is changed\nX*$/
3629 Newly created multi line commands show up as single command
3631 category: !no-stderr-ed
3635 env-setup: !ENV=./Env!HISTFILE=hist.file!
3636 file-setup: file 644 "Env"
3655 expected-stderr-pattern:
3656 /^X*13\n32\necho FOOBAR def\necho a new line\nX*$/
3660 Simple test, default IFS
3662 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3678 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3695 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3708 name: IFS-space-colon-1
3710 Simple test, IFS=<white-space>:
3712 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3727 name: IFS-space-colon-2
3729 Simple test, IFS=<white-space>:
3730 AT&T ksh fails this, POSIX says the test is correct.
3732 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3739 name: IFS-space-colon-4
3741 Simple test, IFS=<white-space>:
3743 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3750 name: IFS-space-colon-5
3752 Simple test, IFS=<white-space>:
3753 Don't know what POSIX thinks of this. AT&T ksh does not do this.
3755 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3764 Simple test, IFS=<white-space>:
3766 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3769 echo -n '1:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3770 echo -n '2:'; for i in :b:: ; do echo -n " [$i]" ; done ; echo
3774 echo -n '5:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3777 echo -n '7:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3779 echo -n '9:'; for i in ${FOO-`echo -n h:i`th:ere} ; do echo -n " [$i]" ; done ; echo
3780 showargs 10 ${FOO-`echo -n h:i`th:ere}
3781 showargs 11 "${FOO-`echo -n h:i`th:ere}"
3783 echo -n '12:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3795 <10> <h> <ith> <ere> .
3798 <13> <A> <B> <> <D> .
3802 Check leading whitespace after trim does not make a field
3804 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3806 showargs 1 shift ${x#X}
3808 <1> <shift> <1> <2> .
3810 name: IFS-subst-3-arr
3812 Check leading IFS non-whitespace after trim does make a field
3813 but leading IFS whitespace does not, nor empty replacements
3815 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3818 showargs 1 ${-+:foo:bar}
3820 showargs 2 ${-+ foo bar}
3823 <1> <> <foo> <bar> .
3826 name: IFS-subst-3-ass
3828 Check non-field semantics
3830 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3833 showargs 1 x=${-+:foo:bar}
3835 showargs 2 x=${-+ foo bar}
3838 <1> <x=> <foo> <bar> .
3839 <2> <x=> <foo> <bar> .
3841 name: IFS-subst-3-lcl
3843 Check non-field semantics, smaller corner case (LP#1381965)
3848 expected-exit: e != 0
3849 expected-stderr-pattern:
3854 reported by mikeserv
3856 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
3857 a='space divded argument
3860 IFS= ; q="$*" ; nq=$*
3861 pfn "$*" $* "$q" "$nq"
3862 [ "$q" = "$nq" ] && echo =true || echo =false
3864 <spacedivdedargument
3870 <spacedivdedargument
3872 <spacedivdedargument
3878 extended testsuite based on problem by mikeserv
3880 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
3881 a='space divded argument
3884 IFS= ; q="$@" ; nq=$@
3885 pfn "$*" $* "$q" "$nq"
3886 [ "$q" = "$nq" ] && echo =true || echo =false
3888 <spacedivdedargument
3894 <space divded argument
3896 <space divded argument
3902 extended testsuite based on problem by mikeserv
3904 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
3905 a='space divded argument
3907 IFS=\ ; set -- $a; IFS=
3912 print -nr -- '= qs '; pfn "$qs"
3913 print -nr -- '=nqs '; pfn "$nqs"
3914 print -nr -- '= qk '; pfn "$qk"
3915 print -nr -- '=nqk '; pfn "$nqk"
3916 print -nr -- '~ qs '; pfn "$*"
3917 print -nr -- '~nqs '; pfn $*
3918 print -nr -- '~ qk '; pfn "$@"
3919 print -nr -- '~nqk '; pfn $@
3921 = qs <spacedivdedargument
3923 =nqs <spacedivdedargument
3925 = qk <space divded argument
3927 =nqk <space divded argument
3929 ~ qs <spacedivdedargument
3946 extended testsuite based on problem by mikeserv
3948 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
3949 a='space divded argument
3951 IFS=\ ; set -- $a; IFS=
3953 print -nr -- '= qs '; pfn "$qs"
3954 print -nr -- '~ qs '; pfn "$*"
3956 print -nr -- '=nqs '; pfn "$nqs"
3957 print -nr -- '~nqs '; pfn $*
3959 print -nr -- '= qk '; pfn "$qk"
3960 print -nr -- '~ qk '; pfn "$@"
3962 print -nr -- '=nqk '; pfn "$nqk"
3963 print -nr -- '~nqk '; pfn $@
3965 = qs <spacedivdedargument
3967 ~ qs <spacedivdedargument
3969 =nqs <spacedivdedargument
3975 = qk <space divded argument
3981 =nqk <space divded argument
3988 name: IFS-subst-4-4p
3990 extended testsuite based on problem by mikeserv
3992 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
3993 a='space divded argument
3995 IFS=\ ; set -- $a; IFS=
3998 print -nr -- '= qs '; pfn "$qs"
3999 print -nr -- '~ qs '; pfn ${v:-"$*"}
4001 print -nr -- '=nqs '; pfn "$nqs"
4002 print -nr -- '~nqs '; pfn ${v:-$*}
4004 print -nr -- '= qk '; pfn "$qk"
4005 print -nr -- '~ qk '; pfn ${v:-"$@"}
4007 print -nr -- '=nqk '; pfn "$nqk"
4008 print -nr -- '~nqk '; pfn ${v:-$@}
4010 = qs <spacedivdedargument
4012 ~ qs <spacedivdedargument
4014 =nqs <spacedivdedargument
4020 = qk <space divded argument
4026 =nqk <space divded argument
4035 extended testsuite based on problem by mikeserv
4037 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4038 a='space divded argument
4040 IFS=\ ; set -- $a; IFS=,
4042 print -nr -- '= qs '; pfn "$qs"
4043 print -nr -- '~ qs '; pfn "$*"
4045 print -nr -- '=nqs '; pfn "$nqs"
4046 print -nr -- '~nqs '; pfn $*
4048 print -nr -- '= qk '; pfn "$qk"
4049 print -nr -- '~ qk '; pfn "$@"
4051 print -nr -- '=nqk '; pfn "$nqk"
4052 print -nr -- '~nqk '; pfn $@
4054 = qs <space,divded,argument
4056 ~ qs <space,divded,argument
4058 =nqs <space,divded,argument
4064 = qk <space divded argument
4070 =nqk <space divded argument
4077 name: IFS-subst-4-5p
4079 extended testsuite based on problem by mikeserv
4081 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4082 a='space divded argument
4084 IFS=\ ; set -- $a; IFS=,
4087 print -nr -- '= qs '; pfn "$qs"
4088 print -nr -- '~ qs '; pfn ${v:-"$*"}
4090 print -nr -- '=nqs '; pfn "$nqs"
4091 print -nr -- '~nqs '; pfn ${v:-$*}
4093 print -nr -- '= qk '; pfn "$qk"
4094 print -nr -- '~ qk '; pfn ${v:-"$@"}
4096 print -nr -- '=nqk '; pfn "$nqk"
4097 print -nr -- '~nqk '; pfn ${v:-$@}
4099 = qs <space,divded,argument
4101 ~ qs <space,divded,argument
4103 =nqs <space,divded,argument
4109 = qk <space divded argument
4115 =nqk <space divded argument
4124 extended testsuite based on IFS-subst-3
4125 differs slightly from ksh93:
4126 - omit trailing field in a3zna, a7ina (unquoted $@ expansion)
4127 - has extra middle fields in b5ins, b7ina (IFS_NWS unquoted expansion)
4128 differs slightly from bash:
4129 - omit leading field in a5ins, a7ina (IFS_NWS unquoted expansion)
4130 differs slightly from zsh:
4131 - differs in assignment, not expansion; probably zsh bug
4132 - has extra middle fields in b5ins, b7ina (IFS_NWS unquoted expansion)
4133 'emulate sh' zsh has extra fields in
4134 - a5ins (IFS_NWS unquoted $*)
4135 - b5ins, matching mksh’s
4136 !!WARNING!! more to come: http://austingroupbugs.net/view.php?id=888
4138 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4139 IFS=; set -- "" 2 ""; pfb $*; x=$*; pfn "$x"'
4141 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4142 IFS=; set -- "" 2 ""; pfb "$*"; x="$*"; pfn "$x"'
4144 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4145 IFS=; set -- "" 2 ""; pfb $@; x=$@; pfn "$x"'
4147 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4148 IFS=; set -- "" 2 ""; pfb "$@"; x="$@"; pfn "$x"'
4150 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4151 IFS=,; set -- "" 2 ""; pfb $*; x=$*; pfn "$x"'
4153 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4154 IFS=,; set -- "" 2 ""; pfb "$*"; x="$*"; pfn "$x"'
4156 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4157 IFS=,; set -- "" 2 ""; pfb $@; x=$@; pfn "$x"'
4159 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4160 IFS=,; set -- "" 2 ""; pfb "$@"; x="$@"; pfn "$x"'
4162 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4163 IFS=; set -- A B "" "" C; pfb $*; x=$*; pfn "$x"'
4165 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4166 IFS=; set -- A B "" "" C; pfb "$*"; x="$*"; pfn "$x"'
4168 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4169 IFS=; set -- A B "" "" C; pfb $@; x=$@; pfn "$x"'
4171 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4172 IFS=; set -- A B "" "" C; pfb "$@"; x="$@"; pfn "$x"'
4174 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4175 IFS=,; set -- A B "" "" C; pfb $*; x=$*; pfn "$x"'
4177 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4178 IFS=,; set -- A B "" "" C; pfb "$*"; x="$*"; pfn "$x"'
4180 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4181 IFS=,; set -- A B "" "" C; pfb $@; x=$@; pfn "$x"'
4183 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4184 IFS=,; set -- A B "" "" C; pfb "$@"; x="$@"; pfn "$x"'
4262 Regression wrt. vector expansion in trim
4264 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4274 ksh93 bug wrt. vector expansion in trim
4276 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4280 showargs "$*" ${a##"$*"}
4286 http://austingroupbugs.net/view.php?id=221
4288 n() { echo "$#"; }; n "${foo-$@}"
4294 Scalar context for $*/$@ in [[ and case
4296 "$__progname" -c 'IFS=; set a b; [[ $* = "$1$2" ]]; echo 1 $?' sh a b
4297 "$__progname" -c 'IFS=; [[ $* = ab ]]; echo 2 "$?"' sh a b
4298 "$__progname" -c 'IFS=; [[ "$*" = ab ]]; echo 3 "$?"' sh a b
4299 "$__progname" -c 'IFS=; [[ $* = a ]]; echo 4 "$?"' sh a b
4300 "$__progname" -c 'IFS=; [[ "$*" = a ]]; echo 5 "$?"' sh a b
4301 "$__progname" -c 'IFS=; [[ "$@" = a ]]; echo 6 "$?"' sh a b
4302 "$__progname" -c 'IFS=; case "$@" in a) echo 7 a;; ab) echo 7 b;; a\ b) echo 7 ok;; esac' sh a b
4303 "$__progname" -c 'IFS=; case $* in a) echo 8 a;; ab) echo 8 ok;; esac' sh a b
4304 "$__progname" -c 'pfsp() { for s_arg in "$@"; do print -nr -- "<$s_arg> "; done; print .; }; IFS=; star=$* at="$@"; pfsp 9 "$star" "$at"' sh a b
4318 http://austingroupbugs.net/view.php?id=832
4320 ${ZSH_VERSION+false} || emulate sh
4321 ${BASH_VERSION+set -o posix}
4322 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4324 showargs $((1230456))
4328 name: integer-base-err-1
4330 Can't have 0 base (causes shell to exit)
4331 expected-exit: e != 0
4337 expected-stderr-pattern:
4340 name: integer-base-err-2
4342 Can't have multiple bases in a 'constant' (causes shell to exit)
4343 (ksh88 fails this test)
4344 expected-exit: e != 0
4350 expected-stderr-pattern:
4351 /^.*:.*2#110#11.*\n$/
4353 name: integer-base-err-3
4355 Syntax errors in expressions and effects on bases
4356 (interactive so errors don't cause exits)
4357 (ksh88 fails this test - shell exits, even with -i)
4361 PS1= # minimise prompt hassles
4368 expected-stderr-pattern:
4369 /^([#\$] )?.*:.*2+.*\n.*:.*2+.*\n$/
4374 name: integer-base-err-4
4376 Are invalid digits (according to base) errors?
4377 (ksh93 fails this test)
4378 expected-exit: e != 0
4382 expected-stderr-pattern:
4383 /^([#\$] )?.*:.*3#4.*\n$/
4385 name: integer-base-1
4387 Missing number after base is treated as 0.
4396 name: integer-base-2
4398 Check 'stickyness' of base in various situations
4449 name: integer-base-3
4451 More base parsing (hmm doesn't test much..)
4471 name: integer-base-4
4473 Check that things not declared as integers are not made integers,
4474 also, check if base is not reset by -i with no arguments.
4475 (ksh93 fails - prints 10#20 - go figure)
4479 typeset -i | grep '^xx='
4486 name: integer-base-5
4502 for l in 1 2+3 4; do echo $l; done
4514 name: integer-base-6
4516 Even more base stuff
4517 (ksh93 fails this test - prints 0)
4525 name: integer-base-7
4527 Check that non-integer parameters don't get bases assigned
4529 echo $(( zz = 8#100 ))
4535 name: integer-base-check-flat
4537 Check behaviour does not match POSuX (except if set -o posix),
4538 because a not type-safe scripting language has *no* business
4539 interpreting the string "010" as octal numer eight (dangerous).
4541 echo 1 "$("$__progname" -c 'echo :$((10))/$((010)),$((0x10)):')" .
4542 echo 2 "$("$__progname" -o posix -c 'echo :$((10))/$((010)),$((0x10)):')" .
4543 echo 3 "$("$__progname" -o sh -c 'echo :$((10))/$((010)),$((0x10)):')" .
4549 name: integer-base-check-numeric-from
4551 Check behaviour for base one to 36, and that 37 errors out
4555 while (( ++i <= 36 )); do
4556 eval 'echo '$i':$(('$i'#10)).'
4558 echo 37:$($__progname -c 'echo $((37#10))').$?:
4597 expected-stderr-pattern:
4598 /.*bad number '37#10'/
4600 name: integer-base-check-numeric-to
4602 Check behaviour for base one to 36, and that 37 errors out
4605 while (( ++i <= 37 )); do
4606 typeset -Uui$i x=0x40
4607 eval "typeset -i10 y=$x"
4648 expected-stderr-pattern:
4649 /.*bad integer base: 37/
4651 name: integer-arithmetic-span
4653 Check wraparound and size that is defined in mksh
4656 echo s:$((2147483647+1)).$(((2147483647*2)+1)).$(((2147483647*2)+2)).
4657 echo u:$((#2147483647+1)).$((#(2147483647*2)+1)).$((#(2147483647*2)+2)).
4660 u:2147483648.4294967295.0.
4662 name: integer-arithmetic-span-64
4664 Check wraparound and size that is defined in mksh
4667 echo s:$((9223372036854775807+1)).$(((9223372036854775807*2)+1)).$(((9223372036854775807*2)+2)).
4668 echo u:$((#9223372036854775807+1)).$((#(9223372036854775807*2)+1)).$((#(9223372036854775807*2)+2)).
4670 s:-9223372036854775808.-1.0.
4671 u:9223372036854775808.18446744073709551615.0.
4673 name: integer-size-FAIL-to-detect
4675 Notify the user that their ints are not 32 or 64 bit
4682 See if $LINENO is updated and can be modified.
4695 See if $LINENO is set for .'d files.
4696 file-setup: file 644 "dotfile"
4714 See if $LINENO is set for commands in a function.
4733 See if unsetting LINENO makes it non-magic.
4734 file-setup: file 644 "dotfile"
4757 name: lineno-unset-use
4759 See if unsetting LINENO makes it non-magic even
4761 file-setup: file 644 "dotfile"
4787 Check if LINENO is tracked in traps
4793 trap 'fail $LINENO' INT ERR
4801 Ensure unknown traps are not a syntax error
4804 trap "echo trap 1 executed" UNKNOWNSIGNAL || echo "foo"
4806 trap "echo trap 2 executed" UNKNOWNSIGNAL EXIT 999999 FNORD
4808 ) 2>&1 | sed "s
\ 1^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]
\ 1PROG
\ 1"
4810 PROG: trap: bad signal 'UNKNOWNSIGNAL'
4813 PROG: trap: bad signal 'UNKNOWNSIGNAL'
4814 PROG: trap: bad signal '999999'
4815 PROG: trap: bad signal 'FNORD'
4821 Simple test, default IFS
4826 echo 1: "x[$x] y[$y] z[$z]"
4827 echo 1a: ${z-z not set}
4837 If no var specified, REPLY is used
4845 name: read-regress-1
4847 Check a regression of read
4848 file-setup: file 644 "foo"
4853 while read a b c; do
4857 echo "<$a|$b|$c><$d>"
4863 Check read with delimiters
4866 print -n 'foo bar\tbaz\nblah \0blub\tblech\nmyok meck \0'
4868 emit | while IFS= read -d "" foo; do print -r -- "<$foo>"; done
4869 emit | while read -d "" foo; do print -r -- "<$foo>"; done
4870 emit | while read -d "eh?" foo; do print -r -- "<$foo>"; done
4887 Check read with number of bytes specified, and -A
4889 print 'foo\nbar' >x1
4891 print 'foo\\ bar baz' >x3
4893 x1b=u; read -N-1 x1b <x1
4894 x2a=u; read x2a <x2; r2a=$?
4895 x2b=u; read -N2 x2c <x2; r2b=$?
4896 x2c=u; read -n2 x2c <x2; r2c=$?
4897 x3a=u; read -A x3a <x3
4898 print -r "x1a=<$x1a>"
4899 print -r "x1b=<$x1b>"
4900 print -r "x2a=$r2a<$x2a>"
4901 print -r "x2b=$r2b<$x2b>"
4902 print -r "x2c=$r2c<$x2c>"
4903 print -r "x3a=<${x3a[0]}|${x3a[1]}|${x3a[2]}>"
4915 Lex array code had problems with this.
4926 When PATH is set before running a command, the new path is
4927 not used in doing the path search
4928 $ echo echo hi > /tmp/q ; chmod a+rx /tmp/q
4932 in comexec() the two lines
4934 (void) typeset(*vp++, xxx, 0);
4935 need to be moved out of the switch to before findcom() is
4936 called - I don't know what this will break.
4938 : ${PWD:-`pwd 2> /dev/null`}
4939 : ${PWD:?"PWD not set - can't do test"}
4941 cat > Y/xxxscript << EOF
4943 # Need to restore path so echo can be found (some shells don't have
4949 chmod a+rx Y/xxxscript
4950 export OLDPATH="$PATH"
4951 PATH=$PWD/Y xxxscript
4958 Parsing of $(..) expressions is non-optimal. It is
4959 impossible to have any parentheses inside the expression.
4961 $ ksh -c 'echo $(echo \( )'
4963 $ ksh -c 'echo $(echo "(" )'
4966 The solution is to hack the parsing clode in lex.c, the
4967 question is how to hack it: should any parentheses be
4968 escaped by a backslash, or should recursive parsing be done
4969 (so quotes could also be used to hide hem). The former is
4970 easier, the later better...
4980 Continue in a for loop does not work right:
4982 if [ $i = b ] ; then
4991 if [ $i = b ] ; then
4992 if [ $first = no ] ; then
4993 echo 'continue in for loop broken'
4994 break # hope break isn't broken too :-)
5009 should print 0 according to POSIX (dash, bash, ksh93, posh)
5010 but not 0 according to the getopt(1) manual page, ksh88, and
5011 Bourne sh (such as /bin/sh on Solaris).
5012 We honour POSIX except when -o sh is set.
5013 category: shell:legacy-no
5016 [[ -o posix ]]; FPOSIX=$((1-$?))
5017 [[ -o sh ]]; FSH=$((1-$?))
5018 echo -n "FPOSIX=$FPOSIX FSH=$FSH "
5042 name: regression-10-legacy
5047 should print 0 according to POSIX (dash, bash, ksh93, posh)
5048 but not 0 according to the getopt(1) manual page, ksh88, and
5049 Bourne sh (such as /bin/sh on Solaris).
5050 category: shell:legacy-yes
5053 [[ -o posix ]]; FPOSIX=$((1-$?))
5054 [[ -o sh ]]; FSH=$((1-$?))
5055 echo -n "FPOSIX=$FPOSIX FSH=$FSH "
5084 should echo blah but on some machines echos /foo/bar/blah.
5093 Both of the following echos produce the same output under sh/ksh.att:
5096 echo "`echo \"$x\"`"
5098 pdksh produces different output for the former (foo instead of foo\tbar)
5101 echo "`echo \"$x\"`"
5109 The following command hangs forever:
5110 $ (: ; cat /etc/termcap) | sleep 2
5111 This is because the shell forks a shell to run the (..) command
5112 and this shell has the pipe open. When the sleep dies, the cat
5113 doesn't get a SIGPIPE 'cause a process (ie, the second shell)
5114 still has the pipe open.
5116 NOTE: this test provokes a bizarre bug in ksh93 (shell starts reading
5117 commands from /etc/termcap..)
5120 echo A line of text that will be duplicated quite a number of times.> t1
5121 cat t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 > t2
5122 cat t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 > t1
5123 cat t1 t1 t1 t1 > t2
5124 (: ; cat t2 2>/dev/null) | sleep 1
5129 $ (foobar) 2> /dev/null
5130 generates no output under /bin/sh, but pdksh produces the error
5133 $ foobar 2> /dev/null
5134 generates an error under /bin/sh and pdksh, but AT&T ksh88 produces
5135 no error (redirected to /dev/null).
5137 (you/should/not/see/this/error/1) 2> /dev/null
5138 you/should/not/see/this/error/2 2> /dev/null
5145 generates a blank line under pdksh and sets the exit status to 0.
5146 AT&T ksh88 generates no output and sets the exit status to 1. Also,
5149 generates no output under AT&T ksh88 (pdksh generates a blank line
5152 whence does/not/exist > /dev/null
5154 echo 2: $(whence does/not/exist | wc -l)
5155 echo 3: $(whence does/not/exist cat | wc -l)
5163 ${var%%expr} seems to be broken in many places. On the mips
5165 $ read line < /etc/passwd
5173 change the value of line. On sun4s & pas, the echo ${line%%:*} doesn't
5174 work. Haven't checked elsewhere...
5181 root:asdjhasdasjhs:0:1:Root:/:/bin/sh
5184 root:asdjhasdasjhs:0:1:Root:/:/bin/sh
5190 should set the exit status to non-zero (sh and AT&T ksh88 do).
5191 XXX doting a non existent file is a fatal error for a script
5194 expected-exit: e != 0
5195 expected-stderr-pattern: /.?/
5199 Both of the following echos should produce the same thing, but don't:
5213 backslash does not work as expected in case labels:
5232 Quoting backquotes inside backquotes doesn't work:
5233 $ echo `echo hi \`echo there\` folks`
5234 asks for more info. sh and AT&T ksh88 both echo
5237 echo `echo hi \`echo there\` folks`
5243 )) is not treated `correctly':
5244 $ (echo hi ; (echo there ; echo folks))
5247 instead of (as sh and ksh.att)
5248 $ (echo hi ; (echo there ; echo folks))
5254 ( : ; ( : ; echo hi))
5260 Check reading stdin in a while loop. The read should only read
5261 a single line, not a whole stdio buffer; the cat should get
5264 (echo a; echo b) | while read x ; do
5273 Check reading stdin in a while loop. The read should read both
5274 lines, not just the first.
5277 while [ "$a" != xxx ] ; do
5280 cat /dev/null | sed 's/x/y/'
5294 should cause a script to exit.
5298 expected-exit: e != 0
5299 expected-stderr-pattern: /does\/not\/exist/
5303 variable assignements not detected well
5306 expected-exit: e != 0
5307 expected-stderr-pattern: /a\.x=1/
5311 alias expansion different from AT&T ksh88
5313 alias a='for ' b='i in'
5314 a b hi ; do echo $i ; done
5320 strange characters allowed inside ${...}
5323 expected-exit: e != 0
5324 expected-stderr-pattern: /.?/
5328 Does read handle partial lines correctly
5331 while [ "$a" != xxx ] ; do
5348 Does read set variables to null at eof?
5351 while [ "$a" != xxx ] ; do
5355 echo 1: ${x-x not set} ${y-y not set} ${z-z not set}
5356 echo 2: ${x:+x not null} ${y:+y not null} ${z:+z not null}
5366 Does umask print a leading 0 when umask is 3 digits?
5368 # on MiNT, the first umask call seems to fail
5370 # now, the test proper
5378 Tempory files used for here-docs in functions get trashed after
5379 the function is parsed (before it is executed)
5402 Command substitution breaks reading in while loop
5403 (test from <sjg@void.zen.oz.au>)
5405 (echo abcdef; echo; echo 123) |
5408 # the following line breaks it
5409 c=`echo $line | wc -c`
5419 Machines with broken times() (reported by <sjg@void.zen.oz.au>)
5420 time does not report correct real time
5423 expected-stderr-pattern: !/^\s*0\.0[\s\d]+real|^\s*real[\s]+0+\.0/
5427 set -e doesn't ignore exit codes for if/while/until/&&/||/!.
5430 if false; then echo hi ; fi
5433 while false; do echo hi; done
5440 Only posh and oksh(2013-07) say “hi” below; FreeBSD sh,
5441 GNU bash in POSIX mode, dash, ksh93, mksh don’t. All of
5442 them exit 0. The POSIX behaviour is needed by BSD make.
5445 echo `false; echo hi` $(<this-file-does-not-exist)
5450 expected-stderr-pattern: /this-file-does-not-exist/
5454 This used to cause a core dump
5455 env-setup: !RANDOM=12!
5463 foo should be set to bar (should not be empty)
5473 Can't use command line assignments to assign readonly parameters.
5475 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
5476 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
5477 done >env; chmod +x env; PATH=.:$PATH
5480 foo=stuff env | grep '^foo'
5481 expected-exit: e != 0
5482 expected-stderr-pattern:
5487 Can subshells be prefixed by redirections (historical shells allow
5490 < /dev/null (sed 's/^/X/')
5494 Parameter assignments with [] recognised correctly
5512 Check that alias expansion works in command substitutions and
5525 Check that aliases are fully read.
5538 Check that (here doc) temp files are not left behind after an exec.
5541 TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
5543 sed 's/^/X /' << E_O_F
5550 echo=echo; [ -x /bin/echo ] && echo=/bin/echo
5551 exec $echo subtest-1 hi
5553 echo subtest-1 foo/*
5554 TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
5555 echo=echo; [ -x /bin/echo ] && echo=/bin/echo
5556 sed 's/^/X /' << E_O_F; exec $echo subtest-2 hi
5562 echo subtest-2 foo/*
5574 Check that unset params with attributes are reported by set, those
5575 sans attributes are not.
5591 Check that aliases do not use continuation prompt after trailing
5593 file-setup: file 644 "envf"
5596 env-setup: !ENV=./envf!
5600 alias foo='echo hi ; '
5612 Check that set allows both +o and -o options on same command line.
5615 set -o noglob +o allexport
5622 Check that globbing works in pipelined commands
5623 file-setup: file 644 "envf"
5625 file-setup: file 644 "abc"
5627 env-setup: !ENV=./envf!
5633 sed 's/^/X /' < ab* | sed 's/^/Y /'
5645 Check that getopts works in functions
5648 echo bfunc: enter "(args: $*; OPTIND=$OPTIND)"
5649 while getopts B oc; do
5652 echo bfunc: B option
5655 echo bfunc: odd option "($oc)"
5663 echo kfunc: enter "(args: $*; OPTIND=$OPTIND)"
5664 while getopts K oc; do
5667 echo kfunc: K option
5670 echo bfunc: odd option "($oc)"
5678 echo "line 1: OPTIND=$OPTIND"
5680 echo "line 2: ret=$?, optc=$optc, OPTIND=$OPTIND"
5682 echo "line 3: OPTIND=$OPTIND"
5684 echo "line 4: ret=$?, optc=$optc, OPTIND=$OPTIND"
5686 echo "line 5: OPTIND=$OPTIND"
5688 echo "line 6: ret=$?, optc=$optc, OPTIND=$OPTIND"
5693 echo "line 10: OPTIND=$OPTIND"
5695 echo "line 20: ret=$?, optc=$optc, OPTIND=$OPTIND"
5697 echo "line 30: OPTIND=$OPTIND"
5699 echo "line 40: ret=$?, optc=$optc, OPTIND=$OPTIND"
5701 echo "line 50: OPTIND=$OPTIND"
5703 echo "line 60: ret=$?, optc=$optc, OPTIND=$OPTIND"
5706 line 2: ret=0, optc=f, OPTIND=2
5707 bfunc: enter (args: -BBB blah; OPTIND=2)
5712 line 4: ret=0, optc=b, OPTIND=3
5713 kfunc: enter (args: -KKK blah; OPTIND=1)
5719 line 6: ret=0, optc=k, OPTIND=4
5722 line 20: ret=0, optc=f, OPTIND=2
5723 bfunc: enter (args: -BBB blah; OPTIND=2)
5728 line 40: ret=1, optc=?, OPTIND=2
5729 kfunc: enter (args: -KKK blah; OPTIND=1)
5735 line 60: ret=1, optc=?, OPTIND=2
5739 Check that ; is not required before the then in if (( ... )) then ...
5753 Check ${foo:%bar} is allowed (ksh88 allows it...)
5776 Check if typeset output is correct for
5777 uninitialised array elements.
5781 typeset -i | grep xxx | sed 's/^/ /'
5783 typeset | grep xxx | sed 's/^/ /'
5787 typeset -i | grep xxx | sed 's/^/ /'
5789 typeset | grep xxx | sed 's/^/ /'
5803 Check if trap exit is ok (exit not mistaken for signal name)
5812 Check if ${#array[*]} is calculated correctly.
5822 Check if default exit status is previous command
5828 ( (exit 103) ; exit)
5837 Check if EXIT trap is executed for sub shells.
5839 trap 'echo parent exit' EXIT
5841 (echo A; echo A last)
5843 (echo C; trap 'echo sub exit' EXIT; echo C last)
5858 Check if test -nt/-ot succeeds if second(first) file is missing.
5861 test a -nt b && echo nt OK || echo nt BAD
5862 test b -ot a && echo ot OK || echo ot BAD
5869 Check if typeset, export, and readonly work
5881 integer FNORD_E FNORD_F FNORD_G FNORD_H
5882 export FNORD_C FNORD_D FNORD_G FNORD_H
5883 readonly FNORD_B FNORD_D FNORD_F FNORD_H
5929 typeset -x -r FNORD_D
5931 typeset -i -r FNORD_F
5932 typeset -i -x FNORD_G
5933 typeset -i -x -r FNORD_H
5936 typeset -r FNORD_B=2
5937 typeset -x FNORD_C=3
5938 typeset -x -r FNORD_D=4
5939 typeset -i FNORD_E=5
5940 typeset -i -r FNORD_F=6
5941 typeset -i -x FNORD_G=7
5942 typeset -i -x -r FNORD_H=8
5960 Check that we can redefine functions calling time builtin
5972 check for a regression with sleep builtin and signal mask
5978 while read -p line; do :; done
5985 Check that quoting is sane
5993 while IFS= read -pr line; do
5994 if [[ $line = *space* ]]; then
6000 for line in "${lines[@]}"; do
6009 Ensure readonly is honoured for assignments and unset
6011 "$__progname" -c 'u=x; echo $? $u .' || echo aborted, $?
6013 "$__progname" -c 'readonly u; u=x; echo $? $u .' || echo aborted, $?
6015 "$__progname" -c 'u=x; readonly u; unset u; echo $? $u .' || echo aborted, $?
6022 expected-stderr-pattern:
6027 http://austingroupbugs.net/view.php?id=367 for export
6029 "$__progname" -c 'readonly foo; export foo=a; echo $?' || echo aborted, $?
6032 expected-stderr-pattern:
6037 Check that getopts works as intended, for readonly-2b to be valid
6039 "$__progname" -c 'set -- -a b; getopts a c; echo $? $c .; getopts a c; echo $? $c .' || echo aborted, $?
6046 http://austingroupbugs.net/view.php?id=367 for getopts
6048 "$__progname" -c 'readonly c; set -- -a b; getopts a c; echo $? $c .' || echo aborted, $?
6051 expected-stderr-pattern:
6056 http://austingroupbugs.net/view.php?id=367 for read
6058 echo x | "$__progname" -c 'read s; echo $? $s .' || echo aborted, $?
6059 echo y | "$__progname" -c 'readonly s; read s; echo $? $s .' || echo aborted, $?
6063 expected-stderr-pattern:
6068 Do not permit bypassing readonly for first array item
6070 set -A arr -- foo bar
6073 print -r -- "${arr[@]}"
6074 expected-exit: e != 0
6075 expected-stderr-pattern:
6080 Check that lone ampersand is a syntax error
6083 expected-exit: e != 0
6084 expected-stderr-pattern:
6087 name: xxx-quoted-newline-1
6089 Check that \<newline> works inside of ${}
6097 name: xxx-quoted-newline-2
6099 Check that \<newline> works at the start of a here document
6108 name: xxx-quoted-newline-3
6110 Check that \<newline> works at the end of a here document
6119 name: xxx-multi-assignment-cmd
6121 Check that assignments in a command affect subsequent assignments
6130 name: xxx-multi-assignment-posix-cmd
6132 Check that the behaviour for multiple assignments with a
6133 command name matches POSIX. See:
6134 http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925
6136 X=a Y=b; X=$Y Y=$X "$__progname" -c 'echo 1 $X $Y .'; echo 2 $X $Y .
6138 X=a Y=${X=b} Z=$X "$__progname" -c 'echo 3 $Z .'
6140 X=a Y=${X=b} Z=$X; echo 4 $Z .
6147 name: xxx-multi-assignment-posix-nocmd
6149 Check that the behaviour for multiple assignments with no
6150 command name matches POSIX (Debian #334182). See:
6151 http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925
6153 X=a Y=b; X=$Y Y=$X; echo 1 $X $Y .
6157 name: xxx-multi-assignment-posix-subassign
6159 Check that the behaviour for multiple assignments matches POSIX:
6160 - The assignment words shall be expanded in the current execution
6162 - The assignments happen in the temporary execution environment.
6165 Z=a Y=${X:=b} sh -c 'echo +$X+ +$Y+ +$Z+'
6167 # Now for the special case:
6169 X= Y=${X:=b} sh -c 'echo +$X+ +$Y+'
6177 name: xxx-exec-environment-1
6179 Check to see if exec sets it's environment correctly
6181 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
6182 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
6183 done >env; chmod +x env; PATH=.:$PATH
6185 expected-stdout-pattern:
6188 name: xxx-exec-environment-2
6190 Check to make sure exec doesn't change environment if a program
6193 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
6194 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
6195 done >env; chmod +x env; PATH=.:$PATH
6197 FOO=bar exec; env >bar2
6200 name: exec-function-environment-1
6202 Check assignments in function calls and whether they affect
6203 the current execution environment (ksh93, SUSv4)
6205 f() { a=2; }; g() { b=3; echo y$c-; }; a=1 f; b=2; c=1 g
6211 name: xxx-what-do-you-call-this-1
6217 name: xxx-prefix-strip-1
6224 name: xxx-prefix-strip-2
6232 name: xxx-variable-syntax-1
6235 expected-stderr-pattern:
6239 name: xxx-variable-syntax-2
6243 expected-stderr-pattern:
6247 name: xxx-variable-syntax-3
6251 expected-stderr-pattern:
6255 name: xxx-substitution-eval-order
6257 Check order of evaluation of expressions
6260 set -A A abc def GHI j G k
6261 echo ${A[x=(i+=1)]#${A[y=(i+=2)]}}
6267 name: xxx-set-option-1
6269 Check option parsing in set
6271 set -vsA foo -- A 1 3 2
6280 Check that exec exits for built-ins
6288 expected-stderr-pattern: /.*/
6292 Check the return value of while loops
6293 XXX need to do same for for/select/until loops
6296 while [ $i != xxx ] ; do
6298 if [ $i = xxx ] ; then
6306 while [ $i != xxx ] ; do
6308 if [ $i = xxx ] ; then
6316 while [ $i != xxx ] ; do
6328 Check that blank lines don't clear $?
6341 expected-stderr-pattern: /.*/
6345 Check that $? is preserved in subshells, includes, traps.
6354 echo 'echo include: $?' > foo
6358 trap 'echo trap: $?' ERR
6368 name: xxx-clean-chars-1
6370 Check MAGIC character is stuffed correctly
6376 name: xxx-param-subst-qmark-1
6378 Check suppresion of error message with null string. According to
6379 POSIX, it shouldn't print the error as 'word' isn't ommitted.
6380 ksh88/93, Solaris /bin/sh and /usr/xpg4/bin/sh all print the error,
6381 that's why the condition is reversed.
6389 #expected-stderr-pattern: !/not set/
6391 expected-stderr-pattern: /parameter null or not set/
6394 # fails due to weirdness of execv stuff
6395 category: !os:uwin-nt
6397 Check c flag is set.
6398 arguments: !-c!echo "[$-]"!
6399 expected-stdout-pattern: /^\[.*c.*\]$/
6401 name: tilde-expand-1
6403 Check tilde expansion after equal signs
6404 env-setup: !HOME=/sweet!
6406 echo ${A=a=}~ b=~ c=d~ ~
6409 echo ${A=a=}~ b=~ c=d~ ~
6411 a=/sweet b=/sweet c=d~ /sweet
6414 name: tilde-expand-2
6416 Check tilde expansion works
6417 env-setup: !HOME=/sweet!
6421 plus=$(print -r -- ~+)
6422 minus=$(print -r -- ~-)
6423 nix=$(print -r -- ~)
6424 [[ $plus = / ]]; echo one $? .
6425 [[ $minus = "$wd" ]]; echo two $? .
6426 [[ $nix = /sweet ]]; echo nix $? .
6434 Check some "exit on error" conditions
6436 print '#!'"$__progname"'\nexec "$1"' >env
6437 print '#!'"$__progname"'\nexit 1' >false
6441 env false && echo something
6451 Check some "exit on error" edge conditions (POSIXly)
6453 print '#!'"$__progname"'\nexec "$1"' >env
6454 print '#!'"$__progname"'\nexit 1' >false
6455 print '#!'"$__progname"'\nexit 0' >true
6460 env false && echo something
6472 pdksh regression which AT&T ksh does right
6473 TFM says: [set] -e | errexit
6474 Exit (after executing the ERR trap) ...
6476 trap 'echo EXIT' EXIT
6479 cd /XXXXX 2>/dev/null
6485 expected-exit: e != 0
6489 "set -e" test suite (POSIX)
6503 "set -e" test suite (POSIX)
6509 [ "$1" = "$E" ] && { shift ; continue 2 ; }
6526 "set -e" test suite (BSD make)
6530 print 'all:\n\t@echo eins\n\t@exit 42\n' >zd/a/Makefile
6531 print 'all:\n\t@echo zwei\n' >zd/b/Makefile
6534 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"
6540 Stop in WD/zd/a (line 2 of Makefile).
6544 "set -e" regression (LP#1104543)
6548 [ -x $PWD/nonexistant ] && $PWD/nonexistant
6559 "set -e" regression (Debian #700526)
6562 _db_cmd() { return $1; }
6563 db_input() { _db_cmd 30; }
6564 db_go() { _db_cmd 0; }
6571 SUSv4 says that the shell should exit with 126/127 in some situations
6575 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6576 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6578 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6579 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6581 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6582 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6593 Check eval vs substitution exit codes (ksh93 alike)
6605 eval "eval $(false)"
6608 eval 'eval '"$(false)"
6612 eval $(echo :; false)
6630 Check that "exit" with no arguments behaves SUSv4 conformant.
6632 trap 'echo hi; exit' EXIT
6640 Check that ERR and EXIT traps are run just like ksh93 does.
6641 GNU bash does not run ERtrap in ±e eval-undef but runs it
6642 twice (bug?) in +e eval-false, so does ksh93 (bug?), which
6643 also has a bug to continue execution (echoing "and out" and
6644 returning 0) in +e eval-undef.
6645 file-setup: file 644 "x"
6647 trap 'echo EXtrap' EXIT
6648 trap 'echo ERtrap' ERR
6653 file-setup: file 644 "xt"
6655 trap 'echo EXtrap' EXIT
6656 trap 'echo ERtrap' ERR
6661 file-setup: file 644 "xf"
6663 trap 'echo EXtrap' EXIT
6664 trap 'echo ERtrap' ERR
6666 echo 'and run false'
6669 file-setup: file 644 "xu"
6671 trap 'echo EXtrap' EXIT
6672 trap 'echo ERtrap' ERR
6674 echo 'and run ${v?}'
6684 -e 's/parameter not set/parameter null or not set/' \
6685 -e 's/[[]6]//' -e 's/: eval: line 1//' -e 's/: line 6//' \
6686 -e "s
\ 1^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]
\ 1PROG
\ 1"
6691 echo = eval-true $(<rc) .
6693 echo = eval-false $(<rc) .
6694 runtest x $xe '${v?}'
6695 echo = eval-undef $(<rc) .
6697 echo = noeval-true $(<rc) .
6699 echo = noeval-false $(<rc) .
6701 echo = noeval-undef $(<rc) .
6705 echo = eval-true $(<rc) .
6707 echo = eval-false $(<rc) .
6708 runtest x $xe '${v?}'
6709 echo = eval-undef $(<rc) .
6711 echo = noeval-true $(<rc) .
6713 echo = noeval-false $(<rc) .
6715 echo = noeval-undef $(<rc) .
6727 x: v: parameter null or not set
6740 xu: v: parameter null or not set
6754 x: v: parameter null or not set
6768 xu: v: parameter null or not set
6772 name: exit-trap-interactive
6774 Check that interactive shell doesn't exit via EXIT trap on syntax error
6779 echo 'After error 1'
6780 trap 'echo Exit trap' EXIT
6782 echo 'After error 2'
6783 trap 'echo Exit trap' EXIT
6790 expected-stderr-pattern:
6791 /syntax error: 'newline' unexpected/
6795 Check that test also can handle string1 < string2 etc.
6797 test 2005/10/08 '<' 2005/08/21 && echo ja || echo nein
6798 test 2005/08/21 \< 2005/10/08 && echo ja || echo nein
6799 test 2005/10/08 '>' 2005/08/21 && echo ja || echo nein
6800 test 2005/08/21 \> 2005/10/08 && echo ja || echo nein
6806 expected-stderr-pattern: !/unexpected op/
6808 name: test-precedence-1
6810 Check a weird precedence case (and POSIX echo)
6820 Test the test -o operator
6825 [[ -o $1 ]]; echo $?
6828 test -o $1 -o -o !$1; echo $?
6829 [ -o $1 -o -o !$1 ]; echo $?
6830 [[ -o $1 || -o !$1 ]]; echo $?
6831 test -o ?$1; echo $?
6833 echo 0y $(if_test utf8-mode) =
6834 echo 0n $(if_test utf8-hack) =
6835 echo 1= $(runtest utf8-hack) =
6836 echo 2= $(runtest !utf8-hack) =
6837 echo 3= $(runtest ?utf8-hack) =
6839 echo 1+ $(runtest utf8-mode) =
6840 echo 2+ $(runtest !utf8-mode) =
6841 echo 3+ $(runtest ?utf8-mode) =
6843 echo 1- $(runtest utf8-mode) =
6844 echo 2- $(runtest !utf8-mode) =
6845 echo 3- $(runtest ?utf8-mode) =
6846 echo = short flags =
6847 echo 0y $(if_test -U) =
6848 echo 0y $(if_test +U) =
6849 echo 0n $(if_test -_) =
6850 echo 0n $(if_test -U-) =
6851 echo 1= $(runtest -_) =
6852 echo 2= $(runtest !-_) =
6853 echo 3= $(runtest ?-_) =
6855 echo 1+ $(runtest -U) =
6856 echo 2+ $(runtest !-U) =
6857 echo 3+ $(runtest ?-U) =
6858 echo 1+ $(runtest +U) =
6859 echo 2+ $(runtest !+U) =
6860 echo 3+ $(runtest ?+U) =
6862 echo 1- $(runtest -U) =
6863 echo 2- $(runtest !-U) =
6864 echo 3- $(runtest ?-U) =
6865 echo 1- $(runtest +U) =
6866 echo 2- $(runtest !+U) =
6867 echo 3- $(runtest ?+U) =
6903 Check that ~/.mkshrc works correctly.
6904 Part 1: verify user environment is not read (internal)
6912 Check that ~/.mkshrc works correctly.
6913 Part 2: verify mkshrc is not read (non-interactive shells)
6914 file-setup: file 644 ".mkshrc"
6916 env-setup: !HOME=.!ENV=!
6924 Check that ~/.mkshrc works correctly.
6925 Part 2: verify mkshrc can be read (interactive shells)
6926 file-setup: file 644 ".mkshrc"
6930 env-setup: !HOME=.!ENV=!PS1=!
6935 expected-stderr-pattern:
6940 Check that ~/.mkshrc works correctly.
6941 Part 3: verify mkshrc can be turned off
6942 file-setup: file 644 ".mkshrc"
6944 env-setup: !HOME=.!ENV=nonexistant!
6952 Check that sh mode turns braceexpand off
6953 and that that works correctly
6957 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
6958 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
6966 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
6967 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
6970 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
6971 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
6987 Check that posix or sh mode is *not* automatically turned on
6990 ln -s "$__progname" ksh || cp "$__progname" ksh
6991 ln -s "$__progname" sh || cp "$__progname" sh
6992 ln -s "$__progname" ./-ksh || cp "$__progname" ./-ksh
6993 ln -s "$__progname" ./-sh || cp "$__progname" ./-sh
6994 for shell in {,-}{,k}sh; do
6995 print -- $shell $(./$shell +l -c \
6996 '[[ $(set +o) == *"-o "@(sh|posix)@(| *) ]] && echo sh || echo nosh')
7006 Check that posix or sh mode *is* automatically turned on
7009 ln -s "$__progname" ksh || cp "$__progname" ksh
7010 ln -s "$__progname" sh || cp "$__progname" sh
7011 ln -s "$__progname" ./-ksh || cp "$__progname" ./-ksh
7012 ln -s "$__progname" ./-sh || cp "$__progname" ./-sh
7013 for shell in {,-}{,k}sh; do
7014 print -- $shell $(./$shell +l -c \
7015 '[[ $(set +o) == *"-o "@(sh|posix)@(| *) ]] && echo sh || echo nosh')
7025 pdksh bug: last command of a pipeline is executed in a
7026 subshell - make sure it still is, scripts depend on it
7027 file-setup: file 644 "abcx"
7028 file-setup: file 644 "abcy"
7031 echo a | while read d; do
7051 check that co-processes work with TCOMs, TPIPEs and TPARENs
7054 "$__progname" -c 'i=100; echo hi |& while read -p line; do echo "$((i++)) $line"; done'
7055 "$__progname" -c 'i=200; echo hi | cat |& while read -p line; do echo "$((i++)) $line"; done'
7056 "$__progname" -c 'i=300; (echo hi | cat) |& while read -p line; do echo "$((i++)) $line"; done'
7064 Check that PIPESTATUS does what it's supposed to
7066 echo 1 $PIPESTATUS .
7067 echo 2 ${PIPESTATUS[0]} .
7068 echo 3 ${PIPESTATUS[1]} .
7069 (echo x; exit 12) | (cat; exit 23) | (cat; exit 42)
7070 echo 5 $? , $PIPESTATUS , ${PIPESTATUS[0]} , ${PIPESTATUS[1]} , ${PIPESTATUS[2]} , ${PIPESTATUS[3]} .
7071 echo 6 ${PIPESTATUS[0]} .
7072 set | fgrep PIPESTATUS
7073 echo 8 $(set | fgrep PIPESTATUS) .
7079 5 42 , 12 , 12 , 23 , 42 , .
7082 8 PIPESTATUS[0]=0 PIPESTATUS[1]=0 .
7086 Check that "set -o pipefail" does what it's supposed to
7088 echo 1 "$("$__progname" -c '(exit 12) | (exit 23) | (exit 42); echo $?')" .
7089 echo 2 "$("$__progname" -c '! (exit 12) | (exit 23) | (exit 42); echo $?')" .
7090 echo 3 "$("$__progname" -o pipefail -c '(exit 12) | (exit 23) | (exit 42); echo $?')" .
7091 echo 4 "$("$__progname" -o pipefail -c '! (exit 12) | (exit 23) | (exit 42); echo $?')" .
7092 echo 5 "$("$__progname" -c '(exit 23) | (exit 42) | :; echo $?')" .
7093 echo 6 "$("$__progname" -c '! (exit 23) | (exit 42) | :; echo $?')" .
7094 echo 7 "$("$__progname" -o pipefail -c '(exit 23) | (exit 42) | :; echo $?')" .
7095 echo 8 "$("$__progname" -o pipefail -c '! (exit 23) | (exit 42) | :; echo $?')" .
7096 echo 9 "$("$__progname" -o pipefail -c 'x=$( (exit 23) | (exit 42) | :); echo $?')" .
7108 name: persist-history-1
7110 Check if persistent history saving works
7111 category: !no-histfile
7114 env-setup: !ENV=./Env!HISTFILE=hist.file!
7115 file-setup: file 644 "Env"
7119 expected-stdout-pattern:
7121 expected-stderr-pattern:
7126 Check that global does what typeset is supposed to do
7130 global -Uui16 arrfoo[*]
7132 echo before ${arrfoo[0]} .
7134 echo after ${arrfoo[0]} .
7137 echo inside before ${arrbar[0]} .
7139 echo inside changed ${arrbar[0]} .
7140 global -Uui16 arrbar[*]
7141 echo inside typeset ${arrbar[0]} .
7143 echo inside changed ${arrbar[0]} .
7145 echo before ${arrbar[0]} .
7147 echo after ${arrbar[0]} .
7154 inside typeset 16#61 .
7155 inside changed 16#30 .
7158 name: typeset-padding-1
7160 Check if left/right justification works as per TFM
7162 typeset -L10 ln=0hall0
7163 typeset -R10 rn=0hall0
7164 typeset -ZL10 lz=0hall0
7165 typeset -ZR10 rz=0hall0
7166 typeset -Z10 rx=" hallo "
7167 echo "<$ln> <$rn> <$lz> <$rz> <$rx>"
7169 <0hall0 > < 0hall0> <hall0 > <00000hall0> <0000 hallo>
7171 name: typeset-padding-2
7173 Check if base-!10 integers are padded right
7175 typeset -Uui16 -L9 ln=16#1
7176 typeset -Uui16 -R9 rn=16#1
7177 typeset -Uui16 -Z9 zn=16#1
7181 echo "<$ln> <$rn> <$zn> <$ls> <$rs> <$zs>"
7183 <16#1 > < 16#1> <16#000001> <16#1 > < 16#1> <0000016#1>
7187 Check that the UTF-8 Byte Order Mark is ignored as the first
7188 multibyte character of the shell input (with -c, from standard
7189 input, as file, or as eval argument), but nowhere else
7190 # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
7191 category: !os:darwin
7194 print '#!/bin/sh\necho ohne' >foo/fnord
7195 print '#!/bin/sh\necho mit' >foo/fnord
7196 print 'fnord\nfnord\nfnord\nfnord' >foo/bar
7197 print eval \''fnord\nfnord\nfnord\nfnord'\' >foo/zoo
7198 set -A anzahl -- foo/*
7199 echo got ${#anzahl[*]} files
7201 export PATH=$(pwd)/foo:$PATH
7202 "$__progname" -c 'fnord'
7204 "$__progname" -c 'fnord; fnord; fnord; fnord'
7206 "$__progname" foo/bar
7208 "$__progname" <foo/bar
7210 "$__progname" foo/zoo
7212 "$__progname" -c 'echo : $(fnord)'
7242 Check that we can execute BOM-shebangs (failures not fatal)
7243 XXX if the OS can already execute them, we lose
7244 note: cygwin execve(2) doesn't return to us with ENOEXEC, we lose
7245 note: Ultrix perl5 t4 returns 65280 (exit-code 255) and no text
7246 XXX fails when LD_PRELOAD is set with -e and Perl chokes it (ASan)
7248 category: !os:cygwin,!os:msys,!os:ultrix,!os:uwin-nt,!smksh
7249 env-setup: !FOO=BAR!
7251 print '#!'"$__progname"'\nprint "1 a=$ENV{FOO}";' >t1
7252 print '#!'"$__progname"'\nprint "2 a=$ENV{FOO}";' >t2
7253 print '#!'"$__perlname"'\nprint "3 a=$ENV{FOO}\n";' >t3
7254 print '#!'"$__perlname"'\nprint "4 a=$ENV{FOO}\n";' >t4
7261 1 a=/nonexistant{FOO}
7262 2 a=/nonexistant{FOO}
7265 expected-stderr-pattern:
7266 /(Unrecognized character .... ignored at \..t4 line 1)*/
7270 Check that the utf8-mode flag is not set at non-interactive startup
7272 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8!
7274 if [[ $- = *U* ]]; then
7284 Check that the utf8-mode flag is not set at non-interactive startup
7286 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.utf8!
7288 if [[ $- = *U* ]]; then
7298 Check that the utf8-mode flag is set at interactive startup.
7299 -DMKSH_ASSUME_UTF8=0 => expected failure, please ignore
7300 -DMKSH_ASSUME_UTF8=1 => not expected, please investigate
7301 -UMKSH_ASSUME_UTF8 => not expected, but if your OS is old,
7302 try passing HAVE_SETLOCALE_CTYPE=0 to Build.sh
7304 category: !os:hpux,!os:msys
7307 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8!
7309 if [[ $- = *U* ]]; then
7316 expected-stderr-pattern:
7321 Check that the utf8-mode flag is set at interactive startup
7322 Expected failure if -DMKSH_ASSUME_UTF8=0
7326 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.utf8!
7328 if [[ $- = *U* ]]; then
7335 expected-stderr-pattern:
7340 Ensure ±U on the command line is honoured
7341 (these two tests may pass falsely depending on CPPFLAGS)
7344 code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi'
7345 let i++; "$__progname" -U -c "$code"
7346 let i++; "$__progname" +U -c "$code"
7355 Ensure ±U on the command line is honoured, interactive shells
7359 code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi'
7360 let i++; "$__progname" -U -ic "$code"
7361 let i++; "$__progname" +U -ic "$code"
7370 Check if built-in shell aliases are okay
7371 category: !android,!arge
7376 autoload='typeset -fu'
7377 functions='typeset -f'
7380 integer='typeset -i'
7383 nameref='typeset -n'
7386 source='PATH=$PATH:. command .'
7390 name: aliases-1-hartz4
7392 Check if built-in shell aliases are okay
7393 category: android,arge
7398 autoload='typeset -fu'
7399 functions='typeset -f'
7402 integer='typeset -i'
7405 nameref='typeset -n'
7408 source='PATH=$PATH:. command .'
7413 Check if “set -o sh” disables built-in aliases (except a few)
7420 integer='typeset -i'
7425 Check if running as sh disables built-in aliases (except a few)
7429 ./sh -c 'alias; typeset -f'
7432 integer='typeset -i'
7437 Check if “set -o sh” does not influence built-in aliases
7438 category: !android,!arge
7444 autoload='typeset -fu'
7445 functions='typeset -f'
7448 integer='typeset -i'
7451 nameref='typeset -n'
7454 source='PATH=$PATH:. command .'
7460 Check if running as sh does not influence built-in aliases
7461 category: !android,!arge
7464 ./sh -c 'alias; typeset -f'
7467 autoload='typeset -fu'
7468 functions='typeset -f'
7471 integer='typeset -i'
7474 nameref='typeset -n'
7477 source='PATH=$PATH:. command .'
7481 name: aliases-2b-hartz4
7483 Check if “set -o sh” does not influence built-in aliases
7484 category: android,arge
7490 autoload='typeset -fu'
7491 functions='typeset -f'
7494 integer='typeset -i'
7497 nameref='typeset -n'
7500 source='PATH=$PATH:. command .'
7503 name: aliases-3b-hartz4
7505 Check if running as sh does not influence built-in aliases
7506 category: android,arge
7509 ./sh -c 'alias; typeset -f'
7512 autoload='typeset -fu'
7513 functions='typeset -f'
7516 integer='typeset -i'
7519 nameref='typeset -n'
7522 source='PATH=$PATH:. command .'
7525 name: aliases-cmdline
7527 Check that aliases work from the command line (Debian #517009)
7528 Note that due to the nature of the lexing process, defining
7529 aliases in COMSUBs then immediately using them, and things
7530 like 'alias foo=bar && foo', still fail.
7532 "$__progname" -c $'alias a="echo OK"\na'
7536 name: aliases-funcdef-1
7538 Check if POSIX functions take precedences over aliases
7540 alias foo='echo makro'
7548 name: aliases-funcdef-2
7550 Check if POSIX functions take precedences over aliases
7552 alias foo='echo makro'
7560 name: aliases-funcdef-3
7562 Check if aliases take precedences over Korn functions
7564 alias foo='echo makro'
7572 name: aliases-funcdef-4
7574 Functions should only take over if actually being defined
7585 Check if Korn Shell arrays work as expected
7588 set -A foo -- a \$v "$v" '$v' b
7589 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
7595 Check if bash-style arrays work as expected
7598 foo=(a \$v "$v" '$v' b)
7599 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
7605 Check if bash-style arrays work as expected, with newlines
7607 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "$x|"; done' >pfp
7609 test -n "$ZSH_VERSION" && setopt KSH_ARRAYS
7615 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
7620 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
7625 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
7627 7|a|bc|d|$v|e f|$v|g|
7628 7|a|bc|d|$v|e f|$v|g|
7629 6|abc\|d|$v|e f|$v|g||
7633 Check if array bounds are uint32_t
7640 echo ${foo[4294967295]} g ${foo[*]}
7647 Check if Korn Shell arrays with specified indices work as expected
7650 set -A foo -- [1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b
7651 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|"
7652 # we don't want this at all:
7654 set -A arr "[5]=meh"
7655 echo "<${arr[0]}><${arr[5]}>"
7657 5|[1]=$v|[2]=c d|[4]=$v|[0]=a|[5]=b||
7662 Check if bash-style arrays with specified indices work as expected
7663 (taken out temporarily to fix arrays-4; see also arrays-9a comment)
7667 foo=([1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b)
7668 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|"
7669 x=([128]=foo bar baz)
7672 # Check that we do not break this by globbing
7677 echo "<${arr[0]}><${arr[5]}>"
7686 Check if we can get the array keys (indices) for indexed arrays,
7692 echo -n "$((i++))<$x>"
7703 echo a $(of ${foo[*]}) = $(of ${bar[*]}) a
7704 echo b $(of "${foo[*]}") = $(of "${bar[*]}") b
7705 echo c $(of ${foo[@]}) = $(of ${bar[@]}) c
7706 echo d $(of "${foo[@]}") = $(of "${bar[@]}") d
7707 echo e $(of ${!foo[*]}) = $(of ${!bar[*]}) e
7708 echo f $(of "${!foo[*]}") = $(of "${!bar[*]}") f
7709 echo g $(of ${!foo[@]}) = $(of ${!bar[@]}) g
7710 echo h $(of "${!foo[@]}") = $(of "${!bar[@]}") h
7718 a 0<zwei>1<eins>2<drei> = a
7719 b 0<zwei eins drei> = 0<> b
7720 c 0<zwei>1<eins>2<drei> = c
7721 d 0<zwei>1<eins>2<drei> = d
7729 Check if we can get the array keys (indices) for indexed arrays,
7730 Korn shell style, in some corner cases
7733 echo !arz[0]: ${!arz[0]}
7734 echo !arz[1]: ${!arz[1]}
7737 echo !arz[0]: ${!arz[0]}
7738 echo !arz[1]: ${!arz[1]}
7741 echo !arz[0]: ${!arz[0]}
7742 echo !arz[1]: ${!arz[1]}
7756 Check some behavioural rules for arrays.
7794 typeset -Z3 aa ab ac ad ae af ag
7839 Check that we can concatenate arrays
7841 unset foo; foo=(bar); foo+=(baz); echo 1 ${!foo[*]} : ${foo[*]} .
7842 unset foo; foo=(foo bar); foo+=(baz); echo 2 ${!foo[*]} : ${foo[*]} .
7843 # unset foo; foo=([2]=foo [0]=bar); foo+=(baz [5]=quux); echo 3 ${!foo[*]} : ${foo[*]} .
7846 2 0 1 2 : foo bar baz .
7847 # 3 0 2 3 5 : bar foo baz quux .
7851 Check that we can concatenate parameters too
7853 unset foo; foo=bar; foo+=baz; echo 1 $foo .
7854 unset foo; typeset -i16 foo=10; foo+=20; echo 2 $foo .
7859 name: arrassign-basic
7861 Check basic whitespace conserving properties of wdarrassign
7869 c+=("$(echo "c d")")
7871 echo ".a:${a[0]}.${a[1]}.${a[2]}.${a[3]}:"
7872 echo ".b:${b[0]}.${b[1]}.${b[2]}.${b[3]}:"
7873 echo ".c:${c[0]}.${c[1]}.${c[2]}.${c[3]}:"
7874 echo ".d:${d[0]}.${d[1]}.${d[2]}.${d[3]}:"
7881 name: arrassign-fnc-none
7883 Check locality of array access inside a function
7887 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7890 if [[ -n $BASH_VERSION ]]; then
7896 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7900 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7902 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7904 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7905 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7907 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7909 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7922 name: arrassign-fnc-local
7924 Check locality of array access inside a function
7925 with the bash/mksh/ksh93 local/typeset keyword
7926 (note: ksh93 has no local; typeset works only in FKSH)
7931 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7934 if [[ -n $BASH_VERSION ]]; then
7941 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7945 if [[ -n $BASH_VERSION ]]; then
7951 echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
7956 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7958 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7960 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7961 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7963 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7965 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7966 echo ".f0r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
7968 echo ".f1r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
7970 echo ".f2r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
7988 name: arrassign-fnc-global
7990 Check locality of array access inside a function
7991 with the mksh-specific global keyword
7996 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8002 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8008 echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8013 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8015 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8017 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8018 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8020 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8022 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8023 echo ".f0r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8025 echo ".f1r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8027 echo ".f2r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8045 name: strassign-fnc-none
8047 Check locality of string access inside a function
8082 name: strassign-fnc-local
8084 Check locality of string access inside a function
8085 with the bash/mksh/ksh93 local/typeset keyword
8086 (note: ksh93 has no local; typeset works only in FKSH)
8140 name: strassign-fnc-global
8142 Check locality of string access inside a function
8143 with the mksh-specific global keyword
8197 name: unset-fnc-local-ksh
8199 Check that “unset” removes a previous “local”
8200 (ksh93 syntax compatible version); apparently,
8201 there are shells which fail this?
8227 name: unset-fnc-local-sh
8229 Check that “unset” removes a previous “local”
8230 (Debian Policy §10.4 sh version); apparently,
8231 there are shells which fail this?
8257 name: varexpand-substr-1
8259 Check if bash-style substring expansion works
8260 when using positive numerics
8263 typeset -i y=123456789
8264 typeset -i 16 z=123456789 # 16#75bcd15
8265 echo a t${x:2:2} ${y:2:3} ${z:2:3} a
8266 echo b ${x::3} ${y::3} ${z::3} b
8267 echo c ${x:2:} ${y:2:} ${z:2:} c
8268 echo d ${x:2} ${y:2} ${z:2} d
8269 echo e ${x:2:6} ${y:2:6} ${z:2:7} e
8270 echo f ${x:2:7} ${y:2:7} ${z:2:8} f
8271 echo g ${x:2:8} ${y:2:8} ${z:2:9} g
8276 d cdefghi 3456789 #75bcd15 d
8277 e cdefgh 345678 #75bcd1 e
8278 f cdefghi 3456789 #75bcd15 f
8279 g cdefghi 3456789 #75bcd15 g
8281 name: varexpand-substr-2
8283 Check if bash-style substring expansion works
8284 when using negative numerics or expressions
8287 typeset -i y=123456789
8288 typeset -i 16 z=123456789 # 16#75bcd15
8290 echo a ${x:$n:3} ${y:$n:3} ${z:$n:3} a
8291 echo b ${x:(n):3} ${y:(n):3} ${z:(n):3} b
8292 echo c ${x:(-2):1} ${y:(-2):1} ${z:(-2):1} c
8293 echo d t${x: n:2} ${y: n:3} ${z: n:3} d
8300 name: varexpand-substr-3
8302 Check that some things that work in bash fail.
8303 This is by design. And that some things fail in both.
8305 export x=abcdefghi n=2
8306 "$__progname" -c 'echo v${x:(n)}x'
8307 "$__progname" -c 'echo w${x: n}x'
8308 "$__progname" -c 'echo x${x:n}x'
8309 "$__progname" -c 'echo y${x:}x'
8310 "$__progname" -c 'echo z${x}x'
8311 "$__progname" -c 'x=abcdef;y=123;echo ${x:${y:2:1}:2}' >/dev/null 2>&1; echo $?
8317 expected-stderr-pattern:
8318 /x:n.*bad substitution.*\n.*bad substitution/
8320 name: varexpand-substr-4
8322 Check corner cases for substring expansion
8326 echo a ${x:(y == 1 ? 2 : 3):4} a
8330 name: varexpand-substr-5A
8332 Check that substring expansions work on characters
8336 echo a ${x::1} ${x: -1} a
8337 echo b ${x::3} ${x: -3} b
8338 echo c ${x:1:2} ${x: -3:2} c
8346 name: varexpand-substr-5W
8348 Check that substring expansions work on characters
8352 echo a ${x::1} ${x: -1} a
8353 echo b ${x::2} ${x: -2} b
8354 echo c ${x:1:1} ${x: -2:1} c
8362 name: varexpand-substr-6
8364 Check that string substitution works correctly
8369 echo a ${baz: foo: bar}
8370 echo b ${baz: foo: $bar}
8371 echo c ${baz: $foo: bar}
8372 echo d ${baz: $foo: $bar}
8379 name: varexpand-special-hash
8381 Check special ${var@x} expansion for x=hash
8386 print ${foo@#} ${bar@#} ${baz@#} .
8388 9B15FBFB CFBDD32B 00000000 .
8390 name: varexpand-special-quote
8392 Check special ${var@Q} expansion for quoted strings
8399 print -r -- "<i=$i j=$j k=$k>"
8400 s="u=${i@Q} v=${j@Q} w=${k@Q}"
8401 print -r -- "s=\"$s\""
8407 s="u=x v='a b' w=$'c\nd\240e\u20ACf'"
8410 typeset w=$'c\nd\240e\u20ACf'
8412 name: varexpand-null-1
8414 Ensure empty strings expand emptily
8416 print s ${a} . ${b} S
8417 print t ${a#?} . ${b%?} T
8418 print r ${a=} . ${b/c/d} R
8420 print s "${a}" . "${b}" S
8421 print t "${a#?}" . "${b%?}" T
8422 print r "${a=}" . "${b/c/d}" R
8432 name: varexpand-null-2
8434 Ensure empty strings, when quoted, are expanded as empty strings
8436 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "<$x> "; done' >pfs
8438 ./pfs 1 "${a}" 2 "${a#?}" + "${b%?}" 3 "${a=}" + "${b/c/d}"
8441 <1> <> <2> <> <+> <> <3> <> <+> <> .
8443 name: varexpand-null-3
8445 Ensure concatenating behaviour matches other shells
8447 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
8448 x=; showargs 1 "$x"$@
8449 set A; showargs 2 "${@:+}"
8482 name: print-funny-chars
8484 Check print builtin's capability to output designated characters
8486 print '<\0144\0344\xDB\u00DB\u20AC\uDB\x40>'
8492 Check print builtin's \c escape
8494 print '\ca'; print b
8500 Check that CR+LF is not collapsed into LF as some MSYS shells wrongly do
8502 echo '#!'"$__progname" >foo
8504 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'
8509 ./foo | while IFS= read -r line; do
8510 print -r -- "{$line}"
8513 [220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT
\r
8514 220->> Bitte keine Werbung einwerfen! <<
\r\r
8515 220 Who do you wanna pretend to be today?
\r]
8516 {220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT
\r}
8517 {220->> Bitte keine Werbung einwerfen! <<
\r\r}
8518 {220 Who do you wanna pretend to be today?
\r}
8520 name: print-nul-chars
8522 Check handling of NUL characters for print and COMSUB
8525 print $(($(print '<\0>' | wc -c))) $(($(print "$x" | wc -c))) \
8527 expected-stdout-pattern:
8532 Check backslash expansion by the print builtin
8534 print '\ \!\"\#\$\%\&'\\\''\(\)\*\+\,\-\.\/\0\1\2\3\4\5\6\7\8' \
8535 '\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T' \
8536 '\U\V\W\X\Y\Z\[\\\]\^\_\`\a\b \d\e\f\g\h\i\j\k\l\m\n\o\p' \
8537 '\q\r\s\t\u\v\w\x\y\z\{\|\}\~' '\u20acd' '\U20acd' '\x123' \
8538 '\0x' '\0123' '\01234' | {
8539 # integer-base-one-3As
8540 typeset -Uui16 -Z11 pos=0
8541 typeset -Uui16 -Z5 hv=2147483647
8545 while IFS= read -r line; do
8547 while [[ -n $line ]]; do
8549 if (( (pos & 15) == 0 )); then
8550 (( pos )) && print "$dasc|"
8551 print -n "${pos#16#} "
8554 print -n "${hv#16#} "
8555 if (( (hv < 32) || (hv > 126) )); then
8558 dasc=$dasc${line::1}
8560 (( (pos++ & 15) == 7 )) && print -n -- '- '
8564 while (( pos & 15 )); do
8566 (( (pos++ & 15) == 7 )) && print -n -- '- '
8568 (( hv == 2147483647 )) || print "$dasc|"
8571 00000000 5C 20 5C 21 5C 22 5C 23 - 5C 24 5C 25 5C 26 5C 27 |\ \!\"\#\$\%\&\'|
8572 00000010 5C 28 5C 29 5C 2A 5C 2B - 5C 2C 5C 2D 5C 2E 5C 2F |\(\)\*\+\,\-\.\/|
8573 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|
8574 00000030 20 5C 39 5C 3A 5C 3B 5C - 3C 5C 3D 5C 3E 5C 3F 5C | \9\:\;\<\=\>\?\|
8575 00000040 40 5C 41 5C 42 5C 43 5C - 44 1B 5C 46 5C 47 5C 48 |@\A\B\C\D.\F\G\H|
8576 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|
8577 00000060 5C 51 5C 52 5C 53 5C 54 - 20 5C 56 5C 57 5C 58 5C |\Q\R\S\T \V\W\X\|
8578 00000070 59 5C 5A 5C 5B 5C 5C 5D - 5C 5E 5C 5F 5C 60 07 08 |Y\Z\[\]\^\_\`..|
8579 00000080 20 20 5C 64 1B 0C 5C 67 - 5C 68 5C 69 5C 6A 5C 6B | \d..\g\h\i\j\k|
8580 00000090 5C 6C 5C 6D 0A 5C 6F 5C - 70 20 5C 71 0D 5C 73 09 |\l\m.\o\p \q.\s.|
8581 000000A0 0B 5C 77 5C 79 5C 7A 5C - 7B 5C 7C 5C 7D 5C 7E 20 |.\w\y\z\{\|\}\~ |
8582 000000B0 E2 82 AC 64 20 EF BF BD - 20 12 33 20 78 20 53 20 |...d ... .3 x S |
8583 000000C0 53 34 0A - |S4.|
8585 name: dollar-doublequoted-strings
8587 Check that a $ preceding "…" is ignored
8589 echo $"Localise me!"
8594 I do not take a $V for a V!
8599 I do not take a $V for a V!
8601 name: dollar-quoted-strings
8603 Check backslash expansion by $'…' strings
8605 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
8607 ./pfn $'\ \!\"\#\$\%\&\'\(\)\*\+\,\-\.\/ \1\2\3\4\5\6' \
8608 $'a\0b' $'a\01b' $'\7\8\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I' \
8609 $'\J\K\L\M\N\O\P\Q\R\S\T\U1\V\W\X\Y\Z\[\\\]\^\_\`\a\b\d\e' \
8610 $'\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u1\v\w\x1\y\z\{\|\}\~ $x' \
8611 $'\u20acd' $'\U20acd' $'\x123' $'fn\x0rd' $'\0234' $'\234' \
8612 $'\2345' $'\ca' $'\c!' $'\c?' $'\c€' $'a\
8614 # integer-base-one-3As
8615 typeset -Uui16 -Z11 pos=0
8616 typeset -Uui16 -Z5 hv=2147483647
8620 while IFS= read -r line; do
8622 while [[ -n $line ]]; do
8624 if (( (pos & 15) == 0 )); then
8625 (( pos )) && print "$dasc|"
8626 print -n "${pos#16#} "
8629 print -n "${hv#16#} "
8630 if (( (hv < 32) || (hv > 126) )); then
8633 dasc=$dasc${line::1}
8635 (( (pos++ & 15) == 7 )) && print -n -- '- '
8639 while (( pos & 15 )); do
8641 (( (pos++ & 15) == 7 )) && print -n -- '- '
8643 (( hv == 2147483647 )) || print "$dasc|"
8646 00000000 20 21 22 23 24 25 26 27 - 28 29 2A 2B 2C 2D 2E 2F | !"#$%&'()*+,-./|
8647 00000010 20 01 02 03 04 05 06 0A - 61 0A 61 01 62 0A 07 38 | .......a.a.b..8|
8648 00000020 39 3A 3B 3C 3D 3E 3F 40 - 41 42 43 44 1B 46 47 48 |9:;<=>?@ABCD.FGH|
8649 00000030 49 0A 4A 4B 4C 4D 4E 4F - 50 51 52 53 54 01 56 57 |I.JKLMNOPQRST.VW|
8650 00000040 58 59 5A 5B 5C 5D 5E 5F - 60 07 08 64 1B 0A 0C 67 |XYZ[\]^_`..d...g|
8651 00000050 68 69 6A 6B 6C 6D 0A 6F - 70 71 0D 73 09 01 0B 77 |hijklm.opq.s...w|
8652 00000060 01 79 7A 7B 7C 7D 7E 20 - 24 78 0A E2 82 AC 64 0A |.yz{|}~ $x....d.|
8653 00000070 EF BF BD 0A C4 A3 0A 66 - 6E 0A 13 34 0A 9C 0A 9C |.......fn..4....|
8654 00000080 35 0A 01 0A 01 0A 7F 0A - 02 82 AC 0A 61 0A 62 0A |5...........a.b.|
8656 name: dollar-quotes-in-heredocs-strings
8658 They are, however, not parsed in here documents, here strings
8659 (outside of string delimiters) or regular strings, but in
8660 parameter substitutions.
8663 dollar = strchr(s, '$'); /* ' */
8669 cat <<<"dollar = strchr(s, '$'); /* ' */"
8670 cat <<<'dollar = strchr(s, '\''$'\''); /* '\'' */'
8671 x="dollar = strchr(s, '$'); /* ' */"
8674 unset nl; print -r -- "x${nl:=$'\n'}y"
8680 # probably never reached for here strings?
8682 cat <<<"4 foo\\\"bar"
8684 # old scripts use this (e.g. ncurses)
8686 # make sure this works, outside of quotes
8689 dollar = strchr(s, '$'); /* ' */
8692 dollar = strchr(s, '$'); /* ' */
8693 dollar = strchr(s, '$'); /* ' */
8694 dollar = strchr(s, '$'); /* ' */
8706 name: dot-needs-argument
8708 check Debian #415167 solution: '.' without arguments should fail
8711 "$__progname" -c source
8712 expected-exit: e != 0
8713 expected-stderr-pattern:
8714 /\.: missing argument.*\n.*\.: missing argument/
8716 name: alias-function-no-conflict
8718 make aliases not conflict with functions
8719 note: for ksh-like functions, the order of preference is
8720 different; bash outputs baz instead of bar in line 2 below
8722 alias foo='echo bar'
8726 alias korn='echo bar'
8733 foo 2>/dev/null || echo rab
8739 name: bash-function-parens
8741 ensure the keyword function is ignored when preceding
8742 POSIX style function declarations (bashism)
8745 echo '#!'"$__progname"
8747 echo ' echo "bar='\''$0'\'\"
8751 mk 'function foo' >f-korn
8753 mk 'function foo ()' >f-bash
8754 mk 'function stop ()' stop >f-stop
8755 print '#!'"$__progname"'\nprint -r -- "${0%/f-argh}"' >f-argh
8758 x="korn: $(./f-korn)"; echo "${x/@("$u")/.}"
8759 x="dash: $(./f-dash)"; echo "${x/@("$u")/.}"
8760 x="bash: $(./f-bash)"; echo "${x/@("$u")/.}"
8761 x="stop: $(./f-stop)"; echo "${x/@("$u")/.}"
8764 dash: bar='./f-dash'
8765 bash: bar='./f-bash'
8766 stop: bar='./f-stop'
8768 name: integer-base-one-1
8770 check if the use of fake integer base 1 works
8773 typeset -Uui16 i0=1#ï i1=1#â
\82¬
8775 typeset -i1 o1a=0x263A
8776 typeset -Uui1 o0b=0x7E
8777 typeset -Uui1 o1b=0xFDD0
8778 integer px=0xCAFE 'p0=1# ' p1=1#… pl=1#f
8779 echo "in <$i0> <$i1>"
8780 echo "out <${o0a#1#}|${o0b#1#}> <${o1a#1#}|${o1b#1#}>"
8782 echo "pass <$px> <$p0> <$p1> <$pl> <${i0#1#}|${i1#1#}>"
8783 typeset -Uui16 tv1=1#~ tv2=1#
\7f tv3=1#
\80 tv4=1#
\81 tv5=1#À tv6=1#Á tv7=1#Â tv8=1#Â
\80
8784 echo "specX <${tv1#16#}> <${tv2#16#}> <${tv3#16#}> <${tv4#16#}> <${tv5#16#}> <${tv6#16#}> <${tv7#16#}> <${tv8#16#}>"
8785 typeset -i1 tv1 tv2 tv3 tv4 tv5 tv6 tv7 tv8
8786 echo "specW <${tv1#1#}> <${tv2#1#}> <${tv3#1#}> <${tv4#1#}> <${tv5#1#}> <${tv6#1#}> <${tv7#1#}> <${tv8#1#}>"
8787 typeset -i1 xs1=0xEF7F xs2=0xEF80 xs3=0xFDD0
8788 echo "specU <${xs1#1#}> <${xs2#1#}> <${xs3#1#}>"
8790 in <16#EFEF> <16#20AC>
8792 pass <16#cafe> <1# > <1#â
\80¦> <1#f> <ï|â
\82¬>
8793 specX <7E> <7F> <EF80> <EF81> <EFC0> <EFC1> <A0> <80>
8794 specW <~> <
\7f> <
\80> <
\81> <À> <Á> <Â > <Â
\80>
8795 specU <> <
\80> <ï·
\90>
8797 name: integer-base-one-2a
8799 check if the use of fake integer base 1 stops at correct characters
8804 expected-stderr-pattern:
8805 /1#foo: unexpected 'oo'/
8806 expected-exit: e != 0
8808 name: integer-base-one-2b
8810 check if the use of fake integer base 1 stops at correct characters
8815 expected-stderr-pattern:
8816 /1#À
\80: unexpected '
\80'/
8817 expected-exit: e != 0
8819 name: integer-base-one-2c1
8821 check if the use of fake integer base 1 stops at correct characters
8829 name: integer-base-one-2c2
8831 check if the use of fake integer base 1 stops at correct characters
8836 expected-stderr-pattern:
8837 /1#â
\80¦: unexpected '
\80'/
8838 expected-exit: e != 0
8840 name: integer-base-one-2d1
8842 check if the use of fake integer base 1 handles octets okay
8846 echo /$x/ # invalid utf-8
8850 name: integer-base-one-2d2
8852 check if the use of fake integer base 1 handles octets
8856 echo /$x/ # invalid 2-byte
8860 name: integer-base-one-2d3
8862 check if the use of fake integer base 1 handles octets
8866 echo /$x/ # invalid 2-byte
8870 name: integer-base-one-2d4
8872 check if the use of fake integer base 1 stops at invalid input
8875 typeset -i16 x=1#ï¿À
8876 echo /$x/ # invalid 3-byte
8877 expected-stderr-pattern:
8878 /1#ï¿À: unexpected '¿'/
8879 expected-exit: e != 0
8881 name: integer-base-one-2d5
8883 check if the use of fake integer base 1 stops at invalid input
8886 typeset -i16 x=1#À
\80
8887 echo /$x/ # non-minimalistic
8888 expected-stderr-pattern:
8889 /1#À
\80: unexpected '
\80'/
8890 expected-exit: e != 0
8892 name: integer-base-one-2d6
8894 check if the use of fake integer base 1 stops at invalid input
8897 typeset -i16 x=1#à
\80\80
8898 echo /$x/ # non-minimalistic
8899 expected-stderr-pattern:
8900 /1#à
\80\80: unexpected '
\80'/
8901 expected-exit: e != 0
8903 name: integer-base-one-3As
8905 some sample code for hexdumping
8906 not NUL safe; input lines must be NL terminated
8909 print 'Hello, World!\\\nこんにちは!'
8910 typeset -Uui16 i=0x100
8911 # change that to 0xFF once we can handle embedded
8912 # NUL characters in strings / here documents
8913 while (( i++ < 0x1FF )); do
8914 print -n "\x${i#16#1}"
8918 # integer-base-one-3As
8919 typeset -Uui16 -Z11 pos=0
8920 typeset -Uui16 -Z5 hv=2147483647
8924 while IFS= read -r line; do
8926 while [[ -n $line ]]; do
8928 if (( (pos & 15) == 0 )); then
8929 (( pos )) && print "$dasc|"
8930 print -n "${pos#16#} "
8933 print -n "${hv#16#} "
8934 if (( (hv < 32) || (hv > 126) )); then
8937 dasc=$dasc${line::1}
8939 (( (pos++ & 15) == 7 )) && print -n -- '- '
8943 while (( pos & 15 )); do
8945 (( (pos++ & 15) == 7 )) && print -n -- '- '
8947 (( hv == 2147483647 )) || print "$dasc|"
8950 00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..|
8951 00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................|
8952 00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................|
8953 00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................|
8954 00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.|
8955 00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>|
8956 00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN|
8957 00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^|
8958 00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn|
8959 00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~|
8960 000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................|
8961 000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................|
8962 000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................|
8963 000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................|
8964 000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................|
8965 000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................|
8966 00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................|
8967 00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................|
8968 00000120 FF 7A 0A - |.z.|
8970 name: integer-base-one-3Ws
8972 some sample code for hexdumping Unicode
8973 not NUL safe; input lines must be NL terminated
8977 print 'Hello, World!\\\nこんにちは!'
8978 typeset -Uui16 i=0x100
8979 # change that to 0xFF once we can handle embedded
8980 # NUL characters in strings / here documents
8981 while (( i++ < 0x1FF )); do
8982 print -n "\u${i#16#1}"
8985 print \\xff # invalid utf-8
8986 print \\xc2 # invalid 2-byte
8987 print \\xef\\xbf\\xc0 # invalid 3-byte
8988 print \\xc0\\x80 # non-minimalistic
8989 print \\xe0\\x80\\x80 # non-minimalistic
8990 print '�' # end of range
8991 print '\0z' # embedded NUL
8993 # integer-base-one-3Ws
8994 typeset -Uui16 -Z11 pos=0
8995 typeset -Uui16 -Z7 hv
9000 while IFS= read -r line; do
9003 while (( lpos < ${#line} )); do
9004 wc=1#${line:(lpos++):1}
9005 if (( (wc < 32) || \
9006 ((wc > 126) && (wc < 160)) )); then
9008 elif (( (wc & 0xFF80) == 0xEF80 )); then
9013 if (( (pos & 7) == 7 )); then
9016 elif (( (pos & 7) == 0 )); then
9017 (( pos )) && print "$dasc|"
9018 print -n "${pos#16#} "
9022 print -n "${hv#16#} "
9023 (( (pos++ & 7) == 3 )) && \
9028 while (( pos & 7 )); do
9030 (( (pos++ & 7) == 3 )) && print -n -- '- '
9032 (( hv == 2147483647 )) || print "$dasc|"
9035 00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W|
9036 00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.こ|
9037 00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |んにちは!...|
9038 00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........|
9039 00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........|
9040 00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........|
9041 00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"|
9042 00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*|
9043 00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012|
9044 00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:|
9045 00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB|
9046 00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ|
9047 00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR|
9048 00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ|
9049 00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab|
9050 00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij|
9051 00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr|
9052 00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz|
9053 00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....|
9054 00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........|
9055 000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........|
9056 000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........|
9057 000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |..... ¡¢|
9058 000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA |£¤¥¦§¨©ª|
9059 000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 |«¬®¯°±²|
9060 000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA |³´µ¶·¸¹º|
9061 000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 |»¼½¾¿ÀÁÂ|
9062 000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA |ÃÄÅÆÇÈÉÊ|
9063 000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 |ËÌÍÎÏÐÑÒ|
9064 000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA |ÓÔÕÖ×ØÙÚ|
9065 000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 |ÛÜÝÞßàáâ|
9066 000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA |ãäåæçèéê|
9067 00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 |ëìíîïðñò|
9068 00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA |óôõö÷øùú|
9069 00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |ûüýþÿ.�.|
9070 00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |�.���.��|
9071 00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |.���.���|
9072 00000128 EFBE EFEF EFBF EFBF - 000A 007A 000A |����.z.|
9074 name: integer-base-one-3Ar
9076 some sample code for hexdumping; NUL and binary safe
9079 print 'Hello, World!\\\nこんにちは!'
9080 typeset -Uui16 i=0x100
9081 # change that to 0xFF once we can handle embedded
9082 # NUL characters in strings / here documents
9083 while (( i++ < 0x1FF )); do
9084 print -n "\x${i#16#1}"
9088 # integer-base-one-3Ar
9089 typeset -Uui16 -Z11 pos=0
9090 typeset -Uui16 -Z5 hv=2147483647
9092 if read -arN -1 line; then
9095 while (( i < ${#line[*]} )); do
9097 if (( (pos & 15) == 0 )); then
9098 (( pos )) && print "$dasc|"
9099 print -n "${pos#16#} "
9102 print -n "${hv#16#} "
9103 if (( (hv < 32) || (hv > 126) )); then
9106 dasc=$dasc${line[i-1]#1#}
9108 (( (pos++ & 15) == 7 )) && print -n -- '- '
9111 while (( pos & 15 )); do
9113 (( (pos++ & 15) == 7 )) && print -n -- '- '
9115 (( hv == 2147483647 )) || print "$dasc|"
9118 00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..|
9119 00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................|
9120 00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................|
9121 00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................|
9122 00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.|
9123 00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>|
9124 00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN|
9125 00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^|
9126 00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn|
9127 00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~|
9128 000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................|
9129 000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................|
9130 000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................|
9131 000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................|
9132 000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................|
9133 000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................|
9134 00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................|
9135 00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................|
9136 00000120 FF 00 7A 0A - |..z.|
9138 name: integer-base-one-3Wr
9140 some sample code for hexdumping Unicode; NUL and binary safe
9144 print 'Hello, World!\\\nこんにちは!'
9145 typeset -Uui16 i=0x100
9146 # change that to 0xFF once we can handle embedded
9147 # NUL characters in strings / here documents
9148 while (( i++ < 0x1FF )); do
9149 print -n "\u${i#16#1}"
9152 print \\xff # invalid utf-8
9153 print \\xc2 # invalid 2-byte
9154 print \\xef\\xbf\\xc0 # invalid 3-byte
9155 print \\xc0\\x80 # non-minimalistic
9156 print \\xe0\\x80\\x80 # non-minimalistic
9157 print '�' # end of range
9158 print '\0z' # embedded NUL
9160 # integer-base-one-3Wr
9161 typeset -Uui16 -Z11 pos=0
9162 typeset -Uui16 -Z7 hv=2147483647
9164 if read -arN -1 line; then
9167 while (( i < ${#line[*]} )); do
9169 if (( (hv < 32) || \
9170 ((hv > 126) && (hv < 160)) )); then
9172 elif (( (hv & 0xFF80) == 0xEF80 )); then
9177 if (( (pos & 7) == 7 )); then
9180 elif (( (pos & 7) == 0 )); then
9181 (( pos )) && print "$dasc|"
9182 print -n "${pos#16#} "
9185 print -n "${hv#16#} "
9186 (( (pos++ & 7) == 3 )) && \
9191 while (( pos & 7 )); do
9193 (( (pos++ & 7) == 3 )) && print -n -- '- '
9195 (( hv == 2147483647 )) || print "$dasc|"
9198 00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W|
9199 00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.こ|
9200 00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |んにちは!...|
9201 00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........|
9202 00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........|
9203 00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........|
9204 00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"|
9205 00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*|
9206 00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012|
9207 00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:|
9208 00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB|
9209 00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ|
9210 00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR|
9211 00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ|
9212 00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab|
9213 00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij|
9214 00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr|
9215 00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz|
9216 00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....|
9217 00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........|
9218 000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........|
9219 000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........|
9220 000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |..... ¡¢|
9221 000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA |£¤¥¦§¨©ª|
9222 000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 |«¬®¯°±²|
9223 000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA |³´µ¶·¸¹º|
9224 000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 |»¼½¾¿ÀÁÂ|
9225 000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA |ÃÄÅÆÇÈÉÊ|
9226 000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 |ËÌÍÎÏÐÑÒ|
9227 000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA |ÓÔÕÖ×ØÙÚ|
9228 000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 |ÛÜÝÞßàáâ|
9229 000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA |ãäåæçèéê|
9230 00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 |ëìíîïðñò|
9231 00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA |óôõö÷øùú|
9232 00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |ûüýþÿ.�.|
9233 00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |�.���.��|
9234 00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |.���.���|
9235 00000128 EFBE EFEF EFBF EFBF - 000A 0000 007A 000A |����..z.|
9237 name: integer-base-one-4
9239 Check if ksh93-style base-one integers work
9244 (echo 2f $(('aa'))) 2>&1 | sed "s/^[^']*'/2p '/"
9252 2p 'aa': multi-character character constant
9258 name: integer-base-one-5A
9260 Check to see that we’re NUL and Unicode safe
9263 print 'a\0b\xfdz' >x
9269 16#61 16#0 16#62 16#FD 16#7A .
9271 name: integer-base-one-5W
9273 Check to see that we’re NUL and Unicode safe
9282 16#61 16#0 16#62 16#20AC 16#63 .
9286 Check if we can use a specific syntax idiom for ulimit
9287 category: !os:syllable
9289 if ! x=$(ulimit -d) || [[ $x = unknown ]]; then
9290 #echo expected to fail on this OS
9293 ulimit -dS $x && echo okay
9300 Check some of the most basic invariants of I/O redirection
9305 print -u2 e$((i++)).
9330 Check if GNU bash-like I/O redirection works
9331 Part 1: this is also supported by GNU bash
9332 category: shell:legacy-no
9351 Check if GNU bash-like I/O redirection works
9352 Part 2: this is *not* supported by GNU bash
9353 category: shell:legacy-no
9372 Check if GNU bash-like I/O redirection works
9373 Part 2: this is *not* supported by GNU bash
9374 category: shell:legacy-no
9393 Check if GNU bash-like I/O redirection works
9394 Part 2: this is supported by GNU bash 4 only
9395 category: shell:legacy-no
9417 Check if GNU bash-like I/O redirection fails correctly
9418 Part 1: this is also supported by GNU bash
9419 category: shell:legacy-no
9435 expected-stderr-pattern: /.*: can't (create|overwrite) .*/
9439 Check if GNU bash-like I/O redirection fails correctly
9440 Part 2: this is *not* supported by GNU bash
9441 category: shell:legacy-no
9462 Check if GNU bash-like I/O redirection works
9463 Part 4: this is also supported by GNU bash,
9464 but failed in some mksh versions
9465 category: shell:legacy-no
9474 [[ -e bar ]] && threeout "$bf" &>foo
9487 name: bashiop-5-normal
9489 Check if GNU bash-like I/O redirection is only supported
9490 in !POSIX !sh mode as it breaks existing scripts' syntax
9491 category: shell:legacy-no
9493 :>x; echo 1 "$("$__progname" -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9494 :>x; echo 2 "$("$__progname" -o posix -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9495 :>x; echo 3 "$("$__progname" -o sh -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9501 name: bashiop-5-legacy
9503 Check if GNU bash-like I/O redirection is not parsed
9504 in lksh as it breaks existing scripts' syntax
9505 category: shell:legacy-yes
9507 :>x; echo 1 "$("$__progname" -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9508 :>x; echo 2 "$("$__progname" -o posix -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9509 :>x; echo 3 "$("$__progname" -o sh -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9517 Check for support of more than 9 file descriptors
9520 read -u10 foo 10<<< bar
9527 Check for support of more than 9 file descriptors
9543 for n in ${a#*=}; do echo 1hu ${n} .; done
9544 for n in "${a#*=}"; do echo 1hq ${n} .; done
9545 for n in ${a##*=}; do echo 2hu ${n} .; done
9546 for n in "${a##*=}"; do echo 2hq ${n} .; done
9547 for n in ${a%=*}; do echo 1pu ${n} .; done
9548 for n in "${a%=*}"; do echo 1pq ${n} .; done
9549 for n in ${a%%=*}; do echo 2pu ${n} .; done
9550 for n in "${a%%=*}"; do echo 2pq ${n} .; done
9557 name: oksh-and-list-error-1
9559 Test exit status of rightmost element in 2 element && list in -e mode
9562 echo "should not print"
9564 expected-exit: e != 0
9566 name: oksh-and-list-error-2
9568 Test exit status of rightmost element in 3 element && list in -e mode
9570 true && true && false
9571 echo "should not print"
9573 expected-exit: e != 0
9575 name: oksh-or-list-error-1
9577 Test exit status of || list in -e mode
9580 echo "should not print"
9582 expected-exit: e != 0
9584 name: oksh-longline-crash
9586 This used to cause a core dump
9589 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"
9590 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"
9591 for deplib in $deplibs; do
9594 new_libs="$deplib $new_libs"
9597 case " $specialdeplibs " in
9599 new_libs="$deplib $new_libs";;
9605 name: oksh-seterror-1
9607 The -e flag should be ignored when executing a compound list
9608 followed by an if statement.
9610 if true; then false && false; fi
9613 expected-exit: e == 0
9615 name: oksh-seterror-2
9617 The -e flag should be ignored when executing a compound list
9618 followed by an if statement.
9620 if true; then if true; then false && false; fi; fi
9623 expected-exit: e == 0
9625 name: oksh-seterror-3
9627 The -e flag should be ignored when executing a compound list
9628 followed by an elif statement.
9630 if true; then :; elif true; then false && false; fi
9632 expected-exit: e == 0
9634 name: oksh-seterror-4
9636 The -e flag should be ignored when executing a pipeline
9645 expected-exit: e == 0
9647 name: oksh-seterror-5
9649 The -e flag should be ignored when executing a pipeline
9655 expected-exit: e == 0
9657 name: oksh-seterror-6
9659 When trapping ERR and EXIT, both traps should run in -e mode
9660 when an error occurs.
9662 trap 'echo EXIT' EXIT
9669 expected-exit: e != 0
9674 name: oksh-seterror-7
9676 The -e flag within a command substitution should be honored
9678 echo $( set -e; false; echo foo )
9683 name: oksh-input-comsub
9685 A command substitution using input redirection should exit with
9686 failure if the input file does not exist.
9688 var=$(< non-existent)
9689 expected-exit: e != 0
9690 expected-stderr-pattern: /non-existent/
9692 name: oksh-empty-for-list
9694 A for list which expands to zero items should not execute the body.
9696 set foo bar baz ; for out in ; do echo $out ; done
9698 name: oksh-varfunction-mod1
9700 (Inspired by PR 2450 on OpenBSD.) Calling
9702 where f is a ksh style function, should not set FOO in the current
9703 env. If f is a Bourne style function, FOO should be set. Furthermore,
9704 the function should receive a correct value of FOO. However, differing
9705 from oksh, setting FOO in the function itself must change the value in
9706 setting FOO in the function itself should not change the value in
9709 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
9710 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
9711 done >env; chmod +x env; PATH=.:$PATH
9713 if [ x$FOO != xbar ]; then
9718 if [ "x$x" != "xFOO=bar" ]; then
9726 if [ x$FOO != xbar ]; then
9731 if [ "x$x" != "xFOO=bar" ]; then
9739 if [ $? != 0 ]; then
9742 if [ x$FOO != x ]; then
9746 if [ $? != 0 ]; then
9749 if [ x$FOO != xfoo ]; then
9754 if [ $? != 0 ]; then
9757 if [ x$FOO != xbarbar ]; then
9761 if [ $? != 0 ]; then
9764 if [ x$FOO != xfoo ]; then
9770 Verify that file descriptors > 2 are private for Korn shells
9771 AT&T ksh93 does this still, which means we must keep it as well
9772 category: shell:legacy-no
9773 file-setup: file 644 "test.sh"
9777 "$__progname" test.sh
9778 expected-exit: e != 0
9779 expected-stderr-pattern:
9780 /bad file descriptor/
9784 Verify that file descriptors > 2 are not private for POSIX shells
9785 See Debian Bug #154540, Closes: #499139
9786 file-setup: file 644 "test.sh"
9789 test -n "$POSH_VERSION" || set -o sh
9791 "$__progname" test.sh
9797 Verify that file descriptors > 2 are not private for LEGACY KSH
9798 category: shell:legacy-yes
9799 file-setup: file 644 "test.sh"
9803 "$__progname" test.sh
9809 COMSUB are now parsed recursively, so this works
9810 see also regression-6: matching parenthesēs bug
9811 Fails on: pdksh bash2 bash3 zsh
9812 Passes on: bash4 ksh93 mksh(20110313+)
9814 echo 1 $(case 1 in (1) echo yes;; (2) echo no;; esac) .
9815 echo 2 $(case 1 in 1) echo yes;; 2) echo no;; esac) .
9816 TEST=1234; echo 3 ${TEST: $(case 1 in (1) echo 1;; (*) echo 2;; esac)} .
9817 TEST=5678; echo 4 ${TEST: $(case 1 in 1) echo 1;; *) echo 2;; esac)} .
9818 a=($(case 1 in (1) echo 1;; (*) echo 2;; esac)); echo 5 ${a[0]} .
9819 a=($(case 1 in 1) echo 1;; *) echo 2;; esac)); echo 6 ${a[0]} .
9830 COMSUB are now parsed recursively, so this works
9831 Fails on: pdksh bash2 bash3 bash4 zsh
9832 Passes on: ksh93 mksh(20110313+)
9834 echo 1 $(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10)) .
9835 echo 2 $(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20)) .
9836 (( a = $(case 1 in (1) echo 1;; (*) echo 2;; esac) )); echo 3 $a .
9837 (( a = $(case 1 in 1) echo 1;; *) echo 2;; esac) )); echo 4 $a .
9838 a=($(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10))); echo 5 ${a[0]} .
9839 a=($(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20))); echo 6 ${a[0]} .
9850 RedHat BZ#496791 – another case of missing recursion
9851 in parsing COMSUB expressions
9852 Fails on: pdksh bash2 bash3¹ bash4¹ zsh
9853 Passes on: ksh93 mksh(20110305+)
9854 ① bash[34] seem to choke on comment ending with backslash-newline
9856 # a comment with " ' \
9859 # a comment with " ' \
9867 Extended test for COMSUB explaining why a recursive parser
9868 is a must (a non-recursive parser cannot pass all three of
9869 these test cases, especially the ‘#’ is difficult)
9871 print '#!'"$__progname"'\necho 1234' >id; chmod +x id; PATH=.:$PATH
9872 echo $(typeset -i10 x=16#20; echo $x)
9873 echo $(typeset -Uui16 x=16#$(id -u)
9876 typeset -Uui16 a=36#foo; c=2
9877 typeset -Uui16 b=36 #foo; d=2
9886 Check the tree dump functions for !MKSH_SMALL functionality
9889 x() { case $1 in u) echo x ;;& *) echo $1 ;; esac; }
9905 Check COMSUB works with aliases (does not expand them twice)
9907 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
9918 ./pfn "$(echo foo )"
9921 name: comsub-torture
9923 Check the tree dump functions work correctly
9925 if [[ -z $__progname ]]; then echo >&2 call me with __progname; exit 1; fi
9926 while IFS= read -r line; do
9927 if [[ $line = '#1' ]]; then
9930 elif [[ $line = EOFN* ]]; then
9931 fbody=$fbody$'\n'$line
9933 elif [[ $line != '#'* ]]; then
9934 fbody=$fbody$'\n\t'$line
9937 if (( lastf )); then
9938 x="inline_${nextf}() {"$fbody$'\n}\n'
9940 print -r -- "${x}typeset -f inline_$nextf" | "$__progname"
9941 x="function comsub_$nextf { x=\$("$fbody$'\n); }\n'
9943 print -r -- "${x}typeset -f comsub_$nextf" | "$__progname"
9944 x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n'
9946 print -r -- "${x}typeset -f reread_$nextf" | "$__progname"
9954 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
9956 (echo $foo | tr -dc 0-9; echo)
9958 cmd && echo ja || echo nein
9960 select file in *; do echo "<$file>" ; break ; done
9962 time for i in {1,2,3} ; do echo $i ; done
9964 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
9965 #TIF_TBANG_TDBRACKET_TELIF
9966 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
9968 i=1; while (( i < 10 )); do echo $i; let ++i; done
9970 i=10; until (( !--i )) ; do echo $i; done
9973 #TFUNCT_TBRACE_TASYNC
9974 function korn { echo eins; echo zwei ; }
9975 bourne () { logger * & }
9978 #IOWRITE_IOCLOB_IOHERE_noIOSKIP
9982 #IOWRITE_noIOCLOB_IOHERE_IOSKIP
9987 sh 1<>/dev/console 0<&1 2>&1
9988 #COMSUB_EXPRSUB_FUNSUB_VALSUB
9989 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
9990 #QCHAR_OQUOTE_CQUOTE
9991 echo fo\ob\"a\`r\'b\$az
9992 echo "fo\ob\"a\`r\'b\$az"
9993 echo 'fo\ob\"a\`r'\''b\$az'
9994 #OSUBST_CSUBST_OPAT_SPAT_CPAT
9995 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
9998 note there must be no space between EOFN and )
10002 note the space between EOFN and ) is actually part of the here document marker
10005 x=$(sysctl -n kern.version | sed 1q)
10006 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
10007 ed -s /etc/motd 2>&1 <<-EOF
10014 EOF)" = @(?) ]] && rm -f /etc/motd
10015 if [[ ! -s /etc/motd ]]; then
10016 install -c -o root -g wheel -m 664 /dev/null /etc/motd
10017 print -- "$x\n" >/etc/motd
10027 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
10030 vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4"
10032 function comsub_TCOM { x=$(
10033 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
10035 function comsub_TCOM {
10036 x=$(vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" )
10038 function reread_TCOM { x=$((
10039 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
10041 function reread_TCOM {
10042 x=$(( vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" ) | tr u x )
10044 inline_TPAREN_TPIPE_TLIST() {
10045 (echo $foo | tr -dc 0-9; echo)
10047 inline_TPAREN_TPIPE_TLIST() {
10048 ( echo $foo | tr -dc 0-9
10051 function comsub_TPAREN_TPIPE_TLIST { x=$(
10052 (echo $foo | tr -dc 0-9; echo)
10054 function comsub_TPAREN_TPIPE_TLIST {
10055 x=$(( echo $foo | tr -dc 0-9 ; echo ) )
10057 function reread_TPAREN_TPIPE_TLIST { x=$((
10058 (echo $foo | tr -dc 0-9; echo)
10060 function reread_TPAREN_TPIPE_TLIST {
10061 x=$(( ( echo $foo | tr -dc 0-9 ; echo ) ) | tr u x )
10063 inline_TAND_TOR() {
10064 cmd && echo ja || echo nein
10066 inline_TAND_TOR() {
10067 cmd && echo ja || echo nein
10069 function comsub_TAND_TOR { x=$(
10070 cmd && echo ja || echo nein
10072 function comsub_TAND_TOR {
10073 x=$(cmd && echo ja || echo nein )
10075 function reread_TAND_TOR { x=$((
10076 cmd && echo ja || echo nein
10078 function reread_TAND_TOR {
10079 x=$(( cmd && echo ja || echo nein ) | tr u x )
10082 select file in *; do echo "<$file>" ; break ; done
10091 function comsub_TSELECT { x=$(
10092 select file in *; do echo "<$file>" ; break ; done
10094 function comsub_TSELECT {
10095 x=$(select file in * ; do echo "<$file>" ; break ; done )
10097 function reread_TSELECT { x=$((
10098 select file in *; do echo "<$file>" ; break ; done
10100 function reread_TSELECT {
10101 x=$(( select file in * ; do echo "<$file>" ; break ; done ) | tr u x )
10103 inline_TFOR_TTIME() {
10104 time for i in {1,2,3} ; do echo $i ; done
10106 inline_TFOR_TTIME() {
10107 time for i in {1,2,3}
10112 function comsub_TFOR_TTIME { x=$(
10113 time for i in {1,2,3} ; do echo $i ; done
10115 function comsub_TFOR_TTIME {
10116 x=$(time for i in {1,2,3} ; do echo $i ; done )
10118 function reread_TFOR_TTIME { x=$((
10119 time for i in {1,2,3} ; do echo $i ; done
10121 function reread_TFOR_TTIME {
10122 x=$(( time for i in {1,2,3} ; do echo $i ; done ) | tr u x )
10125 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
10136 echo kann net bis drei zählen
10140 function comsub_TCASE { x=$(
10141 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
10143 function comsub_TCASE {
10144 x=$(case $foo in (1) echo eins ;& (2) echo zwei ;| (*) echo kann net bis drei zählen ;; esac )
10146 function reread_TCASE { x=$((
10147 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
10149 function reread_TCASE {
10150 x=$(( case $foo in (1) echo eins ;& (2) echo zwei ;| (*) echo kann net bis drei zählen ;; esac ) | tr u x )
10152 inline_TIF_TBANG_TDBRACKET_TELIF() {
10153 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
10155 inline_TIF_TBANG_TDBRACKET_TELIF() {
10166 function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$(
10167 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
10169 function comsub_TIF_TBANG_TDBRACKET_TELIF {
10170 x=$(if ! [[ 1 = 1 ]] ; then echo eins ; elif [[ 1 = 2 ]] ; then echo zwei ; else echo drei ; fi )
10172 function reread_TIF_TBANG_TDBRACKET_TELIF { x=$((
10173 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
10175 function reread_TIF_TBANG_TDBRACKET_TELIF {
10176 x=$(( if ! [[ 1 = 1 ]] ; then echo eins ; elif [[ 1 = 2 ]] ; then echo zwei ; else echo drei ; fi ) | tr u x )
10179 i=1; while (( i < 10 )); do echo $i; let ++i; done
10183 while let] " i < 10 "
10189 function comsub_TWHILE { x=$(
10190 i=1; while (( i < 10 )); do echo $i; let ++i; done
10192 function comsub_TWHILE {
10193 x=$(i=1 ; while let] " i < 10 " ; do echo $i ; let ++i ; done )
10195 function reread_TWHILE { x=$((
10196 i=1; while (( i < 10 )); do echo $i; let ++i; done
10198 function reread_TWHILE {
10199 x=$(( i=1 ; while let] " i < 10 " ; do echo $i ; let ++i ; done ) | tr u x )
10202 i=10; until (( !--i )) ; do echo $i; done
10206 until let] " !--i "
10211 function comsub_TUNTIL { x=$(
10212 i=10; until (( !--i )) ; do echo $i; done
10214 function comsub_TUNTIL {
10215 x=$(i=10 ; until let] " !--i " ; do echo $i ; done )
10217 function reread_TUNTIL { x=$((
10218 i=10; until (( !--i )) ; do echo $i; done
10220 function reread_TUNTIL {
10221 x=$(( i=10 ; until let] " !--i " ; do echo $i ; done ) | tr u x )
10230 function comsub_TCOPROC { x=$(
10233 function comsub_TCOPROC {
10236 function reread_TCOPROC { x=$((
10239 function reread_TCOPROC {
10240 x=$(( cat * |& ls ) | tr u x )
10242 inline_TFUNCT_TBRACE_TASYNC() {
10243 function korn { echo eins; echo zwei ; }
10244 bourne () { logger * & }
10246 inline_TFUNCT_TBRACE_TASYNC() {
10255 function comsub_TFUNCT_TBRACE_TASYNC { x=$(
10256 function korn { echo eins; echo zwei ; }
10257 bourne () { logger * & }
10259 function comsub_TFUNCT_TBRACE_TASYNC {
10260 x=$(function korn { echo eins ; echo zwei ; } ; bourne() { logger * & } )
10262 function reread_TFUNCT_TBRACE_TASYNC { x=$((
10263 function korn { echo eins; echo zwei ; }
10264 bourne () { logger * & }
10266 function reread_TFUNCT_TBRACE_TASYNC {
10267 x=$(( function korn { echo eins ; echo zwei ; } ; bourne() { logger * & } ) | tr u x )
10269 inline_IOREAD_IOCAT() {
10272 inline_IOREAD_IOCAT() {
10275 function comsub_IOREAD_IOCAT { x=$(
10278 function comsub_IOREAD_IOCAT {
10279 x=$(tr x u <foo >>bar )
10281 function reread_IOREAD_IOCAT { x=$((
10284 function reread_IOREAD_IOCAT {
10285 x=$(( tr x u <foo >>bar ) | tr u x )
10287 inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
10292 inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
10298 function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$(
10303 function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
10304 x=$(cat >|bar <<"EOFN"
10309 function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$((
10314 function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
10315 x=$(( cat >|bar <<"EOFN"
10320 inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
10325 inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
10331 function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$(
10336 function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
10337 x=$(cat >bar <<-EOFI
10342 function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$((
10347 function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
10348 x=$(( cat >bar <<-EOFI
10353 inline_IORDWR_IODUP() {
10354 sh 1<>/dev/console 0<&1 2>&1
10356 inline_IORDWR_IODUP() {
10357 sh 1<>/dev/console <&1 2>&1
10359 function comsub_IORDWR_IODUP { x=$(
10360 sh 1<>/dev/console 0<&1 2>&1
10362 function comsub_IORDWR_IODUP {
10363 x=$(sh 1<>/dev/console <&1 2>&1 )
10365 function reread_IORDWR_IODUP { x=$((
10366 sh 1<>/dev/console 0<&1 2>&1
10368 function reread_IORDWR_IODUP {
10369 x=$(( sh 1<>/dev/console <&1 2>&1 ) | tr u x )
10371 inline_COMSUB_EXPRSUB_FUNSUB_VALSUB() {
10372 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
10374 inline_COMSUB_EXPRSUB_FUNSUB_VALSUB() {
10375 echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;}
10377 function comsub_COMSUB_EXPRSUB_FUNSUB_VALSUB { x=$(
10378 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
10380 function comsub_COMSUB_EXPRSUB_FUNSUB_VALSUB {
10381 x=$(echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;} )
10383 function reread_COMSUB_EXPRSUB_FUNSUB_VALSUB { x=$((
10384 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
10386 function reread_COMSUB_EXPRSUB_FUNSUB_VALSUB {
10387 x=$(( echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;} ) | tr u x )
10389 inline_QCHAR_OQUOTE_CQUOTE() {
10390 echo fo\ob\"a\`r\'b\$az
10391 echo "fo\ob\"a\`r\'b\$az"
10392 echo 'fo\ob\"a\`r'\''b\$az'
10394 inline_QCHAR_OQUOTE_CQUOTE() {
10395 echo fo\ob\"a\`r\'b\$az
10396 echo "fo\ob\"a\`r\'b\$az"
10397 echo "fo\\ob\\\"a\\\`r"\'"b\\\$az"
10399 function comsub_QCHAR_OQUOTE_CQUOTE { x=$(
10400 echo fo\ob\"a\`r\'b\$az
10401 echo "fo\ob\"a\`r\'b\$az"
10402 echo 'fo\ob\"a\`r'\''b\$az'
10404 function comsub_QCHAR_OQUOTE_CQUOTE {
10405 x=$(echo fo\ob\"a\`r\'b\$az ; echo "fo\ob\"a\`r\'b\$az" ; echo "fo\\ob\\\"a\\\`r"\'"b\\\$az" )
10407 function reread_QCHAR_OQUOTE_CQUOTE { x=$((
10408 echo fo\ob\"a\`r\'b\$az
10409 echo "fo\ob\"a\`r\'b\$az"
10410 echo 'fo\ob\"a\`r'\''b\$az'
10412 function reread_QCHAR_OQUOTE_CQUOTE {
10413 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 )
10415 inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() {
10416 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
10418 inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() {
10419 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
10421 function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$(
10422 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
10424 function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT {
10425 x=$([[ ${foo#bl\(u\)b} = @(bar|baz) ]] )
10427 function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$((
10428 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
10430 function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT {
10431 x=$(( [[ ${foo#bl\(u\)b} = @(bar|baz) ]] ) | tr u x )
10433 inline_heredoc_closed() {
10435 note there must be no space between EOFN and )
10438 inline_heredoc_closed() {
10440 note there must be no space between EOFN and )
10445 function comsub_heredoc_closed { x=$(
10447 note there must be no space between EOFN and )
10450 function comsub_heredoc_closed {
10452 note there must be no space between EOFN and )
10456 function reread_heredoc_closed { x=$((
10458 note there must be no space between EOFN and )
10461 function reread_heredoc_closed {
10462 x=$(( x=$(cat <<EOFN
10463 note there must be no space between EOFN and )
10465 ) ; echo $x ) | tr u x )
10467 inline_heredoc_space() {
10469 note the space between EOFN and ) is actually part of the here document marker
10472 inline_heredoc_space() {
10474 note the space between EOFN and ) is actually part of the here document marker
10479 function comsub_heredoc_space { x=$(
10481 note the space between EOFN and ) is actually part of the here document marker
10484 function comsub_heredoc_space {
10485 x=$(x=$(cat <<EOFN\
10486 note the space between EOFN and ) is actually part of the here document marker
10490 function reread_heredoc_space { x=$((
10492 note the space between EOFN and ) is actually part of the here document marker
10495 function reread_heredoc_space {
10496 x=$(( x=$(cat <<EOFN\
10497 note the space between EOFN and ) is actually part of the here document marker
10499 ) ; echo $x ) | tr u x )
10501 inline_patch_motd() {
10502 x=$(sysctl -n kern.version | sed 1q)
10503 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
10504 ed -s /etc/motd 2>&1 <<-EOF
10511 EOF)" = @(?) ]] && rm -f /etc/motd
10512 if [[ ! -s /etc/motd ]]; then
10513 install -c -o root -g wheel -m 664 /dev/null /etc/motd
10514 print -- "$x\n" >/etc/motd
10517 inline_patch_motd() {
10518 x=$(sysctl -n kern.version | sed 1q )
10519 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
10527 )" = @(?) ]] && rm -f /etc/motd
10528 if [[ ! -s /etc/motd ]]
10530 install -c -o root -g wheel -m 664 /dev/null /etc/motd
10531 print -- "$x\n" >/etc/motd
10534 function comsub_patch_motd { x=$(
10535 x=$(sysctl -n kern.version | sed 1q)
10536 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
10537 ed -s /etc/motd 2>&1 <<-EOF
10544 EOF)" = @(?) ]] && rm -f /etc/motd
10545 if [[ ! -s /etc/motd ]]; then
10546 install -c -o root -g wheel -m 664 /dev/null /etc/motd
10547 print -- "$x\n" >/etc/motd
10550 function comsub_patch_motd {
10551 x=$(x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
10559 )" = @(?) ]] && 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 )
10561 function reread_patch_motd { x=$((
10562 x=$(sysctl -n kern.version | sed 1q)
10563 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
10564 ed -s /etc/motd 2>&1 <<-EOF
10571 EOF)" = @(?) ]] && rm -f /etc/motd
10572 if [[ ! -s /etc/motd ]]; then
10573 install -c -o root -g wheel -m 664 /dev/null /etc/motd
10574 print -- "$x\n" >/etc/motd
10577 function reread_patch_motd {
10578 x=$(( x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
10586 )" = @(?) ]] && 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 )
10588 inline_wdarrassign() {
10593 inline_wdarrassign() {
10601 function comsub_wdarrassign { x=$(
10606 function comsub_wdarrassign {
10607 x=$(case x in (x) a+=b ; set -A c+ -- d e ;; esac )
10609 function reread_wdarrassign { x=$((
10614 function reread_wdarrassign {
10615 x=$(( case x in (x) a+=b ; set -A c+ -- d e ;; esac ) | tr u x )
10618 name: comsub-torture-io
10620 Check the tree dump functions work correctly with I/O redirection
10622 if [[ -z $__progname ]]; then echo >&2 call me with __progname; exit 1; fi
10623 while IFS= read -r line; do
10624 if [[ $line = '#1' ]]; then
10627 elif [[ $line = EOFN* ]]; then
10628 fbody=$fbody$'\n'$line
10630 elif [[ $line != '#'* ]]; then
10631 fbody=$fbody$'\n\t'$line
10634 if (( lastf )); then
10635 x="inline_${nextf}() {"$fbody$'\n}\n'
10637 print -r -- "${x}typeset -f inline_$nextf" | "$__progname"
10638 x="function comsub_$nextf { x=\$("$fbody$'\n); }\n'
10640 print -r -- "${x}typeset -f comsub_$nextf" | "$__progname"
10641 x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n'
10643 print -r -- "${x}typeset -f reread_$nextf" | "$__progname"
10651 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
10652 #TPAREN_TPIPE_TLIST
10653 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
10655 cmd >&3 && >&3 echo ja || echo >&3 nein
10657 select file in *; do echo "<$file>" ; break >&3 ; done >&3
10659 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
10661 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
10662 #TIF_TBANG_TDBRACKET_TELIF
10663 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
10665 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
10667 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
10669 cat * >&3 |& >&3 ls
10670 #TFUNCT_TBRACE_TASYNC
10671 function korn { echo eins; echo >&3 zwei ; }
10672 bourne () { logger * >&3 & }
10674 echo $(true >&3) $((1+ 2))
10679 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
10682 vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" >&3
10684 function comsub_TCOM { x=$(
10685 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
10687 function comsub_TCOM {
10688 x=$(vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" >&3 )
10690 function reread_TCOM { x=$((
10691 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
10693 function reread_TCOM {
10694 x=$(( vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" >&3 ) | tr u x )
10696 inline_TPAREN_TPIPE_TLIST() {
10697 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
10699 inline_TPAREN_TPIPE_TLIST() {
10700 ( echo $foo | tr -dc 0-9 >&3
10703 function comsub_TPAREN_TPIPE_TLIST { x=$(
10704 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
10706 function comsub_TPAREN_TPIPE_TLIST {
10707 x=$(( echo $foo | tr -dc 0-9 >&3 ; echo >&3 ) >&3 )
10709 function reread_TPAREN_TPIPE_TLIST { x=$((
10710 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
10712 function reread_TPAREN_TPIPE_TLIST {
10713 x=$(( ( echo $foo | tr -dc 0-9 >&3 ; echo >&3 ) >&3 ) | tr u x )
10715 inline_TAND_TOR() {
10716 cmd >&3 && >&3 echo ja || echo >&3 nein
10718 inline_TAND_TOR() {
10719 cmd >&3 && echo ja >&3 || echo nein >&3
10721 function comsub_TAND_TOR { x=$(
10722 cmd >&3 && >&3 echo ja || echo >&3 nein
10724 function comsub_TAND_TOR {
10725 x=$(cmd >&3 && echo ja >&3 || echo nein >&3 )
10727 function reread_TAND_TOR { x=$((
10728 cmd >&3 && >&3 echo ja || echo >&3 nein
10730 function reread_TAND_TOR {
10731 x=$(( cmd >&3 && echo ja >&3 || echo nein >&3 ) | tr u x )
10734 select file in *; do echo "<$file>" ; break >&3 ; done >&3
10743 function comsub_TSELECT { x=$(
10744 select file in *; do echo "<$file>" ; break >&3 ; done >&3
10746 function comsub_TSELECT {
10747 x=$(select file in * ; do echo "<$file>" ; break >&3 ; done >&3 )
10749 function reread_TSELECT { x=$((
10750 select file in *; do echo "<$file>" ; break >&3 ; done >&3
10752 function reread_TSELECT {
10753 x=$(( select file in * ; do echo "<$file>" ; break >&3 ; done >&3 ) | tr u x )
10755 inline_TFOR_TTIME() {
10756 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
10758 inline_TFOR_TTIME() {
10764 function comsub_TFOR_TTIME { x=$(
10765 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
10767 function comsub_TFOR_TTIME {
10768 x=$(for i in {1,2,3} ; do time echo $i >&3 ; done >&3 )
10770 function reread_TFOR_TTIME { x=$((
10771 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
10773 function reread_TFOR_TTIME {
10774 x=$(( for i in {1,2,3} ; do time echo $i >&3 ; done >&3 ) | tr u x )
10777 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
10788 echo kann net bis drei zählen >&3
10792 function comsub_TCASE { x=$(
10793 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
10795 function comsub_TCASE {
10796 x=$(case $foo in (1) echo eins >&3 ;& (2) echo zwei >&3 ;| (*) echo kann net bis drei zählen >&3 ;; esac >&3 )
10798 function reread_TCASE { x=$((
10799 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
10801 function reread_TCASE {
10802 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 )
10804 inline_TIF_TBANG_TDBRACKET_TELIF() {
10805 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
10807 inline_TIF_TBANG_TDBRACKET_TELIF() {
10808 if ! [[ 1 = 1 ]] >&3
10811 elif [[ 1 = 2 ]] >&3
10818 function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$(
10819 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
10821 function comsub_TIF_TBANG_TDBRACKET_TELIF {
10822 x=$(if ! [[ 1 = 1 ]] >&3 ; then echo eins ; elif [[ 1 = 2 ]] >&3 ; then echo zwei ; else echo drei ; fi >&3 )
10824 function reread_TIF_TBANG_TDBRACKET_TELIF { x=$((
10825 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
10827 function reread_TIF_TBANG_TDBRACKET_TELIF {
10828 x=$(( if ! [[ 1 = 1 ]] >&3 ; then echo eins ; elif [[ 1 = 2 ]] >&3 ; then echo zwei ; else echo drei ; fi >&3 ) | tr u x )
10831 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
10835 while let] " i < 10 " >&3
10841 function comsub_TWHILE { x=$(
10842 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
10844 function comsub_TWHILE {
10845 x=$(i=1 ; while let] " i < 10 " >&3 ; do echo $i ; let ++i ; done >&3 )
10847 function reread_TWHILE { x=$((
10848 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
10850 function reread_TWHILE {
10851 x=$(( i=1 ; while let] " i < 10 " >&3 ; do echo $i ; let ++i ; done >&3 ) | tr u x )
10854 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
10858 until let] " !--i " >&3
10863 function comsub_TUNTIL { x=$(
10864 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
10866 function comsub_TUNTIL {
10867 x=$(i=10 ; until let] " !--i " >&3 ; do echo $i ; done >&3 )
10869 function reread_TUNTIL { x=$((
10870 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
10872 function reread_TUNTIL {
10873 x=$(( i=10 ; until let] " !--i " >&3 ; do echo $i ; done >&3 ) | tr u x )
10876 cat * >&3 |& >&3 ls
10882 function comsub_TCOPROC { x=$(
10883 cat * >&3 |& >&3 ls
10885 function comsub_TCOPROC {
10886 x=$(cat * >&3 |& ls >&3 )
10888 function reread_TCOPROC { x=$((
10889 cat * >&3 |& >&3 ls
10891 function reread_TCOPROC {
10892 x=$(( cat * >&3 |& ls >&3 ) | tr u x )
10894 inline_TFUNCT_TBRACE_TASYNC() {
10895 function korn { echo eins; echo >&3 zwei ; }
10896 bourne () { logger * >&3 & }
10898 inline_TFUNCT_TBRACE_TASYNC() {
10907 function comsub_TFUNCT_TBRACE_TASYNC { x=$(
10908 function korn { echo eins; echo >&3 zwei ; }
10909 bourne () { logger * >&3 & }
10911 function comsub_TFUNCT_TBRACE_TASYNC {
10912 x=$(function korn { echo eins ; echo zwei >&3 ; } ; bourne() { logger * >&3 & } )
10914 function reread_TFUNCT_TBRACE_TASYNC { x=$((
10915 function korn { echo eins; echo >&3 zwei ; }
10916 bourne () { logger * >&3 & }
10918 function reread_TFUNCT_TBRACE_TASYNC {
10919 x=$(( function korn { echo eins ; echo zwei >&3 ; } ; bourne() { logger * >&3 & } ) | tr u x )
10921 inline_COMSUB_EXPRSUB() {
10922 echo $(true >&3) $((1+ 2))
10924 inline_COMSUB_EXPRSUB() {
10925 echo $(true >&3 ) $((1+ 2))
10927 function comsub_COMSUB_EXPRSUB { x=$(
10928 echo $(true >&3) $((1+ 2))
10930 function comsub_COMSUB_EXPRSUB {
10931 x=$(echo $(true >&3 ) $((1+ 2)) )
10933 function reread_COMSUB_EXPRSUB { x=$((
10934 echo $(true >&3) $((1+ 2))
10936 function reread_COMSUB_EXPRSUB {
10937 x=$(( echo $(true >&3 ) $((1+ 2)) ) | tr u x )
10942 Check that non-subenvironment command substitution works
10962 You can now reliably use local and return in funsubs
10965 x=q; e=1; x=${ echo a; e=2; echo x$e;}; echo 1:y$x,$e,$?.
10966 x=q; e=1; x=${ echo a; typeset e=2; echo x$e;}; echo 2:y$x,$e,$?.
10967 x=q; e=1; x=${ echo a; typeset e=2; return 3; echo x$e;}; echo 3:y$x,$e,$?.
10975 Check that "value substitutions" work as advertised
10981 echo "before: x<$x> y<$y> z<$z> R<$REPLY>"
10984 echo "begin: x<$x> y<$y> z<$z> R<$REPLY>"
10989 echo "end: x<$x> y<$y> z<$z> R<$REPLY>"
10991 echo "after: x<$x> y<$y> z<$z> R<$REPLY>"
10992 # ensure trailing newlines are kept
10993 t=${|REPLY=$'foo\n\n';}
10995 echo -n this used to segfault
10996 echo ${|true;}$(true).
10998 before: x<1> y<2> z<3> R<4>
10999 begin: x<1> y<> z<3> R<>
11000 end: x<5> y<6> z<7> R<8>
11001 after: x<8> y<2> z<7> R<4>
11002 typeset t=$'foo\n\n'
11003 this used to segfault.
11007 Check that the short form [ $x ] works
11011 rv=$?; echo $((++i)) $rv
11013 rv=$?; echo $((++i)) $rv
11015 rv=$?; echo $((++i)) $rv
11017 rv=$?; echo $((++i)) $rv
11020 rv=$?; echo $((++i)) $rv
11022 rv=$?; echo $((++i)) $rv
11024 rv=$?; echo $((++i)) $rv
11026 rv=$?; echo $((++i)) $rv
11029 rv=$?; echo $((++i)) $rv
11031 rv=$?; echo $((++i)) $rv
11033 rv=$?; echo $((++i)) $rv
11035 rv=$?; echo $((++i)) $rv
11052 Check that the short form [[ $x ]] works (ksh93 extension)
11056 rv=$?; echo $((++i)) $rv
11058 rv=$?; echo $((++i)) $rv
11060 rv=$?; echo $((++i)) $rv
11062 rv=$?; echo $((++i)) $rv
11065 rv=$?; echo $((++i)) $rv
11067 rv=$?; echo $((++i)) $rv
11069 rv=$?; echo $((++i)) $rv
11071 rv=$?; echo $((++i)) $rv
11074 rv=$?; echo $((++i)) $rv
11076 rv=$?; echo $((++i)) $rv
11078 rv=$?; echo $((++i)) $rv
11080 rv=$?; echo $((++i)) $rv
11095 name: event-subst-3
11097 Check that '!' substitution in noninteractive mode is ignored
11098 file-setup: file 755 "falsetto"
11102 file-setup: file 755 "!false"
11106 export PATH=.:$PATH
11114 ! false; then echo foo; else echo bar; fi
11123 name: event-subst-0
11125 Check that '!' substitution in interactive mode is ignored
11128 file-setup: file 755 "falsetto"
11132 file-setup: file 755 "!false"
11136 export PATH=.:$PATH
11144 ! false; then echo foo; else echo bar; fi
11152 expected-stderr-pattern:
11157 Check that "set -u" matches (future) SUSv4 requirement
11163 if [[ -n $v ]]; then
11198 (mypid=$$; try mypid)
11200 ) 2>&1 | sed -e 's/^[^]]*]//' -e 's/^[^:]*: *//'
11201 exit ${PIPESTATUS[0]}
11205 y: parameter not set
11209 y: parameter not set
11213 2: parameter not set
11215 1: parameter not set
11223 !: parameter not set
11234 Testsuite for nameref (bound variables)
11249 set|grep ^ir2|sed 's/^/s1: /'
11250 typeset|grep ' ir2'|sed -e 's/^/s2: /' -e 's/nameref/typeset -n/'
11251 set -A blub -- e1 e2 e3
11252 typeset -n ind=blub
11253 typeset -n ir2=blub[2]
11254 echo !ind[1]: ${!ind[1]}
11256 echo ind[1]: ${ind[1]}
11276 Testsuite for nameref (bound variables)
11277 Functions, argument given directly, after local
11280 typeset bar=lokal baz=auch
11312 Advanced testsuite for bound variables (ksh93 fails this)
11314 typeset -n foo=bar[i]
11315 set -A bar -- b c a
11316 for i in 0 1 2 3; do
11327 Ensure we don't run in an infinite loop
11331 typeset -n foo=fnord fnord=foo
11341 expected-stderr-pattern:
11342 /fnord: expression recurses on parameter/
11344 name: better-parens-1a
11346 Check support for ((…)) and $((…)) vs (…) and $(…)
11348 if ( (echo fubar)|tr u x); then
11357 name: better-parens-1b
11359 Check support for ((…)) and $((…)) vs (…) and $(…)
11361 echo $( (echo fubar)|tr u x) $?
11365 name: better-parens-1c
11367 Check support for ((…)) and $((…)) vs (…) and $(…)
11369 x=$( (echo fubar)|tr u x); echo $x $?
11373 name: better-parens-2a
11375 Check support for ((…)) and $((…)) vs (…) and $(…)
11377 if ((echo fubar)|tr u x); then
11386 name: better-parens-2b
11388 Check support for ((…)) and $((…)) vs (…) and $(…)
11390 echo $((echo fubar)|tr u x) $?
11394 name: better-parens-2c
11396 Check support for ((…)) and $((…)) vs (…) and $(…)
11398 x=$((echo fubar)|tr u x); echo $x $?
11402 name: better-parens-3a
11404 Check support for ((…)) and $((…)) vs (…) and $(…)
11406 if ( (echo fubar)|(tr u x)); then
11415 name: better-parens-3b
11417 Check support for ((…)) and $((…)) vs (…) and $(…)
11419 echo $( (echo fubar)|(tr u x)) $?
11423 name: better-parens-3c
11425 Check support for ((…)) and $((…)) vs (…) and $(…)
11427 x=$( (echo fubar)|(tr u x)); echo $x $?
11431 name: better-parens-4a
11433 Check support for ((…)) and $((…)) vs (…) and $(…)
11435 if ((echo fubar)|(tr u x)); then
11444 name: better-parens-4b
11446 Check support for ((…)) and $((…)) vs (…) and $(…)
11448 echo $((echo fubar)|(tr u x)) $?
11452 name: better-parens-4c
11454 Check support for ((…)) and $((…)) vs (…) and $(…)
11456 x=$((echo fubar)|(tr u x)); echo $x $?
11462 Test what the echo builtin does (mksh)
11464 echo -n 'foo\x40bar'
11471 Test what the echo builtin does (POSIX)
11472 Note: this follows Debian Policy 10.4 which mandates
11473 that -n shall be treated as an option, not XSI which
11474 mandates it shall be treated as string but escapes
11477 test -n "$POSH_VERSION" || set -o posix
11478 echo -n 'foo\x40bar'
11483 name: echo-test-3-mnbsd
11485 Test what the echo builtin does, and test a compatibility flag.
11488 "$__progname" -c 'echo -n 1=\\x40$1; echo -e \\x2E' -- foo bar
11489 "$__progname" -o posix -c 'echo -n 2=\\x40$1; echo -e \\x2E' -- foo bar
11490 "$__progname" -o sh -c 'echo -n 3=\\x40$1; echo -e \\x2E' -- foo bar
11496 name: echo-test-3-normal
11498 Test what the echo builtin does, and test a compatibility flag.
11499 category: !mnbsdash
11501 "$__progname" -c 'echo -n 1=\\x40$1; echo -e \\x2E' -- foo bar
11502 "$__progname" -o posix -c 'echo -n 2=\\x40$1; echo -e \\x2E' -- foo bar
11503 "$__progname" -o sh -c 'echo -n 3=\\x40$1; echo -e \\x2E' -- foo bar
11509 name: utilities-getopts-1
11511 getopts sets OPTIND correctly for unparsed option
11514 while getopts :a optc; do
11515 echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
11519 OPTARG=, OPTIND=2, optc=a.
11520 OPTARG=, OPTIND=3, optc=a.
11521 OPTARG=x, OPTIND=4, optc=?.
11524 name: utilities-getopts-2
11529 while getopts a: optc; do
11530 echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
11534 OPTARG=Mary, OPTIND=3, optc=a.
11535 OPTARG=, OPTIND=4, optc=?.
11537 expected-stderr-pattern: /.*-x.*option/
11541 Check the new wcswidth feature
11545 print octets: ${#s} .
11546 print 8-bit width: ${%s} .
11548 print characters: ${#s} .
11549 print columns: ${%s} .
11552 print octets: ${#s} .
11553 print 8-bit width: ${%s} .
11555 print characters: ${#s} .
11556 print columns: ${%s} .
11569 Check some corner cases
11585 Check some corner cases
11588 expected-stderr-pattern:
11594 Check some corner cases
11597 expected-stderr-pattern:
11603 Check some corner cases
11606 expected-stderr-pattern:
11612 Check some corner cases
11621 Check proper return values for realpath
11622 category: os:mirbsd
11635 x=$(realpath "$wd/$1" 2>&1); y=$?
11636 print $((++i)) "?$1" =${x##*$wd/} !$y
11662 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
11667 3 ?dir/file =dir/file !0
11668 4 ?dir/nix =dir/nix !0
11670 6 ?file/ =file/: Not a directory !20
11671 7 ?file/file =file/file: Not a directory !20
11672 8 ?file/nix =file/nix: Not a directory !20
11675 11 ?nix/file =nix/file: No such file or directory !2
11676 12 ?nix/nix =nix/nix: No such file or directory !2
11679 15 ?lndir/file =dir/file !0
11680 16 ?lndir/nix =dir/nix !0
11681 17 ?lnfile =file !0
11682 18 ?lnfile/ =lnfile/: Not a directory !20
11683 19 ?lnfile/file =lnfile/file: Not a directory !20
11684 20 ?lnfile/nix =lnfile/nix: Not a directory !20
11687 23 ?lnnix/file =lnnix/file: No such file or directory !2
11688 24 ?lnnix/nix =lnnix/nix: No such file or directory !2
11689 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
11693 Ensure that exactly two leading slashes are not collapsed
11694 POSIX guarantees this exception, e.g. for UNC paths on Cygwin
11695 category: os:mirbsd
11705 realpath /usr///bin
11714 realpath //usr/include/../bin
11731 Crashed during March 2011, fixed on vernal equinōx ☺
11732 category: os:mirbsd,os:openbsd
11734 export MALLOC_OPTIONS=FGJPRSX
11735 "$__progname" -c 'x=$(tr z r <<<baz); echo $x'
11741 Check test - bug#465250
11743 test \( ! -e \) ; echo $?
11749 Check test - bug#465250
11751 test \( -e \) ; echo $?
11757 Check test - bug#465250
11759 test ! -e ; echo $?
11765 Check test - bug#465250
11773 Check that zsh case variants work
11807 Check that case end tokens are not mixed up (Debian #220272)
11810 for value in 'x' '}' 'esac'; do
11811 print -n "$((++i))($value)bourne "
11816 print -n "$((++i))($value)korn "
11830 name: command-shift
11832 Check that 'command shift' works
11835 echo "before 0='$0' 1='$1' 2='$2'"
11837 echo "after 0='$0' 1='$1' 2='$2'"
11840 echo "before 0='$0' 1='$1' 2='$2'"
11842 echo "after 0='$0' 1='$1' 2='$2'"
11844 echo = without command
11846 echo = with command
11851 before 0='snc' 1='一' 2='二'
11852 after 0='snc' 1='二' 2=''
11854 before 0='swc' 1='一' 2='二'
11855 after 0='swc' 1='二' 2=''
11860 Check that the compiler did not optimise-break them
11861 (lex.c has got a similar one in SHEREDELIM)
11866 while (( ++i < 256 )); do
11869 s+=$'\xC2\xA0\xE2\x82\xAC\xEF\xBF\xBD\xEF\xBF\xBE\xEF\xBF\xBF\xF0\x90\x80\x80.'
11872 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.'
11874 name: stateptr-underflow
11876 This check overflows an Xrestpos stored in a short in R40
11879 function Lb64decode {
11880 [[ -o utf8-mode ]]; local u=$?
11883 [[ -n $s ]] || { s=$(cat;print x); s=${s%x}; }
11884 local -i i=0 n=${#s} p=0 v x
11887 while (( i < n )); do
11891 ([A-Z]) (( v = 1#$c - 65 )) ;;
11892 ([a-z]) (( v = 1#$c - 71 )) ;;
11893 ([0-9]) (( v = 1#$c + 4 )) ;;
11898 (( x = (x << 6) | v ))
11901 (1) (( o = (x >> 4) & 255 )) ;;
11902 (2) (( o = (x >> 2) & 255 )) ;;
11903 (3) (( o = x & 255 ))
11915 while (( ++i < 12120 )); do
11918 Lb64decode $s >/dev/null
11922 Check that "set -x" doesn't redirect too quickly
11924 print '#!'"$__progname" >bash
11926 echo 'GNU bash, version 2.05b.0(1)-release (i386-ecce-mirbsd10)
11927 Copyright (C) 2002 Free Software Foundation, Inc.'
11930 "$__progname" -xc 'foo=$(./bash --version 2>&1 | head -1); echo "=$foo="'
11932 =GNU bash, version 2.05b.0(1)-release (i386-ecce-mirbsd10)=
11933 expected-stderr-pattern:
11938 Check that "set -x" is off during PS4 expansion
11945 PS4='[(p:$-)$(f)] '
11947 set -x -o inherit-xtrace
11956 [(p:sh)(f1:sh)(f2:sh)] print '(o1:shx)'
11957 [(p:sh)(f1:sh)(f2:sh)] set +x