1 # $MirOS: src/bin/mksh/check.t,v 1.721 2016/01/20 21:34:09 tg Exp $
4 # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
5 # 2011, 2012, 2013, 2014, 2015, 2016
6 # mirabilos <m@mirbsd.org>
8 # Provided that these terms and disclaimer and all copyright notices
9 # are retained or reproduced in an accompanying document, permission
10 # is granted to deal in this work without restriction, including un‐
11 # limited rights to use, publicly perform, distribute, sell, modify,
12 # merge, give away, or sublicence.
14 # This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
15 # the utmost extent permitted by applicable law, neither express nor
16 # implied; without malicious intent or gross negligence. In no event
17 # may a licensor, author or contributor be held liable for indirect,
18 # direct, other damage, loss, or other issues arising in any way out
19 # of dealing in the work, even if advised of the possibility of such
20 # damage or existence of a defect, except proven that it results out
21 # of said person’s immediate fault when using the work as intended.
23 # You may also want to test IFS with the script at
24 # http://www.research.att.com/~gsf/public/ifs.sh
27 # http://svnweb.freebsd.org/base/head/bin/test/tests/legacy_test.sh?view=co&content-type=text%2Fplain
29 # Integrated testsuites from:
30 # (2013/12/02 20:39:44) http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
33 @(#)MIRBSD KSH R52 2016/01/20
35 Check version of shell.
39 category: shell:legacy-no
42 @(#)LEGACY KSH R52 2016/01/20
44 Check version of legacy shell.
47 name: KSH_VERSION-legacy
48 category: shell:legacy-yes
52 Regression test self-testing
60 Regression test self-testing
69 Regression test self-testing
70 env-setup: !ENV=fnord!
78 Ensure that the test run directory (default /tmp but can be changed
79 with check.pl flag -T or test.sh $TMPDIR) is not mounted noexec, as
80 we execute scripts from the scratch directory during several tests.
82 print '#!'"$__progname"'\necho tf' >lq
90 Just output the environment variables set (always fails)
97 Check some things in the LEGACY KSH
98 category: shell:legacy-yes
102 [[ "$(set +o) -o" = *"-o emacs -o"* ]] && echo 1=emacs
103 [[ "$(set +o) -o" = *"-o vi -o"* ]] && echo 1=vi
106 [[ "$(set +o) -o" = *"-o emacs -o"* ]] && echo 2=emacs
107 [[ "$(set +o) -o" = *"-o vi -o"* ]] && echo 2=vi
112 name: selftest-direct-builtin-call
114 Check that direct builtin calls work
116 ln -s "$__progname" cat || cp "$__progname" cat
117 ln -s "$__progname" echo || cp "$__progname" echo
118 ./echo -c 'echo foo' | ./cat -u
124 Check that recursion is detected/avoided in aliases.
129 expected-stderr-pattern:
130 /fooBar.*not found.*/
134 Check that recursion is detected/avoided in aliases.
141 expected-stderr-pattern:
142 /fooBar.*not found.*\n.*barFoo.*not found/
146 Check that recursion is detected/avoided in aliases.
160 Check that alias expansion isn't done on keywords (in keyword
165 while false; do echo hi ; done
172 Check that alias expansion done after alias with trailing space.
175 alias foo='bar stuff '
176 alias bar='Bar1 Bar2 '
185 Check that alias expansion done after alias with trailing space.
197 Check that alias expansion done after alias with trailing space
202 X Y in 'Y') echo is y ;; Z) echo is z ; esac
208 Check that newlines in an alias don't cause the command to be lost.
228 Check that recursion is detected/avoided in aliases.
229 This check fails for slow machines or Cygwin, raise
230 the time-limit clause (e.g. to 7) if this occurs.
233 print '#!'"$__progname"'\necho tf' >lq
235 PATH=$PWD$PATHSEP$PATH
251 Check that recursion is detected/avoided in aliases.
252 Regression, introduced during an old bugfix.
254 alias foo='print hello '
255 alias bar='foo world'
262 Check that special argument handling still applies with escaped aliases
264 alias local='\typeset'
275 Check that arithmetic expressions are compound constructs
277 { ! (( 0$(cat >&2) )) <<<1; } <<<2
283 Check that only one side of ternary operator is evaluated
288 echo $((1 ? 20 : (x+=2)))
290 echo $((0 ? (y+=2) : 30))
300 Check that assignments not done on non-evaluated side of ternary
306 echo $((1 ? 20 : (x+=2)))
308 echo $((0 ? (y+=2) : 30))
318 Check that assignments not done on non-evaluated side of ternary
319 operator and this construct is parsed correctly (Debian #445651)
329 Check that preun/postun not done on non-evaluated side of ternary
332 (( m = n = 0, 1 ? n++ : m++ ? 2 : 3 ))
334 m=0; echo $(( 0 ? ++m : 2 )); echo $m
335 m=0; echo $(( 0 ? m++ : 2 )); echo $m
343 name: arith-ternary-prec-1
345 Check precedence of ternary operator vs assignment
349 expected-exit: e != 0
350 expected-stderr-pattern:
351 /.*:.*1 \? 20 : x\+=2.*lvalue.*\n$/
353 name: arith-ternary-prec-2
355 Check precedence of ternary operator vs assignment
358 echo $((0 ? x+=2 : 20))
362 name: arith-div-assoc-1
364 Check associativity of division operator
370 name: arith-div-byzero
372 Check division by zero errors out
378 expected-stderr-pattern:
381 name: arith-div-intmin-by-minusone
383 Check division overflow wraps around silently
386 echo signed:$((-2147483648 / -1))r$((-2147483648 % -1)).
387 echo unsigned:$((# -2147483648 / -1))r$((# -2147483648 % -1)).
389 signed:-2147483648r0.
390 unsigned:0r2147483648.
392 name: arith-div-intmin-by-minusone-64
394 Check division overflow wraps around silently
397 echo signed:$((-9223372036854775808 / -1))r$((-9223372036854775808 % -1)).
398 echo unsigned:$((# -9223372036854775808 / -1))r$((# -9223372036854775808 % -1)).
400 signed:-9223372036854775808r0.
401 unsigned:0r9223372036854775808.
403 name: arith-assop-assoc-1
405 Check associativity of assignment-operator operator
407 typeset -i i=1 j=2 k=3
408 echo $((i += j += k))
414 name: arith-mandatory
416 Passing of this test is *mandatory* for a valid mksh executable!
417 category: shell:legacy-no
422 print -r -- $((x++)):$sari=$uari. #0
424 print -r -- $((x++)):$sari=$uari. #1
425 sari=2147483647 uari=2147483647
426 print -r -- $((x++)):$sari=$uari. #2
428 print -r -- $((x++)):$sari=$uari. #3
430 let 'sari *= 2' 'uari *= 2'
432 print -r -- $((x++)):$sari=$uari. #4
434 print -r -- $((x++)):$sari=$uari. #5
435 sari=-2147483648 uari=-2147483648
436 print -r -- $((x++)):$sari=$uari. #6
438 print -r -- $((x++)):$sari=$uari. #7
440 ((# uari = -5 >> 1 ))
441 print -r -- $((x++)):$sari=$uari. #8
444 print -r -- $((x++)):$sari=$uari. #9
448 2:2147483647=2147483647.
449 3:-2147483648=2147483648.
452 6:-2147483648=2147483648.
453 7:2147483647=2147483647.
457 name: arith-unsigned-1
459 Check if unsigned arithmetics work
463 echo x1 $((-1)) $((#-1))
467 vs=4123456789; vu=4123456789
469 (( vs %= 2147483647 ))
470 (( vu %= 2147483647 ))
472 vs=4123456789; vu=4123456789
473 (( # vs %= 2147483647 ))
474 (( # vu %= 2147483647 ))
476 # make sure the calculation does not change unsigned flag
477 vs=4123456789; vu=4123456789
480 echo x6 $((# vs % 2147483647)) $((# vu % 2147483647))
485 echo x7 ${va[#4123456789%2147483647]}
486 # make sure multiple calculations don't interfere with each other
487 let '# mca = -4 % -2' ' mcb = -4 % -2'
491 x2 -171510507 4123456789
492 x3 -171510507 4123456789
493 x4 1975973142 1975973142
494 x5 -171510507 4123456789
495 x6 1975973142 1975973142
499 name: arith-limit32-1
501 Check if arithmetics are 32 bit
505 echo x1 $((-1)) $((#-1))
509 vs=2147483647; vu=2147483647
513 vs=4294967295; vu=4294967295
521 x2 2147483647 2147483647
522 x3 -2147483648 2147483648
527 name: arith-limit64-1
529 Check if arithmetics are 64 bit
533 echo x1 $((-1)) $((#-1))
537 vs=9223372036854775807; vu=9223372036854775807
541 vs=18446744073709551615; vu=18446744073709551615
548 x1 -1 18446744073709551615
549 x2 9223372036854775807 9223372036854775807
550 x3 -9223372036854775808 9223372036854775808
551 x4 -1 18446744073709551615
557 Check that \newline is not collapsed after #
567 Check that \newline is not collapsed inside single quotes
579 Check that \newline is not collapsed inside single quotes
591 Check interaction of aliases, single quotes and here-documents
592 with backslash-newline
593 (don't know what POSIX has to say about this)
615 Check what happens with backslash at end of input
616 (the old Bourne shell trashes them; so do we)
625 # Places \newline should be collapsed
629 Check that \newline is collapsed before, in the middle of, and
641 Check that \newline is collapsed in $ sequences
665 Check that \newline is collapsed in $(..) and `...` sequences
690 Check that \newline is collapsed in $((..)) sequences
701 echo $((1+2+3+4+5+6)\
712 Check that \newline is collapsed in double quoted strings
727 Check that \newline is collapsed in here document delimiters
728 (ksh93 fails second part of this)
750 Check that \newline is collapsed in double-quoted here-document
769 Check that \newline is collapsed in various 2+ character tokens
814 Check that \ at the end of an alias is collapsed when followed
816 (don't know what POSIX has to say about this)
826 Check that \newline in a keyword is collapsed
836 # Places \newline should be collapsed (ksh extensions)
840 Check that \newline is collapsed in extended globbing
857 Check that \newline is collapsed in ((...)) expressions
872 See if break breaks out of loops
874 for i in a b c; do echo $i; break; echo bad-$i; done
876 for i in a b c; do echo $i; break 1; echo bad-$i; done
902 See if break breaks out of nested loops
919 What if break used outside of any loops
920 (ksh88,ksh93 don't print error messages here)
923 expected-stderr-pattern:
928 What if break N used when only N-1 loops
929 (ksh88,ksh93 don't print error messages here)
931 for i in a b c; do echo $i; break 2; echo bad-$i; done
936 expected-stderr-pattern:
941 Error if break argument isn't a number
943 for i in a b c; do echo $i; break abc; echo more-$i; done
947 expected-exit: e != 0
948 expected-stderr-pattern:
953 See if continue continues loops
955 for i in a b c; do echo $i; continue; echo bad-$i ; done
957 for i in a b c; do echo $i; continue 1; echo bad-$i; done
993 See if continue breaks out of nested loops
1012 What if continue used outside of any loops
1013 (ksh88,ksh93 don't print error messages here)
1016 expected-stderr-pattern:
1021 What if continue N used when only N-1 loops
1022 (ksh88,ksh93 don't print error messages here)
1024 for i in a b c; do echo $i; continue 2; echo bad-$i; done
1031 expected-stderr-pattern:
1036 Error if continue argument isn't a number
1038 for i in a b c; do echo $i; continue abc; echo more-$i; done
1042 expected-exit: e != 0
1043 expected-stderr-pattern:
1048 Test someone's CD history package (uses arrays)
1050 # go to known place before doing anything
1064 if [ "$CDHISTFILE" -a -r "$CDHISTFILE" ] # if directory history exists
1068 while read -r t # read directory history file
1074 if [ "${CDHIST[0]}" != "$PWD" -a "$PWD" != "" ]
1076 _cdins # insert $PWD into cd history
1079 cdlen=${#CDHIST[*]} # number of elements in history
1083 if [ "$OLDPWD" = "" ] && ((cdlen>1))
1085 'print' ${CDHIST[1]}
1093 -l) # print directory list
1096 while (((i=i-1)>=0))
1099 'print' "$num ${CDHIST[i]}"
1103 -[0-9]|-[0-9][0-9]) # cd to dir in list
1104 if (((i=${1#-})<cdlen))
1106 'print' ${CDHIST[i]}
1114 -*) # cd to matched dir in list
1119 case ${CDHIST[i]} in
1121 'print' ${CDHIST[i]}
1141 _cdins # insert $PWD into cd history
1143 if [ "$CDHISTFILE" ]
1145 cdlen=${#CDHIST[*]} # number of elements in history
1150 'print' -r ${CDHIST[i]} # update directory history
1156 function _cdins # insert $PWD into cd history
1157 { # meant to be called only by _cd
1161 while ((i<${#CDHIST[*]})) # see if dir is already in list
1163 if [ "${CDHIST[$i]}" = "$PWD" ]
1170 if ((i>22)) # limit max size of list
1175 while (((i=i-1)>=0)) # bump old dirs in list
1177 CDHIST[i+1]=${CDHIST[i]}
1180 CDHIST[0]=$PWD # insert new directory in list
1208 Check package for cd -Pe
1210 # the mv command fails on Cygwin
1211 # Hurd aborts the testsuite (permission denied)
1212 # QNX does not find subdir to cd into
1213 category: !os:cygwin,!os:gnu,!os:msys,!os:nto,!os:os390,!nosymlink
1214 file-setup: file 644 "x"
1215 mkdir noread noread/target noread/target/subdir
1222 echo 1=$?,${PWD#$bwd/}
1223 epwd=$($TSHELL -c pwd 2>/dev/null)
1224 # This unexpectedly succeeds on GNU/Linux and MidnightBSD
1227 mv ../../noread ../../renamed
1229 echo 2=$?,${PWD#$bwd/}
1232 rm -rf noread link renamed
1234 export TSHELL="$__progname"
1241 2=0,noread/target/subdir
1245 2=1,noread/target/subdir
1249 Check that prompt not printed when processing ENV
1250 env-setup: !ENV=./foo!
1251 file-setup: file 644 "foo"
1266 Check that weird ${foo+bar} constructs are parsed correctly
1268 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
1269 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "<$x> "; done' >pfs
1271 (echo 1 ${IFS+'}'z}) 2>/dev/null || echo failed in 1
1272 (echo 2 "${IFS+'}'z}") 2>/dev/null || echo failed in 2
1273 (echo 3 "foo ${IFS+'bar} baz") 2>/dev/null || echo failed in 3
1274 (echo -n '4 '; ./pfn "foo ${IFS+"b c"} baz") 2>/dev/null || echo failed in 4
1275 (echo -n '5 '; ./pfn "foo ${IFS+b c} baz") 2>/dev/null || echo failed in 5
1276 (echo 6 ${IFS+"}"z}) 2>/dev/null || echo failed in 6
1277 (echo 7 "${IFS+"}"z}") 2>/dev/null || echo failed in 7
1278 (echo 8 "${IFS+\"}\"z}") 2>/dev/null || echo failed in 8
1279 (echo 9 "${IFS+\"\}\"z}") 2>/dev/null || echo failed in 9
1280 (echo 10 foo ${IFS+'bar} baz'}) 2>/dev/null || echo failed in 10
1281 (echo 11 "$(echo "${IFS+'}'z}")") 2>/dev/null || echo failed in 11
1282 (echo 12 "$(echo ${IFS+'}'z})") 2>/dev/null || echo failed in 12
1283 (echo 13 ${IFS+\}z}) 2>/dev/null || echo failed in 13
1284 (echo 14 "${IFS+\}z}") 2>/dev/null || echo failed in 14
1285 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
1286 l=t; (echo 16 ${IFS+h`echo -n i ${IFS+$l}h`ere}) 2>/dev/null || echo failed in 16
1287 l=t; (echo 17 ${IFS+h$(echo -n i ${IFS+$l}h)ere}) 2>/dev/null || echo failed in 17
1288 l=t; (echo 18 "${IFS+h`echo -n i ${IFS+$l}h`ere}") 2>/dev/null || echo failed in 18
1289 l=t; (echo 19 "${IFS+h$(echo -n i ${IFS+$l}h)ere}") 2>/dev/null || echo failed in 19
1290 l=t; (echo 20 ${IFS+h`echo -n i "${IFS+$l}"h`ere}) 2>/dev/null || echo failed in 20
1291 l=t; (echo 21 ${IFS+h$(echo -n i "${IFS+$l}"h)ere}) 2>/dev/null || echo failed in 21
1292 l=t; (echo 22 "${IFS+h`echo -n i "${IFS+$l}"h`ere}") 2>/dev/null || echo failed in 22
1293 l=t; (echo 23 "${IFS+h$(echo -n i "${IFS+$l}"h)ere}") 2>/dev/null || echo failed in 23
1294 key=value; (echo -n '24 '; ./pfn "${IFS+'$key'}") 2>/dev/null || echo failed in 24
1295 key=value; (echo -n '25 '; ./pfn "${IFS+"'$key'"}") 2>/dev/null || echo failed in 25 # ksh93: “'$key'”
1296 key=value; (echo -n '26 '; ./pfn ${IFS+'$key'}) 2>/dev/null || echo failed in 26
1297 key=value; (echo -n '27 '; ./pfn ${IFS+"'$key'"}) 2>/dev/null || echo failed in 27
1298 (echo -n '28 '; ./pfn "${IFS+"'"x ~ x'}'x"'}"x}" #') 2>/dev/null || echo failed in 28
1299 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
1300 (echo -n '30 '; ./pfs ${IFS+foo 'b\
1301 ar' baz}; echo .) 2>/dev/null || (echo failed in 30; echo failed in 31)
1302 (echo -n '32 '; ./pfs ${IFS+foo "b\
1303 ar" baz}; echo .) 2>/dev/null || echo failed in 32
1304 (echo -n '33 '; ./pfs "${IFS+foo 'b\
1305 ar' baz}"; echo .) 2>/dev/null || echo failed in 33
1306 (echo -n '34 '; ./pfs "${IFS+foo "b\
1307 ar" baz}"; echo .) 2>/dev/null || echo failed in 34
1308 (echo -n '35 '; ./pfs ${v=a\ b} x ${v=c\ d}; echo .) 2>/dev/null || echo failed in 35
1309 (echo -n '36 '; ./pfs "${v=a\ b}" x "${v=c\ d}"; echo .) 2>/dev/null || echo failed in 36
1310 (echo -n '37 '; ./pfs ${v-a\ b} x ${v-c\ d}; echo .) 2>/dev/null || echo failed in 37
1311 (echo 38 ${IFS+x'a'y} / "${IFS+x'a'y}" .) 2>/dev/null || echo failed in 38
1312 foo="x'a'y"; (echo 39 ${foo%*'a'*} / "${foo%*'a'*}" .) 2>/dev/null || echo failed in 39
1313 foo="a b c"; (echo -n '40 '; ./pfs "${foo#a}"; echo .) 2>/dev/null || echo failed in 40
1329 15 <foo abx{ {{{}b c d{} bar> <}> <baz> .
1343 29 <foo> <abx{ {{> <{}b> <c> <d{}> <bar> <}> <baz> .
1346 32 <foo> <bar> <baz> .
1347 33 <foo 'bar' baz> .
1349 35 <a> <b> <x> <a> <b> .
1350 36 <a\ b> <x> <a\ b> .
1351 37 <a b> <x> <c d> .
1356 name: expand-unglob-dblq
1358 Check that regular "${foo+bar}" constructs are parsed correctly
1363 test x"$v" = x"-" && unset v
1364 (echo "$1 plus norm foo ${v+'bar'} baz")
1365 (echo "$1 dash norm foo ${v-'bar'} baz")
1366 (echo "$1 eqal norm foo ${v='bar'} baz")
1367 (echo "$1 qstn norm foo ${v?'bar'} baz") 2>/dev/null || \
1368 echo "$1 qstn norm -> error"
1369 (echo "$1 PLUS norm foo ${v:+'bar'} baz")
1370 (echo "$1 DASH norm foo ${v:-'bar'} baz")
1371 (echo "$1 EQAL norm foo ${v:='bar'} baz")
1372 (echo "$1 QSTN norm foo ${v:?'bar'} baz") 2>/dev/null || \
1373 echo "$1 QSTN norm -> error"
1377 test x"$v" = x"-" && unset v
1378 (echo "$1 plus parn foo ${v+(bar)} baz")
1379 (echo "$1 dash parn foo ${v-(bar)} baz")
1380 (echo "$1 eqal parn foo ${v=(bar)} baz")
1381 (echo "$1 qstn parn foo ${v?(bar)} baz") 2>/dev/null || \
1382 echo "$1 qstn parn -> error"
1383 (echo "$1 PLUS parn foo ${v:+(bar)} baz")
1384 (echo "$1 DASH parn foo ${v:-(bar)} baz")
1385 (echo "$1 EQAL parn foo ${v:=(bar)} baz")
1386 (echo "$1 QSTN parn foo ${v:?(bar)} baz") 2>/dev/null || \
1387 echo "$1 QSTN parn -> error"
1391 test x"$v" = x"-" && unset v
1392 (echo "$1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz")
1393 (echo "$1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz")
1394 (echo "$1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz")
1395 (echo "$1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz") 2>/dev/null || \
1396 echo "$1 qstn brac -> error"
1397 (echo "$1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz")
1398 (echo "$1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz")
1399 (echo "$1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz")
1400 (echo "$1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz") 2>/dev/null || \
1401 echo "$1 QSTN brac -> error"
1414 1 dash norm foo 'bar' baz
1415 1 eqal norm foo 'bar' baz
1416 1 qstn norm -> error
1418 1 DASH norm foo 'bar' baz
1419 1 EQAL norm foo 'bar' baz
1420 1 QSTN norm -> error
1421 2 plus norm foo 'bar' baz
1426 2 DASH norm foo 'bar' baz
1427 2 EQAL norm foo 'bar' baz
1428 2 QSTN norm -> error
1429 3 plus norm foo 'bar' baz
1430 3 dash norm foo x baz
1431 3 eqal norm foo x baz
1432 3 qstn norm foo x baz
1433 3 PLUS norm foo 'bar' baz
1434 3 DASH norm foo x baz
1435 3 EQAL norm foo x baz
1436 3 QSTN norm foo x baz
1438 4 dash parn foo (bar) baz
1439 4 eqal parn foo (bar) baz
1440 4 qstn parn -> error
1442 4 DASH parn foo (bar) baz
1443 4 EQAL parn foo (bar) baz
1444 4 QSTN parn -> error
1445 5 plus parn foo (bar) baz
1450 5 DASH parn foo (bar) baz
1451 5 EQAL parn foo (bar) baz
1452 5 QSTN parn -> error
1453 6 plus parn foo (bar) baz
1454 6 dash parn foo x baz
1455 6 eqal parn foo x baz
1456 6 qstn parn foo x baz
1457 6 PLUS parn foo (bar) baz
1458 6 DASH parn foo x baz
1459 6 EQAL parn foo x baz
1460 6 QSTN parn foo x baz
1461 7 plus brac foo c } baz
1462 7 dash brac foo ax{{{}b c d{} baz
1463 7 eqal brac foo ax{{{}b c ax{{{}b} baz
1464 7 qstn brac -> error
1465 7 PLUS brac foo c } baz
1466 7 DASH brac foo ax{{{}b c d{} baz
1467 7 EQAL brac foo ax{{{}b c ax{{{}b} baz
1468 7 QSTN brac -> error
1469 8 plus brac foo ax{{{}b c d{} baz
1470 8 dash brac foo c } baz
1471 8 eqal brac foo c } baz
1472 8 qstn brac foo c } baz
1473 8 PLUS brac foo c } baz
1474 8 DASH brac foo ax{{{}b c d{} baz
1475 8 EQAL brac foo ax{{{}b c ax{{{}b} baz
1476 8 QSTN brac -> error
1477 9 plus brac foo ax{{{}b c d{} baz
1478 9 dash brac foo x c x} baz
1479 9 eqal brac foo x c x} baz
1480 9 qstn brac foo x c x} baz
1481 9 PLUS brac foo ax{{{}b c d{} baz
1482 9 DASH brac foo x c x} baz
1483 9 EQAL brac foo x c x} baz
1484 9 QSTN brac foo x c x} baz
1486 name: expand-unglob-unq
1488 Check that regular ${foo+bar} constructs are parsed correctly
1493 test x"$v" = x"-" && unset v
1494 (echo $1 plus norm foo ${v+'bar'} baz)
1495 (echo $1 dash norm foo ${v-'bar'} baz)
1496 (echo $1 eqal norm foo ${v='bar'} baz)
1497 (echo $1 qstn norm foo ${v?'bar'} baz) 2>/dev/null || \
1498 echo "$1 qstn norm -> error"
1499 (echo $1 PLUS norm foo ${v:+'bar'} baz)
1500 (echo $1 DASH norm foo ${v:-'bar'} baz)
1501 (echo $1 EQAL norm foo ${v:='bar'} baz)
1502 (echo $1 QSTN norm foo ${v:?'bar'} baz) 2>/dev/null || \
1503 echo "$1 QSTN norm -> error"
1507 test x"$v" = x"-" && unset v
1508 (echo $1 plus parn foo ${v+\(bar')'} baz)
1509 (echo $1 dash parn foo ${v-\(bar')'} baz)
1510 (echo $1 eqal parn foo ${v=\(bar')'} baz)
1511 (echo $1 qstn parn foo ${v?\(bar')'} baz) 2>/dev/null || \
1512 echo "$1 qstn parn -> error"
1513 (echo $1 PLUS parn foo ${v:+\(bar')'} baz)
1514 (echo $1 DASH parn foo ${v:-\(bar')'} baz)
1515 (echo $1 EQAL parn foo ${v:=\(bar')'} baz)
1516 (echo $1 QSTN parn foo ${v:?\(bar')'} baz) 2>/dev/null || \
1517 echo "$1 QSTN parn -> error"
1521 test x"$v" = x"-" && unset v
1522 (echo $1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz)
1523 (echo $1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz)
1524 (echo $1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz)
1525 (echo $1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz) 2>/dev/null || \
1526 echo "$1 qstn brac -> error"
1527 (echo $1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz)
1528 (echo $1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz)
1529 (echo $1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz)
1530 (echo $1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz) 2>/dev/null || \
1531 echo "$1 QSTN brac -> error"
1544 1 dash norm foo bar baz
1545 1 eqal norm foo bar baz
1546 1 qstn norm -> error
1548 1 DASH norm foo bar baz
1549 1 EQAL norm foo bar baz
1550 1 QSTN norm -> error
1551 2 plus norm foo bar baz
1556 2 DASH norm foo bar baz
1557 2 EQAL norm foo bar baz
1558 2 QSTN norm -> error
1559 3 plus norm foo bar baz
1560 3 dash norm foo x baz
1561 3 eqal norm foo x baz
1562 3 qstn norm foo x baz
1563 3 PLUS norm foo bar baz
1564 3 DASH norm foo x baz
1565 3 EQAL norm foo x baz
1566 3 QSTN norm foo x baz
1568 4 dash parn foo (bar) baz
1569 4 eqal parn foo (bar) baz
1570 4 qstn parn -> error
1572 4 DASH parn foo (bar) baz
1573 4 EQAL parn foo (bar) baz
1574 4 QSTN parn -> error
1575 5 plus parn foo (bar) baz
1580 5 DASH parn foo (bar) baz
1581 5 EQAL parn foo (bar) baz
1582 5 QSTN parn -> error
1583 6 plus parn foo (bar) baz
1584 6 dash parn foo x baz
1585 6 eqal parn foo x baz
1586 6 qstn parn foo x baz
1587 6 PLUS parn foo (bar) baz
1588 6 DASH parn foo x baz
1589 6 EQAL parn foo x baz
1590 6 QSTN parn foo x baz
1591 7 plus brac foo c } baz
1592 7 dash brac foo ax{{{}b c d{} baz
1593 7 eqal brac foo ax{{{}b c ax{{{}b} baz
1594 7 qstn brac -> error
1595 7 PLUS brac foo c } baz
1596 7 DASH brac foo ax{{{}b c d{} baz
1597 7 EQAL brac foo ax{{{}b c ax{{{}b} baz
1598 7 QSTN brac -> error
1599 8 plus brac foo ax{{{}b c d{} baz
1600 8 dash brac foo c } baz
1601 8 eqal brac foo c } baz
1602 8 qstn brac foo c } baz
1603 8 PLUS brac foo c } baz
1604 8 DASH brac foo ax{{{}b c d{} baz
1605 8 EQAL brac foo ax{{{}b c ax{{{}b} baz
1606 8 QSTN brac -> error
1607 9 plus brac foo ax{{{}b c d{} baz
1608 9 dash brac foo x c x} baz
1609 9 eqal brac foo x c x} baz
1610 9 qstn brac foo x c x} baz
1611 9 PLUS brac foo ax{{{}b c d{} baz
1612 9 DASH brac foo x c x} baz
1613 9 EQAL brac foo x c x} baz
1614 9 QSTN brac foo x c x} baz
1616 name: expand-threecolons-dblq
1618 Check for a particular thing that used to segfault
1621 echo "${TEST:1:2:3}"
1622 echo $? but still living
1623 expected-stderr-pattern:
1627 name: expand-threecolons-unq
1629 Check for a particular thing that used to not error out
1633 echo $? but still living
1634 expected-stderr-pattern:
1638 name: expand-weird-1
1640 Check corner case of trim expansion vs. $# vs. ${#var}
1642 set 1 2 3 4 5 6 7 8 9 10 11
1643 echo ${#} # value of $#
1644 echo ${##} # length of $#
1645 echo ${##1} # $# trimmed 1
1646 set 1 2 3 4 5 6 7 8 9 10 11 12
1654 name: expand-weird-2
1656 Check corner case of ${var?} vs. ${#var}
1666 name: expand-weird-3
1668 Check that trimming works with positional parameters (Debian #48453)
1679 name: expand-weird-4
1681 Check that tilde expansion is enabled in ${x#~}
1682 and cases that are modelled after it (${x/~/~})
1686 echo "<${a#~}> <${a#\~}> <${b:-~}> <${b:-\~}> <${c:=~}><$c> <${a/~}> <${a/x/~}> <${a/x/\~}>"
1688 <~/x> </x> <~> <\~> <~><~> <~/x> <~//etc> <~/~>
1690 name: expand-number-1
1692 Check that positional arguments do not overflow
1694 echo "1 ${12345678901234567890} ."
1700 Check that globbing isn't done when glob has syntax error
1701 file-setup: file 644 "abcx"
1702 file-setup: file 644 "abcz"
1703 file-setup: file 644 "bbc"
1713 Check that globbing isn't done when glob has syntax error
1714 (AT&T ksh fails this test)
1715 file-setup: file 644 "abcx"
1716 file-setup: file 644 "abcz"
1717 file-setup: file 644 "bbc"
1723 name: eglob-infinite-plus
1725 Check that shell doesn't go into infinite loop expanding +(...)
1727 file-setup: file 644 "abc"
1742 Check that eglobbing isn't done on substitution results
1743 file-setup: file 644 "abc"
1750 name: eglob-nomatch-1
1752 Check that the pattern doesn't match
1754 echo 1: no-file+(a|b)stuff
1755 echo 2: no-file+(a*(c)|b)stuff
1756 echo 3: no-file+((((c)))|b)stuff
1758 1: no-file+(a|b)stuff
1759 2: no-file+(a*(c)|b)stuff
1760 3: no-file+((((c)))|b)stuff
1764 Check that the pattern matches correctly
1765 file-setup: file 644 "abd"
1766 file-setup: file 644 "acd"
1767 file-setup: file 644 "abac"
1771 echo 3: *(a(b|c)) # (...|...) can be used within X(..)
1772 echo 4: a[b*(foo|bar)]d # patterns not special inside [...]
1781 Simple negation tests
1783 case foo in !(foo|bar)) echo yes;; *) echo no;; esac
1784 case bar in !(foo|bar)) echo yes;; *) echo no;; esac
1793 case foo in *(a|b[)) echo yes;; *) echo no;; esac
1794 case foo in *(a|b[)|f*) echo yes;; *) echo no;; esac
1795 case '*(a|b[)' in *(a|b[)) echo yes;; *) echo no;; esac
1803 Eglobbing in trim expressions...
1804 (AT&T ksh fails this - docs say # matches shortest string, ## matches
1820 Check eglobbing works in trims...
1823 echo 1: ${x#*(a|b)cd}
1824 echo 2: "${x#*(a|b)cd}"
1825 echo 3: ${x#"*(a|b)cd"}
1835 Check eglobbing works in trims, for Korn Shell
1836 Ensure eglobbing does not work for reduced-feature /bin/sh
1842 echo "<${x%bar|baz},${y%bar|baz},${z%\?}>"
1843 echo "<${x%ba(r|z)},${y%ba(r|z)}>"
1845 echo "<${x%bar|baz},${y%bar|baz},${z%\?}>"
1851 <foobar,foobaz,fooba>
1854 name: eglob-substrpl-1
1856 Check eglobbing works in substs... and they work at all
1858 [[ -n $BASH_VERSION ]] && shopt -s extglob
1859 x=1222321_ab/cde_b/c_1221
1868 echo 8: ${x//+(2)/4}
1869 echo 9: ${x/b/c/e/f}
1870 echo 10: ${x/b\/c/e/f}
1871 echo 11: ${x/b\/c/e\/f}
1872 echo 12: ${x/b\/c/e\\/f}
1873 echo 13: ${x/b\\/c/e\\/f}
1874 echo 14: ${x//b/c/e/f}
1875 echo 15: ${x//b\/c/e/f}
1876 echo 16: ${x//b\/c/e\/f}
1877 echo 17: ${x//b\/c/e\\/f}
1878 echo 18: ${x//b\\/c/e\\/f}
1879 echo 19: ${x/b\/*\/c/x}
1887 echo 27: ${x//\%1/9}
1888 echo 28: ${x//\\%1/9}
1890 echo 30: ${x//\\a/9}
1893 1: 122321_ab/cde_b/c_1221
1894 2: 131_ab/cde_b/c_11
1895 3: 1321_ab/cde_b/c_1221
1896 4: 131_ab/cde_b/c_11
1897 5: 1422321_ab/cde_b/c_1221
1898 6: 1444341_ab/cde_b/c_1441
1899 7: 14321_ab/cde_b/c_1221
1900 8: 14341_ab/cde_b/c_141
1901 9: 1222321_ac/e/f/cde_b/c_1221
1902 10: 1222321_ae/fde_b/c_1221
1903 11: 1222321_ae/fde_b/c_1221
1904 12: 1222321_ae\/fde_b/c_1221
1905 13: 1222321_ab/cde_b/c_1221
1906 14: 1222321_ac/e/f/cde_c/e/f/c_1221
1907 15: 1222321_ae/fde_e/f_1221
1908 16: 1222321_ae/fde_e/f_1221
1909 17: 1222321_ae\/fde_e\/f_1221
1910 18: 1222321_ab/cde_b/c_1221
1912 20: 1222321_ab.cde_b/c_1221
1913 21: 1222321_ab.cde_b.c_1221
1914 22: 1222321_ab/cde_b/c_1221
1915 23: 9222321_ab/cde_b/c_1221
1916 24: 1222321_ab/cde_b/c_1221
1917 25: 1222321_ab/cde_b/c_1229
1918 26: 1222321_ab/cde_b/c_1221
1919 27: 1222321_ab/cde_b/c_1221
1920 28: 1222321_ab/cde_b/c_1221
1921 29: 1222321_9b/cde_b/c_1221
1922 30: 1222321_ab/cde_b/c_1221
1923 31: 1xyz22321_ab/cde_b/c_1221
1925 name: eglob-substrpl-2
1927 Check anchored substring replacement works, corner cases
1944 name: eglob-substrpl-3a
1946 Check substring replacement works with variables and slashes, too
1951 echo "${wd/#$pfx/~}"
1952 echo "${wd/#\$pfx/~}"
1953 echo "${wd/#"$pfx"/~}"
1954 echo "${wd/#'$pfx'/~}"
1955 echo "${wd/#"\$pfx"/~}"
1956 echo "${wd/#'\$pfx'/~}"
1965 name: eglob-substrpl-3b
1967 More of this, bash fails it (bash4 passes)
1972 echo "${wd/#$(echo /home/user)/~}"
1973 echo "${wd/#"$(echo /home/user)"/~}"
1974 echo "${wd/#'$(echo /home/user)'/~}"
1980 name: eglob-substrpl-3c
1982 Even more weird cases
1987 echo 1: ${wd/#$pfx/~}
1988 echo 2: ${wd/#\$pfx/~}
1989 echo 3: ${wd/#"$pfx"/~}
1990 echo 4: ${wd/#'$pfx'/~}
1991 echo 5: ${wd/#"\$pfx"/~}
1992 echo 6: ${wd/#'\$pfx'/~}
1993 ts='a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)'
1996 [[ -n $BASH_VERSION ]] && shopt -s extglob
1997 echo 7: ${ts/a\/b/$tr}
1998 echo 8: ${ts/a\/b/\$tr}
1999 echo 9: ${ts/$tp/$tr}
2000 echo 10: ${ts/\$tp/$tr}
2001 echo 11: ${ts/\\$tp/$tr}
2002 echo 12: ${ts/$tp/c/d}
2003 echo 13: ${ts/$tp/c\/d}
2004 echo 14: ${ts/$tp/c\\/d}
2005 echo 15: ${ts/+(a\/b)/$tr}
2006 echo 16: ${ts/+(a\/b)/\$tr}
2007 echo 17: ${ts/+($tp)/$tr}
2008 echo 18: ${ts/+($tp)/c/d}
2009 echo 19: ${ts/+($tp)/c\/d}
2010 echo 20: ${ts//a\/b/$tr}
2011 echo 21: ${ts//a\/b/\$tr}
2012 echo 22: ${ts//$tp/$tr}
2013 echo 23: ${ts//$tp/c/d}
2014 echo 24: ${ts//$tp/c\/d}
2015 echo 25: ${ts//+(a\/b)/$tr}
2016 echo 26: ${ts//+(a\/b)/\$tr}
2017 echo 27: ${ts//+($tp)/$tr}
2018 echo 28: ${ts//+($tp)/c/d}
2019 echo 29: ${ts//+($tp)/c\/d}
2021 echo 30: ${ts/$tp/$tr}
2022 echo 31: ${ts//$tp/$tr}
2030 7: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2031 8: $tra/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2032 9: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2033 10: a/ba/bc/d$tp_a/b$tp_*(a/b)_*($tp)
2034 11: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2035 12: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2036 13: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2037 14: c\/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2038 15: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2039 16: $tr$tp$tp_a/b$tp_*(a/b)_*($tp)
2040 17: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2041 18: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2042 19: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2043 20: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2044 21: $tr$tr$tp$tp_$tr$tp_*($tr)_*($tp)
2045 22: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2046 23: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2047 24: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2048 25: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2049 26: $tr$tp$tp_$tr$tp_*($tr)_*($tp)
2050 27: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2051 28: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2052 29: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2053 30: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2054 31: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2055 # This is what GNU bash does:
2056 # 30: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2057 # 31: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2061 UTF-8 mode differences for eglobbing
2066 print 2: ${s/b???d/x} .
2069 print 4: ${s/b??d/x} .
2071 print 5: ${x%?} ${x%%?} .
2073 print 6: ${x#?} ${x##?} .
2075 print 7: ${x%?} ${x%%?} .
2077 print 8: ${x%?} ${x%%?} .
2079 print 9: ${x%?} ${x%%?} .
2093 Check that globbing isn't done when glob has syntax error
2094 file-setup: dir 755 "[x"
2095 file-setup: file 644 "[x/foo"
2107 Check that symbolic links aren't stat()'d
2108 # breaks on Dell UNIX 4.0 R2.2 (SVR4) where unlink also fails
2109 # breaks on FreeMiNT (cannot unlink dangling symlinks)
2110 # breaks on MSYS, OS/2 (do not support symlinks)
2111 category: !os:mint,!os:msys,!os:svr4.0,!nosymlink
2112 file-setup: dir 755 "dir"
2113 file-setup: symlink 644 "dir/abc"
2125 file-setup: file 644 ".bc"
2126 file-setup: file 644 "abc"
2127 file-setup: file 644 "bbc"
2128 file-setup: file 644 "cbc"
2129 file-setup: file 644 "-bc"
2152 (AT&T ksh fails this; POSIX says invalid)
2153 file-setup: file 644 "abc"
2161 Check that globbing matches the right things...
2162 # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
2163 # breaks on Cygwin 1.7 (files are now UTF-16 or something)
2164 # breaks on QNX 6.4.1 (says RT)
2165 category: !os:cygwin,!os:darwin,!os:msys,!os:nto,!os:os2
2167 file-setup: file 644 "aÂc"
2175 Results unspecified according to POSIX
2176 file-setup: file 644 ".bc"
2184 Results unspecified according to POSIX
2185 (AT&T ksh treats this like [a-cc-e]*)
2186 file-setup: file 644 "abc"
2187 file-setup: file 644 "bbc"
2188 file-setup: file 644 "cbc"
2189 file-setup: file 644 "dbc"
2190 file-setup: file 644 "ebc"
2191 file-setup: file 644 "-bc"
2199 Check against a regression from fixing IFS-subst-2
2202 print -r "before='$x'"
2204 print -r "after ='$x'"
2211 Check ordering/content of redundent here documents.
2223 Check quoted here-doc is protected.
2242 Check that newline isn't needed after heredoc-delimiter marker.
2254 Check that an error occurs if the heredoc-delimiter is missing.
2259 expected-exit: e > 0
2260 expected-stderr-pattern: /.*/
2264 Check that backslash quotes a $, ` and \ and kills a \newline
2271 th\`echo not-run\`ere
2272 th\\`echo is-run`ere
2289 Check that \newline in initial here-delim word doesn't imply
2304 Check that double quoted $ expressions in here delimiters are
2305 not expanded and match the delimiter.
2306 POSIX says only quote removal is applied to the delimiter.
2323 Check that double quoted escaped $ expressions in here
2324 delimiters are not expanded and match the delimiter.
2325 POSIX says only quote removal is applied to the delimiter
2326 (\ counts as a quote).
2347 Check that here strings work.
2351 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo
2352 "$__progname" -c "tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo"
2353 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$bar"
2354 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<'$bar'
2355 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$bar
2356 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<-foo
2357 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$(echo "foo bar")"
2358 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"A $(echo "foo bar") B"
2359 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$b\$b$bar
2375 Check that a corner case of here strings works like bash
2380 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
2387 Check that a corner case of here strings works like ksh93, zsh
2392 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
2399 Check another corner case of here strings
2401 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<< bar
2407 Check here string related regression with multiple iops
2409 echo $(tr r z <<<'bar' 2>/dev/null)
2415 Check long here strings
2423 Check direct here document assignment
2437 fnd=$(typeset -f foo)
2445 # rather nonsensical, but…
2448 vf=<<<$'=f $x \x40='
2450 print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} ve={$ve} vf={$vf} |"
2458 print -r -- "| ${v//$'\n'/^} |"
2478 Check here documents with no or empty delimiter
2495 fnd=$(typeset -f foo)
2503 print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} |"
2511 print -r -- "| ${v//$'\n'/^} |"
2533 Check here documents can use $* and $@; note shells vary:
2534 • pdksh 5.2.14 acts the same
2535 • dash has 1 and 2 the same but 3 lacks the space
2536 • ksh93, bash4 differ in 2 by using space ipv colon
2578 Check that using multiple here documents works
2581 echo "got $(cat) on stdin"
2582 echo "got $(cat <&4) on fd#4"
2583 echo "got $(cat <&5) on fd#5"
2586 foo 4<<-a <<-b 5<<-c
2597 [[ $x = "$y" ]]; echo $?
2603 foo 4<<-a <<-b 5<<-c
2616 name: heredoc-comsub-1
2618 Tests for here documents in COMSUB, taken from Austin ML
2625 = here is the text =
2627 name: heredoc-comsub-2
2629 Tests for here documents in COMSUB, taken from Austin ML
2631 unbalanced=$(cat <<EOF
2632 this paren ) is a problem
2634 echo = $unbalanced =
2636 = this paren ) is a problem =
2638 name: heredoc-comsub-3
2640 Tests for here documents in COMSUB, taken from Austin ML
2642 balanced=$(cat <<EOF
2643 these parens ( ) are not a problem
2647 = these parens ( ) are not a problem =
2649 name: heredoc-comsub-4
2651 Tests for here documents in COMSUB, taken from Austin ML
2653 balanced=$(cat <<EOF
2654 these parens \( ) are a problem
2658 = these parens \( ) are a problem =
2660 name: heredoc-subshell-1
2662 Tests for here documents in subshells, taken from Austin ML
2672 name: heredoc-subshell-2
2674 Tests for here documents in subshells, taken from Austin ML
2685 name: heredoc-subshell-3
2687 Tests for here documents in subshells, taken from Austin ML
2697 name: heredoc-weird-1
2699 Tests for here documents, taken from Austin ML
2700 Documents current state in mksh, *NOT* necessarily correct!
2713 name: heredoc-weird-2
2715 Tests for here documents, taken from Austin ML
2725 name: heredoc-weird-4
2727 Tests for here documents, taken from Austin ML
2728 Documents current state in mksh, *NOT* necessarily correct!
2739 name: heredoc-weird-5
2741 Tests for here documents, taken from Austin ML
2742 Documents current state in mksh, *NOT* necessarily correct!
2754 name: heredoc-tmpfile-1
2756 Check that heredoc temp files aren't removed too soon or too late.
2757 Heredoc in simple command.
2778 name: heredoc-tmpfile-2
2780 Check that heredoc temp files aren't removed too soon or too late.
2781 Heredoc in function, multiple calls to function.
2800 name: heredoc-tmpfile-3
2802 Check that heredoc temp files aren't removed too soon or too late.
2803 Heredoc in function in loop, multiple calls to function.
2830 name: heredoc-tmpfile-4
2832 Check that heredoc temp files aren't removed too soon or too late.
2833 Backgrounded simple command with here doc
2847 name: heredoc-tmpfile-5
2849 Check that heredoc temp files aren't removed too soon or too late.
2850 Backgrounded subshell command with here doc
2855 sleep 1 # so parent exits
2871 name: heredoc-tmpfile-6
2873 Check that heredoc temp files aren't removed too soon or too late.
2874 Heredoc in pipeline.
2878 cat <<- EOF | sed "s/hi/HI/"
2888 name: heredoc-tmpfile-7
2890 Check that heredoc temp files aren't removed too soon or too late.
2891 Heredoc in backgrounded pipeline.
2895 cat <<- EOF | sed 's/hi/HI/' &
2905 name: heredoc-tmpfile-8
2907 Check that heredoc temp files aren't removed too soon or too
2908 late. Heredoc in function, backgrounded call to function.
2909 This check can fail on slow machines (<100 MHz), or Cygwin,
2914 # Background eval so main shell doesn't do parsing
2922 # sleep so eval can die
2936 name: heredoc-quoting-unsubst
2938 Check for correct handling of quoted characters in
2939 here documents without substitution (marker is quoted).
2943 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
2946 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
2948 name: heredoc-quoting-subst
2950 Check for correct handling of quoted characters in
2951 here documents with substitution (marker is not quoted).
2955 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
2958 x " \" \ \ $ $ baz `echo baz` bar $foo x
2960 name: single-quotes-in-braces
2962 Check that single quotes inside unquoted {} are treated as quotes
2965 echo ${foo:+'blah $foo'}
2969 name: single-quotes-in-quoted-braces
2971 Check that single quotes inside quoted {} are treated as
2975 echo "${foo:+'blah $foo'}"
2979 name: single-quotes-in-braces-nested
2981 Check that single quotes inside unquoted {} are treated as quotes,
2982 even if that's inside a double-quoted command expansion
2985 echo "$( echo ${foo:+'blah $foo'})"
2989 name: single-quotes-in-brace-pattern
2991 Check that single quotes inside {} pattern are treated as quotes
2994 echo ${foo%'2'*} "${foo%'2'*}" ${foo%2'*'} "${foo%2'*'}"
2998 name: single-quotes-in-heredoc-braces
3000 Check that single quotes inside {} in heredoc are treated
3010 name: single-quotes-in-nested-braces
3012 Check that single quotes inside nested unquoted {} are
3016 echo ${foo:+${foo:+'blah $foo'}}
3020 name: single-quotes-in-nested-quoted-braces
3022 Check that single quotes inside nested quoted {} are treated
3026 echo "${foo:+${foo:+'blah $foo'}}"
3030 name: single-quotes-in-nested-braces-nested
3032 Check that single quotes inside nested unquoted {} are treated
3033 as quotes, even if that's inside a double-quoted command expansion
3036 echo "$( echo ${foo:+${foo:+'blah $foo'}})"
3040 name: single-quotes-in-nested-brace-pattern
3042 Check that single quotes inside nested {} pattern are treated as quotes
3045 echo ${foo:+${foo%'2'*}} "${foo:+${foo%'2'*}}" ${foo:+${foo%2'*'}} "${foo:+${foo%2'*'}}"
3049 name: single-quotes-in-heredoc-nested-braces
3051 Check that single quotes inside nested {} in heredoc are treated
3056 ${foo:+${foo:+'blah $foo'}}
3063 See if we can test history at all
3066 env-setup: !ENV=./Env!HISTFILE=hist.file!
3067 file-setup: file 644 "Env"
3075 expected-stderr-pattern:
3080 Verify duplicates and spaces are not entered
3083 env-setup: !ENV=./Env!HISTFILE=hist.file!
3084 file-setup: file 644 "Env"
3096 expected-stderr-pattern:
3099 name: history-unlink
3101 Check if broken HISTFILEs do not cause trouble
3104 env-setup: !ENV=./Env!HISTFILE=foo/hist.file!
3105 file-setup: file 644 "Env"
3107 file-setup: dir 755 "foo"
3108 file-setup: file 644 "foo/hist.file"
3111 perl-setup: chmod(0555, "foo");
3119 expected-stderr-pattern:
3120 /(.*can't unlink HISTFILE.*\n)?X*$/
3122 name: history-e-minus-1
3124 Check if more recent command is executed
3127 env-setup: !ENV=./Env!HISTFILE=hist.file!
3128 file-setup: file 644 "Env"
3138 expected-stderr-pattern:
3139 /^X*echo there\nX*$/
3141 name: history-e-minus-2
3143 Check that repeated command is printed before command
3147 env-setup: !ENV=./Env!HISTFILE=hist.file!
3148 file-setup: file 644 "Env"
3155 expected-stdout-pattern:
3156 /X*hi\nX*there\nX*echo there\nthere\nX*/
3157 expected-stderr-pattern:
3160 name: history-e-minus-3
3162 fc -e - fails when there is no history
3163 (ksh93 has a bug that causes this to fail)
3164 (ksh88 loops on this)
3167 env-setup: !ENV=./Env!HISTFILE=hist.file!
3168 file-setup: file 644 "Env"
3175 expected-stderr-pattern:
3176 /^X*.*:.*history.*\nX*$/
3178 name: history-e-minus-4
3180 Check if "fc -e -" command output goes to stdout.
3183 env-setup: !ENV=./Env!HISTFILE=hist.file!
3184 file-setup: file 644 "Env"
3188 fc -e - | (read x; echo "A $x")
3194 expected-stderr-pattern:
3197 name: history-e-minus-5
3199 fc is replaced in history by new command.
3202 env-setup: !ENV=./Env!HISTFILE=hist.file!
3203 file-setup: file 644 "Env"
3219 expected-stderr-pattern:
3220 /^X*echo ghi jkl\nX*$/
3222 name: history-list-1
3224 List lists correct range
3225 (ksh88 fails 'cause it lists the fc command)
3228 env-setup: !ENV=./Env!HISTFILE=hist.file!
3229 file-setup: file 644 "Env"
3242 expected-stderr-pattern:
3245 name: history-list-2
3247 Lists oldest history if given pre-historic number
3248 (ksh93 has a bug that causes this to fail)
3249 (ksh88 fails 'cause it lists the fc command)
3252 env-setup: !ENV=./Env!HISTFILE=hist.file!
3253 file-setup: file 644 "Env"
3267 expected-stderr-pattern:
3270 name: history-list-3
3272 Can give number 'options' to fc
3275 env-setup: !ENV=./Env!HISTFILE=hist.file!
3276 file-setup: file 644 "Env"
3291 expected-stderr-pattern:
3294 name: history-list-4
3296 -1 refers to previous command
3299 env-setup: !ENV=./Env!HISTFILE=hist.file!
3300 file-setup: file 644 "Env"
3314 expected-stderr-pattern:
3317 name: history-list-5
3319 List command stays in history
3322 env-setup: !ENV=./Env!HISTFILE=hist.file!
3323 file-setup: file 644 "Env"
3340 expected-stderr-pattern:
3343 name: history-list-6
3345 HISTSIZE limits about of history kept.
3346 (ksh88 fails 'cause it lists the fc command)
3349 env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3!
3350 file-setup: file 644 "Env"
3367 expected-stderr-pattern:
3370 name: history-list-7
3372 fc allows too old/new errors in range specification
3375 env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3!
3376 file-setup: file 644 "Env"
3394 expected-stderr-pattern:
3397 name: history-list-r-1
3399 test -r flag in history
3402 env-setup: !ENV=./Env!HISTFILE=hist.file!
3403 file-setup: file 644 "Env"
3421 expected-stderr-pattern:
3424 name: history-list-r-2
3426 If first is newer than last, -r is implied.
3429 env-setup: !ENV=./Env!HISTFILE=hist.file!
3430 file-setup: file 644 "Env"
3448 expected-stderr-pattern:
3451 name: history-list-r-3
3453 If first is newer than last, -r is cancelled.
3456 env-setup: !ENV=./Env!HISTFILE=hist.file!
3457 file-setup: file 644 "Env"
3475 expected-stderr-pattern:
3478 name: history-subst-1
3483 env-setup: !ENV=./Env!HISTFILE=hist.file!
3484 file-setup: file 644 "Env"
3489 fc -e - abc=AB 'echo a'
3494 expected-stderr-pattern:
3495 /^X*echo AB def\nX*$/
3497 name: history-subst-2
3499 Does subst find previous command?
3502 env-setup: !ENV=./Env!HISTFILE=hist.file!
3503 file-setup: file 644 "Env"
3508 fc -e - jkl=XYZQRT 'echo g'
3513 expected-stderr-pattern:
3514 /^X*echo ghi XYZQRT\nX*$/
3516 name: history-subst-3
3518 Does subst find previous command when no arguments given
3521 env-setup: !ENV=./Env!HISTFILE=hist.file!
3522 file-setup: file 644 "Env"
3532 expected-stderr-pattern:
3533 /^X*echo ghi XYZQRT\nX*$/
3535 name: history-subst-4
3537 Global substitutions work
3538 (ksh88 and ksh93 do not have -g option)
3541 env-setup: !ENV=./Env!HISTFILE=hist.file!
3542 file-setup: file 644 "Env"
3545 echo abc def asjj sadjhasdjh asdjhasd
3548 abc def asjj sadjhasdjh asdjhasd
3549 FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd
3550 expected-stderr-pattern:
3551 /^X*echo FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd\nX*$/
3553 name: history-subst-5
3555 Make sure searches don't find current (fc) command
3556 (ksh88/ksh93 don't have the ? prefix thing so they fail this test)
3559 env-setup: !ENV=./Env!HISTFILE=hist.file!
3560 file-setup: file 644 "Env"
3565 fc -e - abc=AB \?abc
3570 expected-stderr-pattern:
3571 /^X*echo AB def\nX*$/
3573 name: history-ed-1-old
3575 Basic (ed) editing works (assumes you have generic ed editor
3576 that prints no prompts). This is for oldish ed(1) which write
3577 the character count to stdout.
3582 env-setup: !ENV=./Env!HISTFILE=hist.file!
3583 file-setup: file 644 "Env"
3596 expected-stderr-pattern:
3597 /^X*echo FOOBAR def\nX*$/
3599 name: history-ed-2-old
3601 Correct command is edited when number given
3606 env-setup: !ENV=./Env!HISTFILE=hist.file!
3607 file-setup: file 644 "Env"
3615 s/is here/is changed/
3626 expected-stderr-pattern:
3627 /^X*echo line 2 is changed\nX*$/
3629 name: history-ed-3-old
3631 Newly created multi line commands show up as single command
3633 (ksh88 fails 'cause it lists the fc command)
3638 env-setup: !ENV=./Env!HISTFILE=hist.file!
3639 file-setup: file 644 "Env"
3660 expected-stderr-pattern:
3661 /^X*echo FOOBAR def\necho a new line\nX*$/
3665 Basic (ed) editing works (assumes you have generic ed editor
3666 that prints no prompts). This is for newish ed(1) and stderr.
3667 category: !no-stderr-ed
3671 env-setup: !ENV=./Env!HISTFILE=hist.file!
3672 file-setup: file 644 "Env"
3683 expected-stderr-pattern:
3684 /^X*13\n16\necho FOOBAR def\nX*$/
3688 Correct command is edited when number given
3689 category: !no-stderr-ed
3693 env-setup: !ENV=./Env!HISTFILE=hist.file!
3694 file-setup: file 644 "Env"
3702 s/is here/is changed/
3711 expected-stderr-pattern:
3712 /^X*20\n23\necho line 2 is changed\nX*$/
3716 Newly created multi line commands show up as single command
3718 category: !no-stderr-ed
3722 env-setup: !ENV=./Env!HISTFILE=hist.file!
3723 file-setup: file 644 "Env"
3742 expected-stderr-pattern:
3743 /^X*13\n32\necho FOOBAR def\necho a new line\nX*$/
3747 Simple test, default IFS
3749 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3765 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3782 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3795 name: IFS-space-colon-1
3797 Simple test, IFS=<white-space>:
3799 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3814 name: IFS-space-colon-2
3816 Simple test, IFS=<white-space>:
3817 AT&T ksh fails this, POSIX says the test is correct.
3819 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3826 name: IFS-space-colon-4
3828 Simple test, IFS=<white-space>:
3830 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3837 name: IFS-space-colon-5
3839 Simple test, IFS=<white-space>:
3840 Don't know what POSIX thinks of this. AT&T ksh does not do this.
3842 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3851 Simple test, IFS=<white-space>:
3853 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3856 echo -n '1:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3857 echo -n '2:'; for i in :b:: ; do echo -n " [$i]" ; done ; echo
3861 echo -n '5:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3864 echo -n '7:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3866 echo -n '9:'; for i in ${FOO-`echo -n h:i`th:ere} ; do echo -n " [$i]" ; done ; echo
3867 showargs 10 ${FOO-`echo -n h:i`th:ere}
3868 showargs 11 "${FOO-`echo -n h:i`th:ere}"
3870 echo -n '12:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3882 <10> <h> <ith> <ere> .
3885 <13> <A> <B> <> <D> .
3889 Check leading whitespace after trim does not make a field
3891 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3893 showargs 1 shift ${x#X}
3895 <1> <shift> <1> <2> .
3897 name: IFS-subst-3-arr
3899 Check leading IFS non-whitespace after trim does make a field
3900 but leading IFS whitespace does not, nor empty replacements
3902 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3905 showargs 1 ${-+:foo:bar}
3907 showargs 2 ${-+ foo bar}
3910 <1> <> <foo> <bar> .
3913 name: IFS-subst-3-ass
3915 Check non-field semantics
3917 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3920 showargs 1 x=${-+:foo:bar}
3922 showargs 2 x=${-+ foo bar}
3925 <1> <x=> <foo> <bar> .
3926 <2> <x=> <foo> <bar> .
3928 name: IFS-subst-3-lcl
3930 Check non-field semantics, smaller corner case (LP#1381965)
3935 expected-exit: e != 0
3936 expected-stderr-pattern:
3941 reported by mikeserv
3943 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
3944 a='space divded argument
3947 IFS= ; q="$*" ; nq=$*
3948 pfn "$*" $* "$q" "$nq"
3949 [ "$q" = "$nq" ] && echo =true || echo =false
3951 <spacedivdedargument
3957 <spacedivdedargument
3959 <spacedivdedargument
3965 extended testsuite based on problem by mikeserv
3967 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
3968 a='space divded argument
3971 IFS= ; q="$@" ; nq=$@
3972 pfn "$*" $* "$q" "$nq"
3973 [ "$q" = "$nq" ] && echo =true || echo =false
3975 <spacedivdedargument
3981 <space divded argument
3983 <space divded argument
3989 extended testsuite based on problem by mikeserv
3991 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
3992 a='space divded argument
3994 IFS=\ ; set -- $a; IFS=
3999 print -nr -- '= qs '; pfn "$qs"
4000 print -nr -- '=nqs '; pfn "$nqs"
4001 print -nr -- '= qk '; pfn "$qk"
4002 print -nr -- '=nqk '; pfn "$nqk"
4003 print -nr -- '~ qs '; pfn "$*"
4004 print -nr -- '~nqs '; pfn $*
4005 print -nr -- '~ qk '; pfn "$@"
4006 print -nr -- '~nqk '; pfn $@
4008 = qs <spacedivdedargument
4010 =nqs <spacedivdedargument
4012 = qk <space divded argument
4014 =nqk <space divded argument
4016 ~ qs <spacedivdedargument
4033 extended testsuite based on problem by mikeserv
4035 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4036 a='space divded argument
4038 IFS=\ ; set -- $a; IFS=
4040 print -nr -- '= qs '; pfn "$qs"
4041 print -nr -- '~ qs '; pfn "$*"
4043 print -nr -- '=nqs '; pfn "$nqs"
4044 print -nr -- '~nqs '; pfn $*
4046 print -nr -- '= qk '; pfn "$qk"
4047 print -nr -- '~ qk '; pfn "$@"
4049 print -nr -- '=nqk '; pfn "$nqk"
4050 print -nr -- '~nqk '; pfn $@
4052 = qs <spacedivdedargument
4054 ~ qs <spacedivdedargument
4056 =nqs <spacedivdedargument
4062 = qk <space divded argument
4068 =nqk <space divded argument
4075 name: IFS-subst-4-4p
4077 extended testsuite based on problem by mikeserv
4079 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4080 a='space divded argument
4082 IFS=\ ; set -- $a; IFS=
4085 print -nr -- '= qs '; pfn "$qs"
4086 print -nr -- '~ qs '; pfn ${v:-"$*"}
4088 print -nr -- '=nqs '; pfn "$nqs"
4089 print -nr -- '~nqs '; pfn ${v:-$*}
4091 print -nr -- '= qk '; pfn "$qk"
4092 print -nr -- '~ qk '; pfn ${v:-"$@"}
4094 print -nr -- '=nqk '; pfn "$nqk"
4095 print -nr -- '~nqk '; pfn ${v:-$@}
4097 = qs <spacedivdedargument
4099 ~ qs <spacedivdedargument
4101 =nqs <spacedivdedargument
4107 = qk <space divded argument
4113 =nqk <space divded argument
4122 extended testsuite based on problem by mikeserv
4124 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4125 a='space divded argument
4127 IFS=\ ; set -- $a; IFS=,
4129 print -nr -- '= qs '; pfn "$qs"
4130 print -nr -- '~ qs '; pfn "$*"
4132 print -nr -- '=nqs '; pfn "$nqs"
4133 print -nr -- '~nqs '; pfn $*
4135 print -nr -- '= qk '; pfn "$qk"
4136 print -nr -- '~ qk '; pfn "$@"
4138 print -nr -- '=nqk '; pfn "$nqk"
4139 print -nr -- '~nqk '; pfn $@
4141 = qs <space,divded,argument
4143 ~ qs <space,divded,argument
4145 =nqs <space,divded,argument
4151 = qk <space divded argument
4157 =nqk <space divded argument
4164 name: IFS-subst-4-5p
4166 extended testsuite based on problem by mikeserv
4168 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4169 a='space divded argument
4171 IFS=\ ; set -- $a; IFS=,
4174 print -nr -- '= qs '; pfn "$qs"
4175 print -nr -- '~ qs '; pfn ${v:-"$*"}
4177 print -nr -- '=nqs '; pfn "$nqs"
4178 print -nr -- '~nqs '; pfn ${v:-$*}
4180 print -nr -- '= qk '; pfn "$qk"
4181 print -nr -- '~ qk '; pfn ${v:-"$@"}
4183 print -nr -- '=nqk '; pfn "$nqk"
4184 print -nr -- '~nqk '; pfn ${v:-$@}
4186 = qs <space,divded,argument
4188 ~ qs <space,divded,argument
4190 =nqs <space,divded,argument
4196 = qk <space divded argument
4202 =nqk <space divded argument
4211 extended testsuite based on IFS-subst-3
4212 differs slightly from ksh93:
4213 - omit trailing field in a3zna, a7ina (unquoted $@ expansion)
4214 - has extra middle fields in b5ins, b7ina (IFS_NWS unquoted expansion)
4215 differs slightly from bash:
4216 - omit leading field in a5ins, a7ina (IFS_NWS unquoted expansion)
4217 differs slightly from zsh:
4218 - differs in assignment, not expansion; probably zsh bug
4219 - has extra middle fields in b5ins, b7ina (IFS_NWS unquoted expansion)
4220 'emulate sh' zsh has extra fields in
4221 - a5ins (IFS_NWS unquoted $*)
4222 - b5ins, matching mksh’s
4223 !!WARNING!! more to come: http://austingroupbugs.net/view.php?id=888
4225 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4226 IFS=; set -- "" 2 ""; pfb $*; x=$*; pfn "$x"'
4228 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4229 IFS=; set -- "" 2 ""; pfb "$*"; x="$*"; pfn "$x"'
4231 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4232 IFS=; set -- "" 2 ""; pfb $@; x=$@; pfn "$x"'
4234 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4235 IFS=; set -- "" 2 ""; pfb "$@"; x="$@"; pfn "$x"'
4237 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4238 IFS=,; set -- "" 2 ""; pfb $*; x=$*; pfn "$x"'
4240 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4241 IFS=,; set -- "" 2 ""; pfb "$*"; x="$*"; pfn "$x"'
4243 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4244 IFS=,; set -- "" 2 ""; pfb $@; x=$@; pfn "$x"'
4246 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4247 IFS=,; set -- "" 2 ""; pfb "$@"; x="$@"; pfn "$x"'
4249 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4250 IFS=; set -- A B "" "" C; pfb $*; x=$*; pfn "$x"'
4252 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4253 IFS=; set -- A B "" "" C; pfb "$*"; x="$*"; pfn "$x"'
4255 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4256 IFS=; set -- A B "" "" C; pfb $@; x=$@; pfn "$x"'
4258 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4259 IFS=; set -- A B "" "" C; pfb "$@"; x="$@"; pfn "$x"'
4261 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4262 IFS=,; set -- A B "" "" C; pfb $*; x=$*; pfn "$x"'
4264 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4265 IFS=,; set -- A B "" "" C; pfb "$*"; x="$*"; pfn "$x"'
4267 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4268 IFS=,; set -- A B "" "" C; pfb $@; x=$@; pfn "$x"'
4270 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4271 IFS=,; set -- A B "" "" C; pfb "$@"; x="$@"; pfn "$x"'
4349 Regression wrt. vector expansion in trim
4351 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4361 ksh93 bug wrt. vector expansion in trim
4363 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4367 showargs "$*" ${a##"$*"}
4373 http://austingroupbugs.net/view.php?id=221
4375 n() { echo "$#"; }; n "${foo-$@}"
4381 Scalar context for $*/$@ in [[ and case
4383 "$__progname" -c 'IFS=; set a b; [[ $* = "$1$2" ]]; echo 1 $?' sh a b
4384 "$__progname" -c 'IFS=; [[ $* = ab ]]; echo 2 "$?"' sh a b
4385 "$__progname" -c 'IFS=; [[ "$*" = ab ]]; echo 3 "$?"' sh a b
4386 "$__progname" -c 'IFS=; [[ $* = a ]]; echo 4 "$?"' sh a b
4387 "$__progname" -c 'IFS=; [[ "$*" = a ]]; echo 5 "$?"' sh a b
4388 "$__progname" -c 'IFS=; [[ "$@" = a ]]; echo 6 "$?"' sh a b
4389 "$__progname" -c 'IFS=; case "$@" in a) echo 7 a;; ab) echo 7 b;; a\ b) echo 7 ok;; esac' sh a b
4390 "$__progname" -c 'IFS=; case $* in a) echo 8 a;; ab) echo 8 ok;; esac' sh a b
4391 "$__progname" -c 'pfsp() { for s_arg in "$@"; do print -nr -- "<$s_arg> "; done; print .; }; IFS=; star=$* at="$@"; pfsp 9 "$star" "$at"' sh a b
4405 http://austingroupbugs.net/view.php?id=832
4407 ${ZSH_VERSION+false} || emulate sh
4408 ${BASH_VERSION+set -o posix}
4409 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4411 showargs $((1230456))
4415 name: integer-base-err-1
4417 Can't have 0 base (causes shell to exit)
4418 expected-exit: e != 0
4424 expected-stderr-pattern:
4427 name: integer-base-err-2
4429 Can't have multiple bases in a 'constant' (causes shell to exit)
4430 (ksh88 fails this test)
4431 expected-exit: e != 0
4437 expected-stderr-pattern:
4438 /^.*:.*2#110#11.*\n$/
4440 name: integer-base-err-3
4442 Syntax errors in expressions and effects on bases
4443 (interactive so errors don't cause exits)
4444 (ksh88 fails this test - shell exits, even with -i)
4448 PS1= # minimise prompt hassles
4455 expected-stderr-pattern:
4456 /^([#\$] )?.*:.*2+.*\n.*:.*2+.*\n$/
4461 name: integer-base-err-4
4463 Are invalid digits (according to base) errors?
4464 (ksh93 fails this test)
4465 expected-exit: e != 0
4469 expected-stderr-pattern:
4470 /^([#\$] )?.*:.*3#4.*\n$/
4472 name: integer-base-1
4474 Missing number after base is treated as 0.
4483 name: integer-base-2
4485 Check 'stickyness' of base in various situations
4536 name: integer-base-3
4538 More base parsing (hmm doesn't test much..)
4558 name: integer-base-4
4560 Check that things not declared as integers are not made integers,
4561 also, check if base is not reset by -i with no arguments.
4562 (ksh93 fails - prints 10#20 - go figure)
4566 typeset -i | grep '^xx='
4573 name: integer-base-5
4589 for l in 1 2+3 4; do echo $l; done
4601 name: integer-base-6
4603 Even more base stuff
4604 (ksh93 fails this test - prints 0)
4612 name: integer-base-7
4614 Check that non-integer parameters don't get bases assigned
4616 echo $(( zz = 8#100 ))
4622 name: integer-base-8
4624 Check that base-36 works (full span)
4626 echo 1:$((36#109AZ)).
4627 typeset -i36 x=1691675
4636 name: integer-base-check-flat
4638 Check behaviour does not match POSuX (except if set -o posix),
4639 because a not type-safe scripting language has *no* business
4640 interpreting the string "010" as octal numer eight (dangerous).
4642 echo 1 "$("$__progname" -c 'echo :$((10))/$((010)),$((0x10)):')" .
4643 echo 2 "$("$__progname" -o posix -c 'echo :$((10))/$((010)),$((0x10)):')" .
4644 echo 3 "$("$__progname" -o sh -c 'echo :$((10))/$((010)),$((0x10)):')" .
4650 name: integer-base-check-numeric-from
4652 Check behaviour for base one to 36, and that 37 degrades to 10
4656 while (( ++i <= 37 )); do
4657 eval 'echo '$i':$(('$i'#10)).'
4659 echo 37:$($__progname -c 'echo $((37#10))').$?:
4700 name: integer-base-check-numeric-to
4702 Check behaviour for base one to 36, and that 37 degrades to 10
4705 while (( ++i <= 37 )); do
4706 typeset -Uui$i x=0x40
4707 eval "typeset -i10 y=$x"
4749 name: integer-arithmetic-span
4751 Check wraparound and size that is defined in mksh
4754 echo s:$((2147483647+1)).$(((2147483647*2)+1)).$(((2147483647*2)+2)).
4755 echo u:$((#2147483647+1)).$((#(2147483647*2)+1)).$((#(2147483647*2)+2)).
4758 u:2147483648.4294967295.0.
4760 name: integer-arithmetic-span-64
4762 Check wraparound and size that is defined in mksh
4765 echo s:$((9223372036854775807+1)).$(((9223372036854775807*2)+1)).$(((9223372036854775807*2)+2)).
4766 echo u:$((#9223372036854775807+1)).$((#(9223372036854775807*2)+1)).$((#(9223372036854775807*2)+2)).
4768 s:-9223372036854775808.-1.0.
4769 u:9223372036854775808.18446744073709551615.0.
4771 name: integer-size-FAIL-to-detect
4773 Notify the user that their ints are not 32 or 64 bit
4780 See if $LINENO is updated and can be modified.
4793 See if $LINENO is set for .'d files.
4794 file-setup: file 644 "dotfile"
4812 See if $LINENO is set for commands in a function.
4831 See if unsetting LINENO makes it non-magic.
4832 file-setup: file 644 "dotfile"
4855 name: lineno-unset-use
4857 See if unsetting LINENO makes it non-magic even
4859 file-setup: file 644 "dotfile"
4885 Check if LINENO is tracked in traps
4891 trap 'fail $LINENO' INT ERR
4899 Ensure unknown traps are not a syntax error
4902 trap "echo trap 1 executed" UNKNOWNSIGNAL || echo "foo"
4904 trap "echo trap 2 executed" UNKNOWNSIGNAL EXIT 999999 FNORD
4906 ) 2>&1 | sed "s
\ 1^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]
\ 1PROG
\ 1"
4908 PROG: trap: bad signal 'UNKNOWNSIGNAL'
4911 PROG: trap: bad signal 'UNKNOWNSIGNAL'
4912 PROG: trap: bad signal '999999'
4913 PROG: trap: bad signal 'FNORD'
4919 Simple test, default IFS
4924 echo 1: "x[$x] y[$y] z[$z]"
4925 echo 1a: ${z-z not set}
4935 Complex tests, IFS either colon (IFS-NWS) or backslash (tricky)
4938 showargs() { print -nr "$1"; shift; for s_arg in "$@"; do print -nr -- " [$s_arg]"; done; print; }
4939 (IFS=\\ a=\<\\\>; showargs 3 $a)
4940 (IFS=: b=\<:\>; showargs 4 $b)
4941 print -r '<\>' | (IFS=\\ read f g; showargs 5 "$f" "$g")
4942 print -r '<\\>' | (IFS=\\ read f g; showargs 6 "$f" "$g")
4943 print '<\\\n>' | (IFS=\\ read f g; showargs 7 "$f" "$g")
4944 print -r '<\>' | (IFS=\\ read f; showargs 8 "$f")
4945 print -r '<\\>' | (IFS=\\ read f; showargs 9 "$f")
4946 print '<\\\n>' | (IFS=\\ read f; showargs 10 "$f")
4947 print -r '<\>' | (IFS=\\ read -r f g; showargs 11 "$f" "$g")
4948 print -r '<\\>' | (IFS=\\ read -r f g; showargs 12 "$f" "$g")
4949 print '<\\\n>' | (IFS=\\ read -r f g; showargs 13 "$f" "$g")
4950 print -r '<\>' | (IFS=\\ read -r f; showargs 14 "$f")
4951 print -r '<\\>' | (IFS=\\ read -r f; showargs 15 "$f")
4952 print '<\\\n>' | (IFS=\\ read -r f; showargs 16 "$f")
4953 print -r '<:>' | (IFS=: read f g; showargs 17 "$f" "$g")
4954 print -r '<::>' | (IFS=: read f g; showargs 18 "$f" "$g")
4955 print '<:\n>' | (IFS=: read f g; showargs 19 "$f" "$g")
4956 print -r '<:>' | (IFS=: read f; showargs 20 "$f")
4957 print -r '<::>' | (IFS=: read f; showargs 21 "$f")
4958 print '<:\n>' | (IFS=: read f; showargs 22 "$f")
4959 print -r '<:>' | (IFS=: read -r f g; showargs 23 "$f" "$g")
4960 print -r '<::>' | (IFS=: read -r f g; showargs 24 "$f" "$g")
4961 print '<:\n>' | (IFS=: read -r f g; showargs 25 "$f" "$g")
4962 print -r '<:>' | (IFS=: read -r f; showargs 26 "$f")
4963 print -r '<::>' | (IFS=: read -r f; showargs 27 "$f")
4964 print '<:\n>' | (IFS=: read -r f; showargs 28 "$f")
4995 If no var specified, REPLY is used
5003 name: read-regress-1
5005 Check a regression of read
5006 file-setup: file 644 "foo"
5011 while read a b c; do
5015 echo "<$a|$b|$c><$d>"
5021 Check read with delimiters
5024 print -n 'foo bar\tbaz\nblah \0blub\tblech\nmyok meck \0'
5026 emit | while IFS= read -d "" foo; do print -r -- "<$foo>"; done
5027 emit | while read -d "" foo; do print -r -- "<$foo>"; done
5028 emit | while read -d "eh?" foo; do print -r -- "<$foo>"; done
5045 Check read with number of bytes specified, and -A
5047 print 'foo\nbar' >x1
5049 print 'foo\\ bar baz' >x3
5051 x1b=u; read -N-1 x1b <x1
5052 x2a=u; read x2a <x2; r2a=$?
5053 x2b=u; read -N2 x2c <x2; r2b=$?
5054 x2c=u; read -n2 x2c <x2; r2c=$?
5055 x3a=u; read -A x3a <x3
5056 print -r "x1a=<$x1a>"
5057 print -r "x1b=<$x1b>"
5058 print -r "x2a=$r2a<$x2a>"
5059 print -r "x2b=$r2b<$x2b>"
5060 print -r "x2c=$r2c<$x2c>"
5061 print -r "x3a=<${x3a[0]}|${x3a[1]}|${x3a[2]}>"
5073 Lex array code had problems with this.
5084 When PATH is set before running a command, the new path is
5085 not used in doing the path search
5086 $ echo echo hi > /tmp/q ; chmod a+rx /tmp/q
5090 in comexec() the two lines
5092 (void) typeset(*vp++, xxx, 0);
5093 need to be moved out of the switch to before findcom() is
5094 called - I don't know what this will break.
5096 : "${PWD:-`pwd 2> /dev/null`}"
5097 : "${PWD:?"PWD not set - cannot do test"}"
5099 cat > Y/xxxscript << EOF
5101 # Need to restore path so echo can be found (some shells don't have
5107 chmod a+rx Y/xxxscript
5108 export OLDPATH="$PATH"
5109 PATH=$PWD/Y xxxscript
5116 Parsing of $(..) expressions is non-optimal. It is
5117 impossible to have any parentheses inside the expression.
5119 $ ksh -c 'echo $(echo \( )'
5121 $ ksh -c 'echo $(echo "(" )'
5124 The solution is to hack the parsing clode in lex.c, the
5125 question is how to hack it: should any parentheses be
5126 escaped by a backslash, or should recursive parsing be done
5127 (so quotes could also be used to hide hem). The former is
5128 easier, the later better...
5138 Continue in a for loop does not work right:
5140 if [ $i = b ] ; then
5149 if [ $i = b ] ; then
5150 if [ $first = no ] ; then
5151 echo 'continue in for loop broken'
5152 break # hope break isn't broken too :-)
5167 should print 0 according to POSIX (dash, bash, ksh93, posh)
5168 but not 0 according to the getopt(1) manual page, ksh88, and
5169 Bourne sh (such as /bin/sh on Solaris).
5170 We honour POSIX except when -o sh is set.
5171 category: shell:legacy-no
5174 [[ -o posix ]]; FPOSIX=$((1-$?))
5175 [[ -o sh ]]; FSH=$((1-$?))
5176 echo -n "FPOSIX=$FPOSIX FSH=$FSH "
5200 name: regression-10-legacy
5205 should print 0 according to POSIX (dash, bash, ksh93, posh)
5206 but not 0 according to the getopt(1) manual page, ksh88, and
5207 Bourne sh (such as /bin/sh on Solaris).
5208 category: shell:legacy-yes
5211 [[ -o posix ]]; FPOSIX=$((1-$?))
5212 [[ -o sh ]]; FSH=$((1-$?))
5213 echo -n "FPOSIX=$FPOSIX FSH=$FSH "
5242 should echo blah but on some machines echos /foo/bar/blah.
5251 Both of the following echos produce the same output under sh/ksh.att:
5254 echo "`echo \"$x\"`"
5256 pdksh produces different output for the former (foo instead of foo\tbar)
5259 echo "`echo \"$x\"`"
5267 The following command hangs forever:
5268 $ (: ; cat /etc/termcap) | sleep 2
5269 This is because the shell forks a shell to run the (..) command
5270 and this shell has the pipe open. When the sleep dies, the cat
5271 doesn't get a SIGPIPE 'cause a process (ie, the second shell)
5272 still has the pipe open.
5274 NOTE: this test provokes a bizarre bug in ksh93 (shell starts reading
5275 commands from /etc/termcap..)
5278 echo A line of text that will be duplicated quite a number of times.> t1
5279 cat t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 > t2
5280 cat t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 > t1
5281 cat t1 t1 t1 t1 > t2
5282 (: ; cat t2 2>/dev/null) | sleep 1
5287 $ (foobar) 2> /dev/null
5288 generates no output under /bin/sh, but pdksh produces the error
5291 $ foobar 2> /dev/null
5292 generates an error under /bin/sh and pdksh, but AT&T ksh88 produces
5293 no error (redirected to /dev/null).
5295 (you/should/not/see/this/error/1) 2> /dev/null
5296 you/should/not/see/this/error/2 2> /dev/null
5303 generates a blank line under pdksh and sets the exit status to 0.
5304 AT&T ksh88 generates no output and sets the exit status to 1. Also,
5307 generates no output under AT&T ksh88 (pdksh generates a blank line
5310 whence does/not/exist > /dev/null
5312 echo 2: $(whence does/not/exist | wc -l)
5313 echo 3: $(whence does/not/exist cat | wc -l)
5321 ${var%%expr} seems to be broken in many places. On the mips
5323 $ read line < /etc/passwd
5331 change the value of line. On sun4s & pas, the echo ${line%%:*} doesn't
5332 work. Haven't checked elsewhere...
5339 root:asdjhasdasjhs:0:1:Root:/:/bin/sh
5342 root:asdjhasdasjhs:0:1:Root:/:/bin/sh
5348 should set the exit status to non-zero (sh and AT&T ksh88 do).
5349 XXX doting a non existent file is a fatal error for a script
5352 expected-exit: e != 0
5353 expected-stderr-pattern: /.?/
5357 Both of the following echos should produce the same thing, but don't:
5371 backslash does not work as expected in case labels:
5390 Quoting backquotes inside backquotes doesn't work:
5391 $ echo `echo hi \`echo there\` folks`
5392 asks for more info. sh and AT&T ksh88 both echo
5395 echo `echo hi \`echo there\` folks`
5401 )) is not treated `correctly':
5402 $ (echo hi ; (echo there ; echo folks))
5405 instead of (as sh and ksh.att)
5406 $ (echo hi ; (echo there ; echo folks))
5412 ( : ; ( : ; echo hi))
5418 Check reading stdin in a while loop. The read should only read
5419 a single line, not a whole stdio buffer; the cat should get
5422 (echo a; echo b) | while read x ; do
5431 Check reading stdin in a while loop. The read should read both
5432 lines, not just the first.
5435 while [ "$a" != xxx ] ; do
5438 cat /dev/null | sed 's/x/y/'
5452 should cause a script to exit.
5456 expected-exit: e != 0
5457 expected-stderr-pattern: /does\/not\/exist/
5461 variable assignements not detected well
5464 expected-exit: e != 0
5465 expected-stderr-pattern: /a\.x=1/
5469 alias expansion different from AT&T ksh88
5471 alias a='for ' b='i in'
5472 a b hi ; do echo $i ; done
5478 strange characters allowed inside ${...}
5481 expected-exit: e != 0
5482 expected-stderr-pattern: /.?/
5486 Does read handle partial lines correctly
5489 while [ "$a" != xxx ] ; do
5506 Does read set variables to null at eof?
5509 while [ "$a" != xxx ] ; do
5513 echo 1: ${x-x not set} ${y-y not set} ${z-z not set}
5514 echo 2: ${x:+x not null} ${y:+y not null} ${z:+z not null}
5524 Does umask print a leading 0 when umask is 3 digits?
5526 # on MiNT, the first umask call seems to fail
5528 # now, the test proper
5536 Tempory files used for here-docs in functions get trashed after
5537 the function is parsed (before it is executed)
5560 Command substitution breaks reading in while loop
5561 (test from <sjg@void.zen.oz.au>)
5563 (echo abcdef; echo; echo 123) |
5566 # the following line breaks it
5567 c=`echo $line | wc -c`
5577 Machines with broken times() (reported by <sjg@void.zen.oz.au>)
5578 time does not report correct real time
5581 expected-stderr-pattern: !/^\s*0\.0[\s\d]+real|^\s*real[\s]+0+\.0/
5585 set -e doesn't ignore exit codes for if/while/until/&&/||/!.
5588 if false; then echo hi ; fi
5591 while false; do echo hi; done
5598 Only posh and oksh(2013-07) say “hi” below; FreeBSD sh,
5599 GNU bash in POSIX mode, dash, ksh93, mksh don’t. All of
5600 them exit 0. The POSIX behaviour is needed by BSD make.
5603 echo `false; echo hi` $(<this-file-does-not-exist)
5608 expected-stderr-pattern: /this-file-does-not-exist/
5612 This used to cause a core dump
5613 env-setup: !RANDOM=12!
5621 foo should be set to bar (should not be empty)
5631 Can't use command line assignments to assign readonly parameters.
5633 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
5634 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
5635 done >env; chmod +x env; PATH=.$PATHSEP$PATH
5638 foo=stuff env | grep '^foo'
5639 expected-exit: e != 0
5640 expected-stderr-pattern:
5645 Can subshells be prefixed by redirections (historical shells allow
5648 < /dev/null (sed 's/^/X/')
5652 Parameter assignments with [] recognised correctly
5670 Check that alias expansion works in command substitutions and
5683 Check that aliases are fully read.
5696 Check that (here doc) temp files are not left behind after an exec.
5699 TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
5701 sed 's/^/X /' << E_O_F
5708 echo=echo; [ -x /bin/echo ] && echo=/bin/echo
5709 exec $echo subtest-1 hi
5711 echo subtest-1 foo/*
5712 TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
5713 echo=echo; [ -x /bin/echo ] && echo=/bin/echo
5714 sed 's/^/X /' << E_O_F; exec $echo subtest-2 hi
5720 echo subtest-2 foo/*
5732 Check that unset params with attributes are reported by set, those
5733 sans attributes are not.
5749 Check that aliases do not use continuation prompt after trailing
5751 file-setup: file 644 "envf"
5754 env-setup: !ENV=./envf!
5758 alias foo='echo hi ; '
5770 Check that set allows both +o and -o options on same command line.
5773 set -o noglob +o allexport
5780 Check that globbing works in pipelined commands
5781 file-setup: file 644 "envf"
5783 file-setup: file 644 "abc"
5785 env-setup: !ENV=./envf!
5791 sed 's/^/X /' < ab* | sed 's/^/Y /'
5803 Check that getopts works in functions
5806 echo bfunc: enter "(args: $*; OPTIND=$OPTIND)"
5807 while getopts B oc; do
5810 echo bfunc: B option
5813 echo bfunc: odd option "($oc)"
5821 echo kfunc: enter "(args: $*; OPTIND=$OPTIND)"
5822 while getopts K oc; do
5825 echo kfunc: K option
5828 echo bfunc: odd option "($oc)"
5836 echo "line 1: OPTIND=$OPTIND"
5838 echo "line 2: ret=$?, optc=$optc, OPTIND=$OPTIND"
5840 echo "line 3: OPTIND=$OPTIND"
5842 echo "line 4: ret=$?, optc=$optc, OPTIND=$OPTIND"
5844 echo "line 5: OPTIND=$OPTIND"
5846 echo "line 6: ret=$?, optc=$optc, OPTIND=$OPTIND"
5851 echo "line 10: OPTIND=$OPTIND"
5853 echo "line 20: ret=$?, optc=$optc, OPTIND=$OPTIND"
5855 echo "line 30: OPTIND=$OPTIND"
5857 echo "line 40: ret=$?, optc=$optc, OPTIND=$OPTIND"
5859 echo "line 50: OPTIND=$OPTIND"
5861 echo "line 60: ret=$?, optc=$optc, OPTIND=$OPTIND"
5864 line 2: ret=0, optc=f, OPTIND=2
5865 bfunc: enter (args: -BBB blah; OPTIND=2)
5870 line 4: ret=0, optc=b, OPTIND=3
5871 kfunc: enter (args: -KKK blah; OPTIND=1)
5877 line 6: ret=0, optc=k, OPTIND=4
5880 line 20: ret=0, optc=f, OPTIND=2
5881 bfunc: enter (args: -BBB blah; OPTIND=2)
5886 line 40: ret=1, optc=?, OPTIND=2
5887 kfunc: enter (args: -KKK blah; OPTIND=1)
5893 line 60: ret=1, optc=?, OPTIND=2
5897 Check that ; is not required before the then in if (( ... )) then ...
5911 Check ${foo:%bar} is allowed (ksh88 allows it...)
5934 Check if typeset output is correct for
5935 uninitialised array elements.
5939 typeset -i | grep xxx | sed 's/^/ /'
5941 typeset | grep xxx | sed 's/^/ /'
5945 typeset -i | grep xxx | sed 's/^/ /'
5947 typeset | grep xxx | sed 's/^/ /'
5961 Check if trap exit is ok (exit not mistaken for signal name)
5970 Check if ${#array[*]} is calculated correctly.
5980 Check if default exit status is previous command
5986 ( (exit 103) ; exit)
5995 Check if EXIT trap is executed for sub shells.
5997 trap 'echo parent exit' EXIT
5999 (echo A; echo A last)
6001 (echo C; trap 'echo sub exit' EXIT; echo C last)
6016 Check if test -nt/-ot succeeds if second(first) file is missing.
6019 test a -nt b && echo nt OK || echo nt BAD
6020 test b -ot a && echo ot OK || echo ot BAD
6027 Check if typeset, export, and readonly work
6039 integer FNORD_E FNORD_F FNORD_G FNORD_H
6040 export FNORD_C FNORD_D FNORD_G FNORD_H
6041 readonly FNORD_B FNORD_D FNORD_F FNORD_H
6087 typeset -x -r FNORD_D
6089 typeset -i -r FNORD_F
6090 typeset -i -x FNORD_G
6091 typeset -i -x -r FNORD_H
6094 typeset -r FNORD_B=2
6095 typeset -x FNORD_C=3
6096 typeset -x -r FNORD_D=4
6097 typeset -i FNORD_E=5
6098 typeset -i -r FNORD_F=6
6099 typeset -i -x FNORD_G=7
6100 typeset -i -x -r FNORD_H=8
6118 Check that we can redefine functions calling time builtin
6130 check for a regression with sleep builtin and signal mask
6136 while read -p line; do :; done
6143 Check that quoting is sane
6151 while IFS= read -pr line; do
6152 if [[ $line = *space* ]]; then
6158 for line in "${lines[@]}"; do
6167 Ensure readonly is honoured for assignments and unset
6169 "$__progname" -c 'u=x; echo $? $u .' || echo aborted, $?
6171 "$__progname" -c 'readonly u; u=x; echo $? $u .' || echo aborted, $?
6173 "$__progname" -c 'u=x; readonly u; unset u; echo $? $u .' || echo aborted, $?
6180 expected-stderr-pattern:
6185 http://austingroupbugs.net/view.php?id=367 for export
6187 "$__progname" -c 'readonly foo; export foo=a; echo $?' || echo aborted, $?
6190 expected-stderr-pattern:
6195 Check that getopts works as intended, for readonly-2b to be valid
6197 "$__progname" -c 'set -- -a b; getopts a c; echo $? $c .; getopts a c; echo $? $c .' || echo aborted, $?
6204 http://austingroupbugs.net/view.php?id=367 for getopts
6206 "$__progname" -c 'readonly c; set -- -a b; getopts a c; echo $? $c .' || echo aborted, $?
6209 expected-stderr-pattern:
6214 http://austingroupbugs.net/view.php?id=367 for read
6216 echo x | "$__progname" -c 'read s; echo $? $s .' || echo aborted, $?
6217 echo y | "$__progname" -c 'readonly s; read s; echo $? $s .' || echo aborted, $?
6221 expected-stderr-pattern:
6226 Do not permit bypassing readonly for first array item
6228 set -A arr -- foo bar
6231 print -r -- "${arr[@]}"
6232 expected-exit: e != 0
6233 expected-stderr-pattern:
6238 Check that lone ampersand is a syntax error
6241 expected-exit: e != 0
6242 expected-stderr-pattern:
6245 name: xxx-quoted-newline-1
6247 Check that \<newline> works inside of ${}
6255 name: xxx-quoted-newline-2
6257 Check that \<newline> works at the start of a here document
6266 name: xxx-quoted-newline-3
6268 Check that \<newline> works at the end of a here document
6277 name: xxx-multi-assignment-cmd
6279 Check that assignments in a command affect subsequent assignments
6288 name: xxx-multi-assignment-posix-cmd
6290 Check that the behaviour for multiple assignments with a
6291 command name matches POSIX. See:
6292 http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925
6294 X=a Y=b; X=$Y Y=$X "$__progname" -c 'echo 1 $X $Y .'; echo 2 $X $Y .
6296 X=a Y=${X=b} Z=$X "$__progname" -c 'echo 3 $Z .'
6298 X=a Y=${X=b} Z=$X; echo 4 $Z .
6305 name: xxx-multi-assignment-posix-nocmd
6307 Check that the behaviour for multiple assignments with no
6308 command name matches POSIX (Debian #334182). See:
6309 http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925
6311 X=a Y=b; X=$Y Y=$X; echo 1 $X $Y .
6315 name: xxx-multi-assignment-posix-subassign
6317 Check that the behaviour for multiple assignments matches POSIX:
6318 - The assignment words shall be expanded in the current execution
6320 - The assignments happen in the temporary execution environment.
6323 Z=a Y=${X:=b} sh -c 'echo +$X+ +$Y+ +$Z+'
6325 # Now for the special case:
6327 X= Y=${X:=b} sh -c 'echo +$X+ +$Y+'
6335 name: xxx-exec-environment-1
6337 Check to see if exec sets it's environment correctly
6339 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
6340 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
6341 done >env; chmod +x env; PATH=.$PATHSEP$PATH
6343 expected-stdout-pattern:
6346 name: xxx-exec-environment-2
6348 Check to make sure exec doesn't change environment if a program
6351 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
6352 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
6353 done >env; chmod +x env; PATH=.$PATHSEP$PATH
6355 FOO=bar exec; env >bar2
6358 name: exec-function-environment-1
6360 Check assignments in function calls and whether they affect
6361 the current execution environment (ksh93, SUSv4)
6363 f() { a=2; }; g() { b=3; echo y$c-; }; a=1 f; b=2; c=1 g
6369 name: xxx-what-do-you-call-this-1
6375 name: xxx-prefix-strip-1
6382 name: xxx-prefix-strip-2
6390 name: xxx-variable-syntax-1
6393 expected-stderr-pattern:
6397 name: xxx-variable-syntax-2
6401 expected-stderr-pattern:
6405 name: xxx-variable-syntax-3
6409 expected-stderr-pattern:
6413 name: xxx-variable-syntax-4
6415 Not all kinds of trims are currently impossible, check those who do
6418 echo "<$*> X${*:+ }X"
6448 name: xxx-substitution-eval-order
6450 Check order of evaluation of expressions
6453 set -A A abc def GHI j G k
6454 echo ${A[x=(i+=1)]#${A[y=(i+=2)]}}
6460 name: xxx-set-option-1
6462 Check option parsing in set
6464 set -vsA foo -- A 1 3 2
6473 Check that exec exits for built-ins
6481 expected-stderr-pattern: /.*/
6485 Check the return value of while loops
6486 XXX need to do same for for/select/until loops
6489 while [ $i != xxx ] ; do
6491 if [ $i = xxx ] ; then
6499 while [ $i != xxx ] ; do
6501 if [ $i = xxx ] ; then
6509 while [ $i != xxx ] ; do
6521 Check that blank lines don't clear $?
6534 expected-stderr-pattern: /.*/
6538 Check that $? is preserved in subshells, includes, traps.
6547 echo 'echo include: $?' > foo
6551 trap 'echo trap: $?' ERR
6561 name: xxx-clean-chars-1
6563 Check MAGIC character is stuffed correctly
6569 name: xxx-param-subst-qmark-1
6571 Check suppresion of error message with null string. According to
6572 POSIX, it shouldn't print the error as 'word' isn't ommitted.
6573 ksh88/93, Solaris /bin/sh and /usr/xpg4/bin/sh all print the error.
6579 expected-stderr-pattern: !/not set/
6582 # fails due to weirdness of execv stuff
6583 category: !os:uwin-nt
6585 Check c flag is set.
6586 arguments: !-c!echo "[$-]"!
6587 expected-stdout-pattern: /^\[.*c.*\]$/
6589 name: tilde-expand-1
6591 Check tilde expansion after equal signs
6592 env-setup: !HOME=/sweet!
6594 echo ${A=a=}~ b=~ c=d~ ~
6596 command command export g=~ h=d~
6601 echo ${A=a=}~ b=~ c=d~ ~
6603 command command export g=~ h=d~
6607 a=/sweet b=/sweet c=d~ /sweet
6614 name: tilde-expand-2
6616 Check tilde expansion works
6617 env-setup: !HOME=/sweet!
6621 plus=$(print -r -- ~+)
6622 minus=$(print -r -- ~-)
6623 nix=$(print -r -- ~)
6624 [[ $plus = / ]]; echo one $? .
6625 [[ $minus = "$wd" ]]; echo two $? .
6626 [[ $nix = /sweet ]]; echo nix $? .
6634 Check some "exit on error" conditions
6636 print '#!'"$__progname"'\nexec "$1"' >env
6637 print '#!'"$__progname"'\nexit 1' >false
6641 env false && echo something
6651 Check some "exit on error" edge conditions (POSIXly)
6653 print '#!'"$__progname"'\nexec "$1"' >env
6654 print '#!'"$__progname"'\nexit 1' >false
6655 print '#!'"$__progname"'\nexit 0' >true
6660 env false && echo something
6672 pdksh regression which AT&T ksh does right
6673 TFM says: [set] -e | errexit
6674 Exit (after executing the ERR trap) ...
6676 trap 'echo EXIT' EXIT
6679 cd /XXXXX 2>/dev/null
6685 expected-exit: e != 0
6689 "set -e" test suite (POSIX)
6703 "set -e" test suite (POSIX)
6709 [ "$1" = "$E" ] && { shift ; continue 2 ; }
6726 "set -e" test suite (BSD make)
6730 print 'all:\n\t@echo eins\n\t@exit 42\n' >zd/a/Makefile
6731 print 'all:\n\t@echo zwei\n' >zd/b/Makefile
6734 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"
6740 Stop in WD/zd/a (line 2 of Makefile).
6744 "set -e" regression (LP#1104543)
6748 [ -x $PWD/nonexistant ] && $PWD/nonexistant
6759 "set -e" regression (Debian #700526)
6762 _db_cmd() { return $1; }
6763 db_input() { _db_cmd 30; }
6764 db_go() { _db_cmd 0; }
6771 SUSv4 says that the shell should exit with 126/127 in some situations
6775 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6776 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6778 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6779 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6781 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6782 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6793 Check eval vs substitution exit codes (ksh93 alike)
6805 eval "eval $(false)"
6808 eval 'eval '"$(false)"
6812 eval $(echo :; false)
6830 Check that "exit" with no arguments behaves SUSv4 conformant.
6832 trap 'echo hi; exit' EXIT
6840 Check that ERR and EXIT traps are run just like ksh93 does.
6841 GNU bash does not run ERtrap in ±e eval-undef but runs it
6842 twice (bug?) in +e eval-false, so does ksh93 (bug?), which
6843 also has a bug to continue execution (echoing "and out" and
6844 returning 0) in +e eval-undef.
6845 file-setup: file 644 "x"
6847 trap 'echo EXtrap' EXIT
6848 trap 'echo ERtrap' ERR
6853 file-setup: file 644 "xt"
6855 trap 'echo EXtrap' EXIT
6856 trap 'echo ERtrap' ERR
6861 file-setup: file 644 "xf"
6863 trap 'echo EXtrap' EXIT
6864 trap 'echo ERtrap' ERR
6866 echo 'and run false'
6869 file-setup: file 644 "xu"
6871 trap 'echo EXtrap' EXIT
6872 trap 'echo ERtrap' ERR
6874 echo 'and run ${v?}'
6884 -e 's/parameter not set/parameter null or not set/' \
6885 -e 's/[[]6]//' -e 's/: eval: line 1//' -e 's/: line 6//' \
6886 -e "s
\ 1^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]
\ 1PROG
\ 1"
6891 echo = eval-true $(<rc) .
6893 echo = eval-false $(<rc) .
6894 runtest x $xe '${v?}'
6895 echo = eval-undef $(<rc) .
6897 echo = noeval-true $(<rc) .
6899 echo = noeval-false $(<rc) .
6901 echo = noeval-undef $(<rc) .
6905 echo = eval-true $(<rc) .
6907 echo = eval-false $(<rc) .
6908 runtest x $xe '${v?}'
6909 echo = eval-undef $(<rc) .
6911 echo = noeval-true $(<rc) .
6913 echo = noeval-false $(<rc) .
6915 echo = noeval-undef $(<rc) .
6927 x: v: parameter null or not set
6940 xu: v: parameter null or not set
6954 x: v: parameter null or not set
6968 xu: v: parameter null or not set
6972 name: exit-trap-interactive
6974 Check that interactive shell doesn't exit via EXIT trap on syntax error
6979 echo 'After error 1'
6980 trap 'echo Exit trap' EXIT
6982 echo 'After error 2'
6983 trap 'echo Exit trap' EXIT
6990 expected-stderr-pattern:
6991 /syntax error: 'newline' unexpected/
6995 Check that test also can handle string1 < string2 etc.
6997 test 2005/10/08 '<' 2005/08/21 && echo ja || echo nein
6998 test 2005/08/21 \< 2005/10/08 && echo ja || echo nein
6999 test 2005/10/08 '>' 2005/08/21 && echo ja || echo nein
7000 test 2005/08/21 \> 2005/10/08 && echo ja || echo nein
7006 expected-stderr-pattern: !/unexpected op/
7008 name: test-precedence-1
7010 Check a weird precedence case (and POSIX echo)
7020 Test the test -o operator
7025 [[ -o $1 ]]; echo $?
7028 test -o $1 -o -o !$1; echo $?
7029 [ -o $1 -o -o !$1 ]; echo $?
7030 [[ -o $1 || -o !$1 ]]; echo $?
7031 test -o ?$1; echo $?
7033 echo 0y $(if_test utf8-mode) =
7034 echo 0n $(if_test utf8-hack) =
7035 echo 1= $(runtest utf8-hack) =
7036 echo 2= $(runtest !utf8-hack) =
7037 echo 3= $(runtest ?utf8-hack) =
7039 echo 1+ $(runtest utf8-mode) =
7040 echo 2+ $(runtest !utf8-mode) =
7041 echo 3+ $(runtest ?utf8-mode) =
7043 echo 1- $(runtest utf8-mode) =
7044 echo 2- $(runtest !utf8-mode) =
7045 echo 3- $(runtest ?utf8-mode) =
7046 echo = short flags =
7047 echo 0y $(if_test -U) =
7048 echo 0y $(if_test +U) =
7049 echo 0n $(if_test -_) =
7050 echo 0n $(if_test -U-) =
7051 echo 1= $(runtest -_) =
7052 echo 2= $(runtest !-_) =
7053 echo 3= $(runtest ?-_) =
7055 echo 1+ $(runtest -U) =
7056 echo 2+ $(runtest !-U) =
7057 echo 3+ $(runtest ?-U) =
7058 echo 1+ $(runtest +U) =
7059 echo 2+ $(runtest !+U) =
7060 echo 3+ $(runtest ?+U) =
7062 echo 1- $(runtest -U) =
7063 echo 2- $(runtest !-U) =
7064 echo 3- $(runtest ?-U) =
7065 echo 1- $(runtest +U) =
7066 echo 2- $(runtest !+U) =
7067 echo 3- $(runtest ?+U) =
7103 Check that the short form [ $x ] works
7107 rv=$?; echo $((++i)) $rv
7109 rv=$?; echo $((++i)) $rv
7111 rv=$?; echo $((++i)) $rv
7113 rv=$?; echo $((++i)) $rv
7116 rv=$?; echo $((++i)) $rv
7118 rv=$?; echo $((++i)) $rv
7120 rv=$?; echo $((++i)) $rv
7122 rv=$?; echo $((++i)) $rv
7125 rv=$?; echo $((++i)) $rv
7127 rv=$?; echo $((++i)) $rv
7129 rv=$?; echo $((++i)) $rv
7131 rv=$?; echo $((++i)) $rv
7148 Check that the short form [[ $x ]] works (ksh93 extension)
7152 rv=$?; echo $((++i)) $rv
7154 rv=$?; echo $((++i)) $rv
7156 rv=$?; echo $((++i)) $rv
7158 rv=$?; echo $((++i)) $rv
7161 rv=$?; echo $((++i)) $rv
7163 rv=$?; echo $((++i)) $rv
7165 rv=$?; echo $((++i)) $rv
7167 rv=$?; echo $((++i)) $rv
7170 rv=$?; echo $((++i)) $rv
7172 rv=$?; echo $((++i)) $rv
7174 rv=$?; echo $((++i)) $rv
7176 rv=$?; echo $((++i)) $rv
7193 Check numeric -eq works (R40d regression); spotted by Martijn Dekker
7198 (0) echo yepp 0 \#"$*" ;;
7199 (1) echo nope 1 \#"$*" ;;
7200 (2) echo terr 2 \#"$*" ;;
7201 (*) echo wtf\? $? \#"$*" ;;
7204 tst 1 'test 2 -eq 2'
7205 tst 2 'test 2 -eq 2a'
7206 tst 3 'test 2 -eq 3'
7207 tst 4 'test 2 -ne 2'
7208 tst 5 'test 2 -ne 2a'
7209 tst 6 'test 2 -ne 3'
7210 tst 7 'test \! 2 -eq 2'
7211 tst 8 'test \! 2 -eq 2a'
7212 tst 9 'test \! 2 -eq 3'
7214 yepp 0 #1 test 2 -eq 2
7215 terr 2 #2 test 2 -eq 2a
7216 nope 1 #3 test 2 -eq 3
7217 nope 1 #4 test 2 -ne 2
7218 terr 2 #5 test 2 -ne 2a
7219 yepp 0 #6 test 2 -ne 3
7220 nope 1 #7 test \! 2 -eq 2
7221 terr 2 #8 test \! 2 -eq 2a
7222 yepp 0 #9 test \! 2 -eq 3
7223 expected-stderr-pattern:
7228 Check that ~/.mkshrc works correctly.
7229 Part 1: verify user environment is not read (internal)
7237 Check that ~/.mkshrc works correctly.
7238 Part 2: verify mkshrc is not read (non-interactive shells)
7239 file-setup: file 644 ".mkshrc"
7241 env-setup: !HOME=.!ENV=!
7249 Check that ~/.mkshrc works correctly.
7250 Part 2: verify mkshrc can be read (interactive shells)
7251 file-setup: file 644 ".mkshrc"
7255 env-setup: !HOME=.!ENV=!PS1=!
7260 expected-stderr-pattern:
7265 Check that ~/.mkshrc works correctly.
7266 Part 3: verify mkshrc can be turned off
7267 file-setup: file 644 ".mkshrc"
7269 env-setup: !HOME=.!ENV=nonexistant!
7277 Check that sh mode turns braceexpand off
7278 and that that works correctly
7282 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
7283 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
7291 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
7292 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
7295 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
7296 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
7312 Check that posix or sh mode is *not* automatically turned on
7315 ln -s "$__progname" ksh || cp "$__progname" ksh
7316 ln -s "$__progname" sh || cp "$__progname" sh
7317 ln -s "$__progname" ./-ksh || cp "$__progname" ./-ksh
7318 ln -s "$__progname" ./-sh || cp "$__progname" ./-sh
7319 for shell in {,-}{,k}sh; do
7320 print -- $shell $(./$shell +l -c \
7321 '[[ $(set +o) == *"-o "@(sh|posix)@(| *) ]] && echo sh || echo nosh')
7331 Check that posix or sh mode *is* automatically turned on
7334 ln -s "$__progname" ksh || cp "$__progname" ksh
7335 ln -s "$__progname" sh || cp "$__progname" sh
7336 ln -s "$__progname" ./-ksh || cp "$__progname" ./-ksh
7337 ln -s "$__progname" ./-sh || cp "$__progname" ./-sh
7338 for shell in {,-}{,k}sh; do
7339 print -- $shell $(./$shell +l -c \
7340 '[[ $(set +o) == *"-o "@(sh|posix)@(| *) ]] && echo sh || echo nosh')
7350 pdksh bug: last command of a pipeline is executed in a
7351 subshell - make sure it still is, scripts depend on it
7352 file-setup: file 644 "abcx"
7353 file-setup: file 644 "abcy"
7356 echo a | while read d; do
7376 check that co-processes work with TCOMs, TPIPEs and TPARENs
7379 "$__progname" -c 'i=100; echo hi |& while read -p line; do echo "$((i++)) $line"; done'
7380 "$__progname" -c 'i=200; echo hi | cat |& while read -p line; do echo "$((i++)) $line"; done'
7381 "$__progname" -c 'i=300; (echo hi | cat) |& while read -p line; do echo "$((i++)) $line"; done'
7389 Check that PIPESTATUS does what it's supposed to
7391 echo 1 $PIPESTATUS .
7392 echo 2 ${PIPESTATUS[0]} .
7393 echo 3 ${PIPESTATUS[1]} .
7394 (echo x; exit 12) | (cat; exit 23) | (cat; exit 42)
7395 echo 5 $? , $PIPESTATUS , ${PIPESTATUS[0]} , ${PIPESTATUS[1]} , ${PIPESTATUS[2]} , ${PIPESTATUS[3]} .
7396 echo 6 ${PIPESTATUS[0]} .
7397 set | fgrep PIPESTATUS
7398 echo 8 $(set | fgrep PIPESTATUS) .
7404 5 42 , 12 , 12 , 23 , 42 , .
7407 8 PIPESTATUS[0]=0 PIPESTATUS[1]=0 .
7411 Check that "set -o pipefail" does what it's supposed to
7413 echo 1 "$("$__progname" -c '(exit 12) | (exit 23) | (exit 42); echo $?')" .
7414 echo 2 "$("$__progname" -c '! (exit 12) | (exit 23) | (exit 42); echo $?')" .
7415 echo 3 "$("$__progname" -o pipefail -c '(exit 12) | (exit 23) | (exit 42); echo $?')" .
7416 echo 4 "$("$__progname" -o pipefail -c '! (exit 12) | (exit 23) | (exit 42); echo $?')" .
7417 echo 5 "$("$__progname" -c '(exit 23) | (exit 42) | :; echo $?')" .
7418 echo 6 "$("$__progname" -c '! (exit 23) | (exit 42) | :; echo $?')" .
7419 echo 7 "$("$__progname" -o pipefail -c '(exit 23) | (exit 42) | :; echo $?')" .
7420 echo 8 "$("$__progname" -o pipefail -c '! (exit 23) | (exit 42) | :; echo $?')" .
7421 echo 9 "$("$__progname" -o pipefail -c 'x=$( (exit 23) | (exit 42) | :); echo $?')" .
7433 name: persist-history-1
7435 Check if persistent history saving works
7436 category: !no-histfile
7439 env-setup: !ENV=./Env!HISTFILE=hist.file!
7440 file-setup: file 644 "Env"
7444 expected-stdout-pattern:
7446 expected-stderr-pattern:
7451 Check that global does what typeset is supposed to do
7455 global -Uui16 arrfoo[*]
7457 echo before ${arrfoo[0]} .
7459 echo after ${arrfoo[0]} .
7462 echo inside before ${arrbar[0]} .
7464 echo inside changed ${arrbar[0]} .
7465 global -Uui16 arrbar[*]
7466 echo inside typeset ${arrbar[0]} .
7468 echo inside changed ${arrbar[0]} .
7470 echo before ${arrbar[0]} .
7472 echo after ${arrbar[0]} .
7479 inside typeset 16#61 .
7480 inside changed 16#30 .
7483 name: typeset-padding-1
7485 Check if left/right justification works as per TFM
7487 typeset -L10 ln=0hall0
7488 typeset -R10 rn=0hall0
7489 typeset -ZL10 lz=0hall0
7490 typeset -ZR10 rz=0hall0
7491 typeset -Z10 rx=" hallo "
7492 echo "<$ln> <$rn> <$lz> <$rz> <$rx>"
7494 <0hall0 > < 0hall0> <hall0 > <00000hall0> <0000 hallo>
7496 name: typeset-padding-2
7498 Check if base-!10 integers are padded right
7500 typeset -Uui16 -L9 ln=16#1
7501 typeset -Uui16 -R9 rn=16#1
7502 typeset -Uui16 -Z9 zn=16#1
7506 echo "<$ln> <$rn> <$zn> <$ls> <$rs> <$zs>"
7508 <16#1 > < 16#1> <16#000001> <16#1 > < 16#1> <0000016#1>
7512 Check that the UTF-8 Byte Order Mark is ignored as the first
7513 multibyte character of the shell input (with -c, from standard
7514 input, as file, or as eval argument), but nowhere else
7515 # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
7516 category: !os:darwin
7519 print '#!/bin/sh\necho ohne' >foo/fnord
7520 print '#!/bin/sh\necho mit' >foo/fnord
7521 print 'fnord\nfnord\nfnord\nfnord' >foo/bar
7522 print eval \''fnord\nfnord\nfnord\nfnord'\' >foo/zoo
7523 set -A anzahl -- foo/*
7524 echo got ${#anzahl[*]} files
7526 export PATH=$(pwd)/foo$PATHSEP$PATH
7527 "$__progname" -c 'fnord'
7529 "$__progname" -c 'fnord; fnord; fnord; fnord'
7531 "$__progname" foo/bar
7533 "$__progname" <foo/bar
7535 "$__progname" foo/zoo
7537 "$__progname" -c 'echo : $(fnord)'
7567 Check that we can execute BOM-shebangs (failures not fatal)
7568 XXX if the OS can already execute them, we lose
7569 note: cygwin execve(2) doesn't return to us with ENOEXEC, we lose
7570 note: Ultrix perl5 t4 returns 65280 (exit-code 255) and no text
7571 XXX fails when LD_PRELOAD is set with -e and Perl chokes it (ASan)
7573 category: !os:cygwin,!os:msys,!os:ultrix,!os:uwin-nt,!smksh
7574 env-setup: !FOO=BAR!
7576 print '#!'"$__progname"'\nprint "1 a=$ENV{FOO}";' >t1
7577 print '#!'"$__progname"'\nprint "2 a=$ENV{FOO}";' >t2
7578 print '#!'"$__perlname"'\nprint "3 a=$ENV{FOO}\n";' >t3
7579 print '#!'"$__perlname"'\nprint "4 a=$ENV{FOO}\n";' >t4
7586 1 a=/nonexistant{FOO}
7587 2 a=/nonexistant{FOO}
7590 expected-stderr-pattern:
7591 /(Unrecognized character .... ignored at \..t4 line 1)*/
7595 Check that the utf8-mode flag is not set at non-interactive startup
7597 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8!
7599 if [[ $- = *U* ]]; then
7609 Check that the utf8-mode flag is not set at non-interactive startup
7611 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.utf8!
7613 if [[ $- = *U* ]]; then
7623 Check that the utf8-mode flag is set at interactive startup.
7624 -DMKSH_ASSUME_UTF8=0 => expected failure, please ignore
7625 -DMKSH_ASSUME_UTF8=1 => not expected, please investigate
7626 -UMKSH_ASSUME_UTF8 => not expected, but if your OS is old,
7627 try passing HAVE_SETLOCALE_CTYPE=0 to Build.sh
7629 category: !os:hpux,!os:msys
7632 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8!
7634 if [[ $- = *U* ]]; then
7641 expected-stderr-pattern:
7646 Check that the utf8-mode flag is set at interactive startup
7647 Expected failure if -DMKSH_ASSUME_UTF8=0
7651 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.utf8!
7653 if [[ $- = *U* ]]; then
7660 expected-stderr-pattern:
7665 Ensure ±U on the command line is honoured
7666 (these two tests may pass falsely depending on CPPFLAGS)
7669 code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi'
7670 let i++; "$__progname" -U -c "$code"
7671 let i++; "$__progname" +U -c "$code"
7680 Ensure ±U on the command line is honoured, interactive shells
7684 code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi'
7685 let i++; "$__progname" -U -ic "$code"
7686 let i++; "$__progname" +U -ic "$code"
7695 Check if built-in shell aliases are okay
7700 autoload='\typeset -fu'
7701 functions='\typeset -f'
7702 hash='\builtin alias -t'
7703 history='\builtin fc -l'
7704 integer='\typeset -i'
7707 nameref='\typeset -n'
7709 r='\builtin fc -e -'
7710 type='\builtin whence -v'
7714 Check if “set -o sh” does not influence built-in aliases
7720 autoload='\typeset -fu'
7721 functions='\typeset -f'
7722 hash='\builtin alias -t'
7723 history='\builtin fc -l'
7724 integer='\typeset -i'
7727 nameref='\typeset -n'
7729 r='\builtin fc -e -'
7730 type='\builtin whence -v'
7734 Check if running as sh does not influence built-in aliases
7737 ./sh -c 'alias; typeset -f'
7740 autoload='\typeset -fu'
7741 functions='\typeset -f'
7742 hash='\builtin alias -t'
7743 history='\builtin fc -l'
7744 integer='\typeset -i'
7747 nameref='\typeset -n'
7749 r='\builtin fc -e -'
7750 type='\builtin whence -v'
7752 name: aliases-cmdline
7754 Check that aliases work from the command line (Debian #517009)
7755 Note that due to the nature of the lexing process, defining
7756 aliases in COMSUBs then immediately using them, and things
7757 like 'alias foo=bar && foo', still fail.
7759 "$__progname" -c $'alias a="echo OK"\na'
7763 name: aliases-funcdef-1
7765 Check if POSIX functions take precedences over aliases
7767 alias foo='echo makro'
7775 name: aliases-funcdef-2
7777 Check if POSIX functions take precedences over aliases
7779 alias foo='echo makro'
7787 name: aliases-funcdef-3
7789 Check if aliases take precedences over Korn functions
7791 alias foo='echo makro'
7799 name: aliases-funcdef-4
7801 Functions should only take over if actually being defined
7812 Check if Korn Shell arrays work as expected
7815 set -A foo -- a \$v "$v" '$v' b
7816 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
7822 Check if bash-style arrays work as expected
7825 foo=(a \$v "$v" '$v' b)
7826 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
7832 Check if bash-style arrays work as expected, with newlines
7834 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "$x|"; done' >pfp
7836 test -n "$ZSH_VERSION" && setopt KSH_ARRAYS
7842 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
7847 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
7852 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
7854 7|a|bc|d|$v|e f|$v|g|
7855 7|a|bc|d|$v|e f|$v|g|
7856 6|abc\|d|$v|e f|$v|g||
7860 Check if array bounds are uint32_t
7867 echo ${foo[4294967295]} g ${foo[*]}
7874 Check if Korn Shell arrays with specified indices work as expected
7877 set -A foo -- [1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b
7878 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|"
7879 # we don't want this at all:
7881 set -A arr "[5]=meh"
7882 echo "<${arr[0]}><${arr[5]}>"
7884 5|[1]=$v|[2]=c d|[4]=$v|[0]=a|[5]=b||
7889 Check if bash-style arrays with specified indices work as expected
7890 (taken out temporarily to fix arrays-4; see also arrays-9a comment)
7894 foo=([1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b)
7895 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|"
7896 x=([128]=foo bar baz)
7899 # Check that we do not break this by globbing
7904 echo "<${arr[0]}><${arr[5]}>"
7913 Check if we can get the array keys (indices) for indexed arrays,
7919 echo -n "$((i++))<$x>"
7930 echo a $(of ${foo[*]}) = $(of ${bar[*]}) a
7931 echo b $(of "${foo[*]}") = $(of "${bar[*]}") b
7932 echo c $(of ${foo[@]}) = $(of ${bar[@]}) c
7933 echo d $(of "${foo[@]}") = $(of "${bar[@]}") d
7934 echo e $(of ${!foo[*]}) = $(of ${!bar[*]}) e
7935 echo f $(of "${!foo[*]}") = $(of "${!bar[*]}") f
7936 echo g $(of ${!foo[@]}) = $(of ${!bar[@]}) g
7937 echo h $(of "${!foo[@]}") = $(of "${!bar[@]}") h
7945 a 0<zwei>1<eins>2<drei> = a
7946 b 0<zwei eins drei> = 0<> b
7947 c 0<zwei>1<eins>2<drei> = c
7948 d 0<zwei>1<eins>2<drei> = d
7956 Check if we can get the array keys (indices) for indexed arrays,
7957 Korn shell style, in some corner cases
7960 echo !arz[0]: ${!arz[0]}
7961 echo !arz[1]: ${!arz[1]}
7964 echo !arz[0]: ${!arz[0]}
7965 echo !arz[1]: ${!arz[1]}
7968 echo !arz[0]: ${!arz[0]}
7969 echo !arz[1]: ${!arz[1]}
7983 Check some behavioural rules for arrays.
8021 typeset -Z3 aa ab ac ad ae af ag
8066 Check that we can concatenate arrays
8068 unset foo; foo=(bar); foo+=(baz); echo 1 ${!foo[*]} : ${foo[*]} .
8069 unset foo; foo=(foo bar); foo+=(baz); echo 2 ${!foo[*]} : ${foo[*]} .
8070 # unset foo; foo=([2]=foo [0]=bar); foo+=(baz [5]=quux); echo 3 ${!foo[*]} : ${foo[*]} .
8073 2 0 1 2 : foo bar baz .
8074 # 3 0 2 3 5 : bar foo baz quux .
8078 Check that we can concatenate parameters too
8080 unset foo; foo=bar; foo+=baz; echo 1 $foo .
8081 unset foo; typeset -i16 foo=10; foo+=20; echo 2 $foo .
8086 name: arrassign-basic
8088 Check basic whitespace conserving properties of wdarrassign
8096 c+=("$(echo "c d")")
8098 echo ".a:${a[0]}.${a[1]}.${a[2]}.${a[3]}:"
8099 echo ".b:${b[0]}.${b[1]}.${b[2]}.${b[3]}:"
8100 echo ".c:${c[0]}.${c[1]}.${c[2]}.${c[3]}:"
8101 echo ".d:${d[0]}.${d[1]}.${d[2]}.${d[3]}:"
8108 name: arrassign-fnc-none
8110 Check locality of array access inside a function
8114 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8117 if [[ -n $BASH_VERSION ]]; then
8123 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8127 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8129 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8131 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8132 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8134 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8136 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8149 name: arrassign-fnc-local
8151 Check locality of array access inside a function
8152 with the bash/mksh/ksh93 local/typeset keyword
8153 (note: ksh93 has no local; typeset works only in FKSH)
8158 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8161 if [[ -n $BASH_VERSION ]]; then
8168 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8172 if [[ -n $BASH_VERSION ]]; then
8178 echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8183 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8185 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8187 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8188 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8190 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8192 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8193 echo ".f0r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8195 echo ".f1r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8197 echo ".f2r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8215 name: arrassign-fnc-global
8217 Check locality of array access inside a function
8218 with the mksh-specific global keyword
8223 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8229 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8235 echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8240 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8242 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8244 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8245 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8247 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8249 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8250 echo ".f0r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8252 echo ".f1r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8254 echo ".f2r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8272 name: strassign-fnc-none
8274 Check locality of string access inside a function
8309 name: strassign-fnc-local
8311 Check locality of string access inside a function
8312 with the bash/mksh/ksh93 local/typeset keyword
8313 (note: ksh93 has no local; typeset works only in FKSH)
8367 name: strassign-fnc-global
8369 Check locality of string access inside a function
8370 with the mksh-specific global keyword
8424 name: unset-fnc-local-ksh
8426 Check that “unset” removes a previous “local”
8427 (ksh93 syntax compatible version); apparently,
8428 there are shells which fail this?
8454 name: unset-fnc-local-sh
8456 Check that “unset” removes a previous “local”
8457 (Debian Policy §10.4 sh version); apparently,
8458 there are shells which fail this?
8484 name: varexpand-substr-1
8486 Check if bash-style substring expansion works
8487 when using positive numerics
8490 typeset -i y=123456789
8491 typeset -i 16 z=123456789 # 16#75bcd15
8492 echo a t${x:2:2} ${y:2:3} ${z:2:3} a
8493 echo b ${x::3} ${y::3} ${z::3} b
8494 echo c ${x:2:} ${y:2:} ${z:2:} c
8495 echo d ${x:2} ${y:2} ${z:2} d
8496 echo e ${x:2:6} ${y:2:6} ${z:2:7} e
8497 echo f ${x:2:7} ${y:2:7} ${z:2:8} f
8498 echo g ${x:2:8} ${y:2:8} ${z:2:9} g
8503 d cdefghi 3456789 #75bcd15 d
8504 e cdefgh 345678 #75bcd1 e
8505 f cdefghi 3456789 #75bcd15 f
8506 g cdefghi 3456789 #75bcd15 g
8508 name: varexpand-substr-2
8510 Check if bash-style substring expansion works
8511 when using negative numerics or expressions
8514 typeset -i y=123456789
8515 typeset -i 16 z=123456789 # 16#75bcd15
8517 echo a ${x:$n:3} ${y:$n:3} ${z:$n:3} a
8518 echo b ${x:(n):3} ${y:(n):3} ${z:(n):3} b
8519 echo c ${x:(-2):1} ${y:(-2):1} ${z:(-2):1} c
8520 echo d t${x: n:2} ${y: n:3} ${z: n:3} d
8527 name: varexpand-substr-3
8529 Check that some things that work in bash fail.
8530 This is by design. Oh and vice versa, nowadays.
8532 export x=abcdefghi n=2
8533 "$__progname" -c 'echo v${x:(n)}x'
8534 "$__progname" -c 'echo w${x: n}x'
8535 "$__progname" -c 'echo x${x:n}x'
8536 "$__progname" -c 'echo y${x:}x'
8537 "$__progname" -c 'echo z${x}x'
8538 # next fails only in bash
8539 "$__progname" -c 'x=abcdef;y=123;echo ${x:${y:2:1}:2}' >/dev/null 2>&1; echo $?
8545 expected-stderr-pattern:
8546 /x:n.*bad substitution.*\n.*bad substitution/
8548 name: varexpand-substr-4
8550 Check corner cases for substring expansion
8554 echo a ${x:(y == 1 ? 2 : 3):4} a
8558 name: varexpand-substr-5A
8560 Check that substring expansions work on characters
8564 echo a ${x::1} ${x: -1} a
8565 echo b ${x::3} ${x: -3} b
8566 echo c ${x:1:2} ${x: -3:2} c
8574 name: varexpand-substr-5W
8576 Check that substring expansions work on characters
8580 echo a ${x::1} ${x: -1} a
8581 echo b ${x::2} ${x: -2} b
8582 echo c ${x:1:1} ${x: -2:1} c
8590 name: varexpand-substr-6
8592 Check that string substitution works correctly
8597 echo a ${baz: foo: bar}
8598 echo b ${baz: foo: $bar}
8599 echo c ${baz: $foo: bar}
8600 echo d ${baz: $foo: $bar}
8607 name: varexpand-special-hash
8609 Check special ${var@x} expansion for x=hash
8614 print ${foo@#} ${bar@#} ${baz@#} .
8616 9B15FBFB CFBDD32B 00000000 .
8618 name: varexpand-special-quote
8620 Check special ${var@Q} expansion for quoted strings
8627 print -r -- "<i=$i j=$j k=$k>"
8628 s="u=${i@Q} v=${j@Q} w=${k@Q}"
8629 print -r -- "s=\"$s\""
8635 s="u=x v='a b' w=$'c\nd\240e\u20ACf'"
8638 typeset w=$'c\nd\240e\u20ACf'
8640 name: varexpand-null-1
8642 Ensure empty strings expand emptily
8644 print s ${a} . ${b} S
8645 print t ${a#?} . ${b%?} T
8646 print r ${a=} . ${b/c/d} R
8648 print s "${a}" . "${b}" S
8649 print t "${a#?}" . "${b%?}" T
8650 print r "${a=}" . "${b/c/d}" R
8660 name: varexpand-null-2
8662 Ensure empty strings, when quoted, are expanded as empty strings
8664 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "<$x> "; done' >pfs
8666 ./pfs 1 "${a}" 2 "${a#?}" + "${b%?}" 3 "${a=}" + "${b/c/d}"
8669 <1> <> <2> <> <+> <> <3> <> <+> <> .
8671 name: varexpand-null-3
8673 Ensure concatenating behaviour matches other shells
8675 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
8677 x=; showargs 1 "$x"$@
8678 set A; showargs 2 "${@:+}"
8712 name: varexpand-funny-chars
8714 Check some characters
8715 XXX \uEF80 is asymmetric, possibly buggy so we don’t check this
8717 x=$'<\x00>'; typeset -p x
8718 x=$'<\x01>'; typeset -p x
8719 x=$'<\u0000>'; typeset -p x
8720 x=$'<\u0001>'; typeset -p x
8727 name: print-funny-chars
8729 Check print builtin's capability to output designated characters
8731 print '<\0144\0344\xDB\u00DB\u20AC\uDB\x40>'
8745 Check print builtin's \c escape
8747 print '\ca'; print b
8753 Check that CR+LF is not collapsed into LF as some MSYS shells wrongly do
8755 echo '#!'"$__progname" >foo
8757 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'
8762 ./foo | while IFS= read -r line; do
8763 print -r -- "{$line}"
8766 [220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT
\r
8767 220->> Bitte keine Werbung einwerfen! <<
\r\r
8768 220 Who do you wanna pretend to be today?
\r]
8769 {220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT
\r}
8770 {220->> Bitte keine Werbung einwerfen! <<
\r\r}
8771 {220 Who do you wanna pretend to be today?
\r}
8775 Check that CR+LF is shown and read as-is
8781 if test x"$KSH_VERSION" = x""; then #
\r
8782 printf '<%s>' "$x" #
\r
8784 print -nr -- "<$x>" #
\r
8787 echo "[$("$__progname" foo)]"
8788 "$__progname" foo | while IFS= read -r line; do
8789 print -r -- "{$line}"
8800 Check that LF-only is shown and read as-is
8806 if test x"$KSH_VERSION" = x""; then #
8807 printf '<%s>' "$x" #
8809 print -nr -- "<$x>" #
8812 echo "[$("$__progname" foo)]"
8813 "$__progname" foo | while IFS= read -r line; do
8814 print -r -- "{$line}"
8823 name: print-nul-chars
8825 Check handling of NUL characters for print and COMSUB
8828 print $(($(print '<\0>' | wc -c))) $(($(print "$x" | wc -c))) \
8830 expected-stdout-pattern:
8835 Check backslash expansion by the print builtin
8837 print '\ \!\"\#\$\%\&'\\\''\(\)\*\+\,\-\.\/\0\1\2\3\4\5\6\7\8' \
8838 '\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T' \
8839 '\U\V\W\X\Y\Z\[\\\]\^\_\`\a\b \d\e\f\g\h\i\j\k\l\m\n\o\p' \
8840 '\q\r\s\t\u\v\w\x\y\z\{\|\}\~' '\u20acd' '\U20acd' '\x123' \
8841 '\0x' '\0123' '\01234' | {
8842 # integer-base-one-3As
8843 typeset -Uui16 -Z11 pos=0
8844 typeset -Uui16 -Z5 hv=2147483647
8848 while IFS= read -r line; do
8850 while [[ -n $line ]]; do
8852 if (( (pos & 15) == 0 )); then
8853 (( pos )) && print "$dasc|"
8854 print -n "${pos#16#} "
8857 print -n "${hv#16#} "
8858 if (( (hv < 32) || (hv > 126) )); then
8861 dasc=$dasc${line::1}
8863 (( (pos++ & 15) == 7 )) && print -n -- '- '
8867 while (( pos & 15 )); do
8869 (( (pos++ & 15) == 7 )) && print -n -- '- '
8871 (( hv == 2147483647 )) || print "$dasc|"
8874 00000000 5C 20 5C 21 5C 22 5C 23 - 5C 24 5C 25 5C 26 5C 27 |\ \!\"\#\$\%\&\'|
8875 00000010 5C 28 5C 29 5C 2A 5C 2B - 5C 2C 5C 2D 5C 2E 5C 2F |\(\)\*\+\,\-\.\/|
8876 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|
8877 00000030 20 5C 39 5C 3A 5C 3B 5C - 3C 5C 3D 5C 3E 5C 3F 5C | \9\:\;\<\=\>\?\|
8878 00000040 40 5C 41 5C 42 5C 43 5C - 44 1B 5C 46 5C 47 5C 48 |@\A\B\C\D.\F\G\H|
8879 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|
8880 00000060 5C 51 5C 52 5C 53 5C 54 - 20 5C 56 5C 57 5C 58 5C |\Q\R\S\T \V\W\X\|
8881 00000070 59 5C 5A 5C 5B 5C 5C 5D - 5C 5E 5C 5F 5C 60 07 08 |Y\Z\[\]\^\_\`..|
8882 00000080 20 20 5C 64 1B 0C 5C 67 - 5C 68 5C 69 5C 6A 5C 6B | \d..\g\h\i\j\k|
8883 00000090 5C 6C 5C 6D 0A 5C 6F 5C - 70 20 5C 71 0D 5C 73 09 |\l\m.\o\p \q.\s.|
8884 000000A0 0B 5C 77 5C 79 5C 7A 5C - 7B 5C 7C 5C 7D 5C 7E 20 |.\w\y\z\{\|\}\~ |
8885 000000B0 E2 82 AC 64 20 EF BF BD - 20 12 33 20 78 20 53 20 |...d ... .3 x S |
8886 000000C0 53 34 0A - |S4.|
8888 name: dollar-doublequoted-strings
8890 Check that a $ preceding "…" is ignored
8892 echo $"Localise me!"
8897 I do not take a $V for a V!
8902 I do not take a $V for a V!
8904 name: dollar-quoted-strings
8906 Check backslash expansion by $'…' strings
8908 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
8910 ./pfn $'\ \!\"\#\$\%\&\'\(\)\*\+\,\-\.\/ \1\2\3\4\5\6' \
8911 $'a\0b' $'a\01b' $'\7\8\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I' \
8912 $'\J\K\L\M\N\O\P\Q\R\S\T\U1\V\W\X\Y\Z\[\\\]\^\_\`\a\b\d\e' \
8913 $'\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u1\v\w\x1\y\z\{\|\}\~ $x' \
8914 $'\u20acd' $'\U20acd' $'\x123' $'fn\x0rd' $'\0234' $'\234' \
8915 $'\2345' $'\ca' $'\c!' $'\c?' $'\c€' $'a\
8917 # integer-base-one-3As
8918 typeset -Uui16 -Z11 pos=0
8919 typeset -Uui16 -Z5 hv=2147483647
8923 while IFS= read -r line; do
8925 while [[ -n $line ]]; do
8927 if (( (pos & 15) == 0 )); then
8928 (( pos )) && print "$dasc|"
8929 print -n "${pos#16#} "
8932 print -n "${hv#16#} "
8933 if (( (hv < 32) || (hv > 126) )); then
8936 dasc=$dasc${line::1}
8938 (( (pos++ & 15) == 7 )) && print -n -- '- '
8942 while (( pos & 15 )); do
8944 (( (pos++ & 15) == 7 )) && print -n -- '- '
8946 (( hv == 2147483647 )) || print "$dasc|"
8949 00000000 20 21 22 23 24 25 26 27 - 28 29 2A 2B 2C 2D 2E 2F | !"#$%&'()*+,-./|
8950 00000010 20 01 02 03 04 05 06 0A - 61 0A 61 01 62 0A 07 38 | .......a.a.b..8|
8951 00000020 39 3A 3B 3C 3D 3E 3F 40 - 41 42 43 44 1B 46 47 48 |9:;<=>?@ABCD.FGH|
8952 00000030 49 0A 4A 4B 4C 4D 4E 4F - 50 51 52 53 54 01 56 57 |I.JKLMNOPQRST.VW|
8953 00000040 58 59 5A 5B 5C 5D 5E 5F - 60 07 08 64 1B 0A 0C 67 |XYZ[\]^_`..d...g|
8954 00000050 68 69 6A 6B 6C 6D 0A 6F - 70 71 0D 73 09 01 0B 77 |hijklm.opq.s...w|
8955 00000060 01 79 7A 7B 7C 7D 7E 20 - 24 78 0A E2 82 AC 64 0A |.yz{|}~ $x....d.|
8956 00000070 EF BF BD 0A C4 A3 0A 66 - 6E 0A 13 34 0A 9C 0A 9C |.......fn..4....|
8957 00000080 35 0A 01 0A 01 0A 7F 0A - 02 82 AC 0A 61 0A 62 0A |5...........a.b.|
8959 name: dollar-quotes-in-heredocs-strings
8961 They are, however, not parsed in here documents, here strings
8962 (outside of string delimiters) or regular strings, but in
8963 parameter substitutions.
8966 dollar = strchr(s, '$'); /* ' */
8972 cat <<<"dollar = strchr(s, '$'); /* ' */"
8973 cat <<<'dollar = strchr(s, '\''$'\''); /* '\'' */'
8974 x="dollar = strchr(s, '$'); /* ' */"
8977 unset nl; print -r -- "x${nl:=$'\n'}y"
8983 # probably never reached for here strings?
8985 cat <<<"4 foo\\\"bar"
8987 # old scripts use this (e.g. ncurses)
8989 # make sure this works, outside of quotes
8992 dollar = strchr(s, '$'); /* ' */
8995 dollar = strchr(s, '$'); /* ' */
8996 dollar = strchr(s, '$'); /* ' */
8997 dollar = strchr(s, '$'); /* ' */
9009 name: dot-needs-argument
9011 check Debian #415167 solution: '.' without arguments should fail
9014 "$__progname" -c source
9015 expected-exit: e != 0
9016 expected-stderr-pattern:
9017 /\.: missing argument.*\n.*source: missing argument/
9019 name: alias-function-no-conflict
9021 make aliases not conflict with function definitions
9023 # POSIX function can be defined, but alias overrides it
9024 alias foo='echo bar'
9031 foo 2>/dev/null || echo rab
9032 # alias overrides ksh function
9033 alias korn='echo bar'
9039 # alias temporarily overrides POSIX function
9044 alias bla='echo bal'
9058 name: bash-function-parens
9060 ensure the keyword function is ignored when preceding
9061 POSIX style function declarations (bashism)
9064 echo '#!'"$__progname"
9066 echo ' echo "bar='\''$0'\'\"
9068 print -r -- "${2:-foo}"
9070 mk 'function foo' >f-korn
9072 mk 'function foo ()' >f-bash
9073 print '#!'"$__progname"'\nprint -r -- "${0%/f-argh}"' >f-argh
9076 x="korn: $(./f-korn)"; echo "${x/@("$u")/.}"
9077 x="dash: $(./f-dash)"; echo "${x/@("$u")/.}"
9078 x="bash: $(./f-bash)"; echo "${x/@("$u")/.}"
9081 dash: bar='./f-dash'
9082 bash: bar='./f-bash'
9084 name: integer-base-one-1
9086 check if the use of fake integer base 1 works
9089 typeset -Uui16 i0=1#ï i1=1#â
\82¬
9091 typeset -i1 o1a=0x263A
9092 typeset -Uui1 o0b=0x7E
9093 typeset -Uui1 o1b=0xFDD0
9094 integer px=0xCAFE 'p0=1# ' p1=1#… pl=1#f
9095 echo "in <$i0> <$i1>"
9096 echo "out <${o0a#1#}|${o0b#1#}> <${o1a#1#}|${o1b#1#}>"
9098 echo "pass <$px> <$p0> <$p1> <$pl> <${i0#1#}|${i1#1#}>"
9099 typeset -Uui16 tv1=1#~ tv2=1#
\7f tv3=1#
\80 tv4=1#
\81 tv5=1#À tv6=1#Á tv7=1#Â tv8=1#Â
\80
9100 echo "specX <${tv1#16#}> <${tv2#16#}> <${tv3#16#}> <${tv4#16#}> <${tv5#16#}> <${tv6#16#}> <${tv7#16#}> <${tv8#16#}>"
9101 typeset -i1 tv1 tv2 tv3 tv4 tv5 tv6 tv7 tv8
9102 echo "specW <${tv1#1#}> <${tv2#1#}> <${tv3#1#}> <${tv4#1#}> <${tv5#1#}> <${tv6#1#}> <${tv7#1#}> <${tv8#1#}>"
9103 typeset -i1 xs1=0xEF7F xs2=0xEF80 xs3=0xFDD0
9104 echo "specU <${xs1#1#}> <${xs2#1#}> <${xs3#1#}>"
9106 in <16#EFEF> <16#20AC>
9108 pass <16#cafe> <1# > <1#â
\80¦> <1#f> <ï|â
\82¬>
9109 specX <7E> <7F> <EF80> <EF81> <EFC0> <EFC1> <A0> <80>
9110 specW <~> <
\7f> <
\80> <
\81> <À> <Á> <Â > <Â
\80>
9111 specU <> <
\80> <ï·
\90>
9113 name: integer-base-one-2a
9115 check if the use of fake integer base 1 stops at correct characters
9120 expected-stderr-pattern:
9121 /1#foo: unexpected 'oo'/
9122 expected-exit: e != 0
9124 name: integer-base-one-2b
9126 check if the use of fake integer base 1 stops at correct characters
9131 expected-stderr-pattern:
9132 /1#À
\80: unexpected '
\80'/
9133 expected-exit: e != 0
9135 name: integer-base-one-2c1
9137 check if the use of fake integer base 1 stops at correct characters
9145 name: integer-base-one-2c2
9147 check if the use of fake integer base 1 stops at correct characters
9152 expected-stderr-pattern:
9153 /1#â
\80¦: unexpected '
\80'/
9154 expected-exit: e != 0
9156 name: integer-base-one-2d1
9158 check if the use of fake integer base 1 handles octets okay
9162 echo /$x/ # invalid utf-8
9166 name: integer-base-one-2d2
9168 check if the use of fake integer base 1 handles octets
9172 echo /$x/ # invalid 2-byte
9176 name: integer-base-one-2d3
9178 check if the use of fake integer base 1 handles octets
9182 echo /$x/ # invalid 2-byte
9186 name: integer-base-one-2d4
9188 check if the use of fake integer base 1 stops at invalid input
9191 typeset -i16 x=1#ï¿À
9192 echo /$x/ # invalid 3-byte
9193 expected-stderr-pattern:
9194 /1#ï¿À: unexpected '¿'/
9195 expected-exit: e != 0
9197 name: integer-base-one-2d5
9199 check if the use of fake integer base 1 stops at invalid input
9202 typeset -i16 x=1#À
\80
9203 echo /$x/ # non-minimalistic
9204 expected-stderr-pattern:
9205 /1#À
\80: unexpected '
\80'/
9206 expected-exit: e != 0
9208 name: integer-base-one-2d6
9210 check if the use of fake integer base 1 stops at invalid input
9213 typeset -i16 x=1#à
\80\80
9214 echo /$x/ # non-minimalistic
9215 expected-stderr-pattern:
9216 /1#à
\80\80: unexpected '
\80'/
9217 expected-exit: e != 0
9219 name: integer-base-one-3As
9221 some sample code for hexdumping
9222 not NUL safe; input lines must be NL terminated
9225 print 'Hello, World!\\\nこんにちは!'
9226 typeset -Uui16 i=0x100
9227 # change that to 0xFF once we can handle embedded
9228 # NUL characters in strings / here documents
9229 while (( i++ < 0x1FF )); do
9230 print -n "\x${i#16#1}"
9234 # integer-base-one-3As
9235 typeset -Uui16 -Z11 pos=0
9236 typeset -Uui16 -Z5 hv=2147483647
9240 while IFS= read -r line; do
9242 while [[ -n $line ]]; do
9244 if (( (pos & 15) == 0 )); then
9245 (( pos )) && print "$dasc|"
9246 print -n "${pos#16#} "
9249 print -n "${hv#16#} "
9250 if (( (hv < 32) || (hv > 126) )); then
9253 dasc=$dasc${line::1}
9255 (( (pos++ & 15) == 7 )) && print -n -- '- '
9259 while (( pos & 15 )); do
9261 (( (pos++ & 15) == 7 )) && print -n -- '- '
9263 (( hv == 2147483647 )) || print "$dasc|"
9266 00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..|
9267 00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................|
9268 00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................|
9269 00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................|
9270 00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.|
9271 00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>|
9272 00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN|
9273 00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^|
9274 00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn|
9275 00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~|
9276 000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................|
9277 000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................|
9278 000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................|
9279 000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................|
9280 000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................|
9281 000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................|
9282 00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................|
9283 00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................|
9284 00000120 FF 7A 0A - |.z.|
9286 name: integer-base-one-3Ws
9288 some sample code for hexdumping Unicode
9289 not NUL safe; input lines must be NL terminated
9293 print 'Hello, World!\\\nこんにちは!'
9294 typeset -Uui16 i=0x100
9295 # change that to 0xFF once we can handle embedded
9296 # NUL characters in strings / here documents
9297 while (( i++ < 0x1FF )); do
9298 print -n "\u${i#16#1}"
9301 print \\xff # invalid utf-8
9302 print \\xc2 # invalid 2-byte
9303 print \\xef\\xbf\\xc0 # invalid 3-byte
9304 print \\xc0\\x80 # non-minimalistic
9305 print \\xe0\\x80\\x80 # non-minimalistic
9306 print '�' # end of range
9307 print '\0z' # embedded NUL
9309 # integer-base-one-3Ws
9310 typeset -Uui16 -Z11 pos=0
9311 typeset -Uui16 -Z7 hv
9316 while IFS= read -r line; do
9319 while (( lpos < ${#line} )); do
9320 wc=1#${line:(lpos++):1}
9321 if (( (wc < 32) || \
9322 ((wc > 126) && (wc < 160)) )); then
9324 elif (( (wc & 0xFF80) == 0xEF80 )); then
9329 if (( (pos & 7) == 7 )); then
9332 elif (( (pos & 7) == 0 )); then
9333 (( pos )) && print "$dasc|"
9334 print -n "${pos#16#} "
9338 print -n "${hv#16#} "
9339 (( (pos++ & 7) == 3 )) && \
9344 while (( pos & 7 )); do
9346 (( (pos++ & 7) == 3 )) && print -n -- '- '
9348 (( hv == 2147483647 )) || print "$dasc|"
9351 00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W|
9352 00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.こ|
9353 00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |んにちは!...|
9354 00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........|
9355 00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........|
9356 00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........|
9357 00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"|
9358 00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*|
9359 00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012|
9360 00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:|
9361 00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB|
9362 00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ|
9363 00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR|
9364 00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ|
9365 00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab|
9366 00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij|
9367 00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr|
9368 00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz|
9369 00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....|
9370 00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........|
9371 000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........|
9372 000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........|
9373 000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |..... ¡¢|
9374 000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA |£¤¥¦§¨©ª|
9375 000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 |«¬®¯°±²|
9376 000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA |³´µ¶·¸¹º|
9377 000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 |»¼½¾¿ÀÁÂ|
9378 000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA |ÃÄÅÆÇÈÉÊ|
9379 000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 |ËÌÍÎÏÐÑÒ|
9380 000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA |ÓÔÕÖ×ØÙÚ|
9381 000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 |ÛÜÝÞßàáâ|
9382 000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA |ãäåæçèéê|
9383 00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 |ëìíîïðñò|
9384 00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA |óôõö÷øùú|
9385 00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |ûüýþÿ.�.|
9386 00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |�.���.��|
9387 00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |.���.���|
9388 00000128 EFBE EFEF EFBF EFBF - 000A 007A 000A |����.z.|
9390 name: integer-base-one-3Ar
9392 some sample code for hexdumping; NUL and binary safe
9395 print 'Hello, World!\\\nこんにちは!'
9396 typeset -Uui16 i=0x100
9397 # change that to 0xFF once we can handle embedded
9398 # NUL characters in strings / here documents
9399 while (( i++ < 0x1FF )); do
9400 print -n "\x${i#16#1}"
9404 # integer-base-one-3Ar
9405 typeset -Uui16 -Z11 pos=0
9406 typeset -Uui16 -Z5 hv=2147483647
9408 if read -arN -1 line; then
9411 while (( i < ${#line[*]} )); do
9413 if (( (pos & 15) == 0 )); then
9414 (( pos )) && print "$dasc|"
9415 print -n "${pos#16#} "
9418 print -n "${hv#16#} "
9419 if (( (hv < 32) || (hv > 126) )); then
9422 dasc=$dasc${line[i-1]#1#}
9424 (( (pos++ & 15) == 7 )) && print -n -- '- '
9427 while (( pos & 15 )); do
9429 (( (pos++ & 15) == 7 )) && print -n -- '- '
9431 (( hv == 2147483647 )) || print "$dasc|"
9434 00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..|
9435 00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................|
9436 00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................|
9437 00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................|
9438 00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.|
9439 00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>|
9440 00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN|
9441 00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^|
9442 00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn|
9443 00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~|
9444 000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................|
9445 000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................|
9446 000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................|
9447 000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................|
9448 000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................|
9449 000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................|
9450 00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................|
9451 00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................|
9452 00000120 FF 00 7A 0A - |..z.|
9454 name: integer-base-one-3Wr
9456 some sample code for hexdumping Unicode; NUL and binary safe
9460 print 'Hello, World!\\\nこんにちは!'
9461 typeset -Uui16 i=0x100
9462 # change that to 0xFF once we can handle embedded
9463 # NUL characters in strings / here documents
9464 while (( i++ < 0x1FF )); do
9465 print -n "\u${i#16#1}"
9468 print \\xff # invalid utf-8
9469 print \\xc2 # invalid 2-byte
9470 print \\xef\\xbf\\xc0 # invalid 3-byte
9471 print \\xc0\\x80 # non-minimalistic
9472 print \\xe0\\x80\\x80 # non-minimalistic
9473 print '�' # end of range
9474 print '\0z' # embedded NUL
9476 # integer-base-one-3Wr
9477 typeset -Uui16 -Z11 pos=0
9478 typeset -Uui16 -Z7 hv=2147483647
9480 if read -arN -1 line; then
9483 while (( i < ${#line[*]} )); do
9485 if (( (hv < 32) || \
9486 ((hv > 126) && (hv < 160)) )); then
9488 elif (( (hv & 0xFF80) == 0xEF80 )); then
9493 if (( (pos & 7) == 7 )); then
9496 elif (( (pos & 7) == 0 )); then
9497 (( pos )) && print "$dasc|"
9498 print -n "${pos#16#} "
9501 print -n "${hv#16#} "
9502 (( (pos++ & 7) == 3 )) && \
9507 while (( pos & 7 )); do
9509 (( (pos++ & 7) == 3 )) && print -n -- '- '
9511 (( hv == 2147483647 )) || print "$dasc|"
9514 00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W|
9515 00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.こ|
9516 00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |んにちは!...|
9517 00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........|
9518 00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........|
9519 00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........|
9520 00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"|
9521 00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*|
9522 00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012|
9523 00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:|
9524 00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB|
9525 00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ|
9526 00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR|
9527 00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ|
9528 00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab|
9529 00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij|
9530 00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr|
9531 00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz|
9532 00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....|
9533 00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........|
9534 000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........|
9535 000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........|
9536 000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |..... ¡¢|
9537 000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA |£¤¥¦§¨©ª|
9538 000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 |«¬®¯°±²|
9539 000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA |³´µ¶·¸¹º|
9540 000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 |»¼½¾¿ÀÁÂ|
9541 000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA |ÃÄÅÆÇÈÉÊ|
9542 000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 |ËÌÍÎÏÐÑÒ|
9543 000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA |ÓÔÕÖ×ØÙÚ|
9544 000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 |ÛÜÝÞßàáâ|
9545 000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA |ãäåæçèéê|
9546 00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 |ëìíîïðñò|
9547 00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA |óôõö÷øùú|
9548 00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |ûüýþÿ.�.|
9549 00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |�.���.��|
9550 00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |.���.���|
9551 00000128 EFBE EFEF EFBF EFBF - 000A 0000 007A 000A |����..z.|
9553 name: integer-base-one-4
9555 Check if ksh93-style base-one integers work
9560 (echo 2f $(('aa'))) 2>&1 | sed "s/^[^']*'/2p '/"
9568 2p 'aa': multi-character character constant
9574 name: integer-base-one-5A
9576 Check to see that we’re NUL and Unicode safe
9579 print 'a\0b\xfdz' >x
9585 16#61 16#0 16#62 16#FD 16#7A .
9587 name: integer-base-one-5W
9589 Check to see that we’re NUL and Unicode safe
9598 16#61 16#0 16#62 16#20AC 16#63 .
9602 Check if we can use a specific syntax idiom for ulimit
9603 category: !os:syllable
9605 if ! x=$(ulimit -d) || [[ $x = unknown ]]; then
9606 #echo expected to fail on this OS
9609 ulimit -dS $x && echo okay
9616 Check some of the most basic invariants of I/O redirection
9621 print -u2 e$((i++)).
9646 Check if GNU bash-like I/O redirection works
9647 Part 1: this is also supported by GNU bash
9648 category: shell:legacy-no
9667 Check if GNU bash-like I/O redirection works
9668 Part 2: this is *not* supported by GNU bash
9669 category: shell:legacy-no
9688 Check if GNU bash-like I/O redirection works
9689 Part 2: this is *not* supported by GNU bash
9690 category: shell:legacy-no
9709 Check if GNU bash-like I/O redirection works
9710 Part 2: this is supported by GNU bash 4 only
9711 category: shell:legacy-no
9733 Check if GNU bash-like I/O redirection fails correctly
9734 Part 1: this is also supported by GNU bash
9735 category: shell:legacy-no
9751 expected-stderr-pattern: /.*: can't (create|overwrite) .*/
9755 Check if GNU bash-like I/O redirection fails correctly
9756 Part 2: this is *not* supported by GNU bash
9757 category: shell:legacy-no
9778 Check if GNU bash-like I/O redirection works
9779 Part 4: this is also supported by GNU bash,
9780 but failed in some mksh versions
9781 category: shell:legacy-no
9790 [[ -e bar ]] && threeout "$bf" &>foo
9803 name: bashiop-5-normal
9805 Check if GNU bash-like I/O redirection is only supported
9806 in !POSIX !sh mode as it breaks existing scripts' syntax
9807 category: shell:legacy-no
9809 :>x; echo 1 "$("$__progname" -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9810 :>x; echo 2 "$("$__progname" -o posix -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9811 :>x; echo 3 "$("$__progname" -o sh -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9817 name: bashiop-5-legacy
9819 Check if GNU bash-like I/O redirection is not parsed
9820 in lksh as it breaks existing scripts' syntax
9821 category: shell:legacy-yes
9823 :>x; echo 1 "$("$__progname" -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9824 :>x; echo 2 "$("$__progname" -o posix -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9825 :>x; echo 3 "$("$__progname" -o sh -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9833 Check for support of more than 9 file descriptors
9836 read -u10 foo 10<<< bar
9843 Check for support of more than 9 file descriptors
9859 for n in ${a#*=}; do echo 1hu ${n} .; done
9860 for n in "${a#*=}"; do echo 1hq ${n} .; done
9861 for n in ${a##*=}; do echo 2hu ${n} .; done
9862 for n in "${a##*=}"; do echo 2hq ${n} .; done
9863 for n in ${a%=*}; do echo 1pu ${n} .; done
9864 for n in "${a%=*}"; do echo 1pq ${n} .; done
9865 for n in ${a%%=*}; do echo 2pu ${n} .; done
9866 for n in "${a%%=*}"; do echo 2pq ${n} .; done
9873 name: oksh-and-list-error-1
9875 Test exit status of rightmost element in 2 element && list in -e mode
9878 echo "should not print"
9880 expected-exit: e != 0
9882 name: oksh-and-list-error-2
9884 Test exit status of rightmost element in 3 element && list in -e mode
9886 true && true && false
9887 echo "should not print"
9889 expected-exit: e != 0
9891 name: oksh-or-list-error-1
9893 Test exit status of || list in -e mode
9896 echo "should not print"
9898 expected-exit: e != 0
9900 name: oksh-longline-crash
9902 This used to cause a core dump
9905 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"
9906 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"
9907 for deplib in $deplibs; do
9910 new_libs="$deplib $new_libs"
9913 case " $specialdeplibs " in
9915 new_libs="$deplib $new_libs";;
9921 name: oksh-seterror-1
9923 The -e flag should be ignored when executing a compound list
9924 followed by an if statement.
9926 if true; then false && false; fi
9929 expected-exit: e == 0
9931 name: oksh-seterror-2
9933 The -e flag should be ignored when executing a compound list
9934 followed by an if statement.
9936 if true; then if true; then false && false; fi; fi
9939 expected-exit: e == 0
9941 name: oksh-seterror-3
9943 The -e flag should be ignored when executing a compound list
9944 followed by an elif statement.
9946 if true; then :; elif true; then false && false; fi
9948 expected-exit: e == 0
9950 name: oksh-seterror-4
9952 The -e flag should be ignored when executing a pipeline
9961 expected-exit: e == 0
9963 name: oksh-seterror-5
9965 The -e flag should be ignored when executing a pipeline
9971 expected-exit: e == 0
9973 name: oksh-seterror-6
9975 When trapping ERR and EXIT, both traps should run in -e mode
9976 when an error occurs.
9978 trap 'echo EXIT' EXIT
9985 expected-exit: e != 0
9990 name: oksh-seterror-7
9992 The -e flag within a command substitution should be honored
9994 echo $( set -e; false; echo foo )
9999 name: oksh-input-comsub
10001 A command substitution using input redirection should exit with
10002 failure if the input file does not exist.
10004 var=$(< non-existent)
10005 expected-exit: e != 0
10006 expected-stderr-pattern: /non-existent/
10008 name: oksh-empty-for-list
10010 A for list which expands to zero items should not execute the body.
10012 set foo bar baz ; for out in ; do echo $out ; done
10014 name: oksh-varfunction-mod1
10016 (Inspired by PR 2450 on OpenBSD.) Calling
10018 where f is a ksh style function, should not set FOO in the current
10019 env. If f is a Bourne style function, FOO should be set. Furthermore,
10020 the function should receive a correct value of FOO. However, differing
10021 from oksh, setting FOO in the function itself must change the value in
10022 setting FOO in the function itself should not change the value in
10023 global environment.
10025 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
10026 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
10027 done >env; chmod +x env; PATH=.$PATHSEP$PATH
10029 if [ x$FOO != xbar ]; then
10033 x=$(env | grep FOO)
10034 if [ "x$x" != "xFOO=bar" ]; then
10042 if [ x$FOO != xbar ]; then
10046 x=$(env | grep FOO)
10047 if [ "x$x" != "xFOO=bar" ]; then
10055 if [ $? != 0 ]; then
10058 if [ x$FOO != x ]; then
10062 if [ $? != 0 ]; then
10065 if [ x$FOO != xfoo ]; then
10070 if [ $? != 0 ]; then
10073 if [ x$FOO != xbarbar ]; then
10077 if [ $? != 0 ]; then
10080 if [ x$FOO != xfoo ]; then
10086 Verify that file descriptors > 2 are private for Korn shells
10087 AT&T ksh93 does this still, which means we must keep it as well
10088 category: shell:legacy-no
10092 open(my \$fh, ">&", 9) or die "E: open \$!";
10093 syswrite(\$fh, "Fowl\\n", 5) or die "E: write \$!";
10098 expected-exit: e != 0
10099 expected-stderr-pattern:
10104 Verify that file descriptors > 2 are not private for POSIX shells
10105 See Debian Bug #154540, Closes: #499139
10109 open(my \$fh, ">&", 9) or die "E: open \$!";
10110 syswrite(\$fh, "Fowl\\n", 5) or die "E: write \$!";
10113 test -n "$POSH_VERSION" || set -o posix
10121 Verify that file descriptors > 2 are not private for LEGACY KSH
10122 category: shell:legacy-yes
10126 open(my \$fh, ">&", 9) or die "E: open \$!";
10127 syswrite(\$fh, "Fowl\\n", 5) or die "E: write \$!";
10137 COMSUB are now parsed recursively, so this works
10138 see also regression-6: matching parenthesēs bug
10139 Fails on: pdksh bash2 bash3 zsh
10140 Passes on: bash4 ksh93 mksh(20110313+)
10142 echo 1 $(case 1 in (1) echo yes;; (2) echo no;; esac) .
10143 echo 2 $(case 1 in 1) echo yes;; 2) echo no;; esac) .
10144 TEST=1234; echo 3 ${TEST: $(case 1 in (1) echo 1;; (*) echo 2;; esac)} .
10145 TEST=5678; echo 4 ${TEST: $(case 1 in 1) echo 1;; *) echo 2;; esac)} .
10146 a=($(case 1 in (1) echo 1;; (*) echo 2;; esac)); echo 5 ${a[0]} .
10147 a=($(case 1 in 1) echo 1;; *) echo 2;; esac)); echo 6 ${a[0]} .
10158 COMSUB are now parsed recursively, so this works
10159 Fails on: pdksh bash2 bash3 bash4 zsh
10160 Passes on: ksh93 mksh(20110313+)
10162 echo 1 $(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10)) .
10163 echo 2 $(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20)) .
10164 (( a = $(case 1 in (1) echo 1;; (*) echo 2;; esac) )); echo 3 $a .
10165 (( a = $(case 1 in 1) echo 1;; *) echo 2;; esac) )); echo 4 $a .
10166 a=($(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10))); echo 5 ${a[0]} .
10167 a=($(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20))); echo 6 ${a[0]} .
10178 RedHat BZ#496791 – another case of missing recursion
10179 in parsing COMSUB expressions
10180 Fails on: pdksh bash2 bash3¹ bash4¹ zsh
10181 Passes on: ksh93 mksh(20110305+)
10182 ① bash[34] seem to choke on comment ending with backslash-newline
10184 # a comment with " ' \
10187 # a comment with " ' \
10195 Extended test for COMSUB explaining why a recursive parser
10196 is a must (a non-recursive parser cannot pass all three of
10197 these test cases, especially the ‘#’ is difficult)
10199 print '#!'"$__progname"'\necho 1234' >id; chmod +x id; PATH=.$PATHSEP$PATH
10200 echo $(typeset -i10 x=16#20; echo $x)
10201 echo $(typeset -Uui16 x=16#$(id -u)
10204 typeset -Uui16 a=36#foo; c=2
10205 typeset -Uui16 b=36 #foo; d=2
10214 Check the tree dump functions for !MKSH_SMALL functionality
10217 x() { case $1 in u) echo x ;;& *) echo $1 ;; esac; }
10233 Check COMSUB works with aliases (does not expand them twice)
10235 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
10237 alias echo='echo a'
10239 ./pfn "$(echo foo)"
10246 ./pfn "$(echo foo )"
10249 name: comsub-torture
10251 Check the tree dump functions work correctly
10253 if [[ -z $__progname ]]; then echo >&2 call me with __progname; exit 1; fi
10254 while IFS= read -r line; do
10255 if [[ $line = '#1' ]]; then
10258 elif [[ $line = EOFN* ]]; then
10259 fbody=$fbody$'\n'$line
10261 elif [[ $line != '#'* ]]; then
10262 fbody=$fbody$'\n\t'$line
10265 if (( lastf )); then
10266 x="inline_${nextf}() {"$fbody$'\n}\n'
10268 print -r -- "${x}typeset -f inline_$nextf" | "$__progname"
10269 x="function comsub_$nextf { x=\$("$fbody$'\n); }\n'
10271 print -r -- "${x}typeset -f comsub_$nextf" | "$__progname"
10272 x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n'
10274 print -r -- "${x}typeset -f reread_$nextf" | "$__progname"
10282 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
10283 #TPAREN_TPIPE_TLIST
10284 (echo $foo | tr -dc 0-9; echo)
10286 cmd && echo ja || echo nein
10288 select file in *; do echo "<$file>" ; break ; done
10290 time for i in {1,2,3} ; do echo $i ; done
10292 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
10293 #TIF_TBANG_TDBRACKET_TELIF
10294 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
10296 i=1; while (( i < 10 )); do echo $i; let ++i; done
10298 i=10; until (( !--i )) ; do echo $i; done
10301 #TFUNCT_TBRACE_TASYNC
10302 function korn { echo eins; echo zwei ; }
10303 bourne () { logger * & }
10306 #IOWRITE_IOCLOB_IOHERE_noIOSKIP
10310 #IOWRITE_noIOCLOB_IOHERE_IOSKIP
10315 sh 1<>/dev/console 0<&1 2>&1
10316 #COMSUB_EXPRSUB_FUNSUB_VALSUB
10317 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
10318 #QCHAR_OQUOTE_CQUOTE
10319 echo fo\ob\"a\`r\'b\$az
10320 echo "fo\ob\"a\`r\'b\$az"
10321 echo 'fo\ob\"a\`r'\''b\$az'
10322 #OSUBST_CSUBST_OPAT_SPAT_CPAT
10323 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
10326 note there must be no space between EOFN and )
10330 note the space between EOFN and ) is actually part of the here document marker
10333 x=$(sysctl -n kern.version | sed 1q)
10334 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
10335 ed -s /etc/motd 2>&1 <<-EOF
10342 EOF)" = @(?) ]] && rm -f /etc/motd
10343 if [[ ! -s /etc/motd ]]; then
10344 install -c -o root -g wheel -m 664 /dev/null /etc/motd
10345 print -- "$x\n" >/etc/motd
10355 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
10358 vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4"
10360 function comsub_TCOM { x=$(
10361 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
10363 function comsub_TCOM {
10364 x=$(vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" )
10366 function reread_TCOM { x=$((
10367 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
10369 function reread_TCOM {
10370 x=$(( vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" ) | tr u x )
10372 inline_TPAREN_TPIPE_TLIST() {
10373 (echo $foo | tr -dc 0-9; echo)
10375 inline_TPAREN_TPIPE_TLIST() {
10376 ( echo $foo | tr -dc 0-9
10379 function comsub_TPAREN_TPIPE_TLIST { x=$(
10380 (echo $foo | tr -dc 0-9; echo)
10382 function comsub_TPAREN_TPIPE_TLIST {
10383 x=$(( echo $foo | tr -dc 0-9 ; echo ) )
10385 function reread_TPAREN_TPIPE_TLIST { x=$((
10386 (echo $foo | tr -dc 0-9; echo)
10388 function reread_TPAREN_TPIPE_TLIST {
10389 x=$(( ( echo $foo | tr -dc 0-9 ; echo ) ) | tr u x )
10391 inline_TAND_TOR() {
10392 cmd && echo ja || echo nein
10394 inline_TAND_TOR() {
10395 cmd && echo ja || echo nein
10397 function comsub_TAND_TOR { x=$(
10398 cmd && echo ja || echo nein
10400 function comsub_TAND_TOR {
10401 x=$(cmd && echo ja || echo nein )
10403 function reread_TAND_TOR { x=$((
10404 cmd && echo ja || echo nein
10406 function reread_TAND_TOR {
10407 x=$(( cmd && echo ja || echo nein ) | tr u x )
10410 select file in *; do echo "<$file>" ; break ; done
10419 function comsub_TSELECT { x=$(
10420 select file in *; do echo "<$file>" ; break ; done
10422 function comsub_TSELECT {
10423 x=$(select file in * ; do echo "<$file>" ; break ; done )
10425 function reread_TSELECT { x=$((
10426 select file in *; do echo "<$file>" ; break ; done
10428 function reread_TSELECT {
10429 x=$(( select file in * ; do echo "<$file>" ; break ; done ) | tr u x )
10431 inline_TFOR_TTIME() {
10432 time for i in {1,2,3} ; do echo $i ; done
10434 inline_TFOR_TTIME() {
10435 time for i in {1,2,3}
10440 function comsub_TFOR_TTIME { x=$(
10441 time for i in {1,2,3} ; do echo $i ; done
10443 function comsub_TFOR_TTIME {
10444 x=$(time for i in {1,2,3} ; do echo $i ; done )
10446 function reread_TFOR_TTIME { x=$((
10447 time for i in {1,2,3} ; do echo $i ; done
10449 function reread_TFOR_TTIME {
10450 x=$(( time for i in {1,2,3} ; do echo $i ; done ) | tr u x )
10453 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
10464 echo kann net bis drei zählen
10468 function comsub_TCASE { x=$(
10469 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
10471 function comsub_TCASE {
10472 x=$(case $foo in (1) echo eins ;& (2) echo zwei ;| (*) echo kann net bis drei zählen ;; esac )
10474 function reread_TCASE { x=$((
10475 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
10477 function reread_TCASE {
10478 x=$(( case $foo in (1) echo eins ;& (2) echo zwei ;| (*) echo kann net bis drei zählen ;; esac ) | tr u x )
10480 inline_TIF_TBANG_TDBRACKET_TELIF() {
10481 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
10483 inline_TIF_TBANG_TDBRACKET_TELIF() {
10494 function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$(
10495 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
10497 function comsub_TIF_TBANG_TDBRACKET_TELIF {
10498 x=$(if ! [[ 1 = 1 ]] ; then echo eins ; elif [[ 1 = 2 ]] ; then echo zwei ; else echo drei ; fi )
10500 function reread_TIF_TBANG_TDBRACKET_TELIF { x=$((
10501 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
10503 function reread_TIF_TBANG_TDBRACKET_TELIF {
10504 x=$(( if ! [[ 1 = 1 ]] ; then echo eins ; elif [[ 1 = 2 ]] ; then echo zwei ; else echo drei ; fi ) | tr u x )
10507 i=1; while (( i < 10 )); do echo $i; let ++i; done
10519 function comsub_TWHILE { x=$(
10520 i=1; while (( i < 10 )); do echo $i; let ++i; done
10522 function comsub_TWHILE {
10523 x=$(i=1 ; while { \let] " i < 10 " ; } ; do echo $i ; let ++i ; done )
10525 function reread_TWHILE { x=$((
10526 i=1; while (( i < 10 )); do echo $i; let ++i; done
10528 function reread_TWHILE {
10529 x=$(( i=1 ; while { \let] " i < 10 " ; } ; do echo $i ; let ++i ; done ) | tr u x )
10532 i=10; until (( !--i )) ; do echo $i; done
10543 function comsub_TUNTIL { x=$(
10544 i=10; until (( !--i )) ; do echo $i; done
10546 function comsub_TUNTIL {
10547 x=$(i=10 ; until { \let] " !--i " ; } ; do echo $i ; done )
10549 function reread_TUNTIL { x=$((
10550 i=10; until (( !--i )) ; do echo $i; done
10552 function reread_TUNTIL {
10553 x=$(( i=10 ; until { \let] " !--i " ; } ; do echo $i ; done ) | tr u x )
10562 function comsub_TCOPROC { x=$(
10565 function comsub_TCOPROC {
10568 function reread_TCOPROC { x=$((
10571 function reread_TCOPROC {
10572 x=$(( cat * |& ls ) | tr u x )
10574 inline_TFUNCT_TBRACE_TASYNC() {
10575 function korn { echo eins; echo zwei ; }
10576 bourne () { logger * & }
10578 inline_TFUNCT_TBRACE_TASYNC() {
10587 function comsub_TFUNCT_TBRACE_TASYNC { x=$(
10588 function korn { echo eins; echo zwei ; }
10589 bourne () { logger * & }
10591 function comsub_TFUNCT_TBRACE_TASYNC {
10592 x=$(function korn { echo eins ; echo zwei ; } ; bourne() { logger * & } )
10594 function reread_TFUNCT_TBRACE_TASYNC { x=$((
10595 function korn { echo eins; echo zwei ; }
10596 bourne () { logger * & }
10598 function reread_TFUNCT_TBRACE_TASYNC {
10599 x=$(( function korn { echo eins ; echo zwei ; } ; bourne() { logger * & } ) | tr u x )
10601 inline_IOREAD_IOCAT() {
10604 inline_IOREAD_IOCAT() {
10607 function comsub_IOREAD_IOCAT { x=$(
10610 function comsub_IOREAD_IOCAT {
10611 x=$(tr x u <foo >>bar )
10613 function reread_IOREAD_IOCAT { x=$((
10616 function reread_IOREAD_IOCAT {
10617 x=$(( tr x u <foo >>bar ) | tr u x )
10619 inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
10624 inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
10630 function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$(
10635 function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
10636 x=$(cat >|bar <<"EOFN"
10641 function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$((
10646 function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
10647 x=$(( cat >|bar <<"EOFN"
10652 inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
10657 inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
10663 function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$(
10668 function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
10669 x=$(cat >bar <<-EOFI
10674 function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$((
10679 function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
10680 x=$(( cat >bar <<-EOFI
10685 inline_IORDWR_IODUP() {
10686 sh 1<>/dev/console 0<&1 2>&1
10688 inline_IORDWR_IODUP() {
10689 sh 1<>/dev/console <&1 2>&1
10691 function comsub_IORDWR_IODUP { x=$(
10692 sh 1<>/dev/console 0<&1 2>&1
10694 function comsub_IORDWR_IODUP {
10695 x=$(sh 1<>/dev/console <&1 2>&1 )
10697 function reread_IORDWR_IODUP { x=$((
10698 sh 1<>/dev/console 0<&1 2>&1
10700 function reread_IORDWR_IODUP {
10701 x=$(( sh 1<>/dev/console <&1 2>&1 ) | tr u x )
10703 inline_COMSUB_EXPRSUB_FUNSUB_VALSUB() {
10704 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
10706 inline_COMSUB_EXPRSUB_FUNSUB_VALSUB() {
10707 echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;}
10709 function comsub_COMSUB_EXPRSUB_FUNSUB_VALSUB { x=$(
10710 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
10712 function comsub_COMSUB_EXPRSUB_FUNSUB_VALSUB {
10713 x=$(echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;} )
10715 function reread_COMSUB_EXPRSUB_FUNSUB_VALSUB { x=$((
10716 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
10718 function reread_COMSUB_EXPRSUB_FUNSUB_VALSUB {
10719 x=$(( echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;} ) | tr u x )
10721 inline_QCHAR_OQUOTE_CQUOTE() {
10722 echo fo\ob\"a\`r\'b\$az
10723 echo "fo\ob\"a\`r\'b\$az"
10724 echo 'fo\ob\"a\`r'\''b\$az'
10726 inline_QCHAR_OQUOTE_CQUOTE() {
10727 echo fo\ob\"a\`r\'b\$az
10728 echo "fo\ob\"a\`r\'b\$az"
10729 echo "fo\\ob\\\"a\\\`r"\'"b\\\$az"
10731 function comsub_QCHAR_OQUOTE_CQUOTE { x=$(
10732 echo fo\ob\"a\`r\'b\$az
10733 echo "fo\ob\"a\`r\'b\$az"
10734 echo 'fo\ob\"a\`r'\''b\$az'
10736 function comsub_QCHAR_OQUOTE_CQUOTE {
10737 x=$(echo fo\ob\"a\`r\'b\$az ; echo "fo\ob\"a\`r\'b\$az" ; echo "fo\\ob\\\"a\\\`r"\'"b\\\$az" )
10739 function reread_QCHAR_OQUOTE_CQUOTE { x=$((
10740 echo fo\ob\"a\`r\'b\$az
10741 echo "fo\ob\"a\`r\'b\$az"
10742 echo 'fo\ob\"a\`r'\''b\$az'
10744 function reread_QCHAR_OQUOTE_CQUOTE {
10745 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 )
10747 inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() {
10748 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
10750 inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() {
10751 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
10753 function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$(
10754 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
10756 function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT {
10757 x=$([[ ${foo#bl\(u\)b} = @(bar|baz) ]] )
10759 function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$((
10760 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
10762 function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT {
10763 x=$(( [[ ${foo#bl\(u\)b} = @(bar|baz) ]] ) | tr u x )
10765 inline_heredoc_closed() {
10767 note there must be no space between EOFN and )
10770 inline_heredoc_closed() {
10772 note there must be no space between EOFN and )
10777 function comsub_heredoc_closed { x=$(
10779 note there must be no space between EOFN and )
10782 function comsub_heredoc_closed {
10784 note there must be no space between EOFN and )
10788 function reread_heredoc_closed { x=$((
10790 note there must be no space between EOFN and )
10793 function reread_heredoc_closed {
10794 x=$(( x=$(cat <<EOFN
10795 note there must be no space between EOFN and )
10797 ) ; echo $x ) | tr u x )
10799 inline_heredoc_space() {
10801 note the space between EOFN and ) is actually part of the here document marker
10804 inline_heredoc_space() {
10806 note the space between EOFN and ) is actually part of the here document marker
10811 function comsub_heredoc_space { x=$(
10813 note the space between EOFN and ) is actually part of the here document marker
10816 function comsub_heredoc_space {
10817 x=$(x=$(cat <<EOFN\
10818 note the space between EOFN and ) is actually part of the here document marker
10822 function reread_heredoc_space { x=$((
10824 note the space between EOFN and ) is actually part of the here document marker
10827 function reread_heredoc_space {
10828 x=$(( x=$(cat <<EOFN\
10829 note the space between EOFN and ) is actually part of the here document marker
10831 ) ; echo $x ) | tr u x )
10833 inline_patch_motd() {
10834 x=$(sysctl -n kern.version | sed 1q)
10835 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
10836 ed -s /etc/motd 2>&1 <<-EOF
10843 EOF)" = @(?) ]] && rm -f /etc/motd
10844 if [[ ! -s /etc/motd ]]; then
10845 install -c -o root -g wheel -m 664 /dev/null /etc/motd
10846 print -- "$x\n" >/etc/motd
10849 inline_patch_motd() {
10850 x=$(sysctl -n kern.version | sed 1q )
10851 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
10859 )" = @(?) ]] && rm -f /etc/motd
10860 if [[ ! -s /etc/motd ]]
10862 install -c -o root -g wheel -m 664 /dev/null /etc/motd
10863 print -- "$x\n" >/etc/motd
10866 function comsub_patch_motd { x=$(
10867 x=$(sysctl -n kern.version | sed 1q)
10868 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
10869 ed -s /etc/motd 2>&1 <<-EOF
10876 EOF)" = @(?) ]] && rm -f /etc/motd
10877 if [[ ! -s /etc/motd ]]; then
10878 install -c -o root -g wheel -m 664 /dev/null /etc/motd
10879 print -- "$x\n" >/etc/motd
10882 function comsub_patch_motd {
10883 x=$(x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
10891 )" = @(?) ]] && 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 )
10893 function reread_patch_motd { x=$((
10894 x=$(sysctl -n kern.version | sed 1q)
10895 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
10896 ed -s /etc/motd 2>&1 <<-EOF
10903 EOF)" = @(?) ]] && rm -f /etc/motd
10904 if [[ ! -s /etc/motd ]]; then
10905 install -c -o root -g wheel -m 664 /dev/null /etc/motd
10906 print -- "$x\n" >/etc/motd
10909 function reread_patch_motd {
10910 x=$(( x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
10918 )" = @(?) ]] && 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 )
10920 inline_wdarrassign() {
10925 inline_wdarrassign() {
10933 function comsub_wdarrassign { x=$(
10938 function comsub_wdarrassign {
10939 x=$(case x in (x) a+=b ; \set -A c+ -- d e ;; esac )
10941 function reread_wdarrassign { x=$((
10946 function reread_wdarrassign {
10947 x=$(( case x in (x) a+=b ; \set -A c+ -- d e ;; esac ) | tr u x )
10950 name: comsub-torture-io
10952 Check the tree dump functions work correctly with I/O redirection
10954 if [[ -z $__progname ]]; then echo >&2 call me with __progname; exit 1; fi
10955 while IFS= read -r line; do
10956 if [[ $line = '#1' ]]; then
10959 elif [[ $line = EOFN* ]]; then
10960 fbody=$fbody$'\n'$line
10962 elif [[ $line != '#'* ]]; then
10963 fbody=$fbody$'\n\t'$line
10966 if (( lastf )); then
10967 x="inline_${nextf}() {"$fbody$'\n}\n'
10969 print -r -- "${x}typeset -f inline_$nextf" | "$__progname"
10970 x="function comsub_$nextf { x=\$("$fbody$'\n); }\n'
10972 print -r -- "${x}typeset -f comsub_$nextf" | "$__progname"
10973 x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n'
10975 print -r -- "${x}typeset -f reread_$nextf" | "$__progname"
10983 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
10984 #TPAREN_TPIPE_TLIST
10985 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
10987 cmd >&3 && >&3 echo ja || echo >&3 nein
10989 select file in *; do echo "<$file>" ; break >&3 ; done >&3
10991 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
10993 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
10994 #TIF_TBANG_TDBRACKET_TELIF
10995 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
10997 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
10999 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
11001 cat * >&3 |& >&3 ls
11002 #TFUNCT_TBRACE_TASYNC
11003 function korn { echo eins; echo >&3 zwei ; }
11004 bourne () { logger * >&3 & }
11006 echo $(true >&3) $((1+ 2))
11011 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
11014 vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" >&3
11016 function comsub_TCOM { x=$(
11017 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
11019 function comsub_TCOM {
11020 x=$(vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" >&3 )
11022 function reread_TCOM { x=$((
11023 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
11025 function reread_TCOM {
11026 x=$(( vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" >&3 ) | tr u x )
11028 inline_TPAREN_TPIPE_TLIST() {
11029 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
11031 inline_TPAREN_TPIPE_TLIST() {
11032 ( echo $foo | tr -dc 0-9 >&3
11035 function comsub_TPAREN_TPIPE_TLIST { x=$(
11036 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
11038 function comsub_TPAREN_TPIPE_TLIST {
11039 x=$(( echo $foo | tr -dc 0-9 >&3 ; echo >&3 ) >&3 )
11041 function reread_TPAREN_TPIPE_TLIST { x=$((
11042 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
11044 function reread_TPAREN_TPIPE_TLIST {
11045 x=$(( ( echo $foo | tr -dc 0-9 >&3 ; echo >&3 ) >&3 ) | tr u x )
11047 inline_TAND_TOR() {
11048 cmd >&3 && >&3 echo ja || echo >&3 nein
11050 inline_TAND_TOR() {
11051 cmd >&3 && echo ja >&3 || echo nein >&3
11053 function comsub_TAND_TOR { x=$(
11054 cmd >&3 && >&3 echo ja || echo >&3 nein
11056 function comsub_TAND_TOR {
11057 x=$(cmd >&3 && echo ja >&3 || echo nein >&3 )
11059 function reread_TAND_TOR { x=$((
11060 cmd >&3 && >&3 echo ja || echo >&3 nein
11062 function reread_TAND_TOR {
11063 x=$(( cmd >&3 && echo ja >&3 || echo nein >&3 ) | tr u x )
11066 select file in *; do echo "<$file>" ; break >&3 ; done >&3
11075 function comsub_TSELECT { x=$(
11076 select file in *; do echo "<$file>" ; break >&3 ; done >&3
11078 function comsub_TSELECT {
11079 x=$(select file in * ; do echo "<$file>" ; break >&3 ; done >&3 )
11081 function reread_TSELECT { x=$((
11082 select file in *; do echo "<$file>" ; break >&3 ; done >&3
11084 function reread_TSELECT {
11085 x=$(( select file in * ; do echo "<$file>" ; break >&3 ; done >&3 ) | tr u x )
11087 inline_TFOR_TTIME() {
11088 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
11090 inline_TFOR_TTIME() {
11096 function comsub_TFOR_TTIME { x=$(
11097 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
11099 function comsub_TFOR_TTIME {
11100 x=$(for i in {1,2,3} ; do time echo $i >&3 ; done >&3 )
11102 function reread_TFOR_TTIME { x=$((
11103 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
11105 function reread_TFOR_TTIME {
11106 x=$(( for i in {1,2,3} ; do time echo $i >&3 ; done >&3 ) | tr u x )
11109 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
11120 echo kann net bis drei zählen >&3
11124 function comsub_TCASE { x=$(
11125 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
11127 function comsub_TCASE {
11128 x=$(case $foo in (1) echo eins >&3 ;& (2) echo zwei >&3 ;| (*) echo kann net bis drei zählen >&3 ;; esac >&3 )
11130 function reread_TCASE { x=$((
11131 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
11133 function reread_TCASE {
11134 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 )
11136 inline_TIF_TBANG_TDBRACKET_TELIF() {
11137 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
11139 inline_TIF_TBANG_TDBRACKET_TELIF() {
11140 if ! [[ 1 = 1 ]] >&3
11143 elif [[ 1 = 2 ]] >&3
11150 function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$(
11151 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
11153 function comsub_TIF_TBANG_TDBRACKET_TELIF {
11154 x=$(if ! [[ 1 = 1 ]] >&3 ; then echo eins ; elif [[ 1 = 2 ]] >&3 ; then echo zwei ; else echo drei ; fi >&3 )
11156 function reread_TIF_TBANG_TDBRACKET_TELIF { x=$((
11157 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
11159 function reread_TIF_TBANG_TDBRACKET_TELIF {
11160 x=$(( if ! [[ 1 = 1 ]] >&3 ; then echo eins ; elif [[ 1 = 2 ]] >&3 ; then echo zwei ; else echo drei ; fi >&3 ) | tr u x )
11163 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
11175 function comsub_TWHILE { x=$(
11176 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
11178 function comsub_TWHILE {
11179 x=$(i=1 ; while { \let] " i < 10 " ; } >&3 ; do echo $i ; let ++i ; done >&3 )
11181 function reread_TWHILE { x=$((
11182 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
11184 function reread_TWHILE {
11185 x=$(( i=1 ; while { \let] " i < 10 " ; } >&3 ; do echo $i ; let ++i ; done >&3 ) | tr u x )
11188 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
11199 function comsub_TUNTIL { x=$(
11200 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
11202 function comsub_TUNTIL {
11203 x=$(i=10 ; until { \let] " !--i " ; } >&3 ; do echo $i ; done >&3 )
11205 function reread_TUNTIL { x=$((
11206 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
11208 function reread_TUNTIL {
11209 x=$(( i=10 ; until { \let] " !--i " ; } >&3 ; do echo $i ; done >&3 ) | tr u x )
11212 cat * >&3 |& >&3 ls
11218 function comsub_TCOPROC { x=$(
11219 cat * >&3 |& >&3 ls
11221 function comsub_TCOPROC {
11222 x=$(cat * >&3 |& ls >&3 )
11224 function reread_TCOPROC { x=$((
11225 cat * >&3 |& >&3 ls
11227 function reread_TCOPROC {
11228 x=$(( cat * >&3 |& ls >&3 ) | tr u x )
11230 inline_TFUNCT_TBRACE_TASYNC() {
11231 function korn { echo eins; echo >&3 zwei ; }
11232 bourne () { logger * >&3 & }
11234 inline_TFUNCT_TBRACE_TASYNC() {
11243 function comsub_TFUNCT_TBRACE_TASYNC { x=$(
11244 function korn { echo eins; echo >&3 zwei ; }
11245 bourne () { logger * >&3 & }
11247 function comsub_TFUNCT_TBRACE_TASYNC {
11248 x=$(function korn { echo eins ; echo zwei >&3 ; } ; bourne() { logger * >&3 & } )
11250 function reread_TFUNCT_TBRACE_TASYNC { x=$((
11251 function korn { echo eins; echo >&3 zwei ; }
11252 bourne () { logger * >&3 & }
11254 function reread_TFUNCT_TBRACE_TASYNC {
11255 x=$(( function korn { echo eins ; echo zwei >&3 ; } ; bourne() { logger * >&3 & } ) | tr u x )
11257 inline_COMSUB_EXPRSUB() {
11258 echo $(true >&3) $((1+ 2))
11260 inline_COMSUB_EXPRSUB() {
11261 echo $(true >&3 ) $((1+ 2))
11263 function comsub_COMSUB_EXPRSUB { x=$(
11264 echo $(true >&3) $((1+ 2))
11266 function comsub_COMSUB_EXPRSUB {
11267 x=$(echo $(true >&3 ) $((1+ 2)) )
11269 function reread_COMSUB_EXPRSUB { x=$((
11270 echo $(true >&3) $((1+ 2))
11272 function reread_COMSUB_EXPRSUB {
11273 x=$(( echo $(true >&3 ) $((1+ 2)) ) | tr u x )
11278 Check that non-subenvironment command substitution works
11298 You can now reliably use local and return in funsubs
11301 x=q; e=1; x=${ echo a; e=2; echo x$e;}; echo 1:y$x,$e,$?.
11302 x=q; e=1; x=${ echo a; typeset e=2; echo x$e;}; echo 2:y$x,$e,$?.
11303 x=q; e=1; x=${ echo a; typeset e=2; return 3; echo x$e;}; echo 3:y$x,$e,$?.
11311 Check that "value substitutions" work as advertised
11317 echo "before: x<$x> y<$y> z<$z> R<$REPLY>"
11320 echo "begin: x<$x> y<$y> z<$z> R<$REPLY>"
11325 echo "end: x<$x> y<$y> z<$z> R<$REPLY>"
11327 echo "after: x<$x> y<$y> z<$z> R<$REPLY>"
11328 # ensure trailing newlines are kept
11329 t=${|REPLY=$'foo\n\n';}
11331 echo -n this used to segfault
11332 echo ${|true;}$(true).
11334 before: x<1> y<2> z<3> R<4>
11335 begin: x<1> y<> z<3> R<>
11336 end: x<5> y<6> z<7> R<8>
11337 after: x<8> y<2> z<7> R<4>
11338 typeset t=$'foo\n\n'
11339 this used to segfault.
11341 name: event-subst-3
11343 Check that '!' substitution in noninteractive mode is ignored
11344 file-setup: file 755 "falsetto"
11348 file-setup: file 755 "!false"
11352 export PATH=.$PATHSEP$PATH
11360 ! false; then echo foo; else echo bar; fi
11369 name: event-subst-0
11371 Check that '!' substitution in interactive mode is ignored
11374 file-setup: file 755 "falsetto"
11378 file-setup: file 755 "!false"
11382 export PATH=.$PATHSEP$PATH
11390 ! false; then echo foo; else echo bar; fi
11398 expected-stderr-pattern:
11403 Check that "set -u" matches (future) SUSv4 requirement
11409 if [[ -n $v ]]; then
11444 (mypid=$$; try mypid)
11446 ) 2>&1 | sed -e 's/^[^]]*]//' -e 's/^[^:]*: *//'
11447 exit ${PIPESTATUS[0]}
11451 y: parameter not set
11455 y: parameter not set
11459 2: parameter not set
11461 1: parameter not set
11469 !: parameter not set
11480 Testsuite for nameref (bound variables)
11495 set|grep ^ir2|sed 's/^/s1: /'
11496 typeset|grep ' ir2'|sed -e 's/^/s2: /' -e 's/nameref/typeset -n/'
11497 set -A blub -- e1 e2 e3
11498 typeset -n ind=blub
11499 typeset -n ir2=blub[2]
11500 echo !ind[1]: ${!ind[1]}
11502 echo ind[1]: ${ind[1]}
11522 Testsuite for nameref (bound variables)
11523 Functions, argument given directly, after local
11526 typeset bar=lokal baz=auch
11558 Advanced testsuite for bound variables (ksh93 fails this)
11560 typeset -n foo=bar[i]
11561 set -A bar -- b c a
11562 for i in 0 1 2 3; do
11573 Ensure we don't run in an infinite loop
11577 typeset -n foo=fnord fnord=foo
11587 expected-stderr-pattern:
11588 /fnord: expression recurses on parameter/
11590 name: better-parens-1a
11592 Check support for ((…)) and $((…)) vs (…) and $(…)
11594 if ( (echo fubar)|tr u x); then
11603 name: better-parens-1b
11605 Check support for ((…)) and $((…)) vs (…) and $(…)
11607 echo $( (echo fubar)|tr u x) $?
11611 name: better-parens-1c
11613 Check support for ((…)) and $((…)) vs (…) and $(…)
11615 x=$( (echo fubar)|tr u x); echo $x $?
11619 name: better-parens-2a
11621 Check support for ((…)) and $((…)) vs (…) and $(…)
11623 if ((echo fubar)|tr u x); then
11632 name: better-parens-2b
11634 Check support for ((…)) and $((…)) vs (…) and $(…)
11636 echo $((echo fubar)|tr u x) $?
11640 name: better-parens-2c
11642 Check support for ((…)) and $((…)) vs (…) and $(…)
11644 x=$((echo fubar)|tr u x); echo $x $?
11648 name: better-parens-3a
11650 Check support for ((…)) and $((…)) vs (…) and $(…)
11652 if ( (echo fubar)|(tr u x)); then
11661 name: better-parens-3b
11663 Check support for ((…)) and $((…)) vs (…) and $(…)
11665 echo $( (echo fubar)|(tr u x)) $?
11669 name: better-parens-3c
11671 Check support for ((…)) and $((…)) vs (…) and $(…)
11673 x=$( (echo fubar)|(tr u x)); echo $x $?
11677 name: better-parens-4a
11679 Check support for ((…)) and $((…)) vs (…) and $(…)
11681 if ((echo fubar)|(tr u x)); then
11690 name: better-parens-4b
11692 Check support for ((…)) and $((…)) vs (…) and $(…)
11694 echo $((echo fubar)|(tr u x)) $?
11698 name: better-parens-4c
11700 Check support for ((…)) and $((…)) vs (…) and $(…)
11702 x=$((echo fubar)|(tr u x)); echo $x $?
11706 name: better-parens-5
11708 Another corner case
11710 ( (echo 'fo o$bar' "baz\$bla\"" m\$eh) | tr a A)
11711 ((echo 'fo o$bar' "baz\$bla\"" m\$eh) | tr a A)
11713 fo o$bAr bAz$blA" m$eh
11714 fo o$bAr bAz$blA" m$eh
11718 Test what the echo builtin does (mksh)
11720 echo -n 'foo\x40bar'
11727 Test what the echo builtin does (POSIX)
11728 Note: this follows Debian Policy 10.4 which mandates
11729 that -n shall be treated as an option, not XSI which
11730 mandates it shall be treated as string but escapes
11733 test -n "$POSH_VERSION" || set -o posix
11734 echo -n 'foo\x40bar'
11739 name: echo-test-3-mnbsd
11741 Test what the echo builtin does, and test a compatibility flag.
11744 "$__progname" -c 'echo -n 1=\\x40$1; echo -e \\x2E' -- foo bar
11745 "$__progname" -o posix -c 'echo -n 2=\\x40$1; echo -e \\x2E' -- foo bar
11746 "$__progname" -o sh -c 'echo -n 3=\\x40$1; echo -e \\x2E' -- foo bar
11752 name: echo-test-3-normal
11754 Test what the echo builtin does, and test a compatibility flag.
11755 category: !mnbsdash
11757 "$__progname" -c 'echo -n 1=\\x40$1; echo -e \\x2E' -- foo bar
11758 "$__progname" -o posix -c 'echo -n 2=\\x40$1; echo -e \\x2E' -- foo bar
11759 "$__progname" -o sh -c 'echo -n 3=\\x40$1; echo -e \\x2E' -- foo bar
11765 name: utilities-getopts-1
11767 getopts sets OPTIND correctly for unparsed option
11770 while getopts :a optc; do
11771 echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
11775 OPTARG=, OPTIND=2, optc=a.
11776 OPTARG=, OPTIND=3, optc=a.
11777 OPTARG=x, OPTIND=4, optc=?.
11780 name: utilities-getopts-2
11785 while getopts a: optc; do
11786 echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
11790 OPTARG=Mary, OPTIND=3, optc=a.
11791 OPTARG=, OPTIND=4, optc=?.
11793 expected-stderr-pattern: /.*-x.*option/
11797 Check the new wcswidth feature
11801 print octets: ${#s} .
11802 print 8-bit width: ${%s} .
11804 print characters: ${#s} .
11805 print columns: ${%s} .
11808 print octets: ${#s} .
11809 print 8-bit width: ${%s} .
11811 print characters: ${#s} .
11812 print columns: ${%s} .
11825 Check some corner cases
11841 Check some corner cases
11844 expected-stderr-pattern:
11850 Check some corner cases
11853 expected-stderr-pattern:
11859 Check some corner cases
11862 expected-stderr-pattern:
11868 Check some corner cases
11877 Check proper return values for realpath
11878 category: os:mirbsd
11891 x=$(realpath "$wd/$1" 2>&1); y=$?
11892 print $((++i)) "?$1" =${x##*$wd/} !$y
11918 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
11923 3 ?dir/file =dir/file !0
11924 4 ?dir/nix =dir/nix !0
11926 6 ?file/ =file/: Not a directory !20
11927 7 ?file/file =file/file: Not a directory !20
11928 8 ?file/nix =file/nix: Not a directory !20
11931 11 ?nix/file =nix/file: No such file or directory !2
11932 12 ?nix/nix =nix/nix: No such file or directory !2
11935 15 ?lndir/file =dir/file !0
11936 16 ?lndir/nix =dir/nix !0
11937 17 ?lnfile =file !0
11938 18 ?lnfile/ =lnfile/: Not a directory !20
11939 19 ?lnfile/file =lnfile/file: Not a directory !20
11940 20 ?lnfile/nix =lnfile/nix: Not a directory !20
11943 23 ?lnnix/file =lnnix/file: No such file or directory !2
11944 24 ?lnnix/nix =lnnix/nix: No such file or directory !2
11945 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
11949 Ensure that exactly two leading slashes are not collapsed
11950 POSIX guarantees this exception, e.g. for UNC paths on Cygwin
11951 category: os:mirbsd
11961 realpath /usr///bin
11970 realpath //usr/include/../bin
11987 Crashed during March 2011, fixed on vernal equinōx ☺
11988 category: os:mirbsd,os:openbsd
11990 export MALLOC_OPTIONS=FGJPRSX
11991 "$__progname" -c 'x=$(tr z r <<<baz); echo $x'
11997 Check test - bug#465250
11999 test \( ! -e \) ; echo $?
12005 Check test - bug#465250
12007 test \( -e \) ; echo $?
12013 Check test - bug#465250
12015 test ! -e ; echo $?
12021 Check test - bug#465250
12029 Check that zsh case variants work
12063 Check that case end tokens are not mixed up (Debian #220272)
12066 for value in 'x' '}' 'esac'; do
12067 print -n "$((++i))($value)bourne "
12072 print -n "$((++i))($value)korn "
12086 name: command-shift
12088 Check that 'command shift' works
12091 echo "before 0='$0' 1='$1' 2='$2'"
12093 echo "after 0='$0' 1='$1' 2='$2'"
12096 echo "before 0='$0' 1='$1' 2='$2'"
12098 echo "after 0='$0' 1='$1' 2='$2'"
12100 echo = without command
12102 echo = with command
12107 before 0='snc' 1='一' 2='二'
12108 after 0='snc' 1='二' 2=''
12110 before 0='swc' 1='一' 2='二'
12111 after 0='swc' 1='二' 2=''
12116 Check that the compiler did not optimise-break them
12117 (lex.c has got a similar one in SHEREDELIM)
12122 while (( ++i < 256 )); do
12125 s+=$'\xC2\xA0\xE2\x82\xAC\xEF\xBF\xBD\xEF\xBF\xBE\xEF\xBF\xBF\xF0\x90\x80\x80.'
12128 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.'
12130 name: stateptr-underflow
12132 This check overflows an Xrestpos stored in a short in R40
12135 function Lb64decode {
12136 [[ -o utf8-mode ]]; local u=$?
12139 [[ -n $s ]] || { s=$(cat;print x); s=${s%x}; }
12140 local -i i=0 n=${#s} p=0 v x
12143 while (( i < n )); do
12147 ([A-Z]) (( v = 1#$c - 65 )) ;;
12148 ([a-z]) (( v = 1#$c - 71 )) ;;
12149 ([0-9]) (( v = 1#$c + 4 )) ;;
12154 (( x = (x << 6) | v ))
12157 (1) (( o = (x >> 4) & 255 )) ;;
12158 (2) (( o = (x >> 2) & 255 )) ;;
12159 (3) (( o = x & 255 ))
12171 while (( ++i < 12120 )); do
12174 Lb64decode $s >/dev/null
12178 Check that "set -x" doesn't redirect too quickly
12180 print '#!'"$__progname" >bash
12182 echo 'GNU bash, version 2.05b.0(1)-release (i386-ecce-mirbsd10)
12183 Copyright (C) 2002 Free Software Foundation, Inc.'
12186 "$__progname" -xc 'foo=$(./bash --version 2>&1 | head -1); echo "=$foo="'
12188 =GNU bash, version 2.05b.0(1)-release (i386-ecce-mirbsd10)=
12189 expected-stderr-pattern:
12194 Check that "set -x" is off during PS4 expansion
12201 PS4='[(p:$-)$(f)] '
12203 set -x -o inherit-xtrace
12212 [(p:sh)(f1:sh)(f2:sh)] print '(o1:shx)'
12213 [(p:sh)(f1:sh)(f2:sh)] set +x
12217 Check that FKSH functions have their own shell flags
12218 category: shell:legacy-no
12220 [[ $KSH_VERSION = Version* ]] && set +B
12235 name: fksh-flags-legacy
12237 Check that even FKSH functions share the shell flags
12238 category: shell:legacy-yes
12240 [[ $KSH_VERSION = Version* ]] && set +B
12257 Check that !FKSH functions share the shell flags
12259 [[ $KSH_VERSION = Version* ]] && set +B