1 # $MirOS: src/bin/mksh/check.t,v 1.703 2015/07/10 19:36:31 tg Exp $
4 # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
5 # 2011, 2012, 2013, 2014, 2015
6 # Thorsten Glaser <tg@mirbsd.org>
8 # Provided that these terms and disclaimer and all copyright notices
9 # are retained or reproduced in an accompanying document, permission
10 # is granted to deal in this work without restriction, including un‐
11 # limited rights to use, publicly perform, distribute, sell, modify,
12 # merge, give away, or sublicence.
14 # This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
15 # the utmost extent permitted by applicable law, neither express nor
16 # implied; without malicious intent or gross negligence. In no event
17 # may a licensor, author or contributor be held liable for indirect,
18 # direct, other damage, loss, or other issues arising in any way out
19 # of dealing in the work, even if advised of the possibility of such
20 # damage or existence of a defect, except proven that it results out
21 # of said person’s immediate fault when using the work as intended.
23 # You may also want to test IFS with the script at
24 # http://www.research.att.com/~gsf/public/ifs.sh
27 # http://svnweb.freebsd.org/base/head/bin/test/tests/legacy_test.sh?view=co&content-type=text%2Fplain
29 # Integrated testsuites from:
30 # (2013/12/02 20:39:44) http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
33 @(#)MIRBSD KSH R51 2015/07/10
35 Check version of shell.
39 category: shell:legacy-no
42 @(#)LEGACY KSH R51 2015/07/10
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 only one side of ternary operator is evaluated
280 echo $((1 ? 20 : (x+=2)))
282 echo $((0 ? (y+=2) : 30))
292 Check that assignments not done on non-evaluated side of ternary
298 echo $((1 ? 20 : (x+=2)))
300 echo $((0 ? (y+=2) : 30))
310 Check that assignments not done on non-evaluated side of ternary
311 operator and this construct is parsed correctly (Debian #445651)
321 Check that preun/postun not done on non-evaluated side of ternary
324 (( m = n = 0, 1 ? n++ : m++ ? 2 : 3 ))
326 m=0; echo $(( 0 ? ++m : 2 )); echo $m
327 m=0; echo $(( 0 ? m++ : 2 )); echo $m
335 name: arith-ternary-prec-1
337 Check precedence of ternary operator vs assignment
341 expected-exit: e != 0
342 expected-stderr-pattern:
343 /.*:.*1 \? 20 : x\+=2.*lvalue.*\n$/
345 name: arith-ternary-prec-2
347 Check precedence of ternary operator vs assignment
350 echo $((0 ? x+=2 : 20))
354 name: arith-div-assoc-1
356 Check associativity of division operator
362 name: arith-div-byzero
364 Check division by zero errors out
370 expected-stderr-pattern:
373 name: arith-div-intmin-by-minusone
375 Check division overflow wraps around silently
378 echo signed:$((-2147483648 / -1))r$((-2147483648 % -1)).
379 echo unsigned:$((# -2147483648 / -1))r$((# -2147483648 % -1)).
381 signed:-2147483648r0.
382 unsigned:0r2147483648.
384 name: arith-div-intmin-by-minusone-64
386 Check division overflow wraps around silently
389 echo signed:$((-9223372036854775808 / -1))r$((-9223372036854775808 % -1)).
390 echo unsigned:$((# -9223372036854775808 / -1))r$((# -9223372036854775808 % -1)).
392 signed:-9223372036854775808r0.
393 unsigned:0r9223372036854775808.
395 name: arith-assop-assoc-1
397 Check associativity of assignment-operator operator
399 typeset -i i=1 j=2 k=3
400 echo $((i += j += k))
406 name: arith-mandatory
408 Passing of this test is *mandatory* for a valid mksh executable!
409 category: shell:legacy-no
414 print -r -- $((x++)):$sari=$uari. #0
416 print -r -- $((x++)):$sari=$uari. #1
417 sari=2147483647 uari=2147483647
418 print -r -- $((x++)):$sari=$uari. #2
420 print -r -- $((x++)):$sari=$uari. #3
422 let 'sari *= 2' 'uari *= 2'
424 print -r -- $((x++)):$sari=$uari. #4
426 print -r -- $((x++)):$sari=$uari. #5
427 sari=-2147483648 uari=-2147483648
428 print -r -- $((x++)):$sari=$uari. #6
430 print -r -- $((x++)):$sari=$uari. #7
432 ((# uari = -5 >> 1 ))
433 print -r -- $((x++)):$sari=$uari. #8
436 print -r -- $((x++)):$sari=$uari. #9
440 2:2147483647=2147483647.
441 3:-2147483648=2147483648.
444 6:-2147483648=2147483648.
445 7:2147483647=2147483647.
449 name: arith-unsigned-1
451 Check if unsigned arithmetics work
455 echo x1 $((-1)) $((#-1))
459 vs=4123456789; vu=4123456789
461 (( vs %= 2147483647 ))
462 (( vu %= 2147483647 ))
464 vs=4123456789; vu=4123456789
465 (( # vs %= 2147483647 ))
466 (( # vu %= 2147483647 ))
468 # make sure the calculation does not change unsigned flag
469 vs=4123456789; vu=4123456789
472 echo x6 $((# vs % 2147483647)) $((# vu % 2147483647))
477 echo x7 ${va[#4123456789%2147483647]}
480 x2 -171510507 4123456789
481 x3 -171510507 4123456789
482 x4 1975973142 1975973142
483 x5 -171510507 4123456789
484 x6 1975973142 1975973142
487 name: arith-limit32-1
489 Check if arithmetics are 32 bit
493 echo x1 $((-1)) $((#-1))
497 vs=2147483647; vu=2147483647
501 vs=4294967295; vu=4294967295
509 x2 2147483647 2147483647
510 x3 -2147483648 2147483648
515 name: arith-limit64-1
517 Check if arithmetics are 64 bit
521 echo x1 $((-1)) $((#-1))
525 vs=9223372036854775807; vu=9223372036854775807
529 vs=18446744073709551615; vu=18446744073709551615
536 x1 -1 18446744073709551615
537 x2 9223372036854775807 9223372036854775807
538 x3 -9223372036854775808 9223372036854775808
539 x4 -1 18446744073709551615
545 Check that \newline is not collapsed after #
555 Check that \newline is not collapsed inside single quotes
567 Check that \newline is not collapsed inside single quotes
579 Check interaction of aliases, single quotes and here-documents
580 with backslash-newline
581 (don't know what POSIX has to say about this)
603 Check what happens with backslash at end of input
604 (the old Bourne shell trashes them; so do we)
613 # Places \newline should be collapsed
617 Check that \newline is collapsed before, in the middle of, and
629 Check that \newline is collapsed in $ sequences
653 Check that \newline is collapsed in $(..) and `...` sequences
678 Check that \newline is collapsed in $((..)) sequences
689 echo $((1+2+3+4+5+6)\
700 Check that \newline is collapsed in double quoted strings
715 Check that \newline is collapsed in here document delimiters
716 (ksh93 fails second part of this)
738 Check that \newline is collapsed in double-quoted here-document
757 Check that \newline is collapsed in various 2+ character tokens
802 Check that \ at the end of an alias is collapsed when followed
804 (don't know what POSIX has to say about this)
814 Check that \newline in a keyword is collapsed
824 # Places \newline should be collapsed (ksh extensions)
828 Check that \newline is collapsed in extended globbing
845 Check that \newline is collapsed in ((...)) expressions
860 See if break breaks out of loops
862 for i in a b c; do echo $i; break; echo bad-$i; done
864 for i in a b c; do echo $i; break 1; echo bad-$i; done
890 See if break breaks out of nested loops
907 What if break used outside of any loops
908 (ksh88,ksh93 don't print error messages here)
911 expected-stderr-pattern:
916 What if break N used when only N-1 loops
917 (ksh88,ksh93 don't print error messages here)
919 for i in a b c; do echo $i; break 2; echo bad-$i; done
924 expected-stderr-pattern:
929 Error if break argument isn't a number
931 for i in a b c; do echo $i; break abc; echo more-$i; done
935 expected-exit: e != 0
936 expected-stderr-pattern:
941 See if continue continues loops
943 for i in a b c; do echo $i; continue; echo bad-$i ; done
945 for i in a b c; do echo $i; continue 1; echo bad-$i; done
981 See if continue breaks out of nested loops
1000 What if continue used outside of any loops
1001 (ksh88,ksh93 don't print error messages here)
1004 expected-stderr-pattern:
1009 What if continue N used when only N-1 loops
1010 (ksh88,ksh93 don't print error messages here)
1012 for i in a b c; do echo $i; continue 2; echo bad-$i; done
1019 expected-stderr-pattern:
1024 Error if continue argument isn't a number
1026 for i in a b c; do echo $i; continue abc; echo more-$i; done
1030 expected-exit: e != 0
1031 expected-stderr-pattern:
1036 Test someone's CD history package (uses arrays)
1038 # go to known place before doing anything
1052 if [ "$CDHISTFILE" -a -r "$CDHISTFILE" ] # if directory history exists
1056 while read -r t # read directory history file
1062 if [ "${CDHIST[0]}" != "$PWD" -a "$PWD" != "" ]
1064 _cdins # insert $PWD into cd history
1067 cdlen=${#CDHIST[*]} # number of elements in history
1071 if [ "$OLDPWD" = "" ] && ((cdlen>1))
1073 'print' ${CDHIST[1]}
1081 -l) # print directory list
1084 while (((i=i-1)>=0))
1087 'print' "$num ${CDHIST[i]}"
1091 -[0-9]|-[0-9][0-9]) # cd to dir in list
1092 if (((i=${1#-})<cdlen))
1094 'print' ${CDHIST[i]}
1102 -*) # cd to matched dir in list
1107 case ${CDHIST[i]} in
1109 'print' ${CDHIST[i]}
1129 _cdins # insert $PWD into cd history
1131 if [ "$CDHISTFILE" ]
1133 cdlen=${#CDHIST[*]} # number of elements in history
1138 'print' -r ${CDHIST[i]} # update directory history
1144 function _cdins # insert $PWD into cd history
1145 { # meant to be called only by _cd
1149 while ((i<${#CDHIST[*]})) # see if dir is already in list
1151 if [ "${CDHIST[$i]}" = "$PWD" ]
1158 if ((i>22)) # limit max size of list
1163 while (((i=i-1)>=0)) # bump old dirs in list
1165 CDHIST[i+1]=${CDHIST[i]}
1168 CDHIST[0]=$PWD # insert new directory in list
1196 Check package for cd -Pe
1198 # the mv command fails on Cygwin
1199 # Hurd aborts the testsuite (permission denied)
1200 # QNX does not find subdir to cd into
1201 category: !os:cygwin,!os:gnu,!os:msys,!os:nto,!os:os390,!nosymlink
1202 file-setup: file 644 "x"
1203 mkdir noread noread/target noread/target/subdir
1210 echo 1=$?,${PWD#$bwd/}
1211 epwd=$($TSHELL -c pwd 2>/dev/null)
1212 # This unexpectedly succeeds on GNU/Linux and MidnightBSD
1215 mv ../../noread ../../renamed
1217 echo 2=$?,${PWD#$bwd/}
1220 rm -rf noread link renamed
1222 export TSHELL="$__progname"
1229 2=0,noread/target/subdir
1233 2=1,noread/target/subdir
1237 Check that prompt not printed when processing ENV
1238 env-setup: !ENV=./foo!
1239 file-setup: file 644 "foo"
1254 Check that weird ${foo+bar} constructs are parsed correctly
1256 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
1257 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "<$x> "; done' >pfs
1259 (echo 1 ${IFS+'}'z}) 2>/dev/null || echo failed in 1
1260 (echo 2 "${IFS+'}'z}") 2>/dev/null || echo failed in 2
1261 (echo 3 "foo ${IFS+'bar} baz") 2>/dev/null || echo failed in 3
1262 (echo -n '4 '; ./pfn "foo ${IFS+"b c"} baz") 2>/dev/null || echo failed in 4
1263 (echo -n '5 '; ./pfn "foo ${IFS+b c} baz") 2>/dev/null || echo failed in 5
1264 (echo 6 ${IFS+"}"z}) 2>/dev/null || echo failed in 6
1265 (echo 7 "${IFS+"}"z}") 2>/dev/null || echo failed in 7
1266 (echo 8 "${IFS+\"}\"z}") 2>/dev/null || echo failed in 8
1267 (echo 9 "${IFS+\"\}\"z}") 2>/dev/null || echo failed in 9
1268 (echo 10 foo ${IFS+'bar} baz'}) 2>/dev/null || echo failed in 10
1269 (echo 11 "$(echo "${IFS+'}'z}")") 2>/dev/null || echo failed in 11
1270 (echo 12 "$(echo ${IFS+'}'z})") 2>/dev/null || echo failed in 12
1271 (echo 13 ${IFS+\}z}) 2>/dev/null || echo failed in 13
1272 (echo 14 "${IFS+\}z}") 2>/dev/null || echo failed in 14
1273 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
1274 l=t; (echo 16 ${IFS+h`echo -n i ${IFS+$l}h`ere}) 2>/dev/null || echo failed in 16
1275 l=t; (echo 17 ${IFS+h$(echo -n i ${IFS+$l}h)ere}) 2>/dev/null || echo failed in 17
1276 l=t; (echo 18 "${IFS+h`echo -n i ${IFS+$l}h`ere}") 2>/dev/null || echo failed in 18
1277 l=t; (echo 19 "${IFS+h$(echo -n i ${IFS+$l}h)ere}") 2>/dev/null || echo failed in 19
1278 l=t; (echo 20 ${IFS+h`echo -n i "${IFS+$l}"h`ere}) 2>/dev/null || echo failed in 20
1279 l=t; (echo 21 ${IFS+h$(echo -n i "${IFS+$l}"h)ere}) 2>/dev/null || echo failed in 21
1280 l=t; (echo 22 "${IFS+h`echo -n i "${IFS+$l}"h`ere}") 2>/dev/null || echo failed in 22
1281 l=t; (echo 23 "${IFS+h$(echo -n i "${IFS+$l}"h)ere}") 2>/dev/null || echo failed in 23
1282 key=value; (echo -n '24 '; ./pfn "${IFS+'$key'}") 2>/dev/null || echo failed in 24
1283 key=value; (echo -n '25 '; ./pfn "${IFS+"'$key'"}") 2>/dev/null || echo failed in 25 # ksh93: “'$key'”
1284 key=value; (echo -n '26 '; ./pfn ${IFS+'$key'}) 2>/dev/null || echo failed in 26
1285 key=value; (echo -n '27 '; ./pfn ${IFS+"'$key'"}) 2>/dev/null || echo failed in 27
1286 (echo -n '28 '; ./pfn "${IFS+"'"x ~ x'}'x"'}"x}" #') 2>/dev/null || echo failed in 28
1287 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
1288 (echo -n '30 '; ./pfs ${IFS+foo 'b\
1289 ar' baz}; echo .) 2>/dev/null || (echo failed in 30; echo failed in 31)
1290 (echo -n '32 '; ./pfs ${IFS+foo "b\
1291 ar" baz}; echo .) 2>/dev/null || echo failed in 32
1292 (echo -n '33 '; ./pfs "${IFS+foo 'b\
1293 ar' baz}"; echo .) 2>/dev/null || echo failed in 33
1294 (echo -n '34 '; ./pfs "${IFS+foo "b\
1295 ar" baz}"; echo .) 2>/dev/null || echo failed in 34
1296 (echo -n '35 '; ./pfs ${v=a\ b} x ${v=c\ d}; echo .) 2>/dev/null || echo failed in 35
1297 (echo -n '36 '; ./pfs "${v=a\ b}" x "${v=c\ d}"; echo .) 2>/dev/null || echo failed in 36
1298 (echo -n '37 '; ./pfs ${v-a\ b} x ${v-c\ d}; echo .) 2>/dev/null || echo failed in 37
1299 (echo 38 ${IFS+x'a'y} / "${IFS+x'a'y}" .) 2>/dev/null || echo failed in 38
1300 foo="x'a'y"; (echo 39 ${foo%*'a'*} / "${foo%*'a'*}" .) 2>/dev/null || echo failed in 39
1301 foo="a b c"; (echo -n '40 '; ./pfs "${foo#a}"; echo .) 2>/dev/null || echo failed in 40
1317 15 <foo abx{ {{{}b c d{} bar> <}> <baz> .
1331 29 <foo> <abx{ {{> <{}b> <c> <d{}> <bar> <}> <baz> .
1334 32 <foo> <bar> <baz> .
1335 33 <foo 'bar' baz> .
1337 35 <a> <b> <x> <a> <b> .
1338 36 <a\ b> <x> <a\ b> .
1339 37 <a b> <x> <c d> .
1344 name: expand-unglob-dblq
1346 Check that regular "${foo+bar}" constructs are parsed correctly
1351 test x"$v" = x"-" && unset v
1352 (echo "$1 plus norm foo ${v+'bar'} baz")
1353 (echo "$1 dash norm foo ${v-'bar'} baz")
1354 (echo "$1 eqal norm foo ${v='bar'} baz")
1355 (echo "$1 qstn norm foo ${v?'bar'} baz") 2>/dev/null || \
1356 echo "$1 qstn norm -> error"
1357 (echo "$1 PLUS norm foo ${v:+'bar'} baz")
1358 (echo "$1 DASH norm foo ${v:-'bar'} baz")
1359 (echo "$1 EQAL norm foo ${v:='bar'} baz")
1360 (echo "$1 QSTN norm foo ${v:?'bar'} baz") 2>/dev/null || \
1361 echo "$1 QSTN norm -> error"
1365 test x"$v" = x"-" && unset v
1366 (echo "$1 plus parn foo ${v+(bar)} baz")
1367 (echo "$1 dash parn foo ${v-(bar)} baz")
1368 (echo "$1 eqal parn foo ${v=(bar)} baz")
1369 (echo "$1 qstn parn foo ${v?(bar)} baz") 2>/dev/null || \
1370 echo "$1 qstn parn -> error"
1371 (echo "$1 PLUS parn foo ${v:+(bar)} baz")
1372 (echo "$1 DASH parn foo ${v:-(bar)} baz")
1373 (echo "$1 EQAL parn foo ${v:=(bar)} baz")
1374 (echo "$1 QSTN parn foo ${v:?(bar)} baz") 2>/dev/null || \
1375 echo "$1 QSTN parn -> error"
1379 test x"$v" = x"-" && unset v
1380 (echo "$1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz")
1381 (echo "$1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz")
1382 (echo "$1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz")
1383 (echo "$1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz") 2>/dev/null || \
1384 echo "$1 qstn brac -> error"
1385 (echo "$1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz")
1386 (echo "$1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz")
1387 (echo "$1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz")
1388 (echo "$1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz") 2>/dev/null || \
1389 echo "$1 QSTN brac -> error"
1402 1 dash norm foo 'bar' baz
1403 1 eqal norm foo 'bar' baz
1404 1 qstn norm -> error
1406 1 DASH norm foo 'bar' baz
1407 1 EQAL norm foo 'bar' baz
1408 1 QSTN norm -> error
1409 2 plus norm foo 'bar' baz
1414 2 DASH norm foo 'bar' baz
1415 2 EQAL norm foo 'bar' baz
1416 2 QSTN norm -> error
1417 3 plus norm foo 'bar' baz
1418 3 dash norm foo x baz
1419 3 eqal norm foo x baz
1420 3 qstn norm foo x baz
1421 3 PLUS norm foo 'bar' baz
1422 3 DASH norm foo x baz
1423 3 EQAL norm foo x baz
1424 3 QSTN norm foo x baz
1426 4 dash parn foo (bar) baz
1427 4 eqal parn foo (bar) baz
1428 4 qstn parn -> error
1430 4 DASH parn foo (bar) baz
1431 4 EQAL parn foo (bar) baz
1432 4 QSTN parn -> error
1433 5 plus parn foo (bar) baz
1438 5 DASH parn foo (bar) baz
1439 5 EQAL parn foo (bar) baz
1440 5 QSTN parn -> error
1441 6 plus parn foo (bar) baz
1442 6 dash parn foo x baz
1443 6 eqal parn foo x baz
1444 6 qstn parn foo x baz
1445 6 PLUS parn foo (bar) baz
1446 6 DASH parn foo x baz
1447 6 EQAL parn foo x baz
1448 6 QSTN parn foo x baz
1449 7 plus brac foo c } baz
1450 7 dash brac foo ax{{{}b c d{} baz
1451 7 eqal brac foo ax{{{}b c ax{{{}b} baz
1452 7 qstn brac -> error
1453 7 PLUS brac foo c } baz
1454 7 DASH brac foo ax{{{}b c d{} baz
1455 7 EQAL brac foo ax{{{}b c ax{{{}b} baz
1456 7 QSTN brac -> error
1457 8 plus brac foo ax{{{}b c d{} baz
1458 8 dash brac foo c } baz
1459 8 eqal brac foo c } baz
1460 8 qstn brac foo c } baz
1461 8 PLUS brac foo c } baz
1462 8 DASH brac foo ax{{{}b c d{} baz
1463 8 EQAL brac foo ax{{{}b c ax{{{}b} baz
1464 8 QSTN brac -> error
1465 9 plus brac foo ax{{{}b c d{} baz
1466 9 dash brac foo x c x} baz
1467 9 eqal brac foo x c x} baz
1468 9 qstn brac foo x c x} baz
1469 9 PLUS brac foo ax{{{}b c d{} baz
1470 9 DASH brac foo x c x} baz
1471 9 EQAL brac foo x c x} baz
1472 9 QSTN brac foo x c x} baz
1474 name: expand-unglob-unq
1476 Check that regular ${foo+bar} constructs are parsed correctly
1481 test x"$v" = x"-" && unset v
1482 (echo $1 plus norm foo ${v+'bar'} baz)
1483 (echo $1 dash norm foo ${v-'bar'} baz)
1484 (echo $1 eqal norm foo ${v='bar'} baz)
1485 (echo $1 qstn norm foo ${v?'bar'} baz) 2>/dev/null || \
1486 echo "$1 qstn norm -> error"
1487 (echo $1 PLUS norm foo ${v:+'bar'} baz)
1488 (echo $1 DASH norm foo ${v:-'bar'} baz)
1489 (echo $1 EQAL norm foo ${v:='bar'} baz)
1490 (echo $1 QSTN norm foo ${v:?'bar'} baz) 2>/dev/null || \
1491 echo "$1 QSTN norm -> error"
1495 test x"$v" = x"-" && unset v
1496 (echo $1 plus parn foo ${v+\(bar')'} baz)
1497 (echo $1 dash parn foo ${v-\(bar')'} baz)
1498 (echo $1 eqal parn foo ${v=\(bar')'} baz)
1499 (echo $1 qstn parn foo ${v?\(bar')'} baz) 2>/dev/null || \
1500 echo "$1 qstn parn -> error"
1501 (echo $1 PLUS parn foo ${v:+\(bar')'} baz)
1502 (echo $1 DASH parn foo ${v:-\(bar')'} baz)
1503 (echo $1 EQAL parn foo ${v:=\(bar')'} baz)
1504 (echo $1 QSTN parn foo ${v:?\(bar')'} baz) 2>/dev/null || \
1505 echo "$1 QSTN parn -> error"
1509 test x"$v" = x"-" && unset v
1510 (echo $1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz)
1511 (echo $1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz)
1512 (echo $1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz)
1513 (echo $1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz) 2>/dev/null || \
1514 echo "$1 qstn brac -> error"
1515 (echo $1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz)
1516 (echo $1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz)
1517 (echo $1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz)
1518 (echo $1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz) 2>/dev/null || \
1519 echo "$1 QSTN brac -> error"
1532 1 dash norm foo bar baz
1533 1 eqal norm foo bar baz
1534 1 qstn norm -> error
1536 1 DASH norm foo bar baz
1537 1 EQAL norm foo bar baz
1538 1 QSTN norm -> error
1539 2 plus norm foo bar baz
1544 2 DASH norm foo bar baz
1545 2 EQAL norm foo bar baz
1546 2 QSTN norm -> error
1547 3 plus norm foo bar baz
1548 3 dash norm foo x baz
1549 3 eqal norm foo x baz
1550 3 qstn norm foo x baz
1551 3 PLUS norm foo bar baz
1552 3 DASH norm foo x baz
1553 3 EQAL norm foo x baz
1554 3 QSTN norm foo x baz
1556 4 dash parn foo (bar) baz
1557 4 eqal parn foo (bar) baz
1558 4 qstn parn -> error
1560 4 DASH parn foo (bar) baz
1561 4 EQAL parn foo (bar) baz
1562 4 QSTN parn -> error
1563 5 plus parn foo (bar) baz
1568 5 DASH parn foo (bar) baz
1569 5 EQAL parn foo (bar) baz
1570 5 QSTN parn -> error
1571 6 plus parn foo (bar) baz
1572 6 dash parn foo x baz
1573 6 eqal parn foo x baz
1574 6 qstn parn foo x baz
1575 6 PLUS parn foo (bar) baz
1576 6 DASH parn foo x baz
1577 6 EQAL parn foo x baz
1578 6 QSTN parn foo x baz
1579 7 plus brac foo c } baz
1580 7 dash brac foo ax{{{}b c d{} baz
1581 7 eqal brac foo ax{{{}b c ax{{{}b} baz
1582 7 qstn brac -> error
1583 7 PLUS brac foo c } baz
1584 7 DASH brac foo ax{{{}b c d{} baz
1585 7 EQAL brac foo ax{{{}b c ax{{{}b} baz
1586 7 QSTN brac -> error
1587 8 plus brac foo ax{{{}b c d{} baz
1588 8 dash brac foo c } baz
1589 8 eqal brac foo c } baz
1590 8 qstn brac foo c } baz
1591 8 PLUS brac foo c } baz
1592 8 DASH brac foo ax{{{}b c d{} baz
1593 8 EQAL brac foo ax{{{}b c ax{{{}b} baz
1594 8 QSTN brac -> error
1595 9 plus brac foo ax{{{}b c d{} baz
1596 9 dash brac foo x c x} baz
1597 9 eqal brac foo x c x} baz
1598 9 qstn brac foo x c x} baz
1599 9 PLUS brac foo ax{{{}b c d{} baz
1600 9 DASH brac foo x c x} baz
1601 9 EQAL brac foo x c x} baz
1602 9 QSTN brac foo x c x} baz
1604 name: expand-threecolons-dblq
1606 Check for a particular thing that used to segfault
1609 echo "${TEST:1:2:3}"
1610 echo $? but still living
1611 expected-stderr-pattern:
1615 name: expand-threecolons-unq
1617 Check for a particular thing that used to not error out
1621 echo $? but still living
1622 expected-stderr-pattern:
1626 name: expand-weird-1
1628 Check corner case of trim expansion vs. $# vs. ${#var}
1630 set 1 2 3 4 5 6 7 8 9 10 11
1631 echo ${#} # value of $#
1632 echo ${##} # length of $#
1633 echo ${##1} # $# trimmed 1
1634 set 1 2 3 4 5 6 7 8 9 10 11 12
1642 name: expand-weird-2
1644 Check corner case of ${var?} vs. ${#var}
1654 name: expand-weird-3
1656 Check that trimming works with positional parameters (Debian #48453)
1667 name: expand-number-1
1669 Check that positional arguments do not overflow
1671 echo "1 ${12345678901234567890} ."
1677 Check that globbing isn't done when glob has syntax error
1678 file-setup: file 644 "abcx"
1679 file-setup: file 644 "abcz"
1680 file-setup: file 644 "bbc"
1690 Check that globbing isn't done when glob has syntax error
1691 (AT&T ksh fails this test)
1692 file-setup: file 644 "abcx"
1693 file-setup: file 644 "abcz"
1694 file-setup: file 644 "bbc"
1700 name: eglob-infinite-plus
1702 Check that shell doesn't go into infinite loop expanding +(...)
1704 file-setup: file 644 "abc"
1719 Check that eglobbing isn't done on substitution results
1720 file-setup: file 644 "abc"
1727 name: eglob-nomatch-1
1729 Check that the pattern doesn't match
1731 echo 1: no-file+(a|b)stuff
1732 echo 2: no-file+(a*(c)|b)stuff
1733 echo 3: no-file+((((c)))|b)stuff
1735 1: no-file+(a|b)stuff
1736 2: no-file+(a*(c)|b)stuff
1737 3: no-file+((((c)))|b)stuff
1741 Check that the pattern matches correctly
1742 file-setup: file 644 "abd"
1743 file-setup: file 644 "acd"
1744 file-setup: file 644 "abac"
1748 echo 3: *(a(b|c)) # (...|...) can be used within X(..)
1749 echo 4: a[b*(foo|bar)]d # patterns not special inside [...]
1758 Simple negation tests
1760 case foo in !(foo|bar)) echo yes;; *) echo no;; esac
1761 case bar in !(foo|bar)) echo yes;; *) echo no;; esac
1770 case foo in *(a|b[)) echo yes;; *) echo no;; esac
1771 case foo in *(a|b[)|f*) echo yes;; *) echo no;; esac
1772 case '*(a|b[)' in *(a|b[)) echo yes;; *) echo no;; esac
1780 Eglobbing in trim expressions...
1781 (AT&T ksh fails this - docs say # matches shortest string, ## matches
1797 Check eglobbing works in trims...
1800 echo 1: ${x#*(a|b)cd}
1801 echo 2: "${x#*(a|b)cd}"
1802 echo 3: ${x#"*(a|b)cd"}
1812 Check eglobbing works in trims, for Korn Shell
1813 Ensure eglobbing does not work for reduced-feature /bin/sh
1819 echo "<${x%bar|baz},${y%bar|baz},${z%\?}>"
1820 echo "<${x%ba(r|z)},${y%ba(r|z)}>"
1822 echo "<${x%bar|baz},${y%bar|baz},${z%\?}>"
1828 <foobar,foobaz,fooba>
1831 name: eglob-substrpl-1
1833 Check eglobbing works in substs... and they work at all
1835 [[ -n $BASH_VERSION ]] && shopt -s extglob
1836 x=1222321_ab/cde_b/c_1221
1845 echo 8: ${x//+(2)/4}
1846 echo 9: ${x/b/c/e/f}
1847 echo 10: ${x/b\/c/e/f}
1848 echo 11: ${x/b\/c/e\/f}
1849 echo 12: ${x/b\/c/e\\/f}
1850 echo 13: ${x/b\\/c/e\\/f}
1851 echo 14: ${x//b/c/e/f}
1852 echo 15: ${x//b\/c/e/f}
1853 echo 16: ${x//b\/c/e\/f}
1854 echo 17: ${x//b\/c/e\\/f}
1855 echo 18: ${x//b\\/c/e\\/f}
1856 echo 19: ${x/b\/*\/c/x}
1862 echo 25: ${x//\%1/9}
1863 echo 26: ${x//\\%1/9}
1865 echo 28: ${x//\\a/9}
1868 1: 122321_ab/cde_b/c_1221
1869 2: 131_ab/cde_b/c_11
1870 3: 1321_ab/cde_b/c_1221
1871 4: 131_ab/cde_b/c_11
1872 5: 1422321_ab/cde_b/c_1221
1873 6: 1444341_ab/cde_b/c_1441
1874 7: 14321_ab/cde_b/c_1221
1875 8: 14341_ab/cde_b/c_141
1876 9: 1222321_ac/e/f/cde_b/c_1221
1877 10: 1222321_ae/fde_b/c_1221
1878 11: 1222321_ae/fde_b/c_1221
1879 12: 1222321_ae\/fde_b/c_1221
1880 13: 1222321_ab/cde_b/c_1221
1881 14: 1222321_ac/e/f/cde_c/e/f/c_1221
1882 15: 1222321_ae/fde_e/f_1221
1883 16: 1222321_ae/fde_e/f_1221
1884 17: 1222321_ae\/fde_e\/f_1221
1885 18: 1222321_ab/cde_b/c_1221
1887 20: 1222321_ab.cde_b/c_1221
1888 21: 1222321_ab.cde_b.c_1221
1889 22: 1222321_ab/cde_b/c_1221
1890 23: 9222321_ab/cde_b/c_1221
1891 24: 1222321_ab/cde_b/c_1229
1892 25: 1222321_ab/cde_b/c_1229
1893 26: 1222321_ab/cde_b/c_1221
1894 27: 1222321_9b/cde_b/c_1221
1895 28: 1222321_9b/cde_b/c_1221
1896 29: 1xyz22321_ab/cde_b/c_1221
1898 name: eglob-substrpl-2
1900 Check anchored substring replacement works, corner cases
1917 name: eglob-substrpl-3a
1919 Check substring replacement works with variables and slashes, too
1923 echo "${wd/#$pfx/~}"
1924 echo "${wd/#\$pfx/~}"
1925 echo "${wd/#"$pfx"/~}"
1926 echo "${wd/#'$pfx'/~}"
1927 echo "${wd/#"\$pfx"/~}"
1928 echo "${wd/#'\$pfx'/~}"
1937 name: eglob-substrpl-3b
1939 More of this, bash fails it (bash4 passes)
1943 echo "${wd/#$(echo /home/user)/~}"
1944 echo "${wd/#"$(echo /home/user)"/~}"
1945 echo "${wd/#'$(echo /home/user)'/~}"
1951 name: eglob-substrpl-3c
1953 Even more weird cases
1957 echo 1: ${wd/#$pfx/~}
1958 echo 2: ${wd/#\$pfx/~}
1959 echo 3: ${wd/#"$pfx"/~}
1960 echo 4: ${wd/#'$pfx'/~}
1961 echo 5: ${wd/#"\$pfx"/~}
1962 echo 6: ${wd/#'\$pfx'/~}
1963 ts='a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)'
1966 [[ -n $BASH_VERSION ]] && shopt -s extglob
1967 echo 7: ${ts/a\/b/$tr}
1968 echo 8: ${ts/a\/b/\$tr}
1969 echo 9: ${ts/$tp/$tr}
1970 echo 10: ${ts/\$tp/$tr}
1971 echo 11: ${ts/\\$tp/$tr}
1972 echo 12: ${ts/$tp/c/d}
1973 echo 13: ${ts/$tp/c\/d}
1974 echo 14: ${ts/$tp/c\\/d}
1975 echo 15: ${ts/+(a\/b)/$tr}
1976 echo 16: ${ts/+(a\/b)/\$tr}
1977 echo 17: ${ts/+($tp)/$tr}
1978 echo 18: ${ts/+($tp)/c/d}
1979 echo 19: ${ts/+($tp)/c\/d}
1980 echo 25: ${ts//a\/b/$tr}
1981 echo 26: ${ts//a\/b/\$tr}
1982 echo 27: ${ts//$tp/$tr}
1983 echo 28: ${ts//$tp/c/d}
1984 echo 29: ${ts//$tp/c\/d}
1985 echo 30: ${ts//+(a\/b)/$tr}
1986 echo 31: ${ts//+(a\/b)/\$tr}
1987 echo 32: ${ts//+($tp)/$tr}
1988 echo 33: ${ts//+($tp)/c/d}
1989 echo 34: ${ts//+($tp)/c\/d}
1991 echo 40: ${ts/$tp/$tr}
1992 echo 41: ${ts//$tp/$tr}
2000 7: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2001 8: $tra/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2002 9: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2003 10: a/ba/bc/d$tp_a/b$tp_*(a/b)_*($tp)
2004 11: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2005 12: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2006 13: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2007 14: c\/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2008 15: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2009 16: $tr$tp$tp_a/b$tp_*(a/b)_*($tp)
2010 17: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2011 18: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2012 19: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2013 25: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2014 26: $tr$tr$tp$tp_$tr$tp_*($tr)_*($tp)
2015 27: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2016 28: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2017 29: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2018 30: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2019 31: $tr$tp$tp_$tr$tp_*($tr)_*($tp)
2020 32: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2021 33: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2022 34: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2023 40: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2024 41: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2025 # This is what GNU bash does:
2026 # 40: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2027 # 41: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2031 UTF-8 mode differences for eglobbing
2036 print 2: ${s/b???d/x} .
2039 print 4: ${s/b??d/x} .
2041 print 5: ${x%?} ${x%%?} .
2043 print 6: ${x#?} ${x##?} .
2045 print 7: ${x%?} ${x%%?} .
2047 print 8: ${x%?} ${x%%?} .
2049 print 9: ${x%?} ${x%%?} .
2063 Check that globbing isn't done when glob has syntax error
2064 file-setup: dir 755 "[x"
2065 file-setup: file 644 "[x/foo"
2077 Check that symbolic links aren't stat()'d
2078 # breaks on Dell UNIX 4.0 R2.2 (SVR4) where unlink also fails
2079 # breaks on FreeMiNT (cannot unlink dangling symlinks)
2080 # breaks on MSYS, OS/2 (do not support symlinks)
2081 category: !os:mint,!os:msys,!os:svr4.0,!nosymlink
2082 file-setup: dir 755 "dir"
2083 file-setup: symlink 644 "dir/abc"
2095 file-setup: file 644 ".bc"
2096 file-setup: file 644 "abc"
2097 file-setup: file 644 "bbc"
2098 file-setup: file 644 "cbc"
2099 file-setup: file 644 "-bc"
2122 (AT&T ksh fails this; POSIX says invalid)
2123 file-setup: file 644 "abc"
2131 Check that globbing matches the right things...
2132 # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
2133 # breaks on Cygwin 1.7 (files are now UTF-16 or something)
2134 # breaks on QNX 6.4.1 (says RT)
2135 category: !os:cygwin,!os:darwin,!os:msys,!os:nto,!os:os2
2137 file-setup: file 644 "aÂc"
2145 Results unspecified according to POSIX
2146 file-setup: file 644 ".bc"
2154 Results unspecified according to POSIX
2155 (AT&T ksh treats this like [a-cc-e]*)
2156 file-setup: file 644 "abc"
2157 file-setup: file 644 "bbc"
2158 file-setup: file 644 "cbc"
2159 file-setup: file 644 "dbc"
2160 file-setup: file 644 "ebc"
2161 file-setup: file 644 "-bc"
2169 Check against a regression from fixing IFS-subst-2
2172 print -r "before='$x'"
2174 print -r "after ='$x'"
2181 Check ordering/content of redundent here documents.
2193 Check quoted here-doc is protected.
2212 Check that newline isn't needed after heredoc-delimiter marker.
2224 Check that an error occurs if the heredoc-delimiter is missing.
2229 expected-exit: e > 0
2230 expected-stderr-pattern: /.*/
2234 Check that backslash quotes a $, ` and \ and kills a \newline
2241 th\`echo not-run\`ere
2242 th\\`echo is-run`ere
2259 Check that \newline in initial here-delim word doesn't imply
2274 Check that double quoted $ expressions in here delimiters are
2275 not expanded and match the delimiter.
2276 POSIX says only quote removal is applied to the delimiter.
2293 Check that double quoted escaped $ expressions in here
2294 delimiters are not expanded and match the delimiter.
2295 POSIX says only quote removal is applied to the delimiter
2296 (\ counts as a quote).
2317 Check that here strings work.
2321 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo
2322 "$__progname" -c "tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo"
2323 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$bar"
2324 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<'$bar'
2325 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$bar
2326 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<-foo
2327 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$(echo "foo bar")"
2340 Check that a corner case of here strings works like bash
2345 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
2352 Check that a corner case of here strings works like ksh93, zsh
2357 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
2364 Check another corner case of here strings
2366 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<< bar
2372 Check here string related regression with multiple iops
2374 echo $(tr r z <<<'bar' 2>/dev/null)
2380 Check long here strings
2388 Check direct here document assignment
2402 fnd=$(typeset -f foo)
2410 # rather nonsensical, but…
2413 vf=<<<$'=f $x \x40='
2415 print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} ve={$ve} vf={$vf} |"
2423 print -r -- "| ${v//$'\n'/^} |"
2443 Check here documents with no or empty delimiter
2460 fnd=$(typeset -f foo)
2468 print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} |"
2476 print -r -- "| ${v//$'\n'/^} |"
2498 Check here documents can use $* and $@; note shells vary:
2499 • pdksh 5.2.14 acts the same
2500 • dash has 1 and 2 the same but 3 lacks the space
2501 • ksh93, bash4 differ in 2 by using space ipv colon
2541 name: heredoc-comsub-1
2543 Tests for here documents in COMSUB, taken from Austin ML
2550 = here is the text =
2552 name: heredoc-comsub-2
2554 Tests for here documents in COMSUB, taken from Austin ML
2556 unbalanced=$(cat <<EOF
2557 this paren ) is a problem
2559 echo = $unbalanced =
2561 = this paren ) is a problem =
2563 name: heredoc-comsub-3
2565 Tests for here documents in COMSUB, taken from Austin ML
2567 balanced=$(cat <<EOF
2568 these parens ( ) are not a problem
2572 = these parens ( ) are not a problem =
2574 name: heredoc-comsub-4
2576 Tests for here documents in COMSUB, taken from Austin ML
2578 balanced=$(cat <<EOF
2579 these parens \( ) are a problem
2583 = these parens \( ) are a problem =
2585 name: heredoc-subshell-1
2587 Tests for here documents in subshells, taken from Austin ML
2597 name: heredoc-subshell-2
2599 Tests for here documents in subshells, taken from Austin ML
2610 name: heredoc-subshell-3
2612 Tests for here documents in subshells, taken from Austin ML
2622 name: heredoc-weird-1
2624 Tests for here documents, taken from Austin ML
2625 Documents current state in mksh, *NOT* necessarily correct!
2638 name: heredoc-weird-2
2640 Tests for here documents, taken from Austin ML
2650 name: heredoc-weird-4
2652 Tests for here documents, taken from Austin ML
2653 Documents current state in mksh, *NOT* necessarily correct!
2664 name: heredoc-weird-5
2666 Tests for here documents, taken from Austin ML
2667 Documents current state in mksh, *NOT* necessarily correct!
2679 name: heredoc-tmpfile-1
2681 Check that heredoc temp files aren't removed too soon or too late.
2682 Heredoc in simple command.
2703 name: heredoc-tmpfile-2
2705 Check that heredoc temp files aren't removed too soon or too late.
2706 Heredoc in function, multiple calls to function.
2725 name: heredoc-tmpfile-3
2727 Check that heredoc temp files aren't removed too soon or too late.
2728 Heredoc in function in loop, multiple calls to function.
2755 name: heredoc-tmpfile-4
2757 Check that heredoc temp files aren't removed too soon or too late.
2758 Backgrounded simple command with here doc
2772 name: heredoc-tmpfile-5
2774 Check that heredoc temp files aren't removed too soon or too late.
2775 Backgrounded subshell command with here doc
2780 sleep 1 # so parent exits
2796 name: heredoc-tmpfile-6
2798 Check that heredoc temp files aren't removed too soon or too late.
2799 Heredoc in pipeline.
2803 cat <<- EOF | sed "s/hi/HI/"
2813 name: heredoc-tmpfile-7
2815 Check that heredoc temp files aren't removed too soon or too late.
2816 Heredoc in backgrounded pipeline.
2820 cat <<- EOF | sed 's/hi/HI/' &
2830 name: heredoc-tmpfile-8
2832 Check that heredoc temp files aren't removed too soon or too
2833 late. Heredoc in function, backgrounded call to function.
2834 This check can fail on slow machines (<100 MHz), or Cygwin,
2839 # Background eval so main shell doesn't do parsing
2847 # sleep so eval can die
2861 name: heredoc-quoting-unsubst
2863 Check for correct handling of quoted characters in
2864 here documents without substitution (marker is quoted).
2868 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
2871 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
2873 name: heredoc-quoting-subst
2875 Check for correct handling of quoted characters in
2876 here documents with substitution (marker is not quoted).
2880 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
2883 x " \" \ \ $ $ baz `echo baz` bar $foo x
2885 name: single-quotes-in-braces
2887 Check that single quotes inside unquoted {} are treated as quotes
2890 echo ${foo:+'blah $foo'}
2894 name: single-quotes-in-quoted-braces
2896 Check that single quotes inside quoted {} are treated as
2900 echo "${foo:+'blah $foo'}"
2904 name: single-quotes-in-braces-nested
2906 Check that single quotes inside unquoted {} are treated as quotes,
2907 even if that's inside a double-quoted command expansion
2910 echo "$( echo ${foo:+'blah $foo'})"
2914 name: single-quotes-in-brace-pattern
2916 Check that single quotes inside {} pattern are treated as quotes
2919 echo ${foo%'2'*} "${foo%'2'*}" ${foo%2'*'} "${foo%2'*'}"
2923 name: single-quotes-in-heredoc-braces
2925 Check that single quotes inside {} in heredoc are treated
2935 name: single-quotes-in-nested-braces
2937 Check that single quotes inside nested unquoted {} are
2941 echo ${foo:+${foo:+'blah $foo'}}
2945 name: single-quotes-in-nested-quoted-braces
2947 Check that single quotes inside nested quoted {} are treated
2951 echo "${foo:+${foo:+'blah $foo'}}"
2955 name: single-quotes-in-nested-braces-nested
2957 Check that single quotes inside nested unquoted {} are treated
2958 as quotes, even if that's inside a double-quoted command expansion
2961 echo "$( echo ${foo:+${foo:+'blah $foo'}})"
2965 name: single-quotes-in-nested-brace-pattern
2967 Check that single quotes inside nested {} pattern are treated as quotes
2970 echo ${foo:+${foo%'2'*}} "${foo:+${foo%'2'*}}" ${foo:+${foo%2'*'}} "${foo:+${foo%2'*'}}"
2974 name: single-quotes-in-heredoc-nested-braces
2976 Check that single quotes inside nested {} in heredoc are treated
2981 ${foo:+${foo:+'blah $foo'}}
2988 See if we can test history at all
2991 env-setup: !ENV=./Env!HISTFILE=hist.file!
2992 file-setup: file 644 "Env"
3000 expected-stderr-pattern:
3005 Verify duplicates and spaces are not entered
3008 env-setup: !ENV=./Env!HISTFILE=hist.file!
3009 file-setup: file 644 "Env"
3021 expected-stderr-pattern:
3024 name: history-unlink
3026 Check if broken HISTFILEs do not cause trouble
3029 env-setup: !ENV=./Env!HISTFILE=foo/hist.file!
3030 file-setup: file 644 "Env"
3032 file-setup: dir 755 "foo"
3033 file-setup: file 644 "foo/hist.file"
3036 perl-setup: chmod(0555, "foo");
3044 expected-stderr-pattern:
3045 /(.*can't unlink HISTFILE.*\n)?X*$/
3047 name: history-e-minus-1
3049 Check if more recent command is executed
3052 env-setup: !ENV=./Env!HISTFILE=hist.file!
3053 file-setup: file 644 "Env"
3063 expected-stderr-pattern:
3064 /^X*echo there\nX*$/
3066 name: history-e-minus-2
3068 Check that repeated command is printed before command
3072 env-setup: !ENV=./Env!HISTFILE=hist.file!
3073 file-setup: file 644 "Env"
3080 expected-stdout-pattern:
3081 /X*hi\nX*there\nX*echo there\nthere\nX*/
3082 expected-stderr-pattern:
3085 name: history-e-minus-3
3087 fc -e - fails when there is no history
3088 (ksh93 has a bug that causes this to fail)
3089 (ksh88 loops on this)
3092 env-setup: !ENV=./Env!HISTFILE=hist.file!
3093 file-setup: file 644 "Env"
3100 expected-stderr-pattern:
3101 /^X*.*:.*history.*\nX*$/
3103 name: history-e-minus-4
3105 Check if "fc -e -" command output goes to stdout.
3108 env-setup: !ENV=./Env!HISTFILE=hist.file!
3109 file-setup: file 644 "Env"
3113 fc -e - | (read x; echo "A $x")
3119 expected-stderr-pattern:
3122 name: history-e-minus-5
3124 fc is replaced in history by new command.
3127 env-setup: !ENV=./Env!HISTFILE=hist.file!
3128 file-setup: file 644 "Env"
3144 expected-stderr-pattern:
3145 /^X*echo ghi jkl\nX*$/
3147 name: history-list-1
3149 List lists correct range
3150 (ksh88 fails 'cause it lists the fc command)
3153 env-setup: !ENV=./Env!HISTFILE=hist.file!
3154 file-setup: file 644 "Env"
3167 expected-stderr-pattern:
3170 name: history-list-2
3172 Lists oldest history if given pre-historic number
3173 (ksh93 has a bug that causes this to fail)
3174 (ksh88 fails 'cause it lists the fc command)
3177 env-setup: !ENV=./Env!HISTFILE=hist.file!
3178 file-setup: file 644 "Env"
3192 expected-stderr-pattern:
3195 name: history-list-3
3197 Can give number 'options' to fc
3200 env-setup: !ENV=./Env!HISTFILE=hist.file!
3201 file-setup: file 644 "Env"
3216 expected-stderr-pattern:
3219 name: history-list-4
3221 -1 refers to previous command
3224 env-setup: !ENV=./Env!HISTFILE=hist.file!
3225 file-setup: file 644 "Env"
3239 expected-stderr-pattern:
3242 name: history-list-5
3244 List command stays in history
3247 env-setup: !ENV=./Env!HISTFILE=hist.file!
3248 file-setup: file 644 "Env"
3265 expected-stderr-pattern:
3268 name: history-list-6
3270 HISTSIZE limits about of history kept.
3271 (ksh88 fails 'cause it lists the fc command)
3274 env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3!
3275 file-setup: file 644 "Env"
3292 expected-stderr-pattern:
3295 name: history-list-7
3297 fc allows too old/new errors in range specification
3300 env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3!
3301 file-setup: file 644 "Env"
3319 expected-stderr-pattern:
3322 name: history-list-r-1
3324 test -r flag in history
3327 env-setup: !ENV=./Env!HISTFILE=hist.file!
3328 file-setup: file 644 "Env"
3346 expected-stderr-pattern:
3349 name: history-list-r-2
3351 If first is newer than last, -r is implied.
3354 env-setup: !ENV=./Env!HISTFILE=hist.file!
3355 file-setup: file 644 "Env"
3373 expected-stderr-pattern:
3376 name: history-list-r-3
3378 If first is newer than last, -r is cancelled.
3381 env-setup: !ENV=./Env!HISTFILE=hist.file!
3382 file-setup: file 644 "Env"
3400 expected-stderr-pattern:
3403 name: history-subst-1
3408 env-setup: !ENV=./Env!HISTFILE=hist.file!
3409 file-setup: file 644 "Env"
3414 fc -e - abc=AB 'echo a'
3419 expected-stderr-pattern:
3420 /^X*echo AB def\nX*$/
3422 name: history-subst-2
3424 Does subst find previous command?
3427 env-setup: !ENV=./Env!HISTFILE=hist.file!
3428 file-setup: file 644 "Env"
3433 fc -e - jkl=XYZQRT 'echo g'
3438 expected-stderr-pattern:
3439 /^X*echo ghi XYZQRT\nX*$/
3441 name: history-subst-3
3443 Does subst find previous command when no arguments given
3446 env-setup: !ENV=./Env!HISTFILE=hist.file!
3447 file-setup: file 644 "Env"
3457 expected-stderr-pattern:
3458 /^X*echo ghi XYZQRT\nX*$/
3460 name: history-subst-4
3462 Global substitutions work
3463 (ksh88 and ksh93 do not have -g option)
3466 env-setup: !ENV=./Env!HISTFILE=hist.file!
3467 file-setup: file 644 "Env"
3470 echo abc def asjj sadjhasdjh asdjhasd
3473 abc def asjj sadjhasdjh asdjhasd
3474 FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd
3475 expected-stderr-pattern:
3476 /^X*echo FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd\nX*$/
3478 name: history-subst-5
3480 Make sure searches don't find current (fc) command
3481 (ksh88/ksh93 don't have the ? prefix thing so they fail this test)
3484 env-setup: !ENV=./Env!HISTFILE=hist.file!
3485 file-setup: file 644 "Env"
3490 fc -e - abc=AB \?abc
3495 expected-stderr-pattern:
3496 /^X*echo AB def\nX*$/
3498 name: history-ed-1-old
3500 Basic (ed) editing works (assumes you have generic ed editor
3501 that prints no prompts). This is for oldish ed(1) which write
3502 the character count to stdout.
3507 env-setup: !ENV=./Env!HISTFILE=hist.file!
3508 file-setup: file 644 "Env"
3521 expected-stderr-pattern:
3522 /^X*echo FOOBAR def\nX*$/
3524 name: history-ed-2-old
3526 Correct command is edited when number given
3531 env-setup: !ENV=./Env!HISTFILE=hist.file!
3532 file-setup: file 644 "Env"
3540 s/is here/is changed/
3551 expected-stderr-pattern:
3552 /^X*echo line 2 is changed\nX*$/
3554 name: history-ed-3-old
3556 Newly created multi line commands show up as single command
3558 (ksh88 fails 'cause it lists the fc command)
3563 env-setup: !ENV=./Env!HISTFILE=hist.file!
3564 file-setup: file 644 "Env"
3585 expected-stderr-pattern:
3586 /^X*echo FOOBAR def\necho a new line\nX*$/
3590 Basic (ed) editing works (assumes you have generic ed editor
3591 that prints no prompts). This is for newish ed(1) and stderr.
3592 category: !no-stderr-ed
3596 env-setup: !ENV=./Env!HISTFILE=hist.file!
3597 file-setup: file 644 "Env"
3608 expected-stderr-pattern:
3609 /^X*13\n16\necho FOOBAR def\nX*$/
3613 Correct command is edited when number given
3614 category: !no-stderr-ed
3618 env-setup: !ENV=./Env!HISTFILE=hist.file!
3619 file-setup: file 644 "Env"
3627 s/is here/is changed/
3636 expected-stderr-pattern:
3637 /^X*20\n23\necho line 2 is changed\nX*$/
3641 Newly created multi line commands show up as single command
3643 category: !no-stderr-ed
3647 env-setup: !ENV=./Env!HISTFILE=hist.file!
3648 file-setup: file 644 "Env"
3667 expected-stderr-pattern:
3668 /^X*13\n32\necho FOOBAR def\necho a new line\nX*$/
3672 Simple test, default IFS
3674 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3690 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3707 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3720 name: IFS-space-colon-1
3722 Simple test, IFS=<white-space>:
3724 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3739 name: IFS-space-colon-2
3741 Simple test, IFS=<white-space>:
3742 AT&T ksh fails this, POSIX says the test is correct.
3744 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3751 name: IFS-space-colon-4
3753 Simple test, IFS=<white-space>:
3755 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3762 name: IFS-space-colon-5
3764 Simple test, IFS=<white-space>:
3765 Don't know what POSIX thinks of this. AT&T ksh does not do this.
3767 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3776 Simple test, IFS=<white-space>:
3778 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3781 echo -n '1:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3782 echo -n '2:'; for i in :b:: ; do echo -n " [$i]" ; done ; echo
3786 echo -n '5:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3789 echo -n '7:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3791 echo -n '9:'; for i in ${FOO-`echo -n h:i`th:ere} ; do echo -n " [$i]" ; done ; echo
3792 showargs 10 ${FOO-`echo -n h:i`th:ere}
3793 showargs 11 "${FOO-`echo -n h:i`th:ere}"
3795 echo -n '12:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3807 <10> <h> <ith> <ere> .
3810 <13> <A> <B> <> <D> .
3814 Check leading whitespace after trim does not make a field
3816 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3818 showargs 1 shift ${x#X}
3820 <1> <shift> <1> <2> .
3822 name: IFS-subst-3-arr
3824 Check leading IFS non-whitespace after trim does make a field
3825 but leading IFS whitespace does not, nor empty replacements
3827 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3830 showargs 1 ${-+:foo:bar}
3832 showargs 2 ${-+ foo bar}
3835 <1> <> <foo> <bar> .
3838 name: IFS-subst-3-ass
3840 Check non-field semantics
3842 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3845 showargs 1 x=${-+:foo:bar}
3847 showargs 2 x=${-+ foo bar}
3850 <1> <x=> <foo> <bar> .
3851 <2> <x=> <foo> <bar> .
3853 name: IFS-subst-3-lcl
3855 Check non-field semantics, smaller corner case (LP#1381965)
3860 expected-exit: e != 0
3861 expected-stderr-pattern:
3866 reported by mikeserv
3868 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
3869 a='space divded argument
3872 IFS= ; q="$*" ; nq=$*
3873 pfn "$*" $* "$q" "$nq"
3874 [ "$q" = "$nq" ] && echo =true || echo =false
3876 <spacedivdedargument
3882 <spacedivdedargument
3884 <spacedivdedargument
3890 extended testsuite based on problem by mikeserv
3892 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
3893 a='space divded argument
3896 IFS= ; q="$@" ; nq=$@
3897 pfn "$*" $* "$q" "$nq"
3898 [ "$q" = "$nq" ] && echo =true || echo =false
3900 <spacedivdedargument
3906 <space divded argument
3908 <space divded argument
3914 extended testsuite based on problem by mikeserv
3916 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
3917 a='space divded argument
3919 IFS=\ ; set -- $a; IFS=
3924 print -nr -- '= qs '; pfn "$qs"
3925 print -nr -- '=nqs '; pfn "$nqs"
3926 print -nr -- '= qk '; pfn "$qk"
3927 print -nr -- '=nqk '; pfn "$nqk"
3928 print -nr -- '~ qs '; pfn "$*"
3929 print -nr -- '~nqs '; pfn $*
3930 print -nr -- '~ qk '; pfn "$@"
3931 print -nr -- '~nqk '; pfn $@
3933 = qs <spacedivdedargument
3935 =nqs <spacedivdedargument
3937 = qk <space divded argument
3939 =nqk <space divded argument
3941 ~ qs <spacedivdedargument
3958 extended testsuite based on problem by mikeserv
3960 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
3961 a='space divded argument
3963 IFS=\ ; set -- $a; IFS=
3965 print -nr -- '= qs '; pfn "$qs"
3966 print -nr -- '~ qs '; pfn "$*"
3968 print -nr -- '=nqs '; pfn "$nqs"
3969 print -nr -- '~nqs '; pfn $*
3971 print -nr -- '= qk '; pfn "$qk"
3972 print -nr -- '~ qk '; pfn "$@"
3974 print -nr -- '=nqk '; pfn "$nqk"
3975 print -nr -- '~nqk '; pfn $@
3977 = qs <spacedivdedargument
3979 ~ qs <spacedivdedargument
3981 =nqs <spacedivdedargument
3987 = qk <space divded argument
3993 =nqk <space divded argument
4000 name: IFS-subst-4-4p
4002 extended testsuite based on problem by mikeserv
4004 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4005 a='space divded argument
4007 IFS=\ ; set -- $a; IFS=
4010 print -nr -- '= qs '; pfn "$qs"
4011 print -nr -- '~ qs '; pfn ${v:-"$*"}
4013 print -nr -- '=nqs '; pfn "$nqs"
4014 print -nr -- '~nqs '; pfn ${v:-$*}
4016 print -nr -- '= qk '; pfn "$qk"
4017 print -nr -- '~ qk '; pfn ${v:-"$@"}
4019 print -nr -- '=nqk '; pfn "$nqk"
4020 print -nr -- '~nqk '; pfn ${v:-$@}
4022 = qs <spacedivdedargument
4024 ~ qs <spacedivdedargument
4026 =nqs <spacedivdedargument
4032 = qk <space divded argument
4038 =nqk <space divded argument
4047 extended testsuite based on problem by mikeserv
4049 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4050 a='space divded argument
4052 IFS=\ ; set -- $a; IFS=,
4054 print -nr -- '= qs '; pfn "$qs"
4055 print -nr -- '~ qs '; pfn "$*"
4057 print -nr -- '=nqs '; pfn "$nqs"
4058 print -nr -- '~nqs '; pfn $*
4060 print -nr -- '= qk '; pfn "$qk"
4061 print -nr -- '~ qk '; pfn "$@"
4063 print -nr -- '=nqk '; pfn "$nqk"
4064 print -nr -- '~nqk '; pfn $@
4066 = qs <space,divded,argument
4068 ~ qs <space,divded,argument
4070 =nqs <space,divded,argument
4076 = qk <space divded argument
4082 =nqk <space divded argument
4089 name: IFS-subst-4-5p
4091 extended testsuite based on problem by mikeserv
4093 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4094 a='space divded argument
4096 IFS=\ ; set -- $a; IFS=,
4099 print -nr -- '= qs '; pfn "$qs"
4100 print -nr -- '~ qs '; pfn ${v:-"$*"}
4102 print -nr -- '=nqs '; pfn "$nqs"
4103 print -nr -- '~nqs '; pfn ${v:-$*}
4105 print -nr -- '= qk '; pfn "$qk"
4106 print -nr -- '~ qk '; pfn ${v:-"$@"}
4108 print -nr -- '=nqk '; pfn "$nqk"
4109 print -nr -- '~nqk '; pfn ${v:-$@}
4111 = qs <space,divded,argument
4113 ~ qs <space,divded,argument
4115 =nqs <space,divded,argument
4121 = qk <space divded argument
4127 =nqk <space divded argument
4136 extended testsuite based on IFS-subst-3
4137 differs slightly from ksh93:
4138 - omit trailing field in a3zna, a7ina (unquoted $@ expansion)
4139 - has extra middle fields in b5ins, b7ina (IFS_NWS unquoted expansion)
4140 differs slightly from bash:
4141 - omit leading field in a5ins, a7ina (IFS_NWS unquoted expansion)
4142 differs slightly from zsh:
4143 - differs in assignment, not expansion; probably zsh bug
4144 - has extra middle fields in b5ins, b7ina (IFS_NWS unquoted expansion)
4145 'emulate sh' zsh has extra fields in
4146 - a5ins (IFS_NWS unquoted $*)
4147 - b5ins, matching mksh’s
4148 !!WARNING!! more to come: http://austingroupbugs.net/view.php?id=888
4150 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4151 IFS=; set -- "" 2 ""; pfb $*; x=$*; pfn "$x"'
4153 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4154 IFS=; set -- "" 2 ""; pfb "$*"; x="$*"; pfn "$x"'
4156 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4157 IFS=; set -- "" 2 ""; pfb $@; x=$@; pfn "$x"'
4159 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4160 IFS=; set -- "" 2 ""; pfb "$@"; x="$@"; pfn "$x"'
4162 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4163 IFS=,; set -- "" 2 ""; pfb $*; x=$*; pfn "$x"'
4165 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4166 IFS=,; set -- "" 2 ""; pfb "$*"; x="$*"; pfn "$x"'
4168 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4169 IFS=,; set -- "" 2 ""; pfb $@; x=$@; pfn "$x"'
4171 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4172 IFS=,; set -- "" 2 ""; pfb "$@"; x="$@"; pfn "$x"'
4174 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4175 IFS=; set -- A B "" "" C; pfb $*; x=$*; pfn "$x"'
4177 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4178 IFS=; set -- A B "" "" C; pfb "$*"; x="$*"; pfn "$x"'
4180 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4181 IFS=; set -- A B "" "" C; pfb $@; x=$@; pfn "$x"'
4183 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4184 IFS=; set -- A B "" "" C; pfb "$@"; x="$@"; pfn "$x"'
4186 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4187 IFS=,; set -- A B "" "" C; pfb $*; x=$*; pfn "$x"'
4189 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4190 IFS=,; set -- A B "" "" C; pfb "$*"; x="$*"; pfn "$x"'
4192 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4193 IFS=,; set -- A B "" "" C; pfb $@; x=$@; pfn "$x"'
4195 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4196 IFS=,; set -- A B "" "" C; pfb "$@"; x="$@"; pfn "$x"'
4274 Regression wrt. vector expansion in trim
4276 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4286 ksh93 bug wrt. vector expansion in trim
4288 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4292 showargs "$*" ${a##"$*"}
4298 http://austingroupbugs.net/view.php?id=221
4300 n() { echo "$#"; }; n "${foo-$@}"
4306 Scalar context for $*/$@ in [[ and case
4308 "$__progname" -c 'IFS=; set a b; [[ $* = "$1$2" ]]; echo 1 $?' sh a b
4309 "$__progname" -c 'IFS=; [[ $* = ab ]]; echo 2 "$?"' sh a b
4310 "$__progname" -c 'IFS=; [[ "$*" = ab ]]; echo 3 "$?"' sh a b
4311 "$__progname" -c 'IFS=; [[ $* = a ]]; echo 4 "$?"' sh a b
4312 "$__progname" -c 'IFS=; [[ "$*" = a ]]; echo 5 "$?"' sh a b
4313 "$__progname" -c 'IFS=; [[ "$@" = a ]]; echo 6 "$?"' sh a b
4314 "$__progname" -c 'IFS=; case "$@" in a) echo 7 a;; ab) echo 7 b;; a\ b) echo 7 ok;; esac' sh a b
4315 "$__progname" -c 'IFS=; case $* in a) echo 8 a;; ab) echo 8 ok;; esac' sh a b
4316 "$__progname" -c 'pfsp() { for s_arg in "$@"; do print -nr -- "<$s_arg> "; done; print .; }; IFS=; star=$* at="$@"; pfsp 9 "$star" "$at"' sh a b
4330 http://austingroupbugs.net/view.php?id=832
4332 ${ZSH_VERSION+false} || emulate sh
4333 ${BASH_VERSION+set -o posix}
4334 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4336 showargs $((1230456))
4340 name: integer-base-err-1
4342 Can't have 0 base (causes shell to exit)
4343 expected-exit: e != 0
4349 expected-stderr-pattern:
4352 name: integer-base-err-2
4354 Can't have multiple bases in a 'constant' (causes shell to exit)
4355 (ksh88 fails this test)
4356 expected-exit: e != 0
4362 expected-stderr-pattern:
4363 /^.*:.*2#110#11.*\n$/
4365 name: integer-base-err-3
4367 Syntax errors in expressions and effects on bases
4368 (interactive so errors don't cause exits)
4369 (ksh88 fails this test - shell exits, even with -i)
4373 PS1= # minimise prompt hassles
4380 expected-stderr-pattern:
4381 /^([#\$] )?.*:.*2+.*\n.*:.*2+.*\n$/
4386 name: integer-base-err-4
4388 Are invalid digits (according to base) errors?
4389 (ksh93 fails this test)
4390 expected-exit: e != 0
4394 expected-stderr-pattern:
4395 /^([#\$] )?.*:.*3#4.*\n$/
4397 name: integer-base-1
4399 Missing number after base is treated as 0.
4408 name: integer-base-2
4410 Check 'stickyness' of base in various situations
4461 name: integer-base-3
4463 More base parsing (hmm doesn't test much..)
4483 name: integer-base-4
4485 Check that things not declared as integers are not made integers,
4486 also, check if base is not reset by -i with no arguments.
4487 (ksh93 fails - prints 10#20 - go figure)
4491 typeset -i | grep '^xx='
4498 name: integer-base-5
4514 for l in 1 2+3 4; do echo $l; done
4526 name: integer-base-6
4528 Even more base stuff
4529 (ksh93 fails this test - prints 0)
4537 name: integer-base-7
4539 Check that non-integer parameters don't get bases assigned
4541 echo $(( zz = 8#100 ))
4547 name: integer-base-8
4549 Check that base-36 works (full span)
4551 echo 1:$((36#109AZ)).
4552 typeset -i36 x=1691675
4561 name: integer-base-check-flat
4563 Check behaviour does not match POSuX (except if set -o posix),
4564 because a not type-safe scripting language has *no* business
4565 interpreting the string "010" as octal numer eight (dangerous).
4567 echo 1 "$("$__progname" -c 'echo :$((10))/$((010)),$((0x10)):')" .
4568 echo 2 "$("$__progname" -o posix -c 'echo :$((10))/$((010)),$((0x10)):')" .
4569 echo 3 "$("$__progname" -o sh -c 'echo :$((10))/$((010)),$((0x10)):')" .
4575 name: integer-base-check-numeric-from
4577 Check behaviour for base one to 36, and that 37 degrades to 10
4581 while (( ++i <= 37 )); do
4582 eval 'echo '$i':$(('$i'#10)).'
4584 echo 37:$($__progname -c 'echo $((37#10))').$?:
4625 name: integer-base-check-numeric-to
4627 Check behaviour for base one to 36, and that 37 degrades to 10
4630 while (( ++i <= 37 )); do
4631 typeset -Uui$i x=0x40
4632 eval "typeset -i10 y=$x"
4674 name: integer-arithmetic-span
4676 Check wraparound and size that is defined in mksh
4679 echo s:$((2147483647+1)).$(((2147483647*2)+1)).$(((2147483647*2)+2)).
4680 echo u:$((#2147483647+1)).$((#(2147483647*2)+1)).$((#(2147483647*2)+2)).
4683 u:2147483648.4294967295.0.
4685 name: integer-arithmetic-span-64
4687 Check wraparound and size that is defined in mksh
4690 echo s:$((9223372036854775807+1)).$(((9223372036854775807*2)+1)).$(((9223372036854775807*2)+2)).
4691 echo u:$((#9223372036854775807+1)).$((#(9223372036854775807*2)+1)).$((#(9223372036854775807*2)+2)).
4693 s:-9223372036854775808.-1.0.
4694 u:9223372036854775808.18446744073709551615.0.
4696 name: integer-size-FAIL-to-detect
4698 Notify the user that their ints are not 32 or 64 bit
4705 See if $LINENO is updated and can be modified.
4718 See if $LINENO is set for .'d files.
4719 file-setup: file 644 "dotfile"
4737 See if $LINENO is set for commands in a function.
4756 See if unsetting LINENO makes it non-magic.
4757 file-setup: file 644 "dotfile"
4780 name: lineno-unset-use
4782 See if unsetting LINENO makes it non-magic even
4784 file-setup: file 644 "dotfile"
4810 Check if LINENO is tracked in traps
4816 trap 'fail $LINENO' INT ERR
4824 Ensure unknown traps are not a syntax error
4827 trap "echo trap 1 executed" UNKNOWNSIGNAL || echo "foo"
4829 trap "echo trap 2 executed" UNKNOWNSIGNAL EXIT 999999 FNORD
4831 ) 2>&1 | sed "s
\ 1^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]
\ 1PROG
\ 1"
4833 PROG: trap: bad signal 'UNKNOWNSIGNAL'
4836 PROG: trap: bad signal 'UNKNOWNSIGNAL'
4837 PROG: trap: bad signal '999999'
4838 PROG: trap: bad signal 'FNORD'
4844 Simple test, default IFS
4849 echo 1: "x[$x] y[$y] z[$z]"
4850 echo 1a: ${z-z not set}
4860 Complex tests, IFS either colon (IFS-NWS) or backslash (tricky)
4863 showargs() { print -nr "$1"; shift; for s_arg in "$@"; do print -nr -- " [$s_arg]"; done; print; }
4864 (IFS=\\ a=\<\\\>; showargs 3 $a)
4865 (IFS=: b=\<:\>; showargs 4 $b)
4866 print -r '<\>' | (IFS=\\ read f g; showargs 5 "$f" "$g")
4867 print -r '<\\>' | (IFS=\\ read f g; showargs 6 "$f" "$g")
4868 print '<\\\n>' | (IFS=\\ read f g; showargs 7 "$f" "$g")
4869 print -r '<\>' | (IFS=\\ read f; showargs 8 "$f")
4870 print -r '<\\>' | (IFS=\\ read f; showargs 9 "$f")
4871 print '<\\\n>' | (IFS=\\ read f; showargs 10 "$f")
4872 print -r '<\>' | (IFS=\\ read -r f g; showargs 11 "$f" "$g")
4873 print -r '<\\>' | (IFS=\\ read -r f g; showargs 12 "$f" "$g")
4874 print '<\\\n>' | (IFS=\\ read -r f g; showargs 13 "$f" "$g")
4875 print -r '<\>' | (IFS=\\ read -r f; showargs 14 "$f")
4876 print -r '<\\>' | (IFS=\\ read -r f; showargs 15 "$f")
4877 print '<\\\n>' | (IFS=\\ read -r f; showargs 16 "$f")
4878 print -r '<:>' | (IFS=: read f g; showargs 17 "$f" "$g")
4879 print -r '<::>' | (IFS=: read f g; showargs 18 "$f" "$g")
4880 print '<:\n>' | (IFS=: read f g; showargs 19 "$f" "$g")
4881 print -r '<:>' | (IFS=: read f; showargs 20 "$f")
4882 print -r '<::>' | (IFS=: read f; showargs 21 "$f")
4883 print '<:\n>' | (IFS=: read f; showargs 22 "$f")
4884 print -r '<:>' | (IFS=: read -r f g; showargs 23 "$f" "$g")
4885 print -r '<::>' | (IFS=: read -r f g; showargs 24 "$f" "$g")
4886 print '<:\n>' | (IFS=: read -r f g; showargs 25 "$f" "$g")
4887 print -r '<:>' | (IFS=: read -r f; showargs 26 "$f")
4888 print -r '<::>' | (IFS=: read -r f; showargs 27 "$f")
4889 print '<:\n>' | (IFS=: read -r f; showargs 28 "$f")
4920 If no var specified, REPLY is used
4928 name: read-regress-1
4930 Check a regression of read
4931 file-setup: file 644 "foo"
4936 while read a b c; do
4940 echo "<$a|$b|$c><$d>"
4946 Check read with delimiters
4949 print -n 'foo bar\tbaz\nblah \0blub\tblech\nmyok meck \0'
4951 emit | while IFS= read -d "" foo; do print -r -- "<$foo>"; done
4952 emit | while read -d "" foo; do print -r -- "<$foo>"; done
4953 emit | while read -d "eh?" foo; do print -r -- "<$foo>"; done
4970 Check read with number of bytes specified, and -A
4972 print 'foo\nbar' >x1
4974 print 'foo\\ bar baz' >x3
4976 x1b=u; read -N-1 x1b <x1
4977 x2a=u; read x2a <x2; r2a=$?
4978 x2b=u; read -N2 x2c <x2; r2b=$?
4979 x2c=u; read -n2 x2c <x2; r2c=$?
4980 x3a=u; read -A x3a <x3
4981 print -r "x1a=<$x1a>"
4982 print -r "x1b=<$x1b>"
4983 print -r "x2a=$r2a<$x2a>"
4984 print -r "x2b=$r2b<$x2b>"
4985 print -r "x2c=$r2c<$x2c>"
4986 print -r "x3a=<${x3a[0]}|${x3a[1]}|${x3a[2]}>"
4998 Lex array code had problems with this.
5009 When PATH is set before running a command, the new path is
5010 not used in doing the path search
5011 $ echo echo hi > /tmp/q ; chmod a+rx /tmp/q
5015 in comexec() the two lines
5017 (void) typeset(*vp++, xxx, 0);
5018 need to be moved out of the switch to before findcom() is
5019 called - I don't know what this will break.
5021 : "${PWD:-`pwd 2> /dev/null`}"
5022 : "${PWD:?"PWD not set - can't do test"}"
5024 cat > Y/xxxscript << EOF
5026 # Need to restore path so echo can be found (some shells don't have
5032 chmod a+rx Y/xxxscript
5033 export OLDPATH="$PATH"
5034 PATH=$PWD/Y xxxscript
5041 Parsing of $(..) expressions is non-optimal. It is
5042 impossible to have any parentheses inside the expression.
5044 $ ksh -c 'echo $(echo \( )'
5046 $ ksh -c 'echo $(echo "(" )'
5049 The solution is to hack the parsing clode in lex.c, the
5050 question is how to hack it: should any parentheses be
5051 escaped by a backslash, or should recursive parsing be done
5052 (so quotes could also be used to hide hem). The former is
5053 easier, the later better...
5063 Continue in a for loop does not work right:
5065 if [ $i = b ] ; then
5074 if [ $i = b ] ; then
5075 if [ $first = no ] ; then
5076 echo 'continue in for loop broken'
5077 break # hope break isn't broken too :-)
5092 should print 0 according to POSIX (dash, bash, ksh93, posh)
5093 but not 0 according to the getopt(1) manual page, ksh88, and
5094 Bourne sh (such as /bin/sh on Solaris).
5095 We honour POSIX except when -o sh is set.
5096 category: shell:legacy-no
5099 [[ -o posix ]]; FPOSIX=$((1-$?))
5100 [[ -o sh ]]; FSH=$((1-$?))
5101 echo -n "FPOSIX=$FPOSIX FSH=$FSH "
5125 name: regression-10-legacy
5130 should print 0 according to POSIX (dash, bash, ksh93, posh)
5131 but not 0 according to the getopt(1) manual page, ksh88, and
5132 Bourne sh (such as /bin/sh on Solaris).
5133 category: shell:legacy-yes
5136 [[ -o posix ]]; FPOSIX=$((1-$?))
5137 [[ -o sh ]]; FSH=$((1-$?))
5138 echo -n "FPOSIX=$FPOSIX FSH=$FSH "
5167 should echo blah but on some machines echos /foo/bar/blah.
5176 Both of the following echos produce the same output under sh/ksh.att:
5179 echo "`echo \"$x\"`"
5181 pdksh produces different output for the former (foo instead of foo\tbar)
5184 echo "`echo \"$x\"`"
5192 The following command hangs forever:
5193 $ (: ; cat /etc/termcap) | sleep 2
5194 This is because the shell forks a shell to run the (..) command
5195 and this shell has the pipe open. When the sleep dies, the cat
5196 doesn't get a SIGPIPE 'cause a process (ie, the second shell)
5197 still has the pipe open.
5199 NOTE: this test provokes a bizarre bug in ksh93 (shell starts reading
5200 commands from /etc/termcap..)
5203 echo A line of text that will be duplicated quite a number of times.> t1
5204 cat t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 > t2
5205 cat t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 > t1
5206 cat t1 t1 t1 t1 > t2
5207 (: ; cat t2 2>/dev/null) | sleep 1
5212 $ (foobar) 2> /dev/null
5213 generates no output under /bin/sh, but pdksh produces the error
5216 $ foobar 2> /dev/null
5217 generates an error under /bin/sh and pdksh, but AT&T ksh88 produces
5218 no error (redirected to /dev/null).
5220 (you/should/not/see/this/error/1) 2> /dev/null
5221 you/should/not/see/this/error/2 2> /dev/null
5228 generates a blank line under pdksh and sets the exit status to 0.
5229 AT&T ksh88 generates no output and sets the exit status to 1. Also,
5232 generates no output under AT&T ksh88 (pdksh generates a blank line
5235 whence does/not/exist > /dev/null
5237 echo 2: $(whence does/not/exist | wc -l)
5238 echo 3: $(whence does/not/exist cat | wc -l)
5246 ${var%%expr} seems to be broken in many places. On the mips
5248 $ read line < /etc/passwd
5256 change the value of line. On sun4s & pas, the echo ${line%%:*} doesn't
5257 work. Haven't checked elsewhere...
5264 root:asdjhasdasjhs:0:1:Root:/:/bin/sh
5267 root:asdjhasdasjhs:0:1:Root:/:/bin/sh
5273 should set the exit status to non-zero (sh and AT&T ksh88 do).
5274 XXX doting a non existent file is a fatal error for a script
5277 expected-exit: e != 0
5278 expected-stderr-pattern: /.?/
5282 Both of the following echos should produce the same thing, but don't:
5296 backslash does not work as expected in case labels:
5315 Quoting backquotes inside backquotes doesn't work:
5316 $ echo `echo hi \`echo there\` folks`
5317 asks for more info. sh and AT&T ksh88 both echo
5320 echo `echo hi \`echo there\` folks`
5326 )) is not treated `correctly':
5327 $ (echo hi ; (echo there ; echo folks))
5330 instead of (as sh and ksh.att)
5331 $ (echo hi ; (echo there ; echo folks))
5337 ( : ; ( : ; echo hi))
5343 Check reading stdin in a while loop. The read should only read
5344 a single line, not a whole stdio buffer; the cat should get
5347 (echo a; echo b) | while read x ; do
5356 Check reading stdin in a while loop. The read should read both
5357 lines, not just the first.
5360 while [ "$a" != xxx ] ; do
5363 cat /dev/null | sed 's/x/y/'
5377 should cause a script to exit.
5381 expected-exit: e != 0
5382 expected-stderr-pattern: /does\/not\/exist/
5386 variable assignements not detected well
5389 expected-exit: e != 0
5390 expected-stderr-pattern: /a\.x=1/
5394 alias expansion different from AT&T ksh88
5396 alias a='for ' b='i in'
5397 a b hi ; do echo $i ; done
5403 strange characters allowed inside ${...}
5406 expected-exit: e != 0
5407 expected-stderr-pattern: /.?/
5411 Does read handle partial lines correctly
5414 while [ "$a" != xxx ] ; do
5431 Does read set variables to null at eof?
5434 while [ "$a" != xxx ] ; do
5438 echo 1: ${x-x not set} ${y-y not set} ${z-z not set}
5439 echo 2: ${x:+x not null} ${y:+y not null} ${z:+z not null}
5449 Does umask print a leading 0 when umask is 3 digits?
5451 # on MiNT, the first umask call seems to fail
5453 # now, the test proper
5461 Tempory files used for here-docs in functions get trashed after
5462 the function is parsed (before it is executed)
5485 Command substitution breaks reading in while loop
5486 (test from <sjg@void.zen.oz.au>)
5488 (echo abcdef; echo; echo 123) |
5491 # the following line breaks it
5492 c=`echo $line | wc -c`
5502 Machines with broken times() (reported by <sjg@void.zen.oz.au>)
5503 time does not report correct real time
5506 expected-stderr-pattern: !/^\s*0\.0[\s\d]+real|^\s*real[\s]+0+\.0/
5510 set -e doesn't ignore exit codes for if/while/until/&&/||/!.
5513 if false; then echo hi ; fi
5516 while false; do echo hi; done
5523 Only posh and oksh(2013-07) say “hi” below; FreeBSD sh,
5524 GNU bash in POSIX mode, dash, ksh93, mksh don’t. All of
5525 them exit 0. The POSIX behaviour is needed by BSD make.
5528 echo `false; echo hi` $(<this-file-does-not-exist)
5533 expected-stderr-pattern: /this-file-does-not-exist/
5537 This used to cause a core dump
5538 env-setup: !RANDOM=12!
5546 foo should be set to bar (should not be empty)
5556 Can't use command line assignments to assign readonly parameters.
5558 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
5559 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
5560 done >env; chmod +x env; PATH=.$PATHSEP$PATH
5563 foo=stuff env | grep '^foo'
5564 expected-exit: e != 0
5565 expected-stderr-pattern:
5570 Can subshells be prefixed by redirections (historical shells allow
5573 < /dev/null (sed 's/^/X/')
5577 Parameter assignments with [] recognised correctly
5595 Check that alias expansion works in command substitutions and
5608 Check that aliases are fully read.
5621 Check that (here doc) temp files are not left behind after an exec.
5624 TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
5626 sed 's/^/X /' << E_O_F
5633 echo=echo; [ -x /bin/echo ] && echo=/bin/echo
5634 exec $echo subtest-1 hi
5636 echo subtest-1 foo/*
5637 TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
5638 echo=echo; [ -x /bin/echo ] && echo=/bin/echo
5639 sed 's/^/X /' << E_O_F; exec $echo subtest-2 hi
5645 echo subtest-2 foo/*
5657 Check that unset params with attributes are reported by set, those
5658 sans attributes are not.
5674 Check that aliases do not use continuation prompt after trailing
5676 file-setup: file 644 "envf"
5679 env-setup: !ENV=./envf!
5683 alias foo='echo hi ; '
5695 Check that set allows both +o and -o options on same command line.
5698 set -o noglob +o allexport
5705 Check that globbing works in pipelined commands
5706 file-setup: file 644 "envf"
5708 file-setup: file 644 "abc"
5710 env-setup: !ENV=./envf!
5716 sed 's/^/X /' < ab* | sed 's/^/Y /'
5728 Check that getopts works in functions
5731 echo bfunc: enter "(args: $*; OPTIND=$OPTIND)"
5732 while getopts B oc; do
5735 echo bfunc: B option
5738 echo bfunc: odd option "($oc)"
5746 echo kfunc: enter "(args: $*; OPTIND=$OPTIND)"
5747 while getopts K oc; do
5750 echo kfunc: K option
5753 echo bfunc: odd option "($oc)"
5761 echo "line 1: OPTIND=$OPTIND"
5763 echo "line 2: ret=$?, optc=$optc, OPTIND=$OPTIND"
5765 echo "line 3: OPTIND=$OPTIND"
5767 echo "line 4: ret=$?, optc=$optc, OPTIND=$OPTIND"
5769 echo "line 5: OPTIND=$OPTIND"
5771 echo "line 6: ret=$?, optc=$optc, OPTIND=$OPTIND"
5776 echo "line 10: OPTIND=$OPTIND"
5778 echo "line 20: ret=$?, optc=$optc, OPTIND=$OPTIND"
5780 echo "line 30: OPTIND=$OPTIND"
5782 echo "line 40: ret=$?, optc=$optc, OPTIND=$OPTIND"
5784 echo "line 50: OPTIND=$OPTIND"
5786 echo "line 60: ret=$?, optc=$optc, OPTIND=$OPTIND"
5789 line 2: ret=0, optc=f, OPTIND=2
5790 bfunc: enter (args: -BBB blah; OPTIND=2)
5795 line 4: ret=0, optc=b, OPTIND=3
5796 kfunc: enter (args: -KKK blah; OPTIND=1)
5802 line 6: ret=0, optc=k, OPTIND=4
5805 line 20: ret=0, optc=f, OPTIND=2
5806 bfunc: enter (args: -BBB blah; OPTIND=2)
5811 line 40: ret=1, optc=?, OPTIND=2
5812 kfunc: enter (args: -KKK blah; OPTIND=1)
5818 line 60: ret=1, optc=?, OPTIND=2
5822 Check that ; is not required before the then in if (( ... )) then ...
5836 Check ${foo:%bar} is allowed (ksh88 allows it...)
5859 Check if typeset output is correct for
5860 uninitialised array elements.
5864 typeset -i | grep xxx | sed 's/^/ /'
5866 typeset | grep xxx | sed 's/^/ /'
5870 typeset -i | grep xxx | sed 's/^/ /'
5872 typeset | grep xxx | sed 's/^/ /'
5886 Check if trap exit is ok (exit not mistaken for signal name)
5895 Check if ${#array[*]} is calculated correctly.
5905 Check if default exit status is previous command
5911 ( (exit 103) ; exit)
5920 Check if EXIT trap is executed for sub shells.
5922 trap 'echo parent exit' EXIT
5924 (echo A; echo A last)
5926 (echo C; trap 'echo sub exit' EXIT; echo C last)
5941 Check if test -nt/-ot succeeds if second(first) file is missing.
5944 test a -nt b && echo nt OK || echo nt BAD
5945 test b -ot a && echo ot OK || echo ot BAD
5952 Check if typeset, export, and readonly work
5964 integer FNORD_E FNORD_F FNORD_G FNORD_H
5965 export FNORD_C FNORD_D FNORD_G FNORD_H
5966 readonly FNORD_B FNORD_D FNORD_F FNORD_H
6012 typeset -x -r FNORD_D
6014 typeset -i -r FNORD_F
6015 typeset -i -x FNORD_G
6016 typeset -i -x -r FNORD_H
6019 typeset -r FNORD_B=2
6020 typeset -x FNORD_C=3
6021 typeset -x -r FNORD_D=4
6022 typeset -i FNORD_E=5
6023 typeset -i -r FNORD_F=6
6024 typeset -i -x FNORD_G=7
6025 typeset -i -x -r FNORD_H=8
6043 Check that we can redefine functions calling time builtin
6055 check for a regression with sleep builtin and signal mask
6061 while read -p line; do :; done
6068 Check that quoting is sane
6076 while IFS= read -pr line; do
6077 if [[ $line = *space* ]]; then
6083 for line in "${lines[@]}"; do
6092 Ensure readonly is honoured for assignments and unset
6094 "$__progname" -c 'u=x; echo $? $u .' || echo aborted, $?
6096 "$__progname" -c 'readonly u; u=x; echo $? $u .' || echo aborted, $?
6098 "$__progname" -c 'u=x; readonly u; unset u; echo $? $u .' || echo aborted, $?
6105 expected-stderr-pattern:
6110 http://austingroupbugs.net/view.php?id=367 for export
6112 "$__progname" -c 'readonly foo; export foo=a; echo $?' || echo aborted, $?
6115 expected-stderr-pattern:
6120 Check that getopts works as intended, for readonly-2b to be valid
6122 "$__progname" -c 'set -- -a b; getopts a c; echo $? $c .; getopts a c; echo $? $c .' || echo aborted, $?
6129 http://austingroupbugs.net/view.php?id=367 for getopts
6131 "$__progname" -c 'readonly c; set -- -a b; getopts a c; echo $? $c .' || echo aborted, $?
6134 expected-stderr-pattern:
6139 http://austingroupbugs.net/view.php?id=367 for read
6141 echo x | "$__progname" -c 'read s; echo $? $s .' || echo aborted, $?
6142 echo y | "$__progname" -c 'readonly s; read s; echo $? $s .' || echo aborted, $?
6146 expected-stderr-pattern:
6151 Do not permit bypassing readonly for first array item
6153 set -A arr -- foo bar
6156 print -r -- "${arr[@]}"
6157 expected-exit: e != 0
6158 expected-stderr-pattern:
6163 Check that lone ampersand is a syntax error
6166 expected-exit: e != 0
6167 expected-stderr-pattern:
6170 name: xxx-quoted-newline-1
6172 Check that \<newline> works inside of ${}
6180 name: xxx-quoted-newline-2
6182 Check that \<newline> works at the start of a here document
6191 name: xxx-quoted-newline-3
6193 Check that \<newline> works at the end of a here document
6202 name: xxx-multi-assignment-cmd
6204 Check that assignments in a command affect subsequent assignments
6213 name: xxx-multi-assignment-posix-cmd
6215 Check that the behaviour for multiple assignments with a
6216 command name matches POSIX. See:
6217 http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925
6219 X=a Y=b; X=$Y Y=$X "$__progname" -c 'echo 1 $X $Y .'; echo 2 $X $Y .
6221 X=a Y=${X=b} Z=$X "$__progname" -c 'echo 3 $Z .'
6223 X=a Y=${X=b} Z=$X; echo 4 $Z .
6230 name: xxx-multi-assignment-posix-nocmd
6232 Check that the behaviour for multiple assignments with no
6233 command name matches POSIX (Debian #334182). See:
6234 http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925
6236 X=a Y=b; X=$Y Y=$X; echo 1 $X $Y .
6240 name: xxx-multi-assignment-posix-subassign
6242 Check that the behaviour for multiple assignments matches POSIX:
6243 - The assignment words shall be expanded in the current execution
6245 - The assignments happen in the temporary execution environment.
6248 Z=a Y=${X:=b} sh -c 'echo +$X+ +$Y+ +$Z+'
6250 # Now for the special case:
6252 X= Y=${X:=b} sh -c 'echo +$X+ +$Y+'
6260 name: xxx-exec-environment-1
6262 Check to see if exec sets it's environment correctly
6264 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
6265 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
6266 done >env; chmod +x env; PATH=.$PATHSEP$PATH
6268 expected-stdout-pattern:
6271 name: xxx-exec-environment-2
6273 Check to make sure exec doesn't change environment if a program
6276 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
6277 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
6278 done >env; chmod +x env; PATH=.$PATHSEP$PATH
6280 FOO=bar exec; env >bar2
6283 name: exec-function-environment-1
6285 Check assignments in function calls and whether they affect
6286 the current execution environment (ksh93, SUSv4)
6288 f() { a=2; }; g() { b=3; echo y$c-; }; a=1 f; b=2; c=1 g
6294 name: xxx-what-do-you-call-this-1
6300 name: xxx-prefix-strip-1
6307 name: xxx-prefix-strip-2
6315 name: xxx-variable-syntax-1
6318 expected-stderr-pattern:
6322 name: xxx-variable-syntax-2
6326 expected-stderr-pattern:
6330 name: xxx-variable-syntax-3
6334 expected-stderr-pattern:
6338 name: xxx-substitution-eval-order
6340 Check order of evaluation of expressions
6343 set -A A abc def GHI j G k
6344 echo ${A[x=(i+=1)]#${A[y=(i+=2)]}}
6350 name: xxx-set-option-1
6352 Check option parsing in set
6354 set -vsA foo -- A 1 3 2
6363 Check that exec exits for built-ins
6371 expected-stderr-pattern: /.*/
6375 Check the return value of while loops
6376 XXX need to do same for for/select/until loops
6379 while [ $i != xxx ] ; do
6381 if [ $i = xxx ] ; then
6389 while [ $i != xxx ] ; do
6391 if [ $i = xxx ] ; then
6399 while [ $i != xxx ] ; do
6411 Check that blank lines don't clear $?
6424 expected-stderr-pattern: /.*/
6428 Check that $? is preserved in subshells, includes, traps.
6437 echo 'echo include: $?' > foo
6441 trap 'echo trap: $?' ERR
6451 name: xxx-clean-chars-1
6453 Check MAGIC character is stuffed correctly
6459 name: xxx-param-subst-qmark-1
6461 Check suppresion of error message with null string. According to
6462 POSIX, it shouldn't print the error as 'word' isn't ommitted.
6463 ksh88/93, Solaris /bin/sh and /usr/xpg4/bin/sh all print the error,
6464 that's why the condition is reversed.
6472 #expected-stderr-pattern: !/not set/
6474 expected-stderr-pattern: /parameter null or not set/
6477 # fails due to weirdness of execv stuff
6478 category: !os:uwin-nt
6480 Check c flag is set.
6481 arguments: !-c!echo "[$-]"!
6482 expected-stdout-pattern: /^\[.*c.*\]$/
6484 name: tilde-expand-1
6486 Check tilde expansion after equal signs
6487 env-setup: !HOME=/sweet!
6489 echo ${A=a=}~ b=~ c=d~ ~
6492 echo ${A=a=}~ b=~ c=d~ ~
6494 a=/sweet b=/sweet c=d~ /sweet
6497 name: tilde-expand-2
6499 Check tilde expansion works
6500 env-setup: !HOME=/sweet!
6504 plus=$(print -r -- ~+)
6505 minus=$(print -r -- ~-)
6506 nix=$(print -r -- ~)
6507 [[ $plus = / ]]; echo one $? .
6508 [[ $minus = "$wd" ]]; echo two $? .
6509 [[ $nix = /sweet ]]; echo nix $? .
6517 Check some "exit on error" conditions
6519 print '#!'"$__progname"'\nexec "$1"' >env
6520 print '#!'"$__progname"'\nexit 1' >false
6524 env false && echo something
6534 Check some "exit on error" edge conditions (POSIXly)
6536 print '#!'"$__progname"'\nexec "$1"' >env
6537 print '#!'"$__progname"'\nexit 1' >false
6538 print '#!'"$__progname"'\nexit 0' >true
6543 env false && echo something
6555 pdksh regression which AT&T ksh does right
6556 TFM says: [set] -e | errexit
6557 Exit (after executing the ERR trap) ...
6559 trap 'echo EXIT' EXIT
6562 cd /XXXXX 2>/dev/null
6568 expected-exit: e != 0
6572 "set -e" test suite (POSIX)
6586 "set -e" test suite (POSIX)
6592 [ "$1" = "$E" ] && { shift ; continue 2 ; }
6609 "set -e" test suite (BSD make)
6613 print 'all:\n\t@echo eins\n\t@exit 42\n' >zd/a/Makefile
6614 print 'all:\n\t@echo zwei\n' >zd/b/Makefile
6617 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"
6623 Stop in WD/zd/a (line 2 of Makefile).
6627 "set -e" regression (LP#1104543)
6631 [ -x $PWD/nonexistant ] && $PWD/nonexistant
6642 "set -e" regression (Debian #700526)
6645 _db_cmd() { return $1; }
6646 db_input() { _db_cmd 30; }
6647 db_go() { _db_cmd 0; }
6654 SUSv4 says that the shell should exit with 126/127 in some situations
6658 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6659 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6661 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6662 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6664 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6665 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6676 Check eval vs substitution exit codes (ksh93 alike)
6688 eval "eval $(false)"
6691 eval 'eval '"$(false)"
6695 eval $(echo :; false)
6713 Check that "exit" with no arguments behaves SUSv4 conformant.
6715 trap 'echo hi; exit' EXIT
6723 Check that ERR and EXIT traps are run just like ksh93 does.
6724 GNU bash does not run ERtrap in ±e eval-undef but runs it
6725 twice (bug?) in +e eval-false, so does ksh93 (bug?), which
6726 also has a bug to continue execution (echoing "and out" and
6727 returning 0) in +e eval-undef.
6728 file-setup: file 644 "x"
6730 trap 'echo EXtrap' EXIT
6731 trap 'echo ERtrap' ERR
6736 file-setup: file 644 "xt"
6738 trap 'echo EXtrap' EXIT
6739 trap 'echo ERtrap' ERR
6744 file-setup: file 644 "xf"
6746 trap 'echo EXtrap' EXIT
6747 trap 'echo ERtrap' ERR
6749 echo 'and run false'
6752 file-setup: file 644 "xu"
6754 trap 'echo EXtrap' EXIT
6755 trap 'echo ERtrap' ERR
6757 echo 'and run ${v?}'
6767 -e 's/parameter not set/parameter null or not set/' \
6768 -e 's/[[]6]//' -e 's/: eval: line 1//' -e 's/: line 6//' \
6769 -e "s
\ 1^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]
\ 1PROG
\ 1"
6774 echo = eval-true $(<rc) .
6776 echo = eval-false $(<rc) .
6777 runtest x $xe '${v?}'
6778 echo = eval-undef $(<rc) .
6780 echo = noeval-true $(<rc) .
6782 echo = noeval-false $(<rc) .
6784 echo = noeval-undef $(<rc) .
6788 echo = eval-true $(<rc) .
6790 echo = eval-false $(<rc) .
6791 runtest x $xe '${v?}'
6792 echo = eval-undef $(<rc) .
6794 echo = noeval-true $(<rc) .
6796 echo = noeval-false $(<rc) .
6798 echo = noeval-undef $(<rc) .
6810 x: v: parameter null or not set
6823 xu: v: parameter null or not set
6837 x: v: parameter null or not set
6851 xu: v: parameter null or not set
6855 name: exit-trap-interactive
6857 Check that interactive shell doesn't exit via EXIT trap on syntax error
6862 echo 'After error 1'
6863 trap 'echo Exit trap' EXIT
6865 echo 'After error 2'
6866 trap 'echo Exit trap' EXIT
6873 expected-stderr-pattern:
6874 /syntax error: 'newline' unexpected/
6878 Check that test also can handle string1 < string2 etc.
6880 test 2005/10/08 '<' 2005/08/21 && echo ja || echo nein
6881 test 2005/08/21 \< 2005/10/08 && echo ja || echo nein
6882 test 2005/10/08 '>' 2005/08/21 && echo ja || echo nein
6883 test 2005/08/21 \> 2005/10/08 && echo ja || echo nein
6889 expected-stderr-pattern: !/unexpected op/
6891 name: test-precedence-1
6893 Check a weird precedence case (and POSIX echo)
6903 Test the test -o operator
6908 [[ -o $1 ]]; echo $?
6911 test -o $1 -o -o !$1; echo $?
6912 [ -o $1 -o -o !$1 ]; echo $?
6913 [[ -o $1 || -o !$1 ]]; echo $?
6914 test -o ?$1; echo $?
6916 echo 0y $(if_test utf8-mode) =
6917 echo 0n $(if_test utf8-hack) =
6918 echo 1= $(runtest utf8-hack) =
6919 echo 2= $(runtest !utf8-hack) =
6920 echo 3= $(runtest ?utf8-hack) =
6922 echo 1+ $(runtest utf8-mode) =
6923 echo 2+ $(runtest !utf8-mode) =
6924 echo 3+ $(runtest ?utf8-mode) =
6926 echo 1- $(runtest utf8-mode) =
6927 echo 2- $(runtest !utf8-mode) =
6928 echo 3- $(runtest ?utf8-mode) =
6929 echo = short flags =
6930 echo 0y $(if_test -U) =
6931 echo 0y $(if_test +U) =
6932 echo 0n $(if_test -_) =
6933 echo 0n $(if_test -U-) =
6934 echo 1= $(runtest -_) =
6935 echo 2= $(runtest !-_) =
6936 echo 3= $(runtest ?-_) =
6938 echo 1+ $(runtest -U) =
6939 echo 2+ $(runtest !-U) =
6940 echo 3+ $(runtest ?-U) =
6941 echo 1+ $(runtest +U) =
6942 echo 2+ $(runtest !+U) =
6943 echo 3+ $(runtest ?+U) =
6945 echo 1- $(runtest -U) =
6946 echo 2- $(runtest !-U) =
6947 echo 3- $(runtest ?-U) =
6948 echo 1- $(runtest +U) =
6949 echo 2- $(runtest !+U) =
6950 echo 3- $(runtest ?+U) =
6986 Check that ~/.mkshrc works correctly.
6987 Part 1: verify user environment is not read (internal)
6995 Check that ~/.mkshrc works correctly.
6996 Part 2: verify mkshrc is not read (non-interactive shells)
6997 file-setup: file 644 ".mkshrc"
6999 env-setup: !HOME=.!ENV=!
7007 Check that ~/.mkshrc works correctly.
7008 Part 2: verify mkshrc can be read (interactive shells)
7009 file-setup: file 644 ".mkshrc"
7013 env-setup: !HOME=.!ENV=!PS1=!
7018 expected-stderr-pattern:
7023 Check that ~/.mkshrc works correctly.
7024 Part 3: verify mkshrc can be turned off
7025 file-setup: file 644 ".mkshrc"
7027 env-setup: !HOME=.!ENV=nonexistant!
7035 Check that sh mode turns braceexpand off
7036 and that that works correctly
7040 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
7041 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
7049 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
7050 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
7053 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
7054 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
7070 Check that posix or sh mode is *not* automatically turned on
7073 ln -s "$__progname" ksh || cp "$__progname" ksh
7074 ln -s "$__progname" sh || cp "$__progname" sh
7075 ln -s "$__progname" ./-ksh || cp "$__progname" ./-ksh
7076 ln -s "$__progname" ./-sh || cp "$__progname" ./-sh
7077 for shell in {,-}{,k}sh; do
7078 print -- $shell $(./$shell +l -c \
7079 '[[ $(set +o) == *"-o "@(sh|posix)@(| *) ]] && echo sh || echo nosh')
7089 Check that posix or sh mode *is* automatically turned on
7092 ln -s "$__progname" ksh || cp "$__progname" ksh
7093 ln -s "$__progname" sh || cp "$__progname" sh
7094 ln -s "$__progname" ./-ksh || cp "$__progname" ./-ksh
7095 ln -s "$__progname" ./-sh || cp "$__progname" ./-sh
7096 for shell in {,-}{,k}sh; do
7097 print -- $shell $(./$shell +l -c \
7098 '[[ $(set +o) == *"-o "@(sh|posix)@(| *) ]] && echo sh || echo nosh')
7108 pdksh bug: last command of a pipeline is executed in a
7109 subshell - make sure it still is, scripts depend on it
7110 file-setup: file 644 "abcx"
7111 file-setup: file 644 "abcy"
7114 echo a | while read d; do
7134 check that co-processes work with TCOMs, TPIPEs and TPARENs
7137 "$__progname" -c 'i=100; echo hi |& while read -p line; do echo "$((i++)) $line"; done'
7138 "$__progname" -c 'i=200; echo hi | cat |& while read -p line; do echo "$((i++)) $line"; done'
7139 "$__progname" -c 'i=300; (echo hi | cat) |& while read -p line; do echo "$((i++)) $line"; done'
7147 Check that PIPESTATUS does what it's supposed to
7149 echo 1 $PIPESTATUS .
7150 echo 2 ${PIPESTATUS[0]} .
7151 echo 3 ${PIPESTATUS[1]} .
7152 (echo x; exit 12) | (cat; exit 23) | (cat; exit 42)
7153 echo 5 $? , $PIPESTATUS , ${PIPESTATUS[0]} , ${PIPESTATUS[1]} , ${PIPESTATUS[2]} , ${PIPESTATUS[3]} .
7154 echo 6 ${PIPESTATUS[0]} .
7155 set | fgrep PIPESTATUS
7156 echo 8 $(set | fgrep PIPESTATUS) .
7162 5 42 , 12 , 12 , 23 , 42 , .
7165 8 PIPESTATUS[0]=0 PIPESTATUS[1]=0 .
7169 Check that "set -o pipefail" does what it's supposed to
7171 echo 1 "$("$__progname" -c '(exit 12) | (exit 23) | (exit 42); echo $?')" .
7172 echo 2 "$("$__progname" -c '! (exit 12) | (exit 23) | (exit 42); echo $?')" .
7173 echo 3 "$("$__progname" -o pipefail -c '(exit 12) | (exit 23) | (exit 42); echo $?')" .
7174 echo 4 "$("$__progname" -o pipefail -c '! (exit 12) | (exit 23) | (exit 42); echo $?')" .
7175 echo 5 "$("$__progname" -c '(exit 23) | (exit 42) | :; echo $?')" .
7176 echo 6 "$("$__progname" -c '! (exit 23) | (exit 42) | :; echo $?')" .
7177 echo 7 "$("$__progname" -o pipefail -c '(exit 23) | (exit 42) | :; echo $?')" .
7178 echo 8 "$("$__progname" -o pipefail -c '! (exit 23) | (exit 42) | :; echo $?')" .
7179 echo 9 "$("$__progname" -o pipefail -c 'x=$( (exit 23) | (exit 42) | :); echo $?')" .
7191 name: persist-history-1
7193 Check if persistent history saving works
7194 category: !no-histfile
7197 env-setup: !ENV=./Env!HISTFILE=hist.file!
7198 file-setup: file 644 "Env"
7202 expected-stdout-pattern:
7204 expected-stderr-pattern:
7209 Check that global does what typeset is supposed to do
7213 global -Uui16 arrfoo[*]
7215 echo before ${arrfoo[0]} .
7217 echo after ${arrfoo[0]} .
7220 echo inside before ${arrbar[0]} .
7222 echo inside changed ${arrbar[0]} .
7223 global -Uui16 arrbar[*]
7224 echo inside typeset ${arrbar[0]} .
7226 echo inside changed ${arrbar[0]} .
7228 echo before ${arrbar[0]} .
7230 echo after ${arrbar[0]} .
7237 inside typeset 16#61 .
7238 inside changed 16#30 .
7241 name: typeset-padding-1
7243 Check if left/right justification works as per TFM
7245 typeset -L10 ln=0hall0
7246 typeset -R10 rn=0hall0
7247 typeset -ZL10 lz=0hall0
7248 typeset -ZR10 rz=0hall0
7249 typeset -Z10 rx=" hallo "
7250 echo "<$ln> <$rn> <$lz> <$rz> <$rx>"
7252 <0hall0 > < 0hall0> <hall0 > <00000hall0> <0000 hallo>
7254 name: typeset-padding-2
7256 Check if base-!10 integers are padded right
7258 typeset -Uui16 -L9 ln=16#1
7259 typeset -Uui16 -R9 rn=16#1
7260 typeset -Uui16 -Z9 zn=16#1
7264 echo "<$ln> <$rn> <$zn> <$ls> <$rs> <$zs>"
7266 <16#1 > < 16#1> <16#000001> <16#1 > < 16#1> <0000016#1>
7270 Check that the UTF-8 Byte Order Mark is ignored as the first
7271 multibyte character of the shell input (with -c, from standard
7272 input, as file, or as eval argument), but nowhere else
7273 # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
7274 category: !os:darwin
7277 print '#!/bin/sh\necho ohne' >foo/fnord
7278 print '#!/bin/sh\necho mit' >foo/fnord
7279 print 'fnord\nfnord\nfnord\nfnord' >foo/bar
7280 print eval \''fnord\nfnord\nfnord\nfnord'\' >foo/zoo
7281 set -A anzahl -- foo/*
7282 echo got ${#anzahl[*]} files
7284 export PATH=$(pwd)/foo$PATHSEP$PATH
7285 "$__progname" -c 'fnord'
7287 "$__progname" -c 'fnord; fnord; fnord; fnord'
7289 "$__progname" foo/bar
7291 "$__progname" <foo/bar
7293 "$__progname" foo/zoo
7295 "$__progname" -c 'echo : $(fnord)'
7325 Check that we can execute BOM-shebangs (failures not fatal)
7326 XXX if the OS can already execute them, we lose
7327 note: cygwin execve(2) doesn't return to us with ENOEXEC, we lose
7328 note: Ultrix perl5 t4 returns 65280 (exit-code 255) and no text
7329 XXX fails when LD_PRELOAD is set with -e and Perl chokes it (ASan)
7331 category: !os:cygwin,!os:msys,!os:ultrix,!os:uwin-nt,!smksh
7332 env-setup: !FOO=BAR!
7334 print '#!'"$__progname"'\nprint "1 a=$ENV{FOO}";' >t1
7335 print '#!'"$__progname"'\nprint "2 a=$ENV{FOO}";' >t2
7336 print '#!'"$__perlname"'\nprint "3 a=$ENV{FOO}\n";' >t3
7337 print '#!'"$__perlname"'\nprint "4 a=$ENV{FOO}\n";' >t4
7344 1 a=/nonexistant{FOO}
7345 2 a=/nonexistant{FOO}
7348 expected-stderr-pattern:
7349 /(Unrecognized character .... ignored at \..t4 line 1)*/
7353 Check that the utf8-mode flag is not set at non-interactive startup
7355 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8!
7357 if [[ $- = *U* ]]; then
7367 Check that the utf8-mode flag is not set at non-interactive startup
7369 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.utf8!
7371 if [[ $- = *U* ]]; then
7381 Check that the utf8-mode flag is set at interactive startup.
7382 -DMKSH_ASSUME_UTF8=0 => expected failure, please ignore
7383 -DMKSH_ASSUME_UTF8=1 => not expected, please investigate
7384 -UMKSH_ASSUME_UTF8 => not expected, but if your OS is old,
7385 try passing HAVE_SETLOCALE_CTYPE=0 to Build.sh
7387 category: !os:hpux,!os:msys
7390 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8!
7392 if [[ $- = *U* ]]; then
7399 expected-stderr-pattern:
7404 Check that the utf8-mode flag is set at interactive startup
7405 Expected failure if -DMKSH_ASSUME_UTF8=0
7409 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.utf8!
7411 if [[ $- = *U* ]]; then
7418 expected-stderr-pattern:
7423 Ensure ±U on the command line is honoured
7424 (these two tests may pass falsely depending on CPPFLAGS)
7427 code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi'
7428 let i++; "$__progname" -U -c "$code"
7429 let i++; "$__progname" +U -c "$code"
7438 Ensure ±U on the command line is honoured, interactive shells
7442 code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi'
7443 let i++; "$__progname" -U -ic "$code"
7444 let i++; "$__progname" +U -ic "$code"
7453 Check if built-in shell aliases are okay
7454 category: !android,!arge,!os:os2
7459 autoload='\typeset -fu'
7460 functions='\typeset -f'
7461 hash='\builtin alias -t'
7462 history='\builtin fc -l'
7463 integer='\typeset -i'
7466 nameref='\typeset -n'
7468 r='\builtin fc -e -'
7469 source='PATH=$PATH:. \command .'
7471 type='\builtin whence -v'
7473 name: aliases-1-hartz4
7475 Check if built-in shell aliases are okay
7476 category: android,arge
7481 autoload='\typeset -fu'
7482 functions='\typeset -f'
7483 hash='\builtin alias -t'
7484 history='\builtin fc -l'
7485 integer='\typeset -i'
7488 nameref='\typeset -n'
7490 r='\builtin fc -e -'
7491 source='PATH=$PATH:. \command .'
7492 type='\builtin whence -v'
7496 Check if built-in shell aliases are okay
7502 autoload='\typeset -fu'
7503 functions='\typeset -f'
7504 hash='\builtin alias -t'
7505 history='\builtin fc -l'
7506 integer='\typeset -i'
7509 nameref='\typeset -n'
7511 r='\builtin fc -e -'
7512 source='PATH=$PATH;. \command .'
7513 type='\builtin whence -v'
7517 Check if “set -o sh” does not influence built-in aliases
7518 category: !android,!arge,!os:os2
7524 autoload='\typeset -fu'
7525 functions='\typeset -f'
7526 hash='\builtin alias -t'
7527 history='\builtin fc -l'
7528 integer='\typeset -i'
7531 nameref='\typeset -n'
7533 r='\builtin fc -e -'
7534 source='PATH=$PATH:. \command .'
7536 type='\builtin whence -v'
7540 Check if running as sh does not influence built-in aliases
7541 category: !android,!arge,!os:os2
7544 ./sh -c 'alias; typeset -f'
7547 autoload='\typeset -fu'
7548 functions='\typeset -f'
7549 hash='\builtin alias -t'
7550 history='\builtin fc -l'
7551 integer='\typeset -i'
7554 nameref='\typeset -n'
7556 r='\builtin fc -e -'
7557 source='PATH=$PATH:. \command .'
7559 type='\builtin whence -v'
7561 name: aliases-2b-hartz4
7563 Check if “set -o sh” does not influence built-in aliases
7564 category: android,arge
7570 autoload='\typeset -fu'
7571 functions='\typeset -f'
7572 hash='\builtin alias -t'
7573 history='\builtin fc -l'
7574 integer='\typeset -i'
7577 nameref='\typeset -n'
7579 r='\builtin fc -e -'
7580 source='PATH=$PATH:. \command .'
7581 type='\builtin whence -v'
7583 name: aliases-3b-hartz4
7585 Check if running as sh does not influence built-in aliases
7586 category: android,arge
7589 ./sh -c 'alias; typeset -f'
7592 autoload='\typeset -fu'
7593 functions='\typeset -f'
7594 hash='\builtin alias -t'
7595 history='\builtin fc -l'
7596 integer='\typeset -i'
7599 nameref='\typeset -n'
7601 r='\builtin fc -e -'
7602 source='PATH=$PATH:. \command .'
7603 type='\builtin whence -v'
7605 name: aliases-2b-os2
7607 Check if “set -o sh” does not influence built-in aliases
7614 autoload='\typeset -fu'
7615 functions='\typeset -f'
7616 hash='\builtin alias -t'
7617 history='\builtin fc -l'
7618 integer='\typeset -i'
7621 nameref='\typeset -n'
7623 r='\builtin fc -e -'
7624 source='PATH=$PATH;. \command .'
7625 type='\builtin whence -v'
7627 name: aliases-3b-os2
7629 Check if running as sh does not influence built-in aliases
7633 ./sh -c 'alias; typeset -f'
7636 autoload='\typeset -fu'
7637 functions='\typeset -f'
7638 hash='\builtin alias -t'
7639 history='\builtin fc -l'
7640 integer='\typeset -i'
7643 nameref='\typeset -n'
7645 r='\builtin fc -e -'
7646 source='PATH=$PATH;. \command .'
7647 type='\builtin whence -v'
7649 name: aliases-cmdline
7651 Check that aliases work from the command line (Debian #517009)
7652 Note that due to the nature of the lexing process, defining
7653 aliases in COMSUBs then immediately using them, and things
7654 like 'alias foo=bar && foo', still fail.
7656 "$__progname" -c $'alias a="echo OK"\na'
7660 name: aliases-funcdef-1
7662 Check if POSIX functions take precedences over aliases
7663 category: shell:legacy-no
7665 alias foo='echo makro'
7673 name: aliases-funcdef-1-legacy
7675 Check if POSIX functions take precedences over aliases
7676 category: shell:legacy-yes
7678 alias foo='echo makro'
7686 name: aliases-funcdef-2
7688 Check if POSIX functions take precedences over aliases
7689 category: shell:legacy-no
7691 alias foo='echo makro'
7699 name: aliases-funcdef-2-legacy
7701 Check if POSIX functions take precedences over aliases
7702 category: shell:legacy-yes
7704 alias foo='echo makro'
7712 name: aliases-funcdef-3
7714 Check if aliases take precedences over Korn functions
7716 alias foo='echo makro'
7724 name: aliases-funcdef-4
7726 Functions should only take over if actually being defined
7737 Check if Korn Shell arrays work as expected
7740 set -A foo -- a \$v "$v" '$v' b
7741 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
7747 Check if bash-style arrays work as expected
7750 foo=(a \$v "$v" '$v' b)
7751 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
7757 Check if bash-style arrays work as expected, with newlines
7759 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "$x|"; done' >pfp
7761 test -n "$ZSH_VERSION" && setopt KSH_ARRAYS
7767 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
7772 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
7777 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
7779 7|a|bc|d|$v|e f|$v|g|
7780 7|a|bc|d|$v|e f|$v|g|
7781 6|abc\|d|$v|e f|$v|g||
7785 Check if array bounds are uint32_t
7792 echo ${foo[4294967295]} g ${foo[*]}
7799 Check if Korn Shell arrays with specified indices work as expected
7802 set -A foo -- [1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b
7803 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|"
7804 # we don't want this at all:
7806 set -A arr "[5]=meh"
7807 echo "<${arr[0]}><${arr[5]}>"
7809 5|[1]=$v|[2]=c d|[4]=$v|[0]=a|[5]=b||
7814 Check if bash-style arrays with specified indices work as expected
7815 (taken out temporarily to fix arrays-4; see also arrays-9a comment)
7819 foo=([1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b)
7820 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|"
7821 x=([128]=foo bar baz)
7824 # Check that we do not break this by globbing
7829 echo "<${arr[0]}><${arr[5]}>"
7838 Check if we can get the array keys (indices) for indexed arrays,
7844 echo -n "$((i++))<$x>"
7855 echo a $(of ${foo[*]}) = $(of ${bar[*]}) a
7856 echo b $(of "${foo[*]}") = $(of "${bar[*]}") b
7857 echo c $(of ${foo[@]}) = $(of ${bar[@]}) c
7858 echo d $(of "${foo[@]}") = $(of "${bar[@]}") d
7859 echo e $(of ${!foo[*]}) = $(of ${!bar[*]}) e
7860 echo f $(of "${!foo[*]}") = $(of "${!bar[*]}") f
7861 echo g $(of ${!foo[@]}) = $(of ${!bar[@]}) g
7862 echo h $(of "${!foo[@]}") = $(of "${!bar[@]}") h
7870 a 0<zwei>1<eins>2<drei> = a
7871 b 0<zwei eins drei> = 0<> b
7872 c 0<zwei>1<eins>2<drei> = c
7873 d 0<zwei>1<eins>2<drei> = d
7881 Check if we can get the array keys (indices) for indexed arrays,
7882 Korn shell style, in some corner cases
7885 echo !arz[0]: ${!arz[0]}
7886 echo !arz[1]: ${!arz[1]}
7889 echo !arz[0]: ${!arz[0]}
7890 echo !arz[1]: ${!arz[1]}
7893 echo !arz[0]: ${!arz[0]}
7894 echo !arz[1]: ${!arz[1]}
7908 Check some behavioural rules for arrays.
7946 typeset -Z3 aa ab ac ad ae af ag
7991 Check that we can concatenate arrays
7993 unset foo; foo=(bar); foo+=(baz); echo 1 ${!foo[*]} : ${foo[*]} .
7994 unset foo; foo=(foo bar); foo+=(baz); echo 2 ${!foo[*]} : ${foo[*]} .
7995 # unset foo; foo=([2]=foo [0]=bar); foo+=(baz [5]=quux); echo 3 ${!foo[*]} : ${foo[*]} .
7998 2 0 1 2 : foo bar baz .
7999 # 3 0 2 3 5 : bar foo baz quux .
8003 Check that we can concatenate parameters too
8005 unset foo; foo=bar; foo+=baz; echo 1 $foo .
8006 unset foo; typeset -i16 foo=10; foo+=20; echo 2 $foo .
8011 name: arrassign-basic
8013 Check basic whitespace conserving properties of wdarrassign
8021 c+=("$(echo "c d")")
8023 echo ".a:${a[0]}.${a[1]}.${a[2]}.${a[3]}:"
8024 echo ".b:${b[0]}.${b[1]}.${b[2]}.${b[3]}:"
8025 echo ".c:${c[0]}.${c[1]}.${c[2]}.${c[3]}:"
8026 echo ".d:${d[0]}.${d[1]}.${d[2]}.${d[3]}:"
8033 name: arrassign-fnc-none
8035 Check locality of array access inside a function
8039 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8042 if [[ -n $BASH_VERSION ]]; then
8048 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8052 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8054 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8056 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8057 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8059 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8061 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8074 name: arrassign-fnc-local
8076 Check locality of array access inside a function
8077 with the bash/mksh/ksh93 local/typeset keyword
8078 (note: ksh93 has no local; typeset works only in FKSH)
8083 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8086 if [[ -n $BASH_VERSION ]]; then
8093 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8097 if [[ -n $BASH_VERSION ]]; then
8103 echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8108 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8110 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8112 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8113 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8115 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8117 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8118 echo ".f0r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8120 echo ".f1r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8122 echo ".f2r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8140 name: arrassign-fnc-global
8142 Check locality of array access inside a function
8143 with the mksh-specific global keyword
8148 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8154 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8160 echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8165 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8167 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8169 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8170 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8172 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8174 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8175 echo ".f0r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8177 echo ".f1r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8179 echo ".f2r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8197 name: strassign-fnc-none
8199 Check locality of string access inside a function
8234 name: strassign-fnc-local
8236 Check locality of string access inside a function
8237 with the bash/mksh/ksh93 local/typeset keyword
8238 (note: ksh93 has no local; typeset works only in FKSH)
8292 name: strassign-fnc-global
8294 Check locality of string access inside a function
8295 with the mksh-specific global keyword
8349 name: unset-fnc-local-ksh
8351 Check that “unset” removes a previous “local”
8352 (ksh93 syntax compatible version); apparently,
8353 there are shells which fail this?
8379 name: unset-fnc-local-sh
8381 Check that “unset” removes a previous “local”
8382 (Debian Policy §10.4 sh version); apparently,
8383 there are shells which fail this?
8409 name: varexpand-substr-1
8411 Check if bash-style substring expansion works
8412 when using positive numerics
8415 typeset -i y=123456789
8416 typeset -i 16 z=123456789 # 16#75bcd15
8417 echo a t${x:2:2} ${y:2:3} ${z:2:3} a
8418 echo b ${x::3} ${y::3} ${z::3} b
8419 echo c ${x:2:} ${y:2:} ${z:2:} c
8420 echo d ${x:2} ${y:2} ${z:2} d
8421 echo e ${x:2:6} ${y:2:6} ${z:2:7} e
8422 echo f ${x:2:7} ${y:2:7} ${z:2:8} f
8423 echo g ${x:2:8} ${y:2:8} ${z:2:9} g
8428 d cdefghi 3456789 #75bcd15 d
8429 e cdefgh 345678 #75bcd1 e
8430 f cdefghi 3456789 #75bcd15 f
8431 g cdefghi 3456789 #75bcd15 g
8433 name: varexpand-substr-2
8435 Check if bash-style substring expansion works
8436 when using negative numerics or expressions
8439 typeset -i y=123456789
8440 typeset -i 16 z=123456789 # 16#75bcd15
8442 echo a ${x:$n:3} ${y:$n:3} ${z:$n:3} a
8443 echo b ${x:(n):3} ${y:(n):3} ${z:(n):3} b
8444 echo c ${x:(-2):1} ${y:(-2):1} ${z:(-2):1} c
8445 echo d t${x: n:2} ${y: n:3} ${z: n:3} d
8452 name: varexpand-substr-3
8454 Check that some things that work in bash fail.
8455 This is by design. And that some things fail in both.
8457 export x=abcdefghi n=2
8458 "$__progname" -c 'echo v${x:(n)}x'
8459 "$__progname" -c 'echo w${x: n}x'
8460 "$__progname" -c 'echo x${x:n}x'
8461 "$__progname" -c 'echo y${x:}x'
8462 "$__progname" -c 'echo z${x}x'
8463 "$__progname" -c 'x=abcdef;y=123;echo ${x:${y:2:1}:2}' >/dev/null 2>&1; echo $?
8469 expected-stderr-pattern:
8470 /x:n.*bad substitution.*\n.*bad substitution/
8472 name: varexpand-substr-4
8474 Check corner cases for substring expansion
8478 echo a ${x:(y == 1 ? 2 : 3):4} a
8482 name: varexpand-substr-5A
8484 Check that substring expansions work on characters
8488 echo a ${x::1} ${x: -1} a
8489 echo b ${x::3} ${x: -3} b
8490 echo c ${x:1:2} ${x: -3:2} c
8498 name: varexpand-substr-5W
8500 Check that substring expansions work on characters
8504 echo a ${x::1} ${x: -1} a
8505 echo b ${x::2} ${x: -2} b
8506 echo c ${x:1:1} ${x: -2:1} c
8514 name: varexpand-substr-6
8516 Check that string substitution works correctly
8521 echo a ${baz: foo: bar}
8522 echo b ${baz: foo: $bar}
8523 echo c ${baz: $foo: bar}
8524 echo d ${baz: $foo: $bar}
8531 name: varexpand-special-hash
8533 Check special ${var@x} expansion for x=hash
8538 print ${foo@#} ${bar@#} ${baz@#} .
8540 9B15FBFB CFBDD32B 00000000 .
8542 name: varexpand-special-quote
8544 Check special ${var@Q} expansion for quoted strings
8551 print -r -- "<i=$i j=$j k=$k>"
8552 s="u=${i@Q} v=${j@Q} w=${k@Q}"
8553 print -r -- "s=\"$s\""
8559 s="u=x v='a b' w=$'c\nd\240e\u20ACf'"
8562 typeset w=$'c\nd\240e\u20ACf'
8564 name: varexpand-null-1
8566 Ensure empty strings expand emptily
8568 print s ${a} . ${b} S
8569 print t ${a#?} . ${b%?} T
8570 print r ${a=} . ${b/c/d} R
8572 print s "${a}" . "${b}" S
8573 print t "${a#?}" . "${b%?}" T
8574 print r "${a=}" . "${b/c/d}" R
8584 name: varexpand-null-2
8586 Ensure empty strings, when quoted, are expanded as empty strings
8588 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "<$x> "; done' >pfs
8590 ./pfs 1 "${a}" 2 "${a#?}" + "${b%?}" 3 "${a=}" + "${b/c/d}"
8593 <1> <> <2> <> <+> <> <3> <> <+> <> .
8595 name: varexpand-null-3
8597 Ensure concatenating behaviour matches other shells
8599 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
8601 x=; showargs 1 "$x"$@
8602 set A; showargs 2 "${@:+}"
8636 name: print-funny-chars
8638 Check print builtin's capability to output designated characters
8640 print '<\0144\0344\xDB\u00DB\u20AC\uDB\x40>'
8646 Check print builtin's \c escape
8648 print '\ca'; print b
8654 Check that CR+LF is not collapsed into LF as some MSYS shells wrongly do
8656 echo '#!'"$__progname" >foo
8658 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'
8663 ./foo | while IFS= read -r line; do
8664 print -r -- "{$line}"
8667 [220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT
\r
8668 220->> Bitte keine Werbung einwerfen! <<
\r\r
8669 220 Who do you wanna pretend to be today?
\r]
8670 {220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT
\r}
8671 {220->> Bitte keine Werbung einwerfen! <<
\r\r}
8672 {220 Who do you wanna pretend to be today?
\r}
8676 Check that CR+LF is shown and read as-is
8682 if test x"$KSH_VERSION" = x""; then #
\r
8683 printf '<%s>' "$x" #
\r
8685 print -nr -- "<$x>" #
\r
8688 echo "[$("$__progname" foo)]"
8689 "$__progname" foo | while IFS= read -r line; do
8690 print -r -- "{$line}"
8701 Check that LF-only is shown and read as-is
8707 if test x"$KSH_VERSION" = x""; then #
8708 printf '<%s>' "$x" #
8710 print -nr -- "<$x>" #
8713 echo "[$("$__progname" foo)]"
8714 "$__progname" foo | while IFS= read -r line; do
8715 print -r -- "{$line}"
8724 name: print-nul-chars
8726 Check handling of NUL characters for print and COMSUB
8729 print $(($(print '<\0>' | wc -c))) $(($(print "$x" | wc -c))) \
8731 expected-stdout-pattern:
8736 Check backslash expansion by the print builtin
8738 print '\ \!\"\#\$\%\&'\\\''\(\)\*\+\,\-\.\/\0\1\2\3\4\5\6\7\8' \
8739 '\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T' \
8740 '\U\V\W\X\Y\Z\[\\\]\^\_\`\a\b \d\e\f\g\h\i\j\k\l\m\n\o\p' \
8741 '\q\r\s\t\u\v\w\x\y\z\{\|\}\~' '\u20acd' '\U20acd' '\x123' \
8742 '\0x' '\0123' '\01234' | {
8743 # integer-base-one-3As
8744 typeset -Uui16 -Z11 pos=0
8745 typeset -Uui16 -Z5 hv=2147483647
8749 while IFS= read -r line; do
8751 while [[ -n $line ]]; do
8753 if (( (pos & 15) == 0 )); then
8754 (( pos )) && print "$dasc|"
8755 print -n "${pos#16#} "
8758 print -n "${hv#16#} "
8759 if (( (hv < 32) || (hv > 126) )); then
8762 dasc=$dasc${line::1}
8764 (( (pos++ & 15) == 7 )) && print -n -- '- '
8768 while (( pos & 15 )); do
8770 (( (pos++ & 15) == 7 )) && print -n -- '- '
8772 (( hv == 2147483647 )) || print "$dasc|"
8775 00000000 5C 20 5C 21 5C 22 5C 23 - 5C 24 5C 25 5C 26 5C 27 |\ \!\"\#\$\%\&\'|
8776 00000010 5C 28 5C 29 5C 2A 5C 2B - 5C 2C 5C 2D 5C 2E 5C 2F |\(\)\*\+\,\-\.\/|
8777 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|
8778 00000030 20 5C 39 5C 3A 5C 3B 5C - 3C 5C 3D 5C 3E 5C 3F 5C | \9\:\;\<\=\>\?\|
8779 00000040 40 5C 41 5C 42 5C 43 5C - 44 1B 5C 46 5C 47 5C 48 |@\A\B\C\D.\F\G\H|
8780 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|
8781 00000060 5C 51 5C 52 5C 53 5C 54 - 20 5C 56 5C 57 5C 58 5C |\Q\R\S\T \V\W\X\|
8782 00000070 59 5C 5A 5C 5B 5C 5C 5D - 5C 5E 5C 5F 5C 60 07 08 |Y\Z\[\]\^\_\`..|
8783 00000080 20 20 5C 64 1B 0C 5C 67 - 5C 68 5C 69 5C 6A 5C 6B | \d..\g\h\i\j\k|
8784 00000090 5C 6C 5C 6D 0A 5C 6F 5C - 70 20 5C 71 0D 5C 73 09 |\l\m.\o\p \q.\s.|
8785 000000A0 0B 5C 77 5C 79 5C 7A 5C - 7B 5C 7C 5C 7D 5C 7E 20 |.\w\y\z\{\|\}\~ |
8786 000000B0 E2 82 AC 64 20 EF BF BD - 20 12 33 20 78 20 53 20 |...d ... .3 x S |
8787 000000C0 53 34 0A - |S4.|
8789 name: dollar-doublequoted-strings
8791 Check that a $ preceding "…" is ignored
8793 echo $"Localise me!"
8798 I do not take a $V for a V!
8803 I do not take a $V for a V!
8805 name: dollar-quoted-strings
8807 Check backslash expansion by $'…' strings
8809 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
8811 ./pfn $'\ \!\"\#\$\%\&\'\(\)\*\+\,\-\.\/ \1\2\3\4\5\6' \
8812 $'a\0b' $'a\01b' $'\7\8\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I' \
8813 $'\J\K\L\M\N\O\P\Q\R\S\T\U1\V\W\X\Y\Z\[\\\]\^\_\`\a\b\d\e' \
8814 $'\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u1\v\w\x1\y\z\{\|\}\~ $x' \
8815 $'\u20acd' $'\U20acd' $'\x123' $'fn\x0rd' $'\0234' $'\234' \
8816 $'\2345' $'\ca' $'\c!' $'\c?' $'\c€' $'a\
8818 # integer-base-one-3As
8819 typeset -Uui16 -Z11 pos=0
8820 typeset -Uui16 -Z5 hv=2147483647
8824 while IFS= read -r line; do
8826 while [[ -n $line ]]; do
8828 if (( (pos & 15) == 0 )); then
8829 (( pos )) && print "$dasc|"
8830 print -n "${pos#16#} "
8833 print -n "${hv#16#} "
8834 if (( (hv < 32) || (hv > 126) )); then
8837 dasc=$dasc${line::1}
8839 (( (pos++ & 15) == 7 )) && print -n -- '- '
8843 while (( pos & 15 )); do
8845 (( (pos++ & 15) == 7 )) && print -n -- '- '
8847 (( hv == 2147483647 )) || print "$dasc|"
8850 00000000 20 21 22 23 24 25 26 27 - 28 29 2A 2B 2C 2D 2E 2F | !"#$%&'()*+,-./|
8851 00000010 20 01 02 03 04 05 06 0A - 61 0A 61 01 62 0A 07 38 | .......a.a.b..8|
8852 00000020 39 3A 3B 3C 3D 3E 3F 40 - 41 42 43 44 1B 46 47 48 |9:;<=>?@ABCD.FGH|
8853 00000030 49 0A 4A 4B 4C 4D 4E 4F - 50 51 52 53 54 01 56 57 |I.JKLMNOPQRST.VW|
8854 00000040 58 59 5A 5B 5C 5D 5E 5F - 60 07 08 64 1B 0A 0C 67 |XYZ[\]^_`..d...g|
8855 00000050 68 69 6A 6B 6C 6D 0A 6F - 70 71 0D 73 09 01 0B 77 |hijklm.opq.s...w|
8856 00000060 01 79 7A 7B 7C 7D 7E 20 - 24 78 0A E2 82 AC 64 0A |.yz{|}~ $x....d.|
8857 00000070 EF BF BD 0A C4 A3 0A 66 - 6E 0A 13 34 0A 9C 0A 9C |.......fn..4....|
8858 00000080 35 0A 01 0A 01 0A 7F 0A - 02 82 AC 0A 61 0A 62 0A |5...........a.b.|
8860 name: dollar-quotes-in-heredocs-strings
8862 They are, however, not parsed in here documents, here strings
8863 (outside of string delimiters) or regular strings, but in
8864 parameter substitutions.
8867 dollar = strchr(s, '$'); /* ' */
8873 cat <<<"dollar = strchr(s, '$'); /* ' */"
8874 cat <<<'dollar = strchr(s, '\''$'\''); /* '\'' */'
8875 x="dollar = strchr(s, '$'); /* ' */"
8878 unset nl; print -r -- "x${nl:=$'\n'}y"
8884 # probably never reached for here strings?
8886 cat <<<"4 foo\\\"bar"
8888 # old scripts use this (e.g. ncurses)
8890 # make sure this works, outside of quotes
8893 dollar = strchr(s, '$'); /* ' */
8896 dollar = strchr(s, '$'); /* ' */
8897 dollar = strchr(s, '$'); /* ' */
8898 dollar = strchr(s, '$'); /* ' */
8910 name: dot-needs-argument
8912 check Debian #415167 solution: '.' without arguments should fail
8915 "$__progname" -c source
8916 expected-exit: e != 0
8917 expected-stderr-pattern:
8918 /\.: missing argument.*\n.*\.: missing argument/
8920 name: alias-function-no-conflict-legacy
8922 make aliases not conflict with functions, legacy version:
8923 undefine these aliases upon definition of the function
8924 note: for ksh functions, the order of preference differs in GNU bash
8925 category: shell:legacy-yes
8927 # POSIX function overrides and removes alias
8928 alias foo='echo bar'
8935 foo 2>/dev/null || echo rab
8936 # alias overrides ksh function
8937 alias korn='echo bar'
8943 # alias temporarily overrides POSIX function
8948 alias bla='echo bal'
8962 name: alias-function-no-conflict
8964 make aliases not conflict with function definitions
8965 category: shell:legacy-no
8967 # POSIX function can be defined, but alias overrides it
8968 alias foo='echo bar'
8975 foo 2>/dev/null || echo rab
8976 # alias overrides ksh function
8977 alias korn='echo bar'
8983 # alias temporarily overrides POSIX function
8988 alias bla='echo bal'
9002 name: bash-function-parens
9004 ensure the keyword function is ignored when preceding
9005 POSIX style function declarations (bashism)
9008 echo '#!'"$__progname"
9010 echo ' echo "bar='\''$0'\'\"
9012 print -r -- "${2:-foo}"
9014 mk 'function foo' >f-korn
9016 mk 'function foo ()' >f-bash
9017 # lksh can do without the backslash, too (cf. aliases-funcdef-2-legacy)
9018 mk 'function stop ()' '\stop' >f-stop
9019 print '#!'"$__progname"'\nprint -r -- "${0%/f-argh}"' >f-argh
9022 x="korn: $(./f-korn)"; echo "${x/@("$u")/.}"
9023 x="dash: $(./f-dash)"; echo "${x/@("$u")/.}"
9024 x="bash: $(./f-bash)"; echo "${x/@("$u")/.}"
9025 x="stop: $(./f-stop)"; echo "${x/@("$u")/.}"
9028 dash: bar='./f-dash'
9029 bash: bar='./f-bash'
9030 stop: bar='./f-stop'
9032 name: integer-base-one-1
9034 check if the use of fake integer base 1 works
9037 typeset -Uui16 i0=1#ï i1=1#â
\82¬
9039 typeset -i1 o1a=0x263A
9040 typeset -Uui1 o0b=0x7E
9041 typeset -Uui1 o1b=0xFDD0
9042 integer px=0xCAFE 'p0=1# ' p1=1#… pl=1#f
9043 echo "in <$i0> <$i1>"
9044 echo "out <${o0a#1#}|${o0b#1#}> <${o1a#1#}|${o1b#1#}>"
9046 echo "pass <$px> <$p0> <$p1> <$pl> <${i0#1#}|${i1#1#}>"
9047 typeset -Uui16 tv1=1#~ tv2=1#
\7f tv3=1#
\80 tv4=1#
\81 tv5=1#À tv6=1#Á tv7=1#Â tv8=1#Â
\80
9048 echo "specX <${tv1#16#}> <${tv2#16#}> <${tv3#16#}> <${tv4#16#}> <${tv5#16#}> <${tv6#16#}> <${tv7#16#}> <${tv8#16#}>"
9049 typeset -i1 tv1 tv2 tv3 tv4 tv5 tv6 tv7 tv8
9050 echo "specW <${tv1#1#}> <${tv2#1#}> <${tv3#1#}> <${tv4#1#}> <${tv5#1#}> <${tv6#1#}> <${tv7#1#}> <${tv8#1#}>"
9051 typeset -i1 xs1=0xEF7F xs2=0xEF80 xs3=0xFDD0
9052 echo "specU <${xs1#1#}> <${xs2#1#}> <${xs3#1#}>"
9054 in <16#EFEF> <16#20AC>
9056 pass <16#cafe> <1# > <1#â
\80¦> <1#f> <ï|â
\82¬>
9057 specX <7E> <7F> <EF80> <EF81> <EFC0> <EFC1> <A0> <80>
9058 specW <~> <
\7f> <
\80> <
\81> <À> <Á> <Â > <Â
\80>
9059 specU <> <
\80> <ï·
\90>
9061 name: integer-base-one-2a
9063 check if the use of fake integer base 1 stops at correct characters
9068 expected-stderr-pattern:
9069 /1#foo: unexpected 'oo'/
9070 expected-exit: e != 0
9072 name: integer-base-one-2b
9074 check if the use of fake integer base 1 stops at correct characters
9079 expected-stderr-pattern:
9080 /1#À
\80: unexpected '
\80'/
9081 expected-exit: e != 0
9083 name: integer-base-one-2c1
9085 check if the use of fake integer base 1 stops at correct characters
9093 name: integer-base-one-2c2
9095 check if the use of fake integer base 1 stops at correct characters
9100 expected-stderr-pattern:
9101 /1#â
\80¦: unexpected '
\80'/
9102 expected-exit: e != 0
9104 name: integer-base-one-2d1
9106 check if the use of fake integer base 1 handles octets okay
9110 echo /$x/ # invalid utf-8
9114 name: integer-base-one-2d2
9116 check if the use of fake integer base 1 handles octets
9120 echo /$x/ # invalid 2-byte
9124 name: integer-base-one-2d3
9126 check if the use of fake integer base 1 handles octets
9130 echo /$x/ # invalid 2-byte
9134 name: integer-base-one-2d4
9136 check if the use of fake integer base 1 stops at invalid input
9139 typeset -i16 x=1#ï¿À
9140 echo /$x/ # invalid 3-byte
9141 expected-stderr-pattern:
9142 /1#ï¿À: unexpected '¿'/
9143 expected-exit: e != 0
9145 name: integer-base-one-2d5
9147 check if the use of fake integer base 1 stops at invalid input
9150 typeset -i16 x=1#À
\80
9151 echo /$x/ # non-minimalistic
9152 expected-stderr-pattern:
9153 /1#À
\80: unexpected '
\80'/
9154 expected-exit: e != 0
9156 name: integer-base-one-2d6
9158 check if the use of fake integer base 1 stops at invalid input
9161 typeset -i16 x=1#à
\80\80
9162 echo /$x/ # non-minimalistic
9163 expected-stderr-pattern:
9164 /1#à
\80\80: unexpected '
\80'/
9165 expected-exit: e != 0
9167 name: integer-base-one-3As
9169 some sample code for hexdumping
9170 not NUL safe; input lines must be NL terminated
9173 print 'Hello, World!\\\nこんにちは!'
9174 typeset -Uui16 i=0x100
9175 # change that to 0xFF once we can handle embedded
9176 # NUL characters in strings / here documents
9177 while (( i++ < 0x1FF )); do
9178 print -n "\x${i#16#1}"
9182 # integer-base-one-3As
9183 typeset -Uui16 -Z11 pos=0
9184 typeset -Uui16 -Z5 hv=2147483647
9188 while IFS= read -r line; do
9190 while [[ -n $line ]]; do
9192 if (( (pos & 15) == 0 )); then
9193 (( pos )) && print "$dasc|"
9194 print -n "${pos#16#} "
9197 print -n "${hv#16#} "
9198 if (( (hv < 32) || (hv > 126) )); then
9201 dasc=$dasc${line::1}
9203 (( (pos++ & 15) == 7 )) && print -n -- '- '
9207 while (( pos & 15 )); do
9209 (( (pos++ & 15) == 7 )) && print -n -- '- '
9211 (( hv == 2147483647 )) || print "$dasc|"
9214 00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..|
9215 00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................|
9216 00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................|
9217 00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................|
9218 00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.|
9219 00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>|
9220 00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN|
9221 00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^|
9222 00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn|
9223 00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~|
9224 000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................|
9225 000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................|
9226 000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................|
9227 000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................|
9228 000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................|
9229 000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................|
9230 00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................|
9231 00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................|
9232 00000120 FF 7A 0A - |.z.|
9234 name: integer-base-one-3Ws
9236 some sample code for hexdumping Unicode
9237 not NUL safe; input lines must be NL terminated
9241 print 'Hello, World!\\\nこんにちは!'
9242 typeset -Uui16 i=0x100
9243 # change that to 0xFF once we can handle embedded
9244 # NUL characters in strings / here documents
9245 while (( i++ < 0x1FF )); do
9246 print -n "\u${i#16#1}"
9249 print \\xff # invalid utf-8
9250 print \\xc2 # invalid 2-byte
9251 print \\xef\\xbf\\xc0 # invalid 3-byte
9252 print \\xc0\\x80 # non-minimalistic
9253 print \\xe0\\x80\\x80 # non-minimalistic
9254 print '�' # end of range
9255 print '\0z' # embedded NUL
9257 # integer-base-one-3Ws
9258 typeset -Uui16 -Z11 pos=0
9259 typeset -Uui16 -Z7 hv
9264 while IFS= read -r line; do
9267 while (( lpos < ${#line} )); do
9268 wc=1#${line:(lpos++):1}
9269 if (( (wc < 32) || \
9270 ((wc > 126) && (wc < 160)) )); then
9272 elif (( (wc & 0xFF80) == 0xEF80 )); then
9277 if (( (pos & 7) == 7 )); then
9280 elif (( (pos & 7) == 0 )); then
9281 (( pos )) && print "$dasc|"
9282 print -n "${pos#16#} "
9286 print -n "${hv#16#} "
9287 (( (pos++ & 7) == 3 )) && \
9292 while (( pos & 7 )); do
9294 (( (pos++ & 7) == 3 )) && print -n -- '- '
9296 (( hv == 2147483647 )) || print "$dasc|"
9299 00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W|
9300 00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.こ|
9301 00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |んにちは!...|
9302 00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........|
9303 00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........|
9304 00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........|
9305 00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"|
9306 00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*|
9307 00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012|
9308 00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:|
9309 00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB|
9310 00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ|
9311 00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR|
9312 00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ|
9313 00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab|
9314 00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij|
9315 00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr|
9316 00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz|
9317 00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....|
9318 00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........|
9319 000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........|
9320 000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........|
9321 000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |..... ¡¢|
9322 000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA |£¤¥¦§¨©ª|
9323 000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 |«¬®¯°±²|
9324 000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA |³´µ¶·¸¹º|
9325 000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 |»¼½¾¿ÀÁÂ|
9326 000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA |ÃÄÅÆÇÈÉÊ|
9327 000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 |ËÌÍÎÏÐÑÒ|
9328 000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA |ÓÔÕÖ×ØÙÚ|
9329 000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 |ÛÜÝÞßàáâ|
9330 000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA |ãäåæçèéê|
9331 00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 |ëìíîïðñò|
9332 00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA |óôõö÷øùú|
9333 00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |ûüýþÿ.�.|
9334 00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |�.���.��|
9335 00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |.���.���|
9336 00000128 EFBE EFEF EFBF EFBF - 000A 007A 000A |����.z.|
9338 name: integer-base-one-3Ar
9340 some sample code for hexdumping; NUL and binary safe
9343 print 'Hello, World!\\\nこんにちは!'
9344 typeset -Uui16 i=0x100
9345 # change that to 0xFF once we can handle embedded
9346 # NUL characters in strings / here documents
9347 while (( i++ < 0x1FF )); do
9348 print -n "\x${i#16#1}"
9352 # integer-base-one-3Ar
9353 typeset -Uui16 -Z11 pos=0
9354 typeset -Uui16 -Z5 hv=2147483647
9356 if read -arN -1 line; then
9359 while (( i < ${#line[*]} )); do
9361 if (( (pos & 15) == 0 )); then
9362 (( pos )) && print "$dasc|"
9363 print -n "${pos#16#} "
9366 print -n "${hv#16#} "
9367 if (( (hv < 32) || (hv > 126) )); then
9370 dasc=$dasc${line[i-1]#1#}
9372 (( (pos++ & 15) == 7 )) && print -n -- '- '
9375 while (( pos & 15 )); do
9377 (( (pos++ & 15) == 7 )) && print -n -- '- '
9379 (( hv == 2147483647 )) || print "$dasc|"
9382 00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..|
9383 00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................|
9384 00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................|
9385 00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................|
9386 00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.|
9387 00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>|
9388 00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN|
9389 00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^|
9390 00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn|
9391 00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~|
9392 000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................|
9393 000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................|
9394 000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................|
9395 000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................|
9396 000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................|
9397 000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................|
9398 00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................|
9399 00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................|
9400 00000120 FF 00 7A 0A - |..z.|
9402 name: integer-base-one-3Wr
9404 some sample code for hexdumping Unicode; NUL and binary safe
9408 print 'Hello, World!\\\nこんにちは!'
9409 typeset -Uui16 i=0x100
9410 # change that to 0xFF once we can handle embedded
9411 # NUL characters in strings / here documents
9412 while (( i++ < 0x1FF )); do
9413 print -n "\u${i#16#1}"
9416 print \\xff # invalid utf-8
9417 print \\xc2 # invalid 2-byte
9418 print \\xef\\xbf\\xc0 # invalid 3-byte
9419 print \\xc0\\x80 # non-minimalistic
9420 print \\xe0\\x80\\x80 # non-minimalistic
9421 print '�' # end of range
9422 print '\0z' # embedded NUL
9424 # integer-base-one-3Wr
9425 typeset -Uui16 -Z11 pos=0
9426 typeset -Uui16 -Z7 hv=2147483647
9428 if read -arN -1 line; then
9431 while (( i < ${#line[*]} )); do
9433 if (( (hv < 32) || \
9434 ((hv > 126) && (hv < 160)) )); then
9436 elif (( (hv & 0xFF80) == 0xEF80 )); then
9441 if (( (pos & 7) == 7 )); then
9444 elif (( (pos & 7) == 0 )); then
9445 (( pos )) && print "$dasc|"
9446 print -n "${pos#16#} "
9449 print -n "${hv#16#} "
9450 (( (pos++ & 7) == 3 )) && \
9455 while (( pos & 7 )); do
9457 (( (pos++ & 7) == 3 )) && print -n -- '- '
9459 (( hv == 2147483647 )) || print "$dasc|"
9462 00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W|
9463 00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.こ|
9464 00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |んにちは!...|
9465 00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........|
9466 00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........|
9467 00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........|
9468 00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"|
9469 00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*|
9470 00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012|
9471 00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:|
9472 00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB|
9473 00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ|
9474 00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR|
9475 00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ|
9476 00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab|
9477 00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij|
9478 00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr|
9479 00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz|
9480 00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....|
9481 00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........|
9482 000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........|
9483 000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........|
9484 000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |..... ¡¢|
9485 000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA |£¤¥¦§¨©ª|
9486 000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 |«¬®¯°±²|
9487 000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA |³´µ¶·¸¹º|
9488 000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 |»¼½¾¿ÀÁÂ|
9489 000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA |ÃÄÅÆÇÈÉÊ|
9490 000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 |ËÌÍÎÏÐÑÒ|
9491 000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA |ÓÔÕÖ×ØÙÚ|
9492 000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 |ÛÜÝÞßàáâ|
9493 000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA |ãäåæçèéê|
9494 00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 |ëìíîïðñò|
9495 00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA |óôõö÷øùú|
9496 00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |ûüýþÿ.�.|
9497 00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |�.���.��|
9498 00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |.���.���|
9499 00000128 EFBE EFEF EFBF EFBF - 000A 0000 007A 000A |����..z.|
9501 name: integer-base-one-4
9503 Check if ksh93-style base-one integers work
9508 (echo 2f $(('aa'))) 2>&1 | sed "s/^[^']*'/2p '/"
9516 2p 'aa': multi-character character constant
9522 name: integer-base-one-5A
9524 Check to see that we’re NUL and Unicode safe
9527 print 'a\0b\xfdz' >x
9533 16#61 16#0 16#62 16#FD 16#7A .
9535 name: integer-base-one-5W
9537 Check to see that we’re NUL and Unicode safe
9546 16#61 16#0 16#62 16#20AC 16#63 .
9550 Check if we can use a specific syntax idiom for ulimit
9551 category: !os:syllable
9553 if ! x=$(ulimit -d) || [[ $x = unknown ]]; then
9554 #echo expected to fail on this OS
9557 ulimit -dS $x && echo okay
9564 Check some of the most basic invariants of I/O redirection
9569 print -u2 e$((i++)).
9594 Check if GNU bash-like I/O redirection works
9595 Part 1: this is also supported by GNU bash
9596 category: shell:legacy-no
9615 Check if GNU bash-like I/O redirection works
9616 Part 2: this is *not* supported by GNU bash
9617 category: shell:legacy-no
9636 Check if GNU bash-like I/O redirection works
9637 Part 2: this is *not* supported by GNU bash
9638 category: shell:legacy-no
9657 Check if GNU bash-like I/O redirection works
9658 Part 2: this is supported by GNU bash 4 only
9659 category: shell:legacy-no
9681 Check if GNU bash-like I/O redirection fails correctly
9682 Part 1: this is also supported by GNU bash
9683 category: shell:legacy-no
9699 expected-stderr-pattern: /.*: can't (create|overwrite) .*/
9703 Check if GNU bash-like I/O redirection fails correctly
9704 Part 2: this is *not* supported by GNU bash
9705 category: shell:legacy-no
9726 Check if GNU bash-like I/O redirection works
9727 Part 4: this is also supported by GNU bash,
9728 but failed in some mksh versions
9729 category: shell:legacy-no
9738 [[ -e bar ]] && threeout "$bf" &>foo
9751 name: bashiop-5-normal
9753 Check if GNU bash-like I/O redirection is only supported
9754 in !POSIX !sh mode as it breaks existing scripts' syntax
9755 category: shell:legacy-no
9757 :>x; echo 1 "$("$__progname" -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9758 :>x; echo 2 "$("$__progname" -o posix -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9759 :>x; echo 3 "$("$__progname" -o sh -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9765 name: bashiop-5-legacy
9767 Check if GNU bash-like I/O redirection is not parsed
9768 in lksh as it breaks existing scripts' syntax
9769 category: shell:legacy-yes
9771 :>x; echo 1 "$("$__progname" -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9772 :>x; echo 2 "$("$__progname" -o posix -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9773 :>x; echo 3 "$("$__progname" -o sh -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9781 Check for support of more than 9 file descriptors
9784 read -u10 foo 10<<< bar
9791 Check for support of more than 9 file descriptors
9807 for n in ${a#*=}; do echo 1hu ${n} .; done
9808 for n in "${a#*=}"; do echo 1hq ${n} .; done
9809 for n in ${a##*=}; do echo 2hu ${n} .; done
9810 for n in "${a##*=}"; do echo 2hq ${n} .; done
9811 for n in ${a%=*}; do echo 1pu ${n} .; done
9812 for n in "${a%=*}"; do echo 1pq ${n} .; done
9813 for n in ${a%%=*}; do echo 2pu ${n} .; done
9814 for n in "${a%%=*}"; do echo 2pq ${n} .; done
9821 name: oksh-and-list-error-1
9823 Test exit status of rightmost element in 2 element && list in -e mode
9826 echo "should not print"
9828 expected-exit: e != 0
9830 name: oksh-and-list-error-2
9832 Test exit status of rightmost element in 3 element && list in -e mode
9834 true && true && false
9835 echo "should not print"
9837 expected-exit: e != 0
9839 name: oksh-or-list-error-1
9841 Test exit status of || list in -e mode
9844 echo "should not print"
9846 expected-exit: e != 0
9848 name: oksh-longline-crash
9850 This used to cause a core dump
9853 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"
9854 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"
9855 for deplib in $deplibs; do
9858 new_libs="$deplib $new_libs"
9861 case " $specialdeplibs " in
9863 new_libs="$deplib $new_libs";;
9869 name: oksh-seterror-1
9871 The -e flag should be ignored when executing a compound list
9872 followed by an if statement.
9874 if true; then false && false; fi
9877 expected-exit: e == 0
9879 name: oksh-seterror-2
9881 The -e flag should be ignored when executing a compound list
9882 followed by an if statement.
9884 if true; then if true; then false && false; fi; fi
9887 expected-exit: e == 0
9889 name: oksh-seterror-3
9891 The -e flag should be ignored when executing a compound list
9892 followed by an elif statement.
9894 if true; then :; elif true; then false && false; fi
9896 expected-exit: e == 0
9898 name: oksh-seterror-4
9900 The -e flag should be ignored when executing a pipeline
9909 expected-exit: e == 0
9911 name: oksh-seterror-5
9913 The -e flag should be ignored when executing a pipeline
9919 expected-exit: e == 0
9921 name: oksh-seterror-6
9923 When trapping ERR and EXIT, both traps should run in -e mode
9924 when an error occurs.
9926 trap 'echo EXIT' EXIT
9933 expected-exit: e != 0
9938 name: oksh-seterror-7
9940 The -e flag within a command substitution should be honored
9942 echo $( set -e; false; echo foo )
9947 name: oksh-input-comsub
9949 A command substitution using input redirection should exit with
9950 failure if the input file does not exist.
9952 var=$(< non-existent)
9953 expected-exit: e != 0
9954 expected-stderr-pattern: /non-existent/
9956 name: oksh-empty-for-list
9958 A for list which expands to zero items should not execute the body.
9960 set foo bar baz ; for out in ; do echo $out ; done
9962 name: oksh-varfunction-mod1
9964 (Inspired by PR 2450 on OpenBSD.) Calling
9966 where f is a ksh style function, should not set FOO in the current
9967 env. If f is a Bourne style function, FOO should be set. Furthermore,
9968 the function should receive a correct value of FOO. However, differing
9969 from oksh, setting FOO in the function itself must change the value in
9970 setting FOO in the function itself should not change the value in
9973 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
9974 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
9975 done >env; chmod +x env; PATH=.$PATHSEP$PATH
9977 if [ x$FOO != xbar ]; then
9982 if [ "x$x" != "xFOO=bar" ]; then
9990 if [ x$FOO != xbar ]; then
9995 if [ "x$x" != "xFOO=bar" ]; then
10003 if [ $? != 0 ]; then
10006 if [ x$FOO != x ]; then
10010 if [ $? != 0 ]; then
10013 if [ x$FOO != xfoo ]; then
10018 if [ $? != 0 ]; then
10021 if [ x$FOO != xbarbar ]; then
10025 if [ $? != 0 ]; then
10028 if [ x$FOO != xfoo ]; then
10034 Verify that file descriptors > 2 are private for Korn shells
10035 AT&T ksh93 does this still, which means we must keep it as well
10036 category: shell:legacy-no
10040 open(my \$fh, ">&", 9) or die "E: open \$!";
10041 syswrite(\$fh, "Fowl\\n", 5) or die "E: write \$!";
10046 expected-exit: e != 0
10047 expected-stderr-pattern:
10052 Verify that file descriptors > 2 are not private for POSIX shells
10053 See Debian Bug #154540, Closes: #499139
10057 open(my \$fh, ">&", 9) or die "E: open \$!";
10058 syswrite(\$fh, "Fowl\\n", 5) or die "E: write \$!";
10061 test -n "$POSH_VERSION" || set -o posix
10069 Verify that file descriptors > 2 are not private for LEGACY KSH
10070 category: shell:legacy-yes
10074 open(my \$fh, ">&", 9) or die "E: open \$!";
10075 syswrite(\$fh, "Fowl\\n", 5) or die "E: write \$!";
10085 COMSUB are now parsed recursively, so this works
10086 see also regression-6: matching parenthesēs bug
10087 Fails on: pdksh bash2 bash3 zsh
10088 Passes on: bash4 ksh93 mksh(20110313+)
10090 echo 1 $(case 1 in (1) echo yes;; (2) echo no;; esac) .
10091 echo 2 $(case 1 in 1) echo yes;; 2) echo no;; esac) .
10092 TEST=1234; echo 3 ${TEST: $(case 1 in (1) echo 1;; (*) echo 2;; esac)} .
10093 TEST=5678; echo 4 ${TEST: $(case 1 in 1) echo 1;; *) echo 2;; esac)} .
10094 a=($(case 1 in (1) echo 1;; (*) echo 2;; esac)); echo 5 ${a[0]} .
10095 a=($(case 1 in 1) echo 1;; *) echo 2;; esac)); echo 6 ${a[0]} .
10106 COMSUB are now parsed recursively, so this works
10107 Fails on: pdksh bash2 bash3 bash4 zsh
10108 Passes on: ksh93 mksh(20110313+)
10110 echo 1 $(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10)) .
10111 echo 2 $(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20)) .
10112 (( a = $(case 1 in (1) echo 1;; (*) echo 2;; esac) )); echo 3 $a .
10113 (( a = $(case 1 in 1) echo 1;; *) echo 2;; esac) )); echo 4 $a .
10114 a=($(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10))); echo 5 ${a[0]} .
10115 a=($(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20))); echo 6 ${a[0]} .
10126 RedHat BZ#496791 – another case of missing recursion
10127 in parsing COMSUB expressions
10128 Fails on: pdksh bash2 bash3¹ bash4¹ zsh
10129 Passes on: ksh93 mksh(20110305+)
10130 ① bash[34] seem to choke on comment ending with backslash-newline
10132 # a comment with " ' \
10135 # a comment with " ' \
10143 Extended test for COMSUB explaining why a recursive parser
10144 is a must (a non-recursive parser cannot pass all three of
10145 these test cases, especially the ‘#’ is difficult)
10147 print '#!'"$__progname"'\necho 1234' >id; chmod +x id; PATH=.$PATHSEP$PATH
10148 echo $(typeset -i10 x=16#20; echo $x)
10149 echo $(typeset -Uui16 x=16#$(id -u)
10152 typeset -Uui16 a=36#foo; c=2
10153 typeset -Uui16 b=36 #foo; d=2
10162 Check the tree dump functions for !MKSH_SMALL functionality
10165 x() { case $1 in u) echo x ;;& *) echo $1 ;; esac; }
10181 Check COMSUB works with aliases (does not expand them twice)
10183 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
10185 alias echo='echo a'
10187 ./pfn "$(echo foo)"
10194 ./pfn "$(echo foo )"
10197 name: comsub-torture
10199 Check the tree dump functions work correctly
10201 if [[ -z $__progname ]]; then echo >&2 call me with __progname; exit 1; fi
10202 while IFS= read -r line; do
10203 if [[ $line = '#1' ]]; then
10206 elif [[ $line = EOFN* ]]; then
10207 fbody=$fbody$'\n'$line
10209 elif [[ $line != '#'* ]]; then
10210 fbody=$fbody$'\n\t'$line
10213 if (( lastf )); then
10214 x="inline_${nextf}() {"$fbody$'\n}\n'
10216 print -r -- "${x}typeset -f inline_$nextf" | "$__progname"
10217 x="function comsub_$nextf { x=\$("$fbody$'\n); }\n'
10219 print -r -- "${x}typeset -f comsub_$nextf" | "$__progname"
10220 x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n'
10222 print -r -- "${x}typeset -f reread_$nextf" | "$__progname"
10230 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
10231 #TPAREN_TPIPE_TLIST
10232 (echo $foo | tr -dc 0-9; echo)
10234 cmd && echo ja || echo nein
10236 select file in *; do echo "<$file>" ; break ; done
10238 time for i in {1,2,3} ; do echo $i ; done
10240 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
10241 #TIF_TBANG_TDBRACKET_TELIF
10242 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
10244 i=1; while (( i < 10 )); do echo $i; let ++i; done
10246 i=10; until (( !--i )) ; do echo $i; done
10249 #TFUNCT_TBRACE_TASYNC
10250 function korn { echo eins; echo zwei ; }
10251 bourne () { logger * & }
10254 #IOWRITE_IOCLOB_IOHERE_noIOSKIP
10258 #IOWRITE_noIOCLOB_IOHERE_IOSKIP
10263 sh 1<>/dev/console 0<&1 2>&1
10264 #COMSUB_EXPRSUB_FUNSUB_VALSUB
10265 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
10266 #QCHAR_OQUOTE_CQUOTE
10267 echo fo\ob\"a\`r\'b\$az
10268 echo "fo\ob\"a\`r\'b\$az"
10269 echo 'fo\ob\"a\`r'\''b\$az'
10270 #OSUBST_CSUBST_OPAT_SPAT_CPAT
10271 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
10274 note there must be no space between EOFN and )
10278 note the space between EOFN and ) is actually part of the here document marker
10281 x=$(sysctl -n kern.version | sed 1q)
10282 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
10283 ed -s /etc/motd 2>&1 <<-EOF
10290 EOF)" = @(?) ]] && rm -f /etc/motd
10291 if [[ ! -s /etc/motd ]]; then
10292 install -c -o root -g wheel -m 664 /dev/null /etc/motd
10293 print -- "$x\n" >/etc/motd
10303 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
10306 vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4"
10308 function comsub_TCOM { x=$(
10309 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
10311 function comsub_TCOM {
10312 x=$(vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" )
10314 function reread_TCOM { x=$((
10315 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
10317 function reread_TCOM {
10318 x=$(( vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" ) | tr u x )
10320 inline_TPAREN_TPIPE_TLIST() {
10321 (echo $foo | tr -dc 0-9; echo)
10323 inline_TPAREN_TPIPE_TLIST() {
10324 ( echo $foo | tr -dc 0-9
10327 function comsub_TPAREN_TPIPE_TLIST { x=$(
10328 (echo $foo | tr -dc 0-9; echo)
10330 function comsub_TPAREN_TPIPE_TLIST {
10331 x=$(( echo $foo | tr -dc 0-9 ; echo ) )
10333 function reread_TPAREN_TPIPE_TLIST { x=$((
10334 (echo $foo | tr -dc 0-9; echo)
10336 function reread_TPAREN_TPIPE_TLIST {
10337 x=$(( ( echo $foo | tr -dc 0-9 ; echo ) ) | tr u x )
10339 inline_TAND_TOR() {
10340 cmd && echo ja || echo nein
10342 inline_TAND_TOR() {
10343 cmd && echo ja || echo nein
10345 function comsub_TAND_TOR { x=$(
10346 cmd && echo ja || echo nein
10348 function comsub_TAND_TOR {
10349 x=$(cmd && echo ja || echo nein )
10351 function reread_TAND_TOR { x=$((
10352 cmd && echo ja || echo nein
10354 function reread_TAND_TOR {
10355 x=$(( cmd && echo ja || echo nein ) | tr u x )
10358 select file in *; do echo "<$file>" ; break ; done
10367 function comsub_TSELECT { x=$(
10368 select file in *; do echo "<$file>" ; break ; done
10370 function comsub_TSELECT {
10371 x=$(select file in * ; do echo "<$file>" ; break ; done )
10373 function reread_TSELECT { x=$((
10374 select file in *; do echo "<$file>" ; break ; done
10376 function reread_TSELECT {
10377 x=$(( select file in * ; do echo "<$file>" ; break ; done ) | tr u x )
10379 inline_TFOR_TTIME() {
10380 time for i in {1,2,3} ; do echo $i ; done
10382 inline_TFOR_TTIME() {
10383 time for i in {1,2,3}
10388 function comsub_TFOR_TTIME { x=$(
10389 time for i in {1,2,3} ; do echo $i ; done
10391 function comsub_TFOR_TTIME {
10392 x=$(time for i in {1,2,3} ; do echo $i ; done )
10394 function reread_TFOR_TTIME { x=$((
10395 time for i in {1,2,3} ; do echo $i ; done
10397 function reread_TFOR_TTIME {
10398 x=$(( time for i in {1,2,3} ; do echo $i ; done ) | tr u x )
10401 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
10412 echo kann net bis drei zählen
10416 function comsub_TCASE { x=$(
10417 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
10419 function comsub_TCASE {
10420 x=$(case $foo in (1) echo eins ;& (2) echo zwei ;| (*) echo kann net bis drei zählen ;; esac )
10422 function reread_TCASE { x=$((
10423 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
10425 function reread_TCASE {
10426 x=$(( case $foo in (1) echo eins ;& (2) echo zwei ;| (*) echo kann net bis drei zählen ;; esac ) | tr u x )
10428 inline_TIF_TBANG_TDBRACKET_TELIF() {
10429 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
10431 inline_TIF_TBANG_TDBRACKET_TELIF() {
10442 function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$(
10443 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
10445 function comsub_TIF_TBANG_TDBRACKET_TELIF {
10446 x=$(if ! [[ 1 = 1 ]] ; then echo eins ; elif [[ 1 = 2 ]] ; then echo zwei ; else echo drei ; fi )
10448 function reread_TIF_TBANG_TDBRACKET_TELIF { x=$((
10449 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
10451 function reread_TIF_TBANG_TDBRACKET_TELIF {
10452 x=$(( if ! [[ 1 = 1 ]] ; then echo eins ; elif [[ 1 = 2 ]] ; then echo zwei ; else echo drei ; fi ) | tr u x )
10455 i=1; while (( i < 10 )); do echo $i; let ++i; done
10459 while \let] " i < 10 "
10465 function comsub_TWHILE { x=$(
10466 i=1; while (( i < 10 )); do echo $i; let ++i; done
10468 function comsub_TWHILE {
10469 x=$(i=1 ; while \let] " i < 10 " ; do echo $i ; let ++i ; done )
10471 function reread_TWHILE { x=$((
10472 i=1; while (( i < 10 )); do echo $i; let ++i; done
10474 function reread_TWHILE {
10475 x=$(( i=1 ; while \let] " i < 10 " ; do echo $i ; let ++i ; done ) | tr u x )
10478 i=10; until (( !--i )) ; do echo $i; done
10482 until \let] " !--i "
10487 function comsub_TUNTIL { x=$(
10488 i=10; until (( !--i )) ; do echo $i; done
10490 function comsub_TUNTIL {
10491 x=$(i=10 ; until \let] " !--i " ; do echo $i ; done )
10493 function reread_TUNTIL { x=$((
10494 i=10; until (( !--i )) ; do echo $i; done
10496 function reread_TUNTIL {
10497 x=$(( i=10 ; until \let] " !--i " ; do echo $i ; done ) | tr u x )
10506 function comsub_TCOPROC { x=$(
10509 function comsub_TCOPROC {
10512 function reread_TCOPROC { x=$((
10515 function reread_TCOPROC {
10516 x=$(( cat * |& ls ) | tr u x )
10518 inline_TFUNCT_TBRACE_TASYNC() {
10519 function korn { echo eins; echo zwei ; }
10520 bourne () { logger * & }
10522 inline_TFUNCT_TBRACE_TASYNC() {
10531 function comsub_TFUNCT_TBRACE_TASYNC { x=$(
10532 function korn { echo eins; echo zwei ; }
10533 bourne () { logger * & }
10535 function comsub_TFUNCT_TBRACE_TASYNC {
10536 x=$(function korn { echo eins ; echo zwei ; } ; bourne() { logger * & } )
10538 function reread_TFUNCT_TBRACE_TASYNC { x=$((
10539 function korn { echo eins; echo zwei ; }
10540 bourne () { logger * & }
10542 function reread_TFUNCT_TBRACE_TASYNC {
10543 x=$(( function korn { echo eins ; echo zwei ; } ; bourne() { logger * & } ) | tr u x )
10545 inline_IOREAD_IOCAT() {
10548 inline_IOREAD_IOCAT() {
10551 function comsub_IOREAD_IOCAT { x=$(
10554 function comsub_IOREAD_IOCAT {
10555 x=$(tr x u <foo >>bar )
10557 function reread_IOREAD_IOCAT { x=$((
10560 function reread_IOREAD_IOCAT {
10561 x=$(( tr x u <foo >>bar ) | tr u x )
10563 inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
10568 inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
10574 function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$(
10579 function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
10580 x=$(cat >|bar <<"EOFN"
10585 function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$((
10590 function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
10591 x=$(( cat >|bar <<"EOFN"
10596 inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
10601 inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
10607 function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$(
10612 function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
10613 x=$(cat >bar <<-EOFI
10618 function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$((
10623 function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
10624 x=$(( cat >bar <<-EOFI
10629 inline_IORDWR_IODUP() {
10630 sh 1<>/dev/console 0<&1 2>&1
10632 inline_IORDWR_IODUP() {
10633 sh 1<>/dev/console <&1 2>&1
10635 function comsub_IORDWR_IODUP { x=$(
10636 sh 1<>/dev/console 0<&1 2>&1
10638 function comsub_IORDWR_IODUP {
10639 x=$(sh 1<>/dev/console <&1 2>&1 )
10641 function reread_IORDWR_IODUP { x=$((
10642 sh 1<>/dev/console 0<&1 2>&1
10644 function reread_IORDWR_IODUP {
10645 x=$(( sh 1<>/dev/console <&1 2>&1 ) | tr u x )
10647 inline_COMSUB_EXPRSUB_FUNSUB_VALSUB() {
10648 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
10650 inline_COMSUB_EXPRSUB_FUNSUB_VALSUB() {
10651 echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;}
10653 function comsub_COMSUB_EXPRSUB_FUNSUB_VALSUB { x=$(
10654 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
10656 function comsub_COMSUB_EXPRSUB_FUNSUB_VALSUB {
10657 x=$(echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;} )
10659 function reread_COMSUB_EXPRSUB_FUNSUB_VALSUB { x=$((
10660 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
10662 function reread_COMSUB_EXPRSUB_FUNSUB_VALSUB {
10663 x=$(( echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;} ) | tr u x )
10665 inline_QCHAR_OQUOTE_CQUOTE() {
10666 echo fo\ob\"a\`r\'b\$az
10667 echo "fo\ob\"a\`r\'b\$az"
10668 echo 'fo\ob\"a\`r'\''b\$az'
10670 inline_QCHAR_OQUOTE_CQUOTE() {
10671 echo fo\ob\"a\`r\'b\$az
10672 echo "fo\ob\"a\`r\'b\$az"
10673 echo "fo\\ob\\\"a\\\`r"\'"b\\\$az"
10675 function comsub_QCHAR_OQUOTE_CQUOTE { x=$(
10676 echo fo\ob\"a\`r\'b\$az
10677 echo "fo\ob\"a\`r\'b\$az"
10678 echo 'fo\ob\"a\`r'\''b\$az'
10680 function comsub_QCHAR_OQUOTE_CQUOTE {
10681 x=$(echo fo\ob\"a\`r\'b\$az ; echo "fo\ob\"a\`r\'b\$az" ; echo "fo\\ob\\\"a\\\`r"\'"b\\\$az" )
10683 function reread_QCHAR_OQUOTE_CQUOTE { x=$((
10684 echo fo\ob\"a\`r\'b\$az
10685 echo "fo\ob\"a\`r\'b\$az"
10686 echo 'fo\ob\"a\`r'\''b\$az'
10688 function reread_QCHAR_OQUOTE_CQUOTE {
10689 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 )
10691 inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() {
10692 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
10694 inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() {
10695 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
10697 function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$(
10698 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
10700 function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT {
10701 x=$([[ ${foo#bl\(u\)b} = @(bar|baz) ]] )
10703 function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$((
10704 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
10706 function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT {
10707 x=$(( [[ ${foo#bl\(u\)b} = @(bar|baz) ]] ) | tr u x )
10709 inline_heredoc_closed() {
10711 note there must be no space between EOFN and )
10714 inline_heredoc_closed() {
10716 note there must be no space between EOFN and )
10721 function comsub_heredoc_closed { x=$(
10723 note there must be no space between EOFN and )
10726 function comsub_heredoc_closed {
10728 note there must be no space between EOFN and )
10732 function reread_heredoc_closed { x=$((
10734 note there must be no space between EOFN and )
10737 function reread_heredoc_closed {
10738 x=$(( x=$(cat <<EOFN
10739 note there must be no space between EOFN and )
10741 ) ; echo $x ) | tr u x )
10743 inline_heredoc_space() {
10745 note the space between EOFN and ) is actually part of the here document marker
10748 inline_heredoc_space() {
10750 note the space between EOFN and ) is actually part of the here document marker
10755 function comsub_heredoc_space { x=$(
10757 note the space between EOFN and ) is actually part of the here document marker
10760 function comsub_heredoc_space {
10761 x=$(x=$(cat <<EOFN\
10762 note the space between EOFN and ) is actually part of the here document marker
10766 function reread_heredoc_space { x=$((
10768 note the space between EOFN and ) is actually part of the here document marker
10771 function reread_heredoc_space {
10772 x=$(( x=$(cat <<EOFN\
10773 note the space between EOFN and ) is actually part of the here document marker
10775 ) ; echo $x ) | tr u x )
10777 inline_patch_motd() {
10778 x=$(sysctl -n kern.version | sed 1q)
10779 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
10780 ed -s /etc/motd 2>&1 <<-EOF
10787 EOF)" = @(?) ]] && rm -f /etc/motd
10788 if [[ ! -s /etc/motd ]]; then
10789 install -c -o root -g wheel -m 664 /dev/null /etc/motd
10790 print -- "$x\n" >/etc/motd
10793 inline_patch_motd() {
10794 x=$(sysctl -n kern.version | sed 1q )
10795 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
10803 )" = @(?) ]] && rm -f /etc/motd
10804 if [[ ! -s /etc/motd ]]
10806 install -c -o root -g wheel -m 664 /dev/null /etc/motd
10807 print -- "$x\n" >/etc/motd
10810 function comsub_patch_motd { x=$(
10811 x=$(sysctl -n kern.version | sed 1q)
10812 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
10813 ed -s /etc/motd 2>&1 <<-EOF
10820 EOF)" = @(?) ]] && rm -f /etc/motd
10821 if [[ ! -s /etc/motd ]]; then
10822 install -c -o root -g wheel -m 664 /dev/null /etc/motd
10823 print -- "$x\n" >/etc/motd
10826 function comsub_patch_motd {
10827 x=$(x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
10835 )" = @(?) ]] && 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 )
10837 function reread_patch_motd { x=$((
10838 x=$(sysctl -n kern.version | sed 1q)
10839 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
10840 ed -s /etc/motd 2>&1 <<-EOF
10847 EOF)" = @(?) ]] && rm -f /etc/motd
10848 if [[ ! -s /etc/motd ]]; then
10849 install -c -o root -g wheel -m 664 /dev/null /etc/motd
10850 print -- "$x\n" >/etc/motd
10853 function reread_patch_motd {
10854 x=$(( x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
10862 )" = @(?) ]] && 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 )
10864 inline_wdarrassign() {
10869 inline_wdarrassign() {
10877 function comsub_wdarrassign { x=$(
10882 function comsub_wdarrassign {
10883 x=$(case x in (x) a+=b ; \set -A c+ -- d e ;; esac )
10885 function reread_wdarrassign { x=$((
10890 function reread_wdarrassign {
10891 x=$(( case x in (x) a+=b ; \set -A c+ -- d e ;; esac ) | tr u x )
10894 name: comsub-torture-io
10896 Check the tree dump functions work correctly with I/O redirection
10898 if [[ -z $__progname ]]; then echo >&2 call me with __progname; exit 1; fi
10899 while IFS= read -r line; do
10900 if [[ $line = '#1' ]]; then
10903 elif [[ $line = EOFN* ]]; then
10904 fbody=$fbody$'\n'$line
10906 elif [[ $line != '#'* ]]; then
10907 fbody=$fbody$'\n\t'$line
10910 if (( lastf )); then
10911 x="inline_${nextf}() {"$fbody$'\n}\n'
10913 print -r -- "${x}typeset -f inline_$nextf" | "$__progname"
10914 x="function comsub_$nextf { x=\$("$fbody$'\n); }\n'
10916 print -r -- "${x}typeset -f comsub_$nextf" | "$__progname"
10917 x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n'
10919 print -r -- "${x}typeset -f reread_$nextf" | "$__progname"
10927 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
10928 #TPAREN_TPIPE_TLIST
10929 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
10931 cmd >&3 && >&3 echo ja || echo >&3 nein
10933 select file in *; do echo "<$file>" ; break >&3 ; done >&3
10935 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
10937 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
10938 #TIF_TBANG_TDBRACKET_TELIF
10939 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
10941 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
10943 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
10945 cat * >&3 |& >&3 ls
10946 #TFUNCT_TBRACE_TASYNC
10947 function korn { echo eins; echo >&3 zwei ; }
10948 bourne () { logger * >&3 & }
10950 echo $(true >&3) $((1+ 2))
10955 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
10958 vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" >&3
10960 function comsub_TCOM { x=$(
10961 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
10963 function comsub_TCOM {
10964 x=$(vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" >&3 )
10966 function reread_TCOM { x=$((
10967 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
10969 function reread_TCOM {
10970 x=$(( vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" >&3 ) | tr u x )
10972 inline_TPAREN_TPIPE_TLIST() {
10973 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
10975 inline_TPAREN_TPIPE_TLIST() {
10976 ( echo $foo | tr -dc 0-9 >&3
10979 function comsub_TPAREN_TPIPE_TLIST { x=$(
10980 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
10982 function comsub_TPAREN_TPIPE_TLIST {
10983 x=$(( echo $foo | tr -dc 0-9 >&3 ; echo >&3 ) >&3 )
10985 function reread_TPAREN_TPIPE_TLIST { x=$((
10986 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
10988 function reread_TPAREN_TPIPE_TLIST {
10989 x=$(( ( echo $foo | tr -dc 0-9 >&3 ; echo >&3 ) >&3 ) | tr u x )
10991 inline_TAND_TOR() {
10992 cmd >&3 && >&3 echo ja || echo >&3 nein
10994 inline_TAND_TOR() {
10995 cmd >&3 && echo ja >&3 || echo nein >&3
10997 function comsub_TAND_TOR { x=$(
10998 cmd >&3 && >&3 echo ja || echo >&3 nein
11000 function comsub_TAND_TOR {
11001 x=$(cmd >&3 && echo ja >&3 || echo nein >&3 )
11003 function reread_TAND_TOR { x=$((
11004 cmd >&3 && >&3 echo ja || echo >&3 nein
11006 function reread_TAND_TOR {
11007 x=$(( cmd >&3 && echo ja >&3 || echo nein >&3 ) | tr u x )
11010 select file in *; do echo "<$file>" ; break >&3 ; done >&3
11019 function comsub_TSELECT { x=$(
11020 select file in *; do echo "<$file>" ; break >&3 ; done >&3
11022 function comsub_TSELECT {
11023 x=$(select file in * ; do echo "<$file>" ; break >&3 ; done >&3 )
11025 function reread_TSELECT { x=$((
11026 select file in *; do echo "<$file>" ; break >&3 ; done >&3
11028 function reread_TSELECT {
11029 x=$(( select file in * ; do echo "<$file>" ; break >&3 ; done >&3 ) | tr u x )
11031 inline_TFOR_TTIME() {
11032 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
11034 inline_TFOR_TTIME() {
11040 function comsub_TFOR_TTIME { x=$(
11041 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
11043 function comsub_TFOR_TTIME {
11044 x=$(for i in {1,2,3} ; do time echo $i >&3 ; done >&3 )
11046 function reread_TFOR_TTIME { x=$((
11047 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
11049 function reread_TFOR_TTIME {
11050 x=$(( for i in {1,2,3} ; do time echo $i >&3 ; done >&3 ) | tr u x )
11053 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
11064 echo kann net bis drei zählen >&3
11068 function comsub_TCASE { x=$(
11069 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
11071 function comsub_TCASE {
11072 x=$(case $foo in (1) echo eins >&3 ;& (2) echo zwei >&3 ;| (*) echo kann net bis drei zählen >&3 ;; esac >&3 )
11074 function reread_TCASE { x=$((
11075 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
11077 function reread_TCASE {
11078 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 )
11080 inline_TIF_TBANG_TDBRACKET_TELIF() {
11081 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
11083 inline_TIF_TBANG_TDBRACKET_TELIF() {
11084 if ! [[ 1 = 1 ]] >&3
11087 elif [[ 1 = 2 ]] >&3
11094 function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$(
11095 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
11097 function comsub_TIF_TBANG_TDBRACKET_TELIF {
11098 x=$(if ! [[ 1 = 1 ]] >&3 ; then echo eins ; elif [[ 1 = 2 ]] >&3 ; then echo zwei ; else echo drei ; fi >&3 )
11100 function reread_TIF_TBANG_TDBRACKET_TELIF { x=$((
11101 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
11103 function reread_TIF_TBANG_TDBRACKET_TELIF {
11104 x=$(( if ! [[ 1 = 1 ]] >&3 ; then echo eins ; elif [[ 1 = 2 ]] >&3 ; then echo zwei ; else echo drei ; fi >&3 ) | tr u x )
11107 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
11111 while \let] " i < 10 " >&3
11117 function comsub_TWHILE { x=$(
11118 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
11120 function comsub_TWHILE {
11121 x=$(i=1 ; while \let] " i < 10 " >&3 ; do echo $i ; let ++i ; done >&3 )
11123 function reread_TWHILE { x=$((
11124 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
11126 function reread_TWHILE {
11127 x=$(( i=1 ; while \let] " i < 10 " >&3 ; do echo $i ; let ++i ; done >&3 ) | tr u x )
11130 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
11134 until \let] " !--i " >&3
11139 function comsub_TUNTIL { x=$(
11140 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
11142 function comsub_TUNTIL {
11143 x=$(i=10 ; until \let] " !--i " >&3 ; do echo $i ; done >&3 )
11145 function reread_TUNTIL { x=$((
11146 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
11148 function reread_TUNTIL {
11149 x=$(( i=10 ; until \let] " !--i " >&3 ; do echo $i ; done >&3 ) | tr u x )
11152 cat * >&3 |& >&3 ls
11158 function comsub_TCOPROC { x=$(
11159 cat * >&3 |& >&3 ls
11161 function comsub_TCOPROC {
11162 x=$(cat * >&3 |& ls >&3 )
11164 function reread_TCOPROC { x=$((
11165 cat * >&3 |& >&3 ls
11167 function reread_TCOPROC {
11168 x=$(( cat * >&3 |& ls >&3 ) | tr u x )
11170 inline_TFUNCT_TBRACE_TASYNC() {
11171 function korn { echo eins; echo >&3 zwei ; }
11172 bourne () { logger * >&3 & }
11174 inline_TFUNCT_TBRACE_TASYNC() {
11183 function comsub_TFUNCT_TBRACE_TASYNC { x=$(
11184 function korn { echo eins; echo >&3 zwei ; }
11185 bourne () { logger * >&3 & }
11187 function comsub_TFUNCT_TBRACE_TASYNC {
11188 x=$(function korn { echo eins ; echo zwei >&3 ; } ; bourne() { logger * >&3 & } )
11190 function reread_TFUNCT_TBRACE_TASYNC { x=$((
11191 function korn { echo eins; echo >&3 zwei ; }
11192 bourne () { logger * >&3 & }
11194 function reread_TFUNCT_TBRACE_TASYNC {
11195 x=$(( function korn { echo eins ; echo zwei >&3 ; } ; bourne() { logger * >&3 & } ) | tr u x )
11197 inline_COMSUB_EXPRSUB() {
11198 echo $(true >&3) $((1+ 2))
11200 inline_COMSUB_EXPRSUB() {
11201 echo $(true >&3 ) $((1+ 2))
11203 function comsub_COMSUB_EXPRSUB { x=$(
11204 echo $(true >&3) $((1+ 2))
11206 function comsub_COMSUB_EXPRSUB {
11207 x=$(echo $(true >&3 ) $((1+ 2)) )
11209 function reread_COMSUB_EXPRSUB { x=$((
11210 echo $(true >&3) $((1+ 2))
11212 function reread_COMSUB_EXPRSUB {
11213 x=$(( echo $(true >&3 ) $((1+ 2)) ) | tr u x )
11218 Check that non-subenvironment command substitution works
11238 You can now reliably use local and return in funsubs
11241 x=q; e=1; x=${ echo a; e=2; echo x$e;}; echo 1:y$x,$e,$?.
11242 x=q; e=1; x=${ echo a; typeset e=2; echo x$e;}; echo 2:y$x,$e,$?.
11243 x=q; e=1; x=${ echo a; typeset e=2; return 3; echo x$e;}; echo 3:y$x,$e,$?.
11251 Check that "value substitutions" work as advertised
11257 echo "before: x<$x> y<$y> z<$z> R<$REPLY>"
11260 echo "begin: x<$x> y<$y> z<$z> R<$REPLY>"
11265 echo "end: x<$x> y<$y> z<$z> R<$REPLY>"
11267 echo "after: x<$x> y<$y> z<$z> R<$REPLY>"
11268 # ensure trailing newlines are kept
11269 t=${|REPLY=$'foo\n\n';}
11271 echo -n this used to segfault
11272 echo ${|true;}$(true).
11274 before: x<1> y<2> z<3> R<4>
11275 begin: x<1> y<> z<3> R<>
11276 end: x<5> y<6> z<7> R<8>
11277 after: x<8> y<2> z<7> R<4>
11278 typeset t=$'foo\n\n'
11279 this used to segfault.
11283 Check that the short form [ $x ] works
11287 rv=$?; echo $((++i)) $rv
11289 rv=$?; echo $((++i)) $rv
11291 rv=$?; echo $((++i)) $rv
11293 rv=$?; echo $((++i)) $rv
11296 rv=$?; echo $((++i)) $rv
11298 rv=$?; echo $((++i)) $rv
11300 rv=$?; echo $((++i)) $rv
11302 rv=$?; echo $((++i)) $rv
11305 rv=$?; echo $((++i)) $rv
11307 rv=$?; echo $((++i)) $rv
11309 rv=$?; echo $((++i)) $rv
11311 rv=$?; echo $((++i)) $rv
11328 Check that the short form [[ $x ]] works (ksh93 extension)
11332 rv=$?; echo $((++i)) $rv
11334 rv=$?; echo $((++i)) $rv
11336 rv=$?; echo $((++i)) $rv
11338 rv=$?; echo $((++i)) $rv
11341 rv=$?; echo $((++i)) $rv
11343 rv=$?; echo $((++i)) $rv
11345 rv=$?; echo $((++i)) $rv
11347 rv=$?; echo $((++i)) $rv
11350 rv=$?; echo $((++i)) $rv
11352 rv=$?; echo $((++i)) $rv
11354 rv=$?; echo $((++i)) $rv
11356 rv=$?; echo $((++i)) $rv
11371 name: event-subst-3
11373 Check that '!' substitution in noninteractive 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
11399 name: event-subst-0
11401 Check that '!' substitution in interactive mode is ignored
11404 file-setup: file 755 "falsetto"
11408 file-setup: file 755 "!false"
11412 export PATH=.$PATHSEP$PATH
11420 ! false; then echo foo; else echo bar; fi
11428 expected-stderr-pattern:
11433 Check that "set -u" matches (future) SUSv4 requirement
11439 if [[ -n $v ]]; then
11474 (mypid=$$; try mypid)
11476 ) 2>&1 | sed -e 's/^[^]]*]//' -e 's/^[^:]*: *//'
11477 exit ${PIPESTATUS[0]}
11481 y: parameter not set
11485 y: parameter not set
11489 2: parameter not set
11491 1: parameter not set
11499 !: parameter not set
11510 Testsuite for nameref (bound variables)
11525 set|grep ^ir2|sed 's/^/s1: /'
11526 typeset|grep ' ir2'|sed -e 's/^/s2: /' -e 's/nameref/typeset -n/'
11527 set -A blub -- e1 e2 e3
11528 typeset -n ind=blub
11529 typeset -n ir2=blub[2]
11530 echo !ind[1]: ${!ind[1]}
11532 echo ind[1]: ${ind[1]}
11552 Testsuite for nameref (bound variables)
11553 Functions, argument given directly, after local
11556 typeset bar=lokal baz=auch
11588 Advanced testsuite for bound variables (ksh93 fails this)
11590 typeset -n foo=bar[i]
11591 set -A bar -- b c a
11592 for i in 0 1 2 3; do
11603 Ensure we don't run in an infinite loop
11607 typeset -n foo=fnord fnord=foo
11617 expected-stderr-pattern:
11618 /fnord: expression recurses on parameter/
11620 name: better-parens-1a
11622 Check support for ((…)) and $((…)) vs (…) and $(…)
11624 if ( (echo fubar)|tr u x); then
11633 name: better-parens-1b
11635 Check support for ((…)) and $((…)) vs (…) and $(…)
11637 echo $( (echo fubar)|tr u x) $?
11641 name: better-parens-1c
11643 Check support for ((…)) and $((…)) vs (…) and $(…)
11645 x=$( (echo fubar)|tr u x); echo $x $?
11649 name: better-parens-2a
11651 Check support for ((…)) and $((…)) vs (…) and $(…)
11653 if ((echo fubar)|tr u x); then
11662 name: better-parens-2b
11664 Check support for ((…)) and $((…)) vs (…) and $(…)
11666 echo $((echo fubar)|tr u x) $?
11670 name: better-parens-2c
11672 Check support for ((…)) and $((…)) vs (…) and $(…)
11674 x=$((echo fubar)|tr u x); echo $x $?
11678 name: better-parens-3a
11680 Check support for ((…)) and $((…)) vs (…) and $(…)
11682 if ( (echo fubar)|(tr u x)); then
11691 name: better-parens-3b
11693 Check support for ((…)) and $((…)) vs (…) and $(…)
11695 echo $( (echo fubar)|(tr u x)) $?
11699 name: better-parens-3c
11701 Check support for ((…)) and $((…)) vs (…) and $(…)
11703 x=$( (echo fubar)|(tr u x)); echo $x $?
11707 name: better-parens-4a
11709 Check support for ((…)) and $((…)) vs (…) and $(…)
11711 if ((echo fubar)|(tr u x)); then
11720 name: better-parens-4b
11722 Check support for ((…)) and $((…)) vs (…) and $(…)
11724 echo $((echo fubar)|(tr u x)) $?
11728 name: better-parens-4c
11730 Check support for ((…)) and $((…)) vs (…) and $(…)
11732 x=$((echo fubar)|(tr u x)); echo $x $?
11738 Test what the echo builtin does (mksh)
11740 echo -n 'foo\x40bar'
11747 Test what the echo builtin does (POSIX)
11748 Note: this follows Debian Policy 10.4 which mandates
11749 that -n shall be treated as an option, not XSI which
11750 mandates it shall be treated as string but escapes
11753 test -n "$POSH_VERSION" || set -o posix
11754 echo -n 'foo\x40bar'
11759 name: echo-test-3-mnbsd
11761 Test what the echo builtin does, and test a compatibility flag.
11764 "$__progname" -c 'echo -n 1=\\x40$1; echo -e \\x2E' -- foo bar
11765 "$__progname" -o posix -c 'echo -n 2=\\x40$1; echo -e \\x2E' -- foo bar
11766 "$__progname" -o sh -c 'echo -n 3=\\x40$1; echo -e \\x2E' -- foo bar
11772 name: echo-test-3-normal
11774 Test what the echo builtin does, and test a compatibility flag.
11775 category: !mnbsdash
11777 "$__progname" -c 'echo -n 1=\\x40$1; echo -e \\x2E' -- foo bar
11778 "$__progname" -o posix -c 'echo -n 2=\\x40$1; echo -e \\x2E' -- foo bar
11779 "$__progname" -o sh -c 'echo -n 3=\\x40$1; echo -e \\x2E' -- foo bar
11785 name: utilities-getopts-1
11787 getopts sets OPTIND correctly for unparsed option
11790 while getopts :a optc; do
11791 echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
11795 OPTARG=, OPTIND=2, optc=a.
11796 OPTARG=, OPTIND=3, optc=a.
11797 OPTARG=x, OPTIND=4, optc=?.
11800 name: utilities-getopts-2
11805 while getopts a: optc; do
11806 echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
11810 OPTARG=Mary, OPTIND=3, optc=a.
11811 OPTARG=, OPTIND=4, optc=?.
11813 expected-stderr-pattern: /.*-x.*option/
11817 Check the new wcswidth feature
11821 print octets: ${#s} .
11822 print 8-bit width: ${%s} .
11824 print characters: ${#s} .
11825 print columns: ${%s} .
11828 print octets: ${#s} .
11829 print 8-bit width: ${%s} .
11831 print characters: ${#s} .
11832 print columns: ${%s} .
11845 Check some corner cases
11861 Check some corner cases
11864 expected-stderr-pattern:
11870 Check some corner cases
11873 expected-stderr-pattern:
11879 Check some corner cases
11882 expected-stderr-pattern:
11888 Check some corner cases
11897 Check proper return values for realpath
11898 category: os:mirbsd
11911 x=$(realpath "$wd/$1" 2>&1); y=$?
11912 print $((++i)) "?$1" =${x##*$wd/} !$y
11938 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
11943 3 ?dir/file =dir/file !0
11944 4 ?dir/nix =dir/nix !0
11946 6 ?file/ =file/: Not a directory !20
11947 7 ?file/file =file/file: Not a directory !20
11948 8 ?file/nix =file/nix: Not a directory !20
11951 11 ?nix/file =nix/file: No such file or directory !2
11952 12 ?nix/nix =nix/nix: No such file or directory !2
11955 15 ?lndir/file =dir/file !0
11956 16 ?lndir/nix =dir/nix !0
11957 17 ?lnfile =file !0
11958 18 ?lnfile/ =lnfile/: Not a directory !20
11959 19 ?lnfile/file =lnfile/file: Not a directory !20
11960 20 ?lnfile/nix =lnfile/nix: Not a directory !20
11963 23 ?lnnix/file =lnnix/file: No such file or directory !2
11964 24 ?lnnix/nix =lnnix/nix: No such file or directory !2
11965 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
11969 Ensure that exactly two leading slashes are not collapsed
11970 POSIX guarantees this exception, e.g. for UNC paths on Cygwin
11971 category: os:mirbsd
11981 realpath /usr///bin
11990 realpath //usr/include/../bin
12007 Crashed during March 2011, fixed on vernal equinōx ☺
12008 category: os:mirbsd,os:openbsd
12010 export MALLOC_OPTIONS=FGJPRSX
12011 "$__progname" -c 'x=$(tr z r <<<baz); echo $x'
12017 Check test - bug#465250
12019 test \( ! -e \) ; echo $?
12025 Check test - bug#465250
12027 test \( -e \) ; echo $?
12033 Check test - bug#465250
12035 test ! -e ; echo $?
12041 Check test - bug#465250
12049 Check that zsh case variants work
12083 Check that case end tokens are not mixed up (Debian #220272)
12086 for value in 'x' '}' 'esac'; do
12087 print -n "$((++i))($value)bourne "
12092 print -n "$((++i))($value)korn "
12106 name: command-shift
12108 Check that 'command shift' works
12111 echo "before 0='$0' 1='$1' 2='$2'"
12113 echo "after 0='$0' 1='$1' 2='$2'"
12116 echo "before 0='$0' 1='$1' 2='$2'"
12118 echo "after 0='$0' 1='$1' 2='$2'"
12120 echo = without command
12122 echo = with command
12127 before 0='snc' 1='一' 2='二'
12128 after 0='snc' 1='二' 2=''
12130 before 0='swc' 1='一' 2='二'
12131 after 0='swc' 1='二' 2=''
12136 Check that the compiler did not optimise-break them
12137 (lex.c has got a similar one in SHEREDELIM)
12142 while (( ++i < 256 )); do
12145 s+=$'\xC2\xA0\xE2\x82\xAC\xEF\xBF\xBD\xEF\xBF\xBE\xEF\xBF\xBF\xF0\x90\x80\x80.'
12148 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.'
12150 name: stateptr-underflow
12152 This check overflows an Xrestpos stored in a short in R40
12155 function Lb64decode {
12156 [[ -o utf8-mode ]]; local u=$?
12159 [[ -n $s ]] || { s=$(cat;print x); s=${s%x}; }
12160 local -i i=0 n=${#s} p=0 v x
12163 while (( i < n )); do
12167 ([A-Z]) (( v = 1#$c - 65 )) ;;
12168 ([a-z]) (( v = 1#$c - 71 )) ;;
12169 ([0-9]) (( v = 1#$c + 4 )) ;;
12174 (( x = (x << 6) | v ))
12177 (1) (( o = (x >> 4) & 255 )) ;;
12178 (2) (( o = (x >> 2) & 255 )) ;;
12179 (3) (( o = x & 255 ))
12191 while (( ++i < 12120 )); do
12194 Lb64decode $s >/dev/null
12198 Check that "set -x" doesn't redirect too quickly
12200 print '#!'"$__progname" >bash
12202 echo 'GNU bash, version 2.05b.0(1)-release (i386-ecce-mirbsd10)
12203 Copyright (C) 2002 Free Software Foundation, Inc.'
12206 "$__progname" -xc 'foo=$(./bash --version 2>&1 | head -1); echo "=$foo="'
12208 =GNU bash, version 2.05b.0(1)-release (i386-ecce-mirbsd10)=
12209 expected-stderr-pattern:
12214 Check that "set -x" is off during PS4 expansion
12221 PS4='[(p:$-)$(f)] '
12223 set -x -o inherit-xtrace
12232 [(p:sh)(f1:sh)(f2:sh)] print '(o1:shx)'
12233 [(p:sh)(f1:sh)(f2:sh)] set +x
12237 Check that FKSH functions have their own shell flags
12238 category: shell:legacy-no
12240 [[ $KSH_VERSION = Version* ]] && set +B
12255 name: fksh-flags-legacy
12257 Check that even FKSH functions share the shell flags
12258 category: shell:legacy-yes
12260 [[ $KSH_VERSION = Version* ]] && set +B
12277 Check that !FKSH functions share the shell flags
12279 [[ $KSH_VERSION = Version* ]] && set +B