1 # $MirOS: src/bin/mksh/check.t,v 1.667.2.7 2015/04/19 19:18:10 tg Exp $
4 # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
5 # 2011, 2012, 2013, 2014, 2015
6 # Thorsten Glaser <tg@mirbsd.org>
8 # Provided that these terms and disclaimer and all copyright notices
9 # are retained or reproduced in an accompanying document, permission
10 # is granted to deal in this work without restriction, including un‐
11 # limited rights to use, publicly perform, distribute, sell, modify,
12 # merge, give away, or sublicence.
14 # This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
15 # the utmost extent permitted by applicable law, neither express nor
16 # implied; without malicious intent or gross negligence. In no event
17 # may a licensor, author or contributor be held liable for indirect,
18 # direct, other damage, loss, or other issues arising in any way out
19 # of dealing in the work, even if advised of the possibility of such
20 # damage or existence of a defect, except proven that it results out
21 # of said person’s immediate fault when using the work as intended.
23 # You may also want to test IFS with the script at
24 # http://www.research.att.com/~gsf/public/ifs.sh
27 # http://svnweb.freebsd.org/base/head/bin/test/tests/legacy_test.sh?view=co&content-type=text%2Fplain
29 # Integrated testsuites from:
30 # (2013/12/02 20:39:44) http://openbsd.cs.toronto.edu/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
33 @(#)MIRBSD KSH R50 2015/04/19
35 Check version of shell.
39 category: shell:legacy-no
42 @(#)LEGACY KSH R50 2015/04/19
44 Check version of legacy shell.
47 name: KSH_VERSION-legacy
48 category: shell:legacy-yes
52 Regression test self-testing
60 Regression test self-testing
69 Regression test self-testing
70 env-setup: !ENV=fnord!
78 Ensure that the test run directory (default /tmp but can be changed
79 with check.pl flag -T or test.sh $TMPDIR) is not mounted noexec, as
80 we execute scripts from the scratch directory during several tests.
82 print '#!'"$__progname"'\necho tf' >lq
90 Just output the environment variables set (always fails)
97 Check some things in the LEGACY KSH
98 category: shell:legacy-yes
102 [[ "$(set +o) -o" = *"-o emacs -o"* ]] && echo 1=emacs
103 [[ "$(set +o) -o" = *"-o vi -o"* ]] && echo 1=vi
106 [[ "$(set +o) -o" = *"-o emacs -o"* ]] && echo 2=emacs
107 [[ "$(set +o) -o" = *"-o vi -o"* ]] && echo 2=vi
112 name: selftest-direct-builtin-call
114 Check that direct builtin calls work
116 ln -s "$__progname" cat || cp "$__progname" cat
117 ln -s "$__progname" echo || cp "$__progname" echo
118 ./echo -c 'echo foo' | ./cat -u
124 Check that recursion is detected/avoided in aliases.
129 expected-stderr-pattern:
130 /fooBar.*not found.*/
134 Check that recursion is detected/avoided in aliases.
141 expected-stderr-pattern:
142 /fooBar.*not found.*\n.*barFoo.*not found/
146 Check that recursion is detected/avoided in aliases.
160 Check that alias expansion isn't done on keywords (in keyword
165 while false; do echo hi ; done
172 Check that alias expansion done after alias with trailing space.
175 alias foo='bar stuff '
176 alias bar='Bar1 Bar2 '
185 Check that alias expansion done after alias with trailing space.
197 Check that alias expansion done after alias with trailing space
202 X Y in 'Y') echo is y ;; Z) echo is z ; esac
208 Check that newlines in an alias don't cause the command to be lost.
228 Check that recursion is detected/avoided in aliases.
229 This check fails for slow machines or Cygwin, raise
230 the time-limit clause (e.g. to 7) if this occurs.
233 print '#!'"$__progname"'\necho tf' >lq
251 Check that recursion is detected/avoided in aliases.
252 Regression, introduced during an old bugfix.
254 alias foo='print hello '
255 alias bar='foo world'
262 Check that 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,!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 FreeMiNT (cannot unlink dangling symlinks)
2079 # breaks on MSYS (does not support symlinks)
2080 # breaks on Dell UNIX 4.0 R2.2 (SVR4) where unlink also fails
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
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 (NOTE: adjusted for COMPLEX HISTORY compile time option)
3559 (ksh88 fails 'cause it lists the fc command)
3564 env-setup: !ENV=./Env!HISTFILE=hist.file!
3565 file-setup: file 644 "Env"
3586 expected-stderr-pattern:
3587 /^X*echo FOOBAR def\necho a new line\nX*$/
3591 Basic (ed) editing works (assumes you have generic ed editor
3592 that prints no prompts). This is for newish ed(1) and stderr.
3593 category: !no-stderr-ed
3597 env-setup: !ENV=./Env!HISTFILE=hist.file!
3598 file-setup: file 644 "Env"
3609 expected-stderr-pattern:
3610 /^X*13\n16\necho FOOBAR def\nX*$/
3614 Correct command is edited when number given
3615 category: !no-stderr-ed
3619 env-setup: !ENV=./Env!HISTFILE=hist.file!
3620 file-setup: file 644 "Env"
3628 s/is here/is changed/
3637 expected-stderr-pattern:
3638 /^X*20\n23\necho line 2 is changed\nX*$/
3642 Newly created multi line commands show up as single command
3644 category: !no-stderr-ed
3648 env-setup: !ENV=./Env!HISTFILE=hist.file!
3649 file-setup: file 644 "Env"
3668 expected-stderr-pattern:
3669 /^X*13\n32\necho FOOBAR def\necho a new line\nX*$/
3673 Simple test, default IFS
3675 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3691 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3708 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3721 name: IFS-space-colon-1
3723 Simple test, IFS=<white-space>:
3725 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3740 name: IFS-space-colon-2
3742 Simple test, IFS=<white-space>:
3743 AT&T ksh fails this, POSIX says the test is correct.
3745 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3752 name: IFS-space-colon-4
3754 Simple test, IFS=<white-space>:
3756 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3763 name: IFS-space-colon-5
3765 Simple test, IFS=<white-space>:
3766 Don't know what POSIX thinks of this. AT&T ksh does not do this.
3768 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3777 Simple test, IFS=<white-space>:
3779 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3782 echo -n '1:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3783 echo -n '2:'; for i in :b:: ; do echo -n " [$i]" ; done ; echo
3787 echo -n '5:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3790 echo -n '7:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3792 echo -n '9:'; for i in ${FOO-`echo -n h:i`th:ere} ; do echo -n " [$i]" ; done ; echo
3793 showargs 10 ${FOO-`echo -n h:i`th:ere}
3794 showargs 11 "${FOO-`echo -n h:i`th:ere}"
3796 echo -n '12:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3808 <10> <h> <ith> <ere> .
3811 <13> <A> <B> <> <D> .
3815 Check leading whitespace after trim does not make a field
3817 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3819 showargs 1 shift ${x#X}
3821 <1> <shift> <1> <2> .
3823 name: IFS-subst-3-arr
3825 Check leading IFS non-whitespace after trim does make a field
3826 but leading IFS whitespace does not, nor empty replacements
3828 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3831 showargs 1 ${-+:foo:bar}
3833 showargs 2 ${-+ foo bar}
3836 <1> <> <foo> <bar> .
3839 name: IFS-subst-3-ass
3841 Check non-field semantics
3843 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
3846 showargs 1 x=${-+:foo:bar}
3848 showargs 2 x=${-+ foo bar}
3851 <1> <x=> <foo> <bar> .
3852 <2> <x=> <foo> <bar> .
3854 name: IFS-subst-3-lcl
3856 Check non-field semantics, smaller corner case (LP#1381965)
3861 expected-exit: e != 0
3862 expected-stderr-pattern:
3867 reported by mikeserv
3869 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
3870 a='space divded argument
3873 IFS= ; q="$*" ; nq=$*
3874 pfn "$*" $* "$q" "$nq"
3875 [ "$q" = "$nq" ] && echo =true || echo =false
3877 <spacedivdedargument
3883 <spacedivdedargument
3885 <spacedivdedargument
3891 extended testsuite based on problem by mikeserv
3893 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
3894 a='space divded argument
3897 IFS= ; q="$@" ; nq=$@
3898 pfn "$*" $* "$q" "$nq"
3899 [ "$q" = "$nq" ] && echo =true || echo =false
3901 <spacedivdedargument
3907 <space divded argument
3909 <space divded argument
3915 extended testsuite based on problem by mikeserv
3917 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
3918 a='space divded argument
3920 IFS=\ ; set -- $a; IFS=
3925 print -nr -- '= qs '; pfn "$qs"
3926 print -nr -- '=nqs '; pfn "$nqs"
3927 print -nr -- '= qk '; pfn "$qk"
3928 print -nr -- '=nqk '; pfn "$nqk"
3929 print -nr -- '~ qs '; pfn "$*"
3930 print -nr -- '~nqs '; pfn $*
3931 print -nr -- '~ qk '; pfn "$@"
3932 print -nr -- '~nqk '; pfn $@
3934 = qs <spacedivdedargument
3936 =nqs <spacedivdedargument
3938 = qk <space divded argument
3940 =nqk <space divded argument
3942 ~ qs <spacedivdedargument
3959 extended testsuite based on problem by mikeserv
3961 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
3962 a='space divded argument
3964 IFS=\ ; set -- $a; IFS=
3966 print -nr -- '= qs '; pfn "$qs"
3967 print -nr -- '~ qs '; pfn "$*"
3969 print -nr -- '=nqs '; pfn "$nqs"
3970 print -nr -- '~nqs '; pfn $*
3972 print -nr -- '= qk '; pfn "$qk"
3973 print -nr -- '~ qk '; pfn "$@"
3975 print -nr -- '=nqk '; pfn "$nqk"
3976 print -nr -- '~nqk '; pfn $@
3978 = qs <spacedivdedargument
3980 ~ qs <spacedivdedargument
3982 =nqs <spacedivdedargument
3988 = qk <space divded argument
3994 =nqk <space divded argument
4001 name: IFS-subst-4-4p
4003 extended testsuite based on problem by mikeserv
4005 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4006 a='space divded argument
4008 IFS=\ ; set -- $a; IFS=
4011 print -nr -- '= qs '; pfn "$qs"
4012 print -nr -- '~ qs '; pfn ${v:-"$*"}
4014 print -nr -- '=nqs '; pfn "$nqs"
4015 print -nr -- '~nqs '; pfn ${v:-$*}
4017 print -nr -- '= qk '; pfn "$qk"
4018 print -nr -- '~ qk '; pfn ${v:-"$@"}
4020 print -nr -- '=nqk '; pfn "$nqk"
4021 print -nr -- '~nqk '; pfn ${v:-$@}
4023 = qs <spacedivdedargument
4025 ~ qs <spacedivdedargument
4027 =nqs <spacedivdedargument
4033 = qk <space divded argument
4039 =nqk <space divded argument
4048 extended testsuite based on problem by mikeserv
4050 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4051 a='space divded argument
4053 IFS=\ ; set -- $a; IFS=,
4055 print -nr -- '= qs '; pfn "$qs"
4056 print -nr -- '~ qs '; pfn "$*"
4058 print -nr -- '=nqs '; pfn "$nqs"
4059 print -nr -- '~nqs '; pfn $*
4061 print -nr -- '= qk '; pfn "$qk"
4062 print -nr -- '~ qk '; pfn "$@"
4064 print -nr -- '=nqk '; pfn "$nqk"
4065 print -nr -- '~nqk '; pfn $@
4067 = qs <space,divded,argument
4069 ~ qs <space,divded,argument
4071 =nqs <space,divded,argument
4077 = qk <space divded argument
4083 =nqk <space divded argument
4090 name: IFS-subst-4-5p
4092 extended testsuite based on problem by mikeserv
4094 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4095 a='space divded argument
4097 IFS=\ ; set -- $a; IFS=,
4100 print -nr -- '= qs '; pfn "$qs"
4101 print -nr -- '~ qs '; pfn ${v:-"$*"}
4103 print -nr -- '=nqs '; pfn "$nqs"
4104 print -nr -- '~nqs '; pfn ${v:-$*}
4106 print -nr -- '= qk '; pfn "$qk"
4107 print -nr -- '~ qk '; pfn ${v:-"$@"}
4109 print -nr -- '=nqk '; pfn "$nqk"
4110 print -nr -- '~nqk '; pfn ${v:-$@}
4112 = qs <space,divded,argument
4114 ~ qs <space,divded,argument
4116 =nqs <space,divded,argument
4122 = qk <space divded argument
4128 =nqk <space divded argument
4137 extended testsuite based on IFS-subst-3
4138 differs slightly from ksh93:
4139 - omit trailing field in a3zna, a7ina (unquoted $@ expansion)
4140 - has extra middle fields in b5ins, b7ina (IFS_NWS unquoted expansion)
4141 differs slightly from bash:
4142 - omit leading field in a5ins, a7ina (IFS_NWS unquoted expansion)
4143 differs slightly from zsh:
4144 - differs in assignment, not expansion; probably zsh bug
4145 - has extra middle fields in b5ins, b7ina (IFS_NWS unquoted expansion)
4146 'emulate sh' zsh has extra fields in
4147 - a5ins (IFS_NWS unquoted $*)
4148 - b5ins, matching mksh’s
4149 !!WARNING!! more to come: http://austingroupbugs.net/view.php?id=888
4151 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4152 IFS=; set -- "" 2 ""; pfb $*; x=$*; pfn "$x"'
4154 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4155 IFS=; set -- "" 2 ""; pfb "$*"; x="$*"; pfn "$x"'
4157 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4158 IFS=; set -- "" 2 ""; pfb $@; x=$@; pfn "$x"'
4160 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4161 IFS=; set -- "" 2 ""; pfb "$@"; x="$@"; pfn "$x"'
4163 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4164 IFS=,; set -- "" 2 ""; pfb $*; x=$*; pfn "$x"'
4166 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4167 IFS=,; set -- "" 2 ""; pfb "$*"; x="$*"; pfn "$x"'
4169 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4170 IFS=,; set -- "" 2 ""; pfb $@; x=$@; pfn "$x"'
4172 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4173 IFS=,; set -- "" 2 ""; pfb "$@"; x="$@"; pfn "$x"'
4175 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4176 IFS=; set -- A B "" "" C; pfb $*; x=$*; pfn "$x"'
4178 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4179 IFS=; set -- A B "" "" C; pfb "$*"; x="$*"; pfn "$x"'
4181 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4182 IFS=; set -- A B "" "" C; pfb $@; x=$@; pfn "$x"'
4184 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4185 IFS=; set -- A B "" "" C; pfb "$@"; x="$@"; pfn "$x"'
4187 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4188 IFS=,; set -- A B "" "" C; pfb $*; x=$*; pfn "$x"'
4190 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4191 IFS=,; set -- A B "" "" C; pfb "$*"; x="$*"; pfn "$x"'
4193 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4194 IFS=,; set -- A B "" "" C; pfb $@; x=$@; pfn "$x"'
4196 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4197 IFS=,; set -- A B "" "" C; pfb "$@"; x="$@"; pfn "$x"'
4275 Regression wrt. vector expansion in trim
4277 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4287 ksh93 bug wrt. vector expansion in trim
4289 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4293 showargs "$*" ${a##"$*"}
4299 http://austingroupbugs.net/view.php?id=221
4301 n() { echo "$#"; }; n "${foo-$@}"
4307 Scalar context for $*/$@ in [[ and case
4309 "$__progname" -c 'IFS=; set a b; [[ $* = "$1$2" ]]; echo 1 $?' sh a b
4310 "$__progname" -c 'IFS=; [[ $* = ab ]]; echo 2 "$?"' sh a b
4311 "$__progname" -c 'IFS=; [[ "$*" = ab ]]; echo 3 "$?"' sh a b
4312 "$__progname" -c 'IFS=; [[ $* = a ]]; echo 4 "$?"' sh a b
4313 "$__progname" -c 'IFS=; [[ "$*" = a ]]; echo 5 "$?"' sh a b
4314 "$__progname" -c 'IFS=; [[ "$@" = a ]]; echo 6 "$?"' sh a b
4315 "$__progname" -c 'IFS=; case "$@" in a) echo 7 a;; ab) echo 7 b;; a\ b) echo 7 ok;; esac' sh a b
4316 "$__progname" -c 'IFS=; case $* in a) echo 8 a;; ab) echo 8 ok;; esac' sh a b
4317 "$__progname" -c 'pfsp() { for s_arg in "$@"; do print -nr -- "<$s_arg> "; done; print .; }; IFS=; star=$* at="$@"; pfsp 9 "$star" "$at"' sh a b
4331 http://austingroupbugs.net/view.php?id=832
4333 ${ZSH_VERSION+false} || emulate sh
4334 ${BASH_VERSION+set -o posix}
4335 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4337 showargs $((1230456))
4341 name: integer-base-err-1
4343 Can't have 0 base (causes shell to exit)
4344 expected-exit: e != 0
4350 expected-stderr-pattern:
4353 name: integer-base-err-2
4355 Can't have multiple bases in a 'constant' (causes shell to exit)
4356 (ksh88 fails this test)
4357 expected-exit: e != 0
4363 expected-stderr-pattern:
4364 /^.*:.*2#110#11.*\n$/
4366 name: integer-base-err-3
4368 Syntax errors in expressions and effects on bases
4369 (interactive so errors don't cause exits)
4370 (ksh88 fails this test - shell exits, even with -i)
4374 PS1= # minimise prompt hassles
4381 expected-stderr-pattern:
4382 /^([#\$] )?.*:.*2+.*\n.*:.*2+.*\n$/
4387 name: integer-base-err-4
4389 Are invalid digits (according to base) errors?
4390 (ksh93 fails this test)
4391 expected-exit: e != 0
4395 expected-stderr-pattern:
4396 /^([#\$] )?.*:.*3#4.*\n$/
4398 name: integer-base-1
4400 Missing number after base is treated as 0.
4409 name: integer-base-2
4411 Check 'stickyness' of base in various situations
4462 name: integer-base-3
4464 More base parsing (hmm doesn't test much..)
4484 name: integer-base-4
4486 Check that things not declared as integers are not made integers,
4487 also, check if base is not reset by -i with no arguments.
4488 (ksh93 fails - prints 10#20 - go figure)
4492 typeset -i | grep '^xx='
4499 name: integer-base-5
4515 for l in 1 2+3 4; do echo $l; done
4527 name: integer-base-6
4529 Even more base stuff
4530 (ksh93 fails this test - prints 0)
4538 name: integer-base-7
4540 Check that non-integer parameters don't get bases assigned
4542 echo $(( zz = 8#100 ))
4548 name: integer-base-check-flat
4550 Check behaviour does not match POSuX (except if set -o posix),
4551 because a not type-safe scripting language has *no* business
4552 interpreting the string "010" as octal numer eight (dangerous).
4554 echo 1 "$("$__progname" -c 'echo :$((10))/$((010)),$((0x10)):')" .
4555 echo 2 "$("$__progname" -o posix -c 'echo :$((10))/$((010)),$((0x10)):')" .
4556 echo 3 "$("$__progname" -o sh -c 'echo :$((10))/$((010)),$((0x10)):')" .
4562 name: integer-base-check-numeric-from
4564 Check behaviour for base one to 36, and that 37 errors out
4568 while (( ++i <= 36 )); do
4569 eval 'echo '$i':$(('$i'#10)).'
4571 echo 37:$($__progname -c 'echo $((37#10))').$?:
4610 expected-stderr-pattern:
4611 /.*bad number '37#10'/
4613 name: integer-base-check-numeric-to
4615 Check behaviour for base one to 36, and that 37 errors out
4618 while (( ++i <= 37 )); do
4619 typeset -Uui$i x=0x40
4620 eval "typeset -i10 y=$x"
4661 expected-stderr-pattern:
4662 /.*bad integer base: 37/
4664 name: integer-arithmetic-span
4666 Check wraparound and size that is defined in mksh
4669 echo s:$((2147483647+1)).$(((2147483647*2)+1)).$(((2147483647*2)+2)).
4670 echo u:$((#2147483647+1)).$((#(2147483647*2)+1)).$((#(2147483647*2)+2)).
4673 u:2147483648.4294967295.0.
4675 name: integer-arithmetic-span-64
4677 Check wraparound and size that is defined in mksh
4680 echo s:$((9223372036854775807+1)).$(((9223372036854775807*2)+1)).$(((9223372036854775807*2)+2)).
4681 echo u:$((#9223372036854775807+1)).$((#(9223372036854775807*2)+1)).$((#(9223372036854775807*2)+2)).
4683 s:-9223372036854775808.-1.0.
4684 u:9223372036854775808.18446744073709551615.0.
4686 name: integer-size-FAIL-to-detect
4688 Notify the user that their ints are not 32 or 64 bit
4695 See if $LINENO is updated and can be modified.
4708 See if $LINENO is set for .'d files.
4709 file-setup: file 644 "dotfile"
4727 See if $LINENO is set for commands in a function.
4746 See if unsetting LINENO makes it non-magic.
4747 file-setup: file 644 "dotfile"
4770 name: lineno-unset-use
4772 See if unsetting LINENO makes it non-magic even
4774 file-setup: file 644 "dotfile"
4800 Check if LINENO is tracked in traps
4806 trap 'fail $LINENO' INT ERR
4814 Ensure unknown traps are not a syntax error
4817 trap "echo trap 1 executed" UNKNOWNSIGNAL || echo "foo"
4819 trap "echo trap 2 executed" UNKNOWNSIGNAL EXIT 999999 FNORD
4821 ) 2>&1 | sed "s
\ 1^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]
\ 1PROG
\ 1"
4823 PROG: trap: bad signal 'UNKNOWNSIGNAL'
4826 PROG: trap: bad signal 'UNKNOWNSIGNAL'
4827 PROG: trap: bad signal '999999'
4828 PROG: trap: bad signal 'FNORD'
4834 Simple test, default IFS
4839 echo 1: "x[$x] y[$y] z[$z]"
4840 echo 1a: ${z-z not set}
4850 Complex tests, IFS either colon (IFS-NWS) or backslash (tricky)
4853 showargs() { print -nr "$1"; shift; for s_arg in "$@"; do print -nr -- " [$s_arg]"; done; print; }
4854 (IFS=\\ a=\<\\\>; showargs 3 $a)
4855 (IFS=: b=\<:\>; showargs 4 $b)
4856 print -r '<\>' | (IFS=\\ read f g; showargs 5 "$f" "$g")
4857 print -r '<\\>' | (IFS=\\ read f g; showargs 6 "$f" "$g")
4858 print '<\\\n>' | (IFS=\\ read f g; showargs 7 "$f" "$g")
4859 print -r '<\>' | (IFS=\\ read f; showargs 8 "$f")
4860 print -r '<\\>' | (IFS=\\ read f; showargs 9 "$f")
4861 print '<\\\n>' | (IFS=\\ read f; showargs 10 "$f")
4862 print -r '<\>' | (IFS=\\ read -r f g; showargs 11 "$f" "$g")
4863 print -r '<\\>' | (IFS=\\ read -r f g; showargs 12 "$f" "$g")
4864 print '<\\\n>' | (IFS=\\ read -r f g; showargs 13 "$f" "$g")
4865 print -r '<\>' | (IFS=\\ read -r f; showargs 14 "$f")
4866 print -r '<\\>' | (IFS=\\ read -r f; showargs 15 "$f")
4867 print '<\\\n>' | (IFS=\\ read -r f; showargs 16 "$f")
4868 print -r '<:>' | (IFS=: read f g; showargs 17 "$f" "$g")
4869 print -r '<::>' | (IFS=: read f g; showargs 18 "$f" "$g")
4870 print '<:\n>' | (IFS=: read f g; showargs 19 "$f" "$g")
4871 print -r '<:>' | (IFS=: read f; showargs 20 "$f")
4872 print -r '<::>' | (IFS=: read f; showargs 21 "$f")
4873 print '<:\n>' | (IFS=: read f; showargs 22 "$f")
4874 print -r '<:>' | (IFS=: read -r f g; showargs 23 "$f" "$g")
4875 print -r '<::>' | (IFS=: read -r f g; showargs 24 "$f" "$g")
4876 print '<:\n>' | (IFS=: read -r f g; showargs 25 "$f" "$g")
4877 print -r '<:>' | (IFS=: read -r f; showargs 26 "$f")
4878 print -r '<::>' | (IFS=: read -r f; showargs 27 "$f")
4879 print '<:\n>' | (IFS=: read -r f; showargs 28 "$f")
4910 If no var specified, REPLY is used
4918 name: read-regress-1
4920 Check a regression of read
4921 file-setup: file 644 "foo"
4926 while read a b c; do
4930 echo "<$a|$b|$c><$d>"
4936 Check read with delimiters
4939 print -n 'foo bar\tbaz\nblah \0blub\tblech\nmyok meck \0'
4941 emit | while IFS= read -d "" foo; do print -r -- "<$foo>"; done
4942 emit | while read -d "" foo; do print -r -- "<$foo>"; done
4943 emit | while read -d "eh?" foo; do print -r -- "<$foo>"; done
4960 Check read with number of bytes specified, and -A
4962 print 'foo\nbar' >x1
4964 print 'foo\\ bar baz' >x3
4966 x1b=u; read -N-1 x1b <x1
4967 x2a=u; read x2a <x2; r2a=$?
4968 x2b=u; read -N2 x2c <x2; r2b=$?
4969 x2c=u; read -n2 x2c <x2; r2c=$?
4970 x3a=u; read -A x3a <x3
4971 print -r "x1a=<$x1a>"
4972 print -r "x1b=<$x1b>"
4973 print -r "x2a=$r2a<$x2a>"
4974 print -r "x2b=$r2b<$x2b>"
4975 print -r "x2c=$r2c<$x2c>"
4976 print -r "x3a=<${x3a[0]}|${x3a[1]}|${x3a[2]}>"
4988 Lex array code had problems with this.
4999 When PATH is set before running a command, the new path is
5000 not used in doing the path search
5001 $ echo echo hi > /tmp/q ; chmod a+rx /tmp/q
5005 in comexec() the two lines
5007 (void) typeset(*vp++, xxx, 0);
5008 need to be moved out of the switch to before findcom() is
5009 called - I don't know what this will break.
5011 : ${PWD:-`pwd 2> /dev/null`}
5012 : ${PWD:?"PWD not set - can't do test"}
5014 cat > Y/xxxscript << EOF
5016 # Need to restore path so echo can be found (some shells don't have
5022 chmod a+rx Y/xxxscript
5023 export OLDPATH="$PATH"
5024 PATH=$PWD/Y xxxscript
5031 Parsing of $(..) expressions is non-optimal. It is
5032 impossible to have any parentheses inside the expression.
5034 $ ksh -c 'echo $(echo \( )'
5036 $ ksh -c 'echo $(echo "(" )'
5039 The solution is to hack the parsing clode in lex.c, the
5040 question is how to hack it: should any parentheses be
5041 escaped by a backslash, or should recursive parsing be done
5042 (so quotes could also be used to hide hem). The former is
5043 easier, the later better...
5053 Continue in a for loop does not work right:
5055 if [ $i = b ] ; then
5064 if [ $i = b ] ; then
5065 if [ $first = no ] ; then
5066 echo 'continue in for loop broken'
5067 break # hope break isn't broken too :-)
5082 should print 0 according to POSIX (dash, bash, ksh93, posh)
5083 but not 0 according to the getopt(1) manual page, ksh88, and
5084 Bourne sh (such as /bin/sh on Solaris).
5085 We honour POSIX except when -o sh is set.
5086 category: shell:legacy-no
5089 [[ -o posix ]]; FPOSIX=$((1-$?))
5090 [[ -o sh ]]; FSH=$((1-$?))
5091 echo -n "FPOSIX=$FPOSIX FSH=$FSH "
5115 name: regression-10-legacy
5120 should print 0 according to POSIX (dash, bash, ksh93, posh)
5121 but not 0 according to the getopt(1) manual page, ksh88, and
5122 Bourne sh (such as /bin/sh on Solaris).
5123 category: shell:legacy-yes
5126 [[ -o posix ]]; FPOSIX=$((1-$?))
5127 [[ -o sh ]]; FSH=$((1-$?))
5128 echo -n "FPOSIX=$FPOSIX FSH=$FSH "
5157 should echo blah but on some machines echos /foo/bar/blah.
5166 Both of the following echos produce the same output under sh/ksh.att:
5169 echo "`echo \"$x\"`"
5171 pdksh produces different output for the former (foo instead of foo\tbar)
5174 echo "`echo \"$x\"`"
5182 The following command hangs forever:
5183 $ (: ; cat /etc/termcap) | sleep 2
5184 This is because the shell forks a shell to run the (..) command
5185 and this shell has the pipe open. When the sleep dies, the cat
5186 doesn't get a SIGPIPE 'cause a process (ie, the second shell)
5187 still has the pipe open.
5189 NOTE: this test provokes a bizarre bug in ksh93 (shell starts reading
5190 commands from /etc/termcap..)
5193 echo A line of text that will be duplicated quite a number of times.> t1
5194 cat t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 > t2
5195 cat t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 > t1
5196 cat t1 t1 t1 t1 > t2
5197 (: ; cat t2 2>/dev/null) | sleep 1
5202 $ (foobar) 2> /dev/null
5203 generates no output under /bin/sh, but pdksh produces the error
5206 $ foobar 2> /dev/null
5207 generates an error under /bin/sh and pdksh, but AT&T ksh88 produces
5208 no error (redirected to /dev/null).
5210 (you/should/not/see/this/error/1) 2> /dev/null
5211 you/should/not/see/this/error/2 2> /dev/null
5218 generates a blank line under pdksh and sets the exit status to 0.
5219 AT&T ksh88 generates no output and sets the exit status to 1. Also,
5222 generates no output under AT&T ksh88 (pdksh generates a blank line
5225 whence does/not/exist > /dev/null
5227 echo 2: $(whence does/not/exist | wc -l)
5228 echo 3: $(whence does/not/exist cat | wc -l)
5236 ${var%%expr} seems to be broken in many places. On the mips
5238 $ read line < /etc/passwd
5246 change the value of line. On sun4s & pas, the echo ${line%%:*} doesn't
5247 work. Haven't checked elsewhere...
5254 root:asdjhasdasjhs:0:1:Root:/:/bin/sh
5257 root:asdjhasdasjhs:0:1:Root:/:/bin/sh
5263 should set the exit status to non-zero (sh and AT&T ksh88 do).
5264 XXX doting a non existent file is a fatal error for a script
5267 expected-exit: e != 0
5268 expected-stderr-pattern: /.?/
5272 Both of the following echos should produce the same thing, but don't:
5286 backslash does not work as expected in case labels:
5305 Quoting backquotes inside backquotes doesn't work:
5306 $ echo `echo hi \`echo there\` folks`
5307 asks for more info. sh and AT&T ksh88 both echo
5310 echo `echo hi \`echo there\` folks`
5316 )) is not treated `correctly':
5317 $ (echo hi ; (echo there ; echo folks))
5320 instead of (as sh and ksh.att)
5321 $ (echo hi ; (echo there ; echo folks))
5327 ( : ; ( : ; echo hi))
5333 Check reading stdin in a while loop. The read should only read
5334 a single line, not a whole stdio buffer; the cat should get
5337 (echo a; echo b) | while read x ; do
5346 Check reading stdin in a while loop. The read should read both
5347 lines, not just the first.
5350 while [ "$a" != xxx ] ; do
5353 cat /dev/null | sed 's/x/y/'
5367 should cause a script to exit.
5371 expected-exit: e != 0
5372 expected-stderr-pattern: /does\/not\/exist/
5376 variable assignements not detected well
5379 expected-exit: e != 0
5380 expected-stderr-pattern: /a\.x=1/
5384 alias expansion different from AT&T ksh88
5386 alias a='for ' b='i in'
5387 a b hi ; do echo $i ; done
5393 strange characters allowed inside ${...}
5396 expected-exit: e != 0
5397 expected-stderr-pattern: /.?/
5401 Does read handle partial lines correctly
5404 while [ "$a" != xxx ] ; do
5421 Does read set variables to null at eof?
5424 while [ "$a" != xxx ] ; do
5428 echo 1: ${x-x not set} ${y-y not set} ${z-z not set}
5429 echo 2: ${x:+x not null} ${y:+y not null} ${z:+z not null}
5439 Does umask print a leading 0 when umask is 3 digits?
5441 # on MiNT, the first umask call seems to fail
5443 # now, the test proper
5451 Tempory files used for here-docs in functions get trashed after
5452 the function is parsed (before it is executed)
5475 Command substitution breaks reading in while loop
5476 (test from <sjg@void.zen.oz.au>)
5478 (echo abcdef; echo; echo 123) |
5481 # the following line breaks it
5482 c=`echo $line | wc -c`
5492 Machines with broken times() (reported by <sjg@void.zen.oz.au>)
5493 time does not report correct real time
5496 expected-stderr-pattern: !/^\s*0\.0[\s\d]+real|^\s*real[\s]+0+\.0/
5500 set -e doesn't ignore exit codes for if/while/until/&&/||/!.
5503 if false; then echo hi ; fi
5506 while false; do echo hi; done
5513 Only posh and oksh(2013-07) say “hi” below; FreeBSD sh,
5514 GNU bash in POSIX mode, dash, ksh93, mksh don’t. All of
5515 them exit 0. The POSIX behaviour is needed by BSD make.
5518 echo `false; echo hi` $(<this-file-does-not-exist)
5523 expected-stderr-pattern: /this-file-does-not-exist/
5527 This used to cause a core dump
5528 env-setup: !RANDOM=12!
5536 foo should be set to bar (should not be empty)
5546 Can't use command line assignments to assign readonly parameters.
5548 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
5549 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
5550 done >env; chmod +x env; PATH=.:$PATH
5553 foo=stuff env | grep '^foo'
5554 expected-exit: e != 0
5555 expected-stderr-pattern:
5560 Can subshells be prefixed by redirections (historical shells allow
5563 < /dev/null (sed 's/^/X/')
5567 Parameter assignments with [] recognised correctly
5585 Check that alias expansion works in command substitutions and
5598 Check that aliases are fully read.
5611 Check that (here doc) temp files are not left behind after an exec.
5614 TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
5616 sed 's/^/X /' << E_O_F
5623 echo=echo; [ -x /bin/echo ] && echo=/bin/echo
5624 exec $echo subtest-1 hi
5626 echo subtest-1 foo/*
5627 TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
5628 echo=echo; [ -x /bin/echo ] && echo=/bin/echo
5629 sed 's/^/X /' << E_O_F; exec $echo subtest-2 hi
5635 echo subtest-2 foo/*
5647 Check that unset params with attributes are reported by set, those
5648 sans attributes are not.
5664 Check that aliases do not use continuation prompt after trailing
5666 file-setup: file 644 "envf"
5669 env-setup: !ENV=./envf!
5673 alias foo='echo hi ; '
5685 Check that set allows both +o and -o options on same command line.
5688 set -o noglob +o allexport
5695 Check that globbing works in pipelined commands
5696 file-setup: file 644 "envf"
5698 file-setup: file 644 "abc"
5700 env-setup: !ENV=./envf!
5706 sed 's/^/X /' < ab* | sed 's/^/Y /'
5718 Check that getopts works in functions
5721 echo bfunc: enter "(args: $*; OPTIND=$OPTIND)"
5722 while getopts B oc; do
5725 echo bfunc: B option
5728 echo bfunc: odd option "($oc)"
5736 echo kfunc: enter "(args: $*; OPTIND=$OPTIND)"
5737 while getopts K oc; do
5740 echo kfunc: K option
5743 echo bfunc: odd option "($oc)"
5751 echo "line 1: OPTIND=$OPTIND"
5753 echo "line 2: ret=$?, optc=$optc, OPTIND=$OPTIND"
5755 echo "line 3: OPTIND=$OPTIND"
5757 echo "line 4: ret=$?, optc=$optc, OPTIND=$OPTIND"
5759 echo "line 5: OPTIND=$OPTIND"
5761 echo "line 6: ret=$?, optc=$optc, OPTIND=$OPTIND"
5766 echo "line 10: OPTIND=$OPTIND"
5768 echo "line 20: ret=$?, optc=$optc, OPTIND=$OPTIND"
5770 echo "line 30: OPTIND=$OPTIND"
5772 echo "line 40: ret=$?, optc=$optc, OPTIND=$OPTIND"
5774 echo "line 50: OPTIND=$OPTIND"
5776 echo "line 60: ret=$?, optc=$optc, OPTIND=$OPTIND"
5779 line 2: ret=0, optc=f, OPTIND=2
5780 bfunc: enter (args: -BBB blah; OPTIND=2)
5785 line 4: ret=0, optc=b, OPTIND=3
5786 kfunc: enter (args: -KKK blah; OPTIND=1)
5792 line 6: ret=0, optc=k, OPTIND=4
5795 line 20: ret=0, optc=f, OPTIND=2
5796 bfunc: enter (args: -BBB blah; OPTIND=2)
5801 line 40: ret=1, optc=?, OPTIND=2
5802 kfunc: enter (args: -KKK blah; OPTIND=1)
5808 line 60: ret=1, optc=?, OPTIND=2
5812 Check that ; is not required before the then in if (( ... )) then ...
5826 Check ${foo:%bar} is allowed (ksh88 allows it...)
5849 Check if typeset output is correct for
5850 uninitialised array elements.
5854 typeset -i | grep xxx | sed 's/^/ /'
5856 typeset | grep xxx | sed 's/^/ /'
5860 typeset -i | grep xxx | sed 's/^/ /'
5862 typeset | grep xxx | sed 's/^/ /'
5876 Check if trap exit is ok (exit not mistaken for signal name)
5885 Check if ${#array[*]} is calculated correctly.
5895 Check if default exit status is previous command
5901 ( (exit 103) ; exit)
5910 Check if EXIT trap is executed for sub shells.
5912 trap 'echo parent exit' EXIT
5914 (echo A; echo A last)
5916 (echo C; trap 'echo sub exit' EXIT; echo C last)
5931 Check if test -nt/-ot succeeds if second(first) file is missing.
5934 test a -nt b && echo nt OK || echo nt BAD
5935 test b -ot a && echo ot OK || echo ot BAD
5942 Check if typeset, export, and readonly work
5954 integer FNORD_E FNORD_F FNORD_G FNORD_H
5955 export FNORD_C FNORD_D FNORD_G FNORD_H
5956 readonly FNORD_B FNORD_D FNORD_F FNORD_H
6002 typeset -x -r FNORD_D
6004 typeset -i -r FNORD_F
6005 typeset -i -x FNORD_G
6006 typeset -i -x -r FNORD_H
6009 typeset -r FNORD_B=2
6010 typeset -x FNORD_C=3
6011 typeset -x -r FNORD_D=4
6012 typeset -i FNORD_E=5
6013 typeset -i -r FNORD_F=6
6014 typeset -i -x FNORD_G=7
6015 typeset -i -x -r FNORD_H=8
6033 Check that we can redefine functions calling time builtin
6045 check for a regression with sleep builtin and signal mask
6051 while read -p line; do :; done
6058 Check that quoting is sane
6066 while IFS= read -pr line; do
6067 if [[ $line = *space* ]]; then
6073 for line in "${lines[@]}"; do
6082 Ensure readonly is honoured for assignments and unset
6084 "$__progname" -c 'u=x; echo $? $u .' || echo aborted, $?
6086 "$__progname" -c 'readonly u; u=x; echo $? $u .' || echo aborted, $?
6088 "$__progname" -c 'u=x; readonly u; unset u; echo $? $u .' || echo aborted, $?
6095 expected-stderr-pattern:
6100 http://austingroupbugs.net/view.php?id=367 for export
6102 "$__progname" -c 'readonly foo; export foo=a; echo $?' || echo aborted, $?
6105 expected-stderr-pattern:
6110 Check that getopts works as intended, for readonly-2b to be valid
6112 "$__progname" -c 'set -- -a b; getopts a c; echo $? $c .; getopts a c; echo $? $c .' || echo aborted, $?
6119 http://austingroupbugs.net/view.php?id=367 for getopts
6121 "$__progname" -c 'readonly c; set -- -a b; getopts a c; echo $? $c .' || echo aborted, $?
6124 expected-stderr-pattern:
6129 http://austingroupbugs.net/view.php?id=367 for read
6131 echo x | "$__progname" -c 'read s; echo $? $s .' || echo aborted, $?
6132 echo y | "$__progname" -c 'readonly s; read s; echo $? $s .' || echo aborted, $?
6136 expected-stderr-pattern:
6141 Do not permit bypassing readonly for first array item
6143 set -A arr -- foo bar
6146 print -r -- "${arr[@]}"
6147 expected-exit: e != 0
6148 expected-stderr-pattern:
6153 Check that lone ampersand is a syntax error
6156 expected-exit: e != 0
6157 expected-stderr-pattern:
6160 name: xxx-quoted-newline-1
6162 Check that \<newline> works inside of ${}
6170 name: xxx-quoted-newline-2
6172 Check that \<newline> works at the start of a here document
6181 name: xxx-quoted-newline-3
6183 Check that \<newline> works at the end of a here document
6192 name: xxx-multi-assignment-cmd
6194 Check that assignments in a command affect subsequent assignments
6203 name: xxx-multi-assignment-posix-cmd
6205 Check that the behaviour for multiple assignments with a
6206 command name matches POSIX. See:
6207 http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925
6209 X=a Y=b; X=$Y Y=$X "$__progname" -c 'echo 1 $X $Y .'; echo 2 $X $Y .
6211 X=a Y=${X=b} Z=$X "$__progname" -c 'echo 3 $Z .'
6213 X=a Y=${X=b} Z=$X; echo 4 $Z .
6220 name: xxx-multi-assignment-posix-nocmd
6222 Check that the behaviour for multiple assignments with no
6223 command name matches POSIX (Debian #334182). See:
6224 http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925
6226 X=a Y=b; X=$Y Y=$X; echo 1 $X $Y .
6230 name: xxx-multi-assignment-posix-subassign
6232 Check that the behaviour for multiple assignments matches POSIX:
6233 - The assignment words shall be expanded in the current execution
6235 - The assignments happen in the temporary execution environment.
6238 Z=a Y=${X:=b} sh -c 'echo +$X+ +$Y+ +$Z+'
6240 # Now for the special case:
6242 X= Y=${X:=b} sh -c 'echo +$X+ +$Y+'
6250 name: xxx-exec-environment-1
6252 Check to see if exec sets it's environment correctly
6254 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
6255 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
6256 done >env; chmod +x env; PATH=.:$PATH
6258 expected-stdout-pattern:
6261 name: xxx-exec-environment-2
6263 Check to make sure exec doesn't change environment if a program
6266 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
6267 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
6268 done >env; chmod +x env; PATH=.:$PATH
6270 FOO=bar exec; env >bar2
6273 name: exec-function-environment-1
6275 Check assignments in function calls and whether they affect
6276 the current execution environment (ksh93, SUSv4)
6278 f() { a=2; }; g() { b=3; echo y$c-; }; a=1 f; b=2; c=1 g
6284 name: xxx-what-do-you-call-this-1
6290 name: xxx-prefix-strip-1
6297 name: xxx-prefix-strip-2
6305 name: xxx-variable-syntax-1
6308 expected-stderr-pattern:
6312 name: xxx-variable-syntax-2
6316 expected-stderr-pattern:
6320 name: xxx-variable-syntax-3
6324 expected-stderr-pattern:
6328 name: xxx-substitution-eval-order
6330 Check order of evaluation of expressions
6333 set -A A abc def GHI j G k
6334 echo ${A[x=(i+=1)]#${A[y=(i+=2)]}}
6340 name: xxx-set-option-1
6342 Check option parsing in set
6344 set -vsA foo -- A 1 3 2
6353 Check that exec exits for built-ins
6361 expected-stderr-pattern: /.*/
6365 Check the return value of while loops
6366 XXX need to do same for for/select/until loops
6369 while [ $i != xxx ] ; do
6371 if [ $i = xxx ] ; then
6379 while [ $i != xxx ] ; do
6381 if [ $i = xxx ] ; then
6389 while [ $i != xxx ] ; do
6401 Check that blank lines don't clear $?
6414 expected-stderr-pattern: /.*/
6418 Check that $? is preserved in subshells, includes, traps.
6427 echo 'echo include: $?' > foo
6431 trap 'echo trap: $?' ERR
6441 name: xxx-clean-chars-1
6443 Check MAGIC character is stuffed correctly
6449 name: xxx-param-subst-qmark-1
6451 Check suppresion of error message with null string. According to
6452 POSIX, it shouldn't print the error as 'word' isn't ommitted.
6453 ksh88/93, Solaris /bin/sh and /usr/xpg4/bin/sh all print the error,
6454 that's why the condition is reversed.
6462 #expected-stderr-pattern: !/not set/
6464 expected-stderr-pattern: /parameter null or not set/
6467 # fails due to weirdness of execv stuff
6468 category: !os:uwin-nt
6470 Check c flag is set.
6471 arguments: !-c!echo "[$-]"!
6472 expected-stdout-pattern: /^\[.*c.*\]$/
6474 name: tilde-expand-1
6476 Check tilde expansion after equal signs
6477 env-setup: !HOME=/sweet!
6479 echo ${A=a=}~ b=~ c=d~ ~
6482 echo ${A=a=}~ b=~ c=d~ ~
6484 a=/sweet b=/sweet c=d~ /sweet
6487 name: tilde-expand-2
6489 Check tilde expansion works
6490 env-setup: !HOME=/sweet!
6494 plus=$(print -r -- ~+)
6495 minus=$(print -r -- ~-)
6496 nix=$(print -r -- ~)
6497 [[ $plus = / ]]; echo one $? .
6498 [[ $minus = "$wd" ]]; echo two $? .
6499 [[ $nix = /sweet ]]; echo nix $? .
6507 Check some "exit on error" conditions
6509 print '#!'"$__progname"'\nexec "$1"' >env
6510 print '#!'"$__progname"'\nexit 1' >false
6514 env false && echo something
6524 Check some "exit on error" edge conditions (POSIXly)
6526 print '#!'"$__progname"'\nexec "$1"' >env
6527 print '#!'"$__progname"'\nexit 1' >false
6528 print '#!'"$__progname"'\nexit 0' >true
6533 env false && echo something
6545 pdksh regression which AT&T ksh does right
6546 TFM says: [set] -e | errexit
6547 Exit (after executing the ERR trap) ...
6549 trap 'echo EXIT' EXIT
6552 cd /XXXXX 2>/dev/null
6558 expected-exit: e != 0
6562 "set -e" test suite (POSIX)
6576 "set -e" test suite (POSIX)
6582 [ "$1" = "$E" ] && { shift ; continue 2 ; }
6599 "set -e" test suite (BSD make)
6603 print 'all:\n\t@echo eins\n\t@exit 42\n' >zd/a/Makefile
6604 print 'all:\n\t@echo zwei\n' >zd/b/Makefile
6607 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"
6613 Stop in WD/zd/a (line 2 of Makefile).
6617 "set -e" regression (LP#1104543)
6621 [ -x $PWD/nonexistant ] && $PWD/nonexistant
6632 "set -e" regression (Debian #700526)
6635 _db_cmd() { return $1; }
6636 db_input() { _db_cmd 30; }
6637 db_go() { _db_cmd 0; }
6644 SUSv4 says that the shell should exit with 126/127 in some situations
6648 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6649 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6651 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6652 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6654 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6655 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6666 Check eval vs substitution exit codes (ksh93 alike)
6678 eval "eval $(false)"
6681 eval 'eval '"$(false)"
6685 eval $(echo :; false)
6703 Check that "exit" with no arguments behaves SUSv4 conformant.
6705 trap 'echo hi; exit' EXIT
6713 Check that ERR and EXIT traps are run just like ksh93 does.
6714 GNU bash does not run ERtrap in ±e eval-undef but runs it
6715 twice (bug?) in +e eval-false, so does ksh93 (bug?), which
6716 also has a bug to continue execution (echoing "and out" and
6717 returning 0) in +e eval-undef.
6718 file-setup: file 644 "x"
6720 trap 'echo EXtrap' EXIT
6721 trap 'echo ERtrap' ERR
6726 file-setup: file 644 "xt"
6728 trap 'echo EXtrap' EXIT
6729 trap 'echo ERtrap' ERR
6734 file-setup: file 644 "xf"
6736 trap 'echo EXtrap' EXIT
6737 trap 'echo ERtrap' ERR
6739 echo 'and run false'
6742 file-setup: file 644 "xu"
6744 trap 'echo EXtrap' EXIT
6745 trap 'echo ERtrap' ERR
6747 echo 'and run ${v?}'
6757 -e 's/parameter not set/parameter null or not set/' \
6758 -e 's/[[]6]//' -e 's/: eval: line 1//' -e 's/: line 6//' \
6759 -e "s
\ 1^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]
\ 1PROG
\ 1"
6764 echo = eval-true $(<rc) .
6766 echo = eval-false $(<rc) .
6767 runtest x $xe '${v?}'
6768 echo = eval-undef $(<rc) .
6770 echo = noeval-true $(<rc) .
6772 echo = noeval-false $(<rc) .
6774 echo = noeval-undef $(<rc) .
6778 echo = eval-true $(<rc) .
6780 echo = eval-false $(<rc) .
6781 runtest x $xe '${v?}'
6782 echo = eval-undef $(<rc) .
6784 echo = noeval-true $(<rc) .
6786 echo = noeval-false $(<rc) .
6788 echo = noeval-undef $(<rc) .
6800 x: v: parameter null or not set
6813 xu: v: parameter null or not set
6827 x: v: parameter null or not set
6841 xu: v: parameter null or not set
6845 name: exit-trap-interactive
6847 Check that interactive shell doesn't exit via EXIT trap on syntax error
6852 echo 'After error 1'
6853 trap 'echo Exit trap' EXIT
6855 echo 'After error 2'
6856 trap 'echo Exit trap' EXIT
6863 expected-stderr-pattern:
6864 /syntax error: 'newline' unexpected/
6868 Check that test also can handle string1 < string2 etc.
6870 test 2005/10/08 '<' 2005/08/21 && echo ja || echo nein
6871 test 2005/08/21 \< 2005/10/08 && echo ja || echo nein
6872 test 2005/10/08 '>' 2005/08/21 && echo ja || echo nein
6873 test 2005/08/21 \> 2005/10/08 && echo ja || echo nein
6879 expected-stderr-pattern: !/unexpected op/
6881 name: test-precedence-1
6883 Check a weird precedence case (and POSIX echo)
6893 Test the test -o operator
6898 [[ -o $1 ]]; echo $?
6901 test -o $1 -o -o !$1; echo $?
6902 [ -o $1 -o -o !$1 ]; echo $?
6903 [[ -o $1 || -o !$1 ]]; echo $?
6904 test -o ?$1; echo $?
6906 echo 0y $(if_test utf8-mode) =
6907 echo 0n $(if_test utf8-hack) =
6908 echo 1= $(runtest utf8-hack) =
6909 echo 2= $(runtest !utf8-hack) =
6910 echo 3= $(runtest ?utf8-hack) =
6912 echo 1+ $(runtest utf8-mode) =
6913 echo 2+ $(runtest !utf8-mode) =
6914 echo 3+ $(runtest ?utf8-mode) =
6916 echo 1- $(runtest utf8-mode) =
6917 echo 2- $(runtest !utf8-mode) =
6918 echo 3- $(runtest ?utf8-mode) =
6919 echo = short flags =
6920 echo 0y $(if_test -U) =
6921 echo 0y $(if_test +U) =
6922 echo 0n $(if_test -_) =
6923 echo 0n $(if_test -U-) =
6924 echo 1= $(runtest -_) =
6925 echo 2= $(runtest !-_) =
6926 echo 3= $(runtest ?-_) =
6928 echo 1+ $(runtest -U) =
6929 echo 2+ $(runtest !-U) =
6930 echo 3+ $(runtest ?-U) =
6931 echo 1+ $(runtest +U) =
6932 echo 2+ $(runtest !+U) =
6933 echo 3+ $(runtest ?+U) =
6935 echo 1- $(runtest -U) =
6936 echo 2- $(runtest !-U) =
6937 echo 3- $(runtest ?-U) =
6938 echo 1- $(runtest +U) =
6939 echo 2- $(runtest !+U) =
6940 echo 3- $(runtest ?+U) =
6976 Check that ~/.mkshrc works correctly.
6977 Part 1: verify user environment is not read (internal)
6985 Check that ~/.mkshrc works correctly.
6986 Part 2: verify mkshrc is not read (non-interactive shells)
6987 file-setup: file 644 ".mkshrc"
6989 env-setup: !HOME=.!ENV=!
6997 Check that ~/.mkshrc works correctly.
6998 Part 2: verify mkshrc can be read (interactive shells)
6999 file-setup: file 644 ".mkshrc"
7003 env-setup: !HOME=.!ENV=!PS1=!
7008 expected-stderr-pattern:
7013 Check that ~/.mkshrc works correctly.
7014 Part 3: verify mkshrc can be turned off
7015 file-setup: file 644 ".mkshrc"
7017 env-setup: !HOME=.!ENV=nonexistant!
7025 Check that sh mode turns braceexpand off
7026 and that that works correctly
7030 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
7031 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
7039 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
7040 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
7043 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
7044 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
7060 Check that posix or sh mode is *not* automatically turned on
7063 ln -s "$__progname" ksh || cp "$__progname" ksh
7064 ln -s "$__progname" sh || cp "$__progname" sh
7065 ln -s "$__progname" ./-ksh || cp "$__progname" ./-ksh
7066 ln -s "$__progname" ./-sh || cp "$__progname" ./-sh
7067 for shell in {,-}{,k}sh; do
7068 print -- $shell $(./$shell +l -c \
7069 '[[ $(set +o) == *"-o "@(sh|posix)@(| *) ]] && echo sh || echo nosh')
7079 Check that posix or sh mode *is* automatically turned on
7082 ln -s "$__progname" ksh || cp "$__progname" ksh
7083 ln -s "$__progname" sh || cp "$__progname" sh
7084 ln -s "$__progname" ./-ksh || cp "$__progname" ./-ksh
7085 ln -s "$__progname" ./-sh || cp "$__progname" ./-sh
7086 for shell in {,-}{,k}sh; do
7087 print -- $shell $(./$shell +l -c \
7088 '[[ $(set +o) == *"-o "@(sh|posix)@(| *) ]] && echo sh || echo nosh')
7098 pdksh bug: last command of a pipeline is executed in a
7099 subshell - make sure it still is, scripts depend on it
7100 file-setup: file 644 "abcx"
7101 file-setup: file 644 "abcy"
7104 echo a | while read d; do
7124 check that co-processes work with TCOMs, TPIPEs and TPARENs
7127 "$__progname" -c 'i=100; echo hi |& while read -p line; do echo "$((i++)) $line"; done'
7128 "$__progname" -c 'i=200; echo hi | cat |& while read -p line; do echo "$((i++)) $line"; done'
7129 "$__progname" -c 'i=300; (echo hi | cat) |& while read -p line; do echo "$((i++)) $line"; done'
7137 Check that PIPESTATUS does what it's supposed to
7139 echo 1 $PIPESTATUS .
7140 echo 2 ${PIPESTATUS[0]} .
7141 echo 3 ${PIPESTATUS[1]} .
7142 (echo x; exit 12) | (cat; exit 23) | (cat; exit 42)
7143 echo 5 $? , $PIPESTATUS , ${PIPESTATUS[0]} , ${PIPESTATUS[1]} , ${PIPESTATUS[2]} , ${PIPESTATUS[3]} .
7144 echo 6 ${PIPESTATUS[0]} .
7145 set | fgrep PIPESTATUS
7146 echo 8 $(set | fgrep PIPESTATUS) .
7152 5 42 , 12 , 12 , 23 , 42 , .
7155 8 PIPESTATUS[0]=0 PIPESTATUS[1]=0 .
7159 Check that "set -o pipefail" does what it's supposed to
7161 echo 1 "$("$__progname" -c '(exit 12) | (exit 23) | (exit 42); echo $?')" .
7162 echo 2 "$("$__progname" -c '! (exit 12) | (exit 23) | (exit 42); echo $?')" .
7163 echo 3 "$("$__progname" -o pipefail -c '(exit 12) | (exit 23) | (exit 42); echo $?')" .
7164 echo 4 "$("$__progname" -o pipefail -c '! (exit 12) | (exit 23) | (exit 42); echo $?')" .
7165 echo 5 "$("$__progname" -c '(exit 23) | (exit 42) | :; echo $?')" .
7166 echo 6 "$("$__progname" -c '! (exit 23) | (exit 42) | :; echo $?')" .
7167 echo 7 "$("$__progname" -o pipefail -c '(exit 23) | (exit 42) | :; echo $?')" .
7168 echo 8 "$("$__progname" -o pipefail -c '! (exit 23) | (exit 42) | :; echo $?')" .
7169 echo 9 "$("$__progname" -o pipefail -c 'x=$( (exit 23) | (exit 42) | :); echo $?')" .
7181 name: persist-history-1
7183 Check if persistent history saving works
7184 category: !no-histfile
7187 env-setup: !ENV=./Env!HISTFILE=hist.file!
7188 file-setup: file 644 "Env"
7192 expected-stdout-pattern:
7194 expected-stderr-pattern:
7199 Check that global does what typeset is supposed to do
7203 global -Uui16 arrfoo[*]
7205 echo before ${arrfoo[0]} .
7207 echo after ${arrfoo[0]} .
7210 echo inside before ${arrbar[0]} .
7212 echo inside changed ${arrbar[0]} .
7213 global -Uui16 arrbar[*]
7214 echo inside typeset ${arrbar[0]} .
7216 echo inside changed ${arrbar[0]} .
7218 echo before ${arrbar[0]} .
7220 echo after ${arrbar[0]} .
7227 inside typeset 16#61 .
7228 inside changed 16#30 .
7231 name: typeset-padding-1
7233 Check if left/right justification works as per TFM
7235 typeset -L10 ln=0hall0
7236 typeset -R10 rn=0hall0
7237 typeset -ZL10 lz=0hall0
7238 typeset -ZR10 rz=0hall0
7239 typeset -Z10 rx=" hallo "
7240 echo "<$ln> <$rn> <$lz> <$rz> <$rx>"
7242 <0hall0 > < 0hall0> <hall0 > <00000hall0> <0000 hallo>
7244 name: typeset-padding-2
7246 Check if base-!10 integers are padded right
7248 typeset -Uui16 -L9 ln=16#1
7249 typeset -Uui16 -R9 rn=16#1
7250 typeset -Uui16 -Z9 zn=16#1
7254 echo "<$ln> <$rn> <$zn> <$ls> <$rs> <$zs>"
7256 <16#1 > < 16#1> <16#000001> <16#1 > < 16#1> <0000016#1>
7260 Check that the UTF-8 Byte Order Mark is ignored as the first
7261 multibyte character of the shell input (with -c, from standard
7262 input, as file, or as eval argument), but nowhere else
7263 # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
7264 category: !os:darwin
7267 print '#!/bin/sh\necho ohne' >foo/fnord
7268 print '#!/bin/sh\necho mit' >foo/fnord
7269 print 'fnord\nfnord\nfnord\nfnord' >foo/bar
7270 print eval \''fnord\nfnord\nfnord\nfnord'\' >foo/zoo
7271 set -A anzahl -- foo/*
7272 echo got ${#anzahl[*]} files
7274 export PATH=$(pwd)/foo:$PATH
7275 "$__progname" -c 'fnord'
7277 "$__progname" -c 'fnord; fnord; fnord; fnord'
7279 "$__progname" foo/bar
7281 "$__progname" <foo/bar
7283 "$__progname" foo/zoo
7285 "$__progname" -c 'echo : $(fnord)'
7315 Check that we can execute BOM-shebangs (failures not fatal)
7316 XXX if the OS can already execute them, we lose
7317 note: cygwin execve(2) doesn't return to us with ENOEXEC, we lose
7318 note: Ultrix perl5 t4 returns 65280 (exit-code 255) and no text
7319 XXX fails when LD_PRELOAD is set with -e and Perl chokes it (ASan)
7321 category: !os:cygwin,!os:msys,!os:ultrix,!os:uwin-nt,!smksh
7322 env-setup: !FOO=BAR!
7324 print '#!'"$__progname"'\nprint "1 a=$ENV{FOO}";' >t1
7325 print '#!'"$__progname"'\nprint "2 a=$ENV{FOO}";' >t2
7326 print '#!'"$__perlname"'\nprint "3 a=$ENV{FOO}\n";' >t3
7327 print '#!'"$__perlname"'\nprint "4 a=$ENV{FOO}\n";' >t4
7334 1 a=/nonexistant{FOO}
7335 2 a=/nonexistant{FOO}
7338 expected-stderr-pattern:
7339 /(Unrecognized character .... ignored at \..t4 line 1)*/
7343 Check that the utf8-mode flag is not set at non-interactive startup
7345 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8!
7347 if [[ $- = *U* ]]; then
7357 Check that the utf8-mode flag is not set at non-interactive startup
7359 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.utf8!
7361 if [[ $- = *U* ]]; then
7371 Check that the utf8-mode flag is set at interactive startup.
7372 -DMKSH_ASSUME_UTF8=0 => expected failure, please ignore
7373 -DMKSH_ASSUME_UTF8=1 => not expected, please investigate
7374 -UMKSH_ASSUME_UTF8 => not expected, but if your OS is old,
7375 try passing HAVE_SETLOCALE_CTYPE=0 to Build.sh
7377 category: !os:hpux,!os:msys
7380 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8!
7382 if [[ $- = *U* ]]; then
7389 expected-stderr-pattern:
7394 Check that the utf8-mode flag is set at interactive startup
7395 Expected failure if -DMKSH_ASSUME_UTF8=0
7399 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.utf8!
7401 if [[ $- = *U* ]]; then
7408 expected-stderr-pattern:
7413 Ensure ±U on the command line is honoured
7414 (these two tests may pass falsely depending on CPPFLAGS)
7417 code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi'
7418 let i++; "$__progname" -U -c "$code"
7419 let i++; "$__progname" +U -c "$code"
7428 Ensure ±U on the command line is honoured, interactive shells
7432 code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi'
7433 let i++; "$__progname" -U -ic "$code"
7434 let i++; "$__progname" +U -ic "$code"
7443 Check if built-in shell aliases are okay
7444 category: !android,!arge
7449 autoload='typeset -fu'
7450 functions='typeset -f'
7453 integer='typeset -i'
7456 nameref='typeset -n'
7459 source='PATH=$PATH:. command .'
7463 name: aliases-1-hartz4
7465 Check if built-in shell aliases are okay
7466 category: android,arge
7471 autoload='typeset -fu'
7472 functions='typeset -f'
7475 integer='typeset -i'
7478 nameref='typeset -n'
7481 source='PATH=$PATH:. command .'
7486 Check if “set -o sh” disables built-in aliases (except a few)
7493 integer='typeset -i'
7498 Check if running as sh disables built-in aliases (except a few)
7502 ./sh -c 'alias; typeset -f'
7505 integer='typeset -i'
7510 Check if “set -o sh” does not influence built-in aliases
7511 category: !android,!arge
7517 autoload='typeset -fu'
7518 functions='typeset -f'
7521 integer='typeset -i'
7524 nameref='typeset -n'
7527 source='PATH=$PATH:. command .'
7533 Check if running as sh does not influence built-in aliases
7534 category: !android,!arge
7537 ./sh -c 'alias; typeset -f'
7540 autoload='typeset -fu'
7541 functions='typeset -f'
7544 integer='typeset -i'
7547 nameref='typeset -n'
7550 source='PATH=$PATH:. command .'
7554 name: aliases-2b-hartz4
7556 Check if “set -o sh” does not influence built-in aliases
7557 category: android,arge
7563 autoload='typeset -fu'
7564 functions='typeset -f'
7567 integer='typeset -i'
7570 nameref='typeset -n'
7573 source='PATH=$PATH:. command .'
7576 name: aliases-3b-hartz4
7578 Check if running as sh does not influence built-in aliases
7579 category: android,arge
7582 ./sh -c 'alias; typeset -f'
7585 autoload='typeset -fu'
7586 functions='typeset -f'
7589 integer='typeset -i'
7592 nameref='typeset -n'
7595 source='PATH=$PATH:. command .'
7598 name: aliases-cmdline
7600 Check that aliases work from the command line (Debian #517009)
7601 Note that due to the nature of the lexing process, defining
7602 aliases in COMSUBs then immediately using them, and things
7603 like 'alias foo=bar && foo', still fail.
7605 "$__progname" -c $'alias a="echo OK"\na'
7609 name: aliases-funcdef-1
7611 Check if POSIX functions take precedences over aliases
7613 alias foo='echo makro'
7621 name: aliases-funcdef-2
7623 Check if POSIX functions take precedences over aliases
7625 alias foo='echo makro'
7633 name: aliases-funcdef-3
7635 Check if aliases take precedences over Korn functions
7637 alias foo='echo makro'
7645 name: aliases-funcdef-4
7647 Functions should only take over if actually being defined
7658 Check if Korn Shell arrays work as expected
7661 set -A foo -- a \$v "$v" '$v' b
7662 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
7668 Check if bash-style arrays work as expected
7671 foo=(a \$v "$v" '$v' b)
7672 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
7678 Check if bash-style arrays work as expected, with newlines
7680 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "$x|"; done' >pfp
7682 test -n "$ZSH_VERSION" && setopt KSH_ARRAYS
7688 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
7693 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
7698 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
7700 7|a|bc|d|$v|e f|$v|g|
7701 7|a|bc|d|$v|e f|$v|g|
7702 6|abc\|d|$v|e f|$v|g||
7706 Check if array bounds are uint32_t
7713 echo ${foo[4294967295]} g ${foo[*]}
7720 Check if Korn Shell arrays with specified indices work as expected
7723 set -A foo -- [1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b
7724 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|"
7725 # we don't want this at all:
7727 set -A arr "[5]=meh"
7728 echo "<${arr[0]}><${arr[5]}>"
7730 5|[1]=$v|[2]=c d|[4]=$v|[0]=a|[5]=b||
7735 Check if bash-style arrays with specified indices work as expected
7736 (taken out temporarily to fix arrays-4; see also arrays-9a comment)
7740 foo=([1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b)
7741 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|"
7742 x=([128]=foo bar baz)
7745 # Check that we do not break this by globbing
7750 echo "<${arr[0]}><${arr[5]}>"
7759 Check if we can get the array keys (indices) for indexed arrays,
7765 echo -n "$((i++))<$x>"
7776 echo a $(of ${foo[*]}) = $(of ${bar[*]}) a
7777 echo b $(of "${foo[*]}") = $(of "${bar[*]}") b
7778 echo c $(of ${foo[@]}) = $(of ${bar[@]}) c
7779 echo d $(of "${foo[@]}") = $(of "${bar[@]}") d
7780 echo e $(of ${!foo[*]}) = $(of ${!bar[*]}) e
7781 echo f $(of "${!foo[*]}") = $(of "${!bar[*]}") f
7782 echo g $(of ${!foo[@]}) = $(of ${!bar[@]}) g
7783 echo h $(of "${!foo[@]}") = $(of "${!bar[@]}") h
7791 a 0<zwei>1<eins>2<drei> = a
7792 b 0<zwei eins drei> = 0<> b
7793 c 0<zwei>1<eins>2<drei> = c
7794 d 0<zwei>1<eins>2<drei> = d
7802 Check if we can get the array keys (indices) for indexed arrays,
7803 Korn shell style, in some corner cases
7806 echo !arz[0]: ${!arz[0]}
7807 echo !arz[1]: ${!arz[1]}
7810 echo !arz[0]: ${!arz[0]}
7811 echo !arz[1]: ${!arz[1]}
7814 echo !arz[0]: ${!arz[0]}
7815 echo !arz[1]: ${!arz[1]}
7829 Check some behavioural rules for arrays.
7867 typeset -Z3 aa ab ac ad ae af ag
7912 Check that we can concatenate arrays
7914 unset foo; foo=(bar); foo+=(baz); echo 1 ${!foo[*]} : ${foo[*]} .
7915 unset foo; foo=(foo bar); foo+=(baz); echo 2 ${!foo[*]} : ${foo[*]} .
7916 # unset foo; foo=([2]=foo [0]=bar); foo+=(baz [5]=quux); echo 3 ${!foo[*]} : ${foo[*]} .
7919 2 0 1 2 : foo bar baz .
7920 # 3 0 2 3 5 : bar foo baz quux .
7924 Check that we can concatenate parameters too
7926 unset foo; foo=bar; foo+=baz; echo 1 $foo .
7927 unset foo; typeset -i16 foo=10; foo+=20; echo 2 $foo .
7932 name: arrassign-basic
7934 Check basic whitespace conserving properties of wdarrassign
7942 c+=("$(echo "c d")")
7944 echo ".a:${a[0]}.${a[1]}.${a[2]}.${a[3]}:"
7945 echo ".b:${b[0]}.${b[1]}.${b[2]}.${b[3]}:"
7946 echo ".c:${c[0]}.${c[1]}.${c[2]}.${c[3]}:"
7947 echo ".d:${d[0]}.${d[1]}.${d[2]}.${d[3]}:"
7954 name: arrassign-fnc-none
7956 Check locality of array access inside a function
7960 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7963 if [[ -n $BASH_VERSION ]]; then
7969 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7973 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7975 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7977 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7978 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7980 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7982 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7995 name: arrassign-fnc-local
7997 Check locality of array access inside a function
7998 with the bash/mksh/ksh93 local/typeset keyword
7999 (note: ksh93 has no local; typeset works only in FKSH)
8004 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8007 if [[ -n $BASH_VERSION ]]; then
8014 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8018 if [[ -n $BASH_VERSION ]]; then
8024 echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8029 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8031 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8033 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8034 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8036 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8038 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8039 echo ".f0r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8041 echo ".f1r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8043 echo ".f2r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8061 name: arrassign-fnc-global
8063 Check locality of array access inside a function
8064 with the mksh-specific global keyword
8069 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8075 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8081 echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8086 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8088 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8090 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
8091 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8093 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8095 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
8096 echo ".f0r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8098 echo ".f1r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8100 echo ".f2r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
8118 name: strassign-fnc-none
8120 Check locality of string access inside a function
8155 name: strassign-fnc-local
8157 Check locality of string access inside a function
8158 with the bash/mksh/ksh93 local/typeset keyword
8159 (note: ksh93 has no local; typeset works only in FKSH)
8213 name: strassign-fnc-global
8215 Check locality of string access inside a function
8216 with the mksh-specific global keyword
8270 name: unset-fnc-local-ksh
8272 Check that “unset” removes a previous “local”
8273 (ksh93 syntax compatible version); apparently,
8274 there are shells which fail this?
8300 name: unset-fnc-local-sh
8302 Check that “unset” removes a previous “local”
8303 (Debian Policy §10.4 sh version); apparently,
8304 there are shells which fail this?
8330 name: varexpand-substr-1
8332 Check if bash-style substring expansion works
8333 when using positive numerics
8336 typeset -i y=123456789
8337 typeset -i 16 z=123456789 # 16#75bcd15
8338 echo a t${x:2:2} ${y:2:3} ${z:2:3} a
8339 echo b ${x::3} ${y::3} ${z::3} b
8340 echo c ${x:2:} ${y:2:} ${z:2:} c
8341 echo d ${x:2} ${y:2} ${z:2} d
8342 echo e ${x:2:6} ${y:2:6} ${z:2:7} e
8343 echo f ${x:2:7} ${y:2:7} ${z:2:8} f
8344 echo g ${x:2:8} ${y:2:8} ${z:2:9} g
8349 d cdefghi 3456789 #75bcd15 d
8350 e cdefgh 345678 #75bcd1 e
8351 f cdefghi 3456789 #75bcd15 f
8352 g cdefghi 3456789 #75bcd15 g
8354 name: varexpand-substr-2
8356 Check if bash-style substring expansion works
8357 when using negative numerics or expressions
8360 typeset -i y=123456789
8361 typeset -i 16 z=123456789 # 16#75bcd15
8363 echo a ${x:$n:3} ${y:$n:3} ${z:$n:3} a
8364 echo b ${x:(n):3} ${y:(n):3} ${z:(n):3} b
8365 echo c ${x:(-2):1} ${y:(-2):1} ${z:(-2):1} c
8366 echo d t${x: n:2} ${y: n:3} ${z: n:3} d
8373 name: varexpand-substr-3
8375 Check that some things that work in bash fail.
8376 This is by design. And that some things fail in both.
8378 export x=abcdefghi n=2
8379 "$__progname" -c 'echo v${x:(n)}x'
8380 "$__progname" -c 'echo w${x: n}x'
8381 "$__progname" -c 'echo x${x:n}x'
8382 "$__progname" -c 'echo y${x:}x'
8383 "$__progname" -c 'echo z${x}x'
8384 "$__progname" -c 'x=abcdef;y=123;echo ${x:${y:2:1}:2}' >/dev/null 2>&1; echo $?
8390 expected-stderr-pattern:
8391 /x:n.*bad substitution.*\n.*bad substitution/
8393 name: varexpand-substr-4
8395 Check corner cases for substring expansion
8399 echo a ${x:(y == 1 ? 2 : 3):4} a
8403 name: varexpand-substr-5A
8405 Check that substring expansions work on characters
8409 echo a ${x::1} ${x: -1} a
8410 echo b ${x::3} ${x: -3} b
8411 echo c ${x:1:2} ${x: -3:2} c
8419 name: varexpand-substr-5W
8421 Check that substring expansions work on characters
8425 echo a ${x::1} ${x: -1} a
8426 echo b ${x::2} ${x: -2} b
8427 echo c ${x:1:1} ${x: -2:1} c
8435 name: varexpand-substr-6
8437 Check that string substitution works correctly
8442 echo a ${baz: foo: bar}
8443 echo b ${baz: foo: $bar}
8444 echo c ${baz: $foo: bar}
8445 echo d ${baz: $foo: $bar}
8452 name: varexpand-special-hash
8454 Check special ${var@x} expansion for x=hash
8459 print ${foo@#} ${bar@#} ${baz@#} .
8461 9B15FBFB CFBDD32B 00000000 .
8463 name: varexpand-special-quote
8465 Check special ${var@Q} expansion for quoted strings
8472 print -r -- "<i=$i j=$j k=$k>"
8473 s="u=${i@Q} v=${j@Q} w=${k@Q}"
8474 print -r -- "s=\"$s\""
8480 s="u=x v='a b' w=$'c\nd\240e\u20ACf'"
8483 typeset w=$'c\nd\240e\u20ACf'
8485 name: varexpand-null-1
8487 Ensure empty strings expand emptily
8489 print s ${a} . ${b} S
8490 print t ${a#?} . ${b%?} T
8491 print r ${a=} . ${b/c/d} R
8493 print s "${a}" . "${b}" S
8494 print t "${a#?}" . "${b%?}" T
8495 print r "${a=}" . "${b/c/d}" R
8505 name: varexpand-null-2
8507 Ensure empty strings, when quoted, are expanded as empty strings
8509 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "<$x> "; done' >pfs
8511 ./pfs 1 "${a}" 2 "${a#?}" + "${b%?}" 3 "${a=}" + "${b/c/d}"
8514 <1> <> <2> <> <+> <> <3> <> <+> <> .
8516 name: varexpand-null-3
8518 Ensure concatenating behaviour matches other shells
8520 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
8521 x=; showargs 1 "$x"$@
8522 set A; showargs 2 "${@:+}"
8555 name: print-funny-chars
8557 Check print builtin's capability to output designated characters
8559 print '<\0144\0344\xDB\u00DB\u20AC\uDB\x40>'
8565 Check print builtin's \c escape
8567 print '\ca'; print b
8573 Check that CR+LF is not collapsed into LF as some MSYS shells wrongly do
8575 echo '#!'"$__progname" >foo
8577 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'
8582 ./foo | while IFS= read -r line; do
8583 print -r -- "{$line}"
8586 [220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT
\r
8587 220->> Bitte keine Werbung einwerfen! <<
\r\r
8588 220 Who do you wanna pretend to be today?
\r]
8589 {220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT
\r}
8590 {220->> Bitte keine Werbung einwerfen! <<
\r\r}
8591 {220 Who do you wanna pretend to be today?
\r}
8595 Check that CR+LF is shown and read as-is
8600 if test x"$KSH_VERSION" = x""; then #
\r
8601 printf '<%s>' "$x" #
\r
8603 print -nr -- "<$x>" #
\r
8606 echo "[$("$__progname" foo)]"
8607 "$__progname" foo | while IFS= read -r line; do
8608 print -r -- "{$line}"
8617 Check that LF-only is shown and read as-is
8622 if test x"$KSH_VERSION" = x""; then #
8623 printf '<%s>' "$x" #
8625 print -nr -- "<$x>" #
8628 echo "[$("$__progname" foo)]"
8629 "$__progname" foo | while IFS= read -r line; do
8630 print -r -- "{$line}"
8637 name: print-nul-chars
8639 Check handling of NUL characters for print and COMSUB
8642 print $(($(print '<\0>' | wc -c))) $(($(print "$x" | wc -c))) \
8644 expected-stdout-pattern:
8649 Check backslash expansion by the print builtin
8651 print '\ \!\"\#\$\%\&'\\\''\(\)\*\+\,\-\.\/\0\1\2\3\4\5\6\7\8' \
8652 '\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T' \
8653 '\U\V\W\X\Y\Z\[\\\]\^\_\`\a\b \d\e\f\g\h\i\j\k\l\m\n\o\p' \
8654 '\q\r\s\t\u\v\w\x\y\z\{\|\}\~' '\u20acd' '\U20acd' '\x123' \
8655 '\0x' '\0123' '\01234' | {
8656 # integer-base-one-3As
8657 typeset -Uui16 -Z11 pos=0
8658 typeset -Uui16 -Z5 hv=2147483647
8662 while IFS= read -r line; do
8664 while [[ -n $line ]]; do
8666 if (( (pos & 15) == 0 )); then
8667 (( pos )) && print "$dasc|"
8668 print -n "${pos#16#} "
8671 print -n "${hv#16#} "
8672 if (( (hv < 32) || (hv > 126) )); then
8675 dasc=$dasc${line::1}
8677 (( (pos++ & 15) == 7 )) && print -n -- '- '
8681 while (( pos & 15 )); do
8683 (( (pos++ & 15) == 7 )) && print -n -- '- '
8685 (( hv == 2147483647 )) || print "$dasc|"
8688 00000000 5C 20 5C 21 5C 22 5C 23 - 5C 24 5C 25 5C 26 5C 27 |\ \!\"\#\$\%\&\'|
8689 00000010 5C 28 5C 29 5C 2A 5C 2B - 5C 2C 5C 2D 5C 2E 5C 2F |\(\)\*\+\,\-\.\/|
8690 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|
8691 00000030 20 5C 39 5C 3A 5C 3B 5C - 3C 5C 3D 5C 3E 5C 3F 5C | \9\:\;\<\=\>\?\|
8692 00000040 40 5C 41 5C 42 5C 43 5C - 44 1B 5C 46 5C 47 5C 48 |@\A\B\C\D.\F\G\H|
8693 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|
8694 00000060 5C 51 5C 52 5C 53 5C 54 - 20 5C 56 5C 57 5C 58 5C |\Q\R\S\T \V\W\X\|
8695 00000070 59 5C 5A 5C 5B 5C 5C 5D - 5C 5E 5C 5F 5C 60 07 08 |Y\Z\[\]\^\_\`..|
8696 00000080 20 20 5C 64 1B 0C 5C 67 - 5C 68 5C 69 5C 6A 5C 6B | \d..\g\h\i\j\k|
8697 00000090 5C 6C 5C 6D 0A 5C 6F 5C - 70 20 5C 71 0D 5C 73 09 |\l\m.\o\p \q.\s.|
8698 000000A0 0B 5C 77 5C 79 5C 7A 5C - 7B 5C 7C 5C 7D 5C 7E 20 |.\w\y\z\{\|\}\~ |
8699 000000B0 E2 82 AC 64 20 EF BF BD - 20 12 33 20 78 20 53 20 |...d ... .3 x S |
8700 000000C0 53 34 0A - |S4.|
8702 name: dollar-doublequoted-strings
8704 Check that a $ preceding "…" is ignored
8706 echo $"Localise me!"
8711 I do not take a $V for a V!
8716 I do not take a $V for a V!
8718 name: dollar-quoted-strings
8720 Check backslash expansion by $'…' strings
8722 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
8724 ./pfn $'\ \!\"\#\$\%\&\'\(\)\*\+\,\-\.\/ \1\2\3\4\5\6' \
8725 $'a\0b' $'a\01b' $'\7\8\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I' \
8726 $'\J\K\L\M\N\O\P\Q\R\S\T\U1\V\W\X\Y\Z\[\\\]\^\_\`\a\b\d\e' \
8727 $'\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u1\v\w\x1\y\z\{\|\}\~ $x' \
8728 $'\u20acd' $'\U20acd' $'\x123' $'fn\x0rd' $'\0234' $'\234' \
8729 $'\2345' $'\ca' $'\c!' $'\c?' $'\c€' $'a\
8731 # integer-base-one-3As
8732 typeset -Uui16 -Z11 pos=0
8733 typeset -Uui16 -Z5 hv=2147483647
8737 while IFS= read -r line; do
8739 while [[ -n $line ]]; do
8741 if (( (pos & 15) == 0 )); then
8742 (( pos )) && print "$dasc|"
8743 print -n "${pos#16#} "
8746 print -n "${hv#16#} "
8747 if (( (hv < 32) || (hv > 126) )); then
8750 dasc=$dasc${line::1}
8752 (( (pos++ & 15) == 7 )) && print -n -- '- '
8756 while (( pos & 15 )); do
8758 (( (pos++ & 15) == 7 )) && print -n -- '- '
8760 (( hv == 2147483647 )) || print "$dasc|"
8763 00000000 20 21 22 23 24 25 26 27 - 28 29 2A 2B 2C 2D 2E 2F | !"#$%&'()*+,-./|
8764 00000010 20 01 02 03 04 05 06 0A - 61 0A 61 01 62 0A 07 38 | .......a.a.b..8|
8765 00000020 39 3A 3B 3C 3D 3E 3F 40 - 41 42 43 44 1B 46 47 48 |9:;<=>?@ABCD.FGH|
8766 00000030 49 0A 4A 4B 4C 4D 4E 4F - 50 51 52 53 54 01 56 57 |I.JKLMNOPQRST.VW|
8767 00000040 58 59 5A 5B 5C 5D 5E 5F - 60 07 08 64 1B 0A 0C 67 |XYZ[\]^_`..d...g|
8768 00000050 68 69 6A 6B 6C 6D 0A 6F - 70 71 0D 73 09 01 0B 77 |hijklm.opq.s...w|
8769 00000060 01 79 7A 7B 7C 7D 7E 20 - 24 78 0A E2 82 AC 64 0A |.yz{|}~ $x....d.|
8770 00000070 EF BF BD 0A C4 A3 0A 66 - 6E 0A 13 34 0A 9C 0A 9C |.......fn..4....|
8771 00000080 35 0A 01 0A 01 0A 7F 0A - 02 82 AC 0A 61 0A 62 0A |5...........a.b.|
8773 name: dollar-quotes-in-heredocs-strings
8775 They are, however, not parsed in here documents, here strings
8776 (outside of string delimiters) or regular strings, but in
8777 parameter substitutions.
8780 dollar = strchr(s, '$'); /* ' */
8786 cat <<<"dollar = strchr(s, '$'); /* ' */"
8787 cat <<<'dollar = strchr(s, '\''$'\''); /* '\'' */'
8788 x="dollar = strchr(s, '$'); /* ' */"
8791 unset nl; print -r -- "x${nl:=$'\n'}y"
8797 # probably never reached for here strings?
8799 cat <<<"4 foo\\\"bar"
8801 # old scripts use this (e.g. ncurses)
8803 # make sure this works, outside of quotes
8806 dollar = strchr(s, '$'); /* ' */
8809 dollar = strchr(s, '$'); /* ' */
8810 dollar = strchr(s, '$'); /* ' */
8811 dollar = strchr(s, '$'); /* ' */
8823 name: dot-needs-argument
8825 check Debian #415167 solution: '.' without arguments should fail
8828 "$__progname" -c source
8829 expected-exit: e != 0
8830 expected-stderr-pattern:
8831 /\.: missing argument.*\n.*\.: missing argument/
8833 name: alias-function-no-conflict-legacy
8835 make aliases not conflict with functions, legacy version:
8836 undefine these aliases upon definition of the function
8837 note: for ksh functions, the order of preference differs in GNU bash
8839 # POSIX function overrides and removes alias
8840 alias foo='echo bar'
8847 foo 2>/dev/null || echo rab
8848 # alias overrides ksh function
8849 alias korn='echo bar'
8855 # alias temporarily overrides POSIX function
8860 alias bla='echo bal'
8874 name: bash-function-parens
8876 ensure the keyword function is ignored when preceding
8877 POSIX style function declarations (bashism)
8880 echo '#!'"$__progname"
8882 echo ' echo "bar='\''$0'\'\"
8884 print -r -- "${2:-foo}"
8886 mk 'function foo' >f-korn
8888 mk 'function foo ()' >f-bash
8889 # pre-R51 can do without a backslash in front of the second stop
8890 mk 'function stop ()' 'stop' >f-stop
8891 print '#!'"$__progname"'\nprint -r -- "${0%/f-argh}"' >f-argh
8894 x="korn: $(./f-korn)"; echo "${x/@("$u")/.}"
8895 x="dash: $(./f-dash)"; echo "${x/@("$u")/.}"
8896 x="bash: $(./f-bash)"; echo "${x/@("$u")/.}"
8897 x="stop: $(./f-stop)"; echo "${x/@("$u")/.}"
8900 dash: bar='./f-dash'
8901 bash: bar='./f-bash'
8902 stop: bar='./f-stop'
8904 name: integer-base-one-1
8906 check if the use of fake integer base 1 works
8909 typeset -Uui16 i0=1#ï i1=1#â
\82¬
8911 typeset -i1 o1a=0x263A
8912 typeset -Uui1 o0b=0x7E
8913 typeset -Uui1 o1b=0xFDD0
8914 integer px=0xCAFE 'p0=1# ' p1=1#… pl=1#f
8915 echo "in <$i0> <$i1>"
8916 echo "out <${o0a#1#}|${o0b#1#}> <${o1a#1#}|${o1b#1#}>"
8918 echo "pass <$px> <$p0> <$p1> <$pl> <${i0#1#}|${i1#1#}>"
8919 typeset -Uui16 tv1=1#~ tv2=1#
\7f tv3=1#
\80 tv4=1#
\81 tv5=1#À tv6=1#Á tv7=1#Â tv8=1#Â
\80
8920 echo "specX <${tv1#16#}> <${tv2#16#}> <${tv3#16#}> <${tv4#16#}> <${tv5#16#}> <${tv6#16#}> <${tv7#16#}> <${tv8#16#}>"
8921 typeset -i1 tv1 tv2 tv3 tv4 tv5 tv6 tv7 tv8
8922 echo "specW <${tv1#1#}> <${tv2#1#}> <${tv3#1#}> <${tv4#1#}> <${tv5#1#}> <${tv6#1#}> <${tv7#1#}> <${tv8#1#}>"
8923 typeset -i1 xs1=0xEF7F xs2=0xEF80 xs3=0xFDD0
8924 echo "specU <${xs1#1#}> <${xs2#1#}> <${xs3#1#}>"
8926 in <16#EFEF> <16#20AC>
8928 pass <16#cafe> <1# > <1#â
\80¦> <1#f> <ï|â
\82¬>
8929 specX <7E> <7F> <EF80> <EF81> <EFC0> <EFC1> <A0> <80>
8930 specW <~> <
\7f> <
\80> <
\81> <À> <Á> <Â > <Â
\80>
8931 specU <> <
\80> <ï·
\90>
8933 name: integer-base-one-2a
8935 check if the use of fake integer base 1 stops at correct characters
8940 expected-stderr-pattern:
8941 /1#foo: unexpected 'oo'/
8942 expected-exit: e != 0
8944 name: integer-base-one-2b
8946 check if the use of fake integer base 1 stops at correct characters
8951 expected-stderr-pattern:
8952 /1#À
\80: unexpected '
\80'/
8953 expected-exit: e != 0
8955 name: integer-base-one-2c1
8957 check if the use of fake integer base 1 stops at correct characters
8965 name: integer-base-one-2c2
8967 check if the use of fake integer base 1 stops at correct characters
8972 expected-stderr-pattern:
8973 /1#â
\80¦: unexpected '
\80'/
8974 expected-exit: e != 0
8976 name: integer-base-one-2d1
8978 check if the use of fake integer base 1 handles octets okay
8982 echo /$x/ # invalid utf-8
8986 name: integer-base-one-2d2
8988 check if the use of fake integer base 1 handles octets
8992 echo /$x/ # invalid 2-byte
8996 name: integer-base-one-2d3
8998 check if the use of fake integer base 1 handles octets
9002 echo /$x/ # invalid 2-byte
9006 name: integer-base-one-2d4
9008 check if the use of fake integer base 1 stops at invalid input
9011 typeset -i16 x=1#ï¿À
9012 echo /$x/ # invalid 3-byte
9013 expected-stderr-pattern:
9014 /1#ï¿À: unexpected '¿'/
9015 expected-exit: e != 0
9017 name: integer-base-one-2d5
9019 check if the use of fake integer base 1 stops at invalid input
9022 typeset -i16 x=1#À
\80
9023 echo /$x/ # non-minimalistic
9024 expected-stderr-pattern:
9025 /1#À
\80: unexpected '
\80'/
9026 expected-exit: e != 0
9028 name: integer-base-one-2d6
9030 check if the use of fake integer base 1 stops at invalid input
9033 typeset -i16 x=1#à
\80\80
9034 echo /$x/ # non-minimalistic
9035 expected-stderr-pattern:
9036 /1#à
\80\80: unexpected '
\80'/
9037 expected-exit: e != 0
9039 name: integer-base-one-3As
9041 some sample code for hexdumping
9042 not NUL safe; input lines must be NL terminated
9045 print 'Hello, World!\\\nこんにちは!'
9046 typeset -Uui16 i=0x100
9047 # change that to 0xFF once we can handle embedded
9048 # NUL characters in strings / here documents
9049 while (( i++ < 0x1FF )); do
9050 print -n "\x${i#16#1}"
9054 # integer-base-one-3As
9055 typeset -Uui16 -Z11 pos=0
9056 typeset -Uui16 -Z5 hv=2147483647
9060 while IFS= read -r line; do
9062 while [[ -n $line ]]; do
9064 if (( (pos & 15) == 0 )); then
9065 (( pos )) && print "$dasc|"
9066 print -n "${pos#16#} "
9069 print -n "${hv#16#} "
9070 if (( (hv < 32) || (hv > 126) )); then
9073 dasc=$dasc${line::1}
9075 (( (pos++ & 15) == 7 )) && print -n -- '- '
9079 while (( pos & 15 )); do
9081 (( (pos++ & 15) == 7 )) && print -n -- '- '
9083 (( hv == 2147483647 )) || print "$dasc|"
9086 00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..|
9087 00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................|
9088 00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................|
9089 00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................|
9090 00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.|
9091 00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>|
9092 00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN|
9093 00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^|
9094 00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn|
9095 00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~|
9096 000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................|
9097 000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................|
9098 000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................|
9099 000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................|
9100 000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................|
9101 000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................|
9102 00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................|
9103 00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................|
9104 00000120 FF 7A 0A - |.z.|
9106 name: integer-base-one-3Ws
9108 some sample code for hexdumping Unicode
9109 not NUL safe; input lines must be NL terminated
9113 print 'Hello, World!\\\nこんにちは!'
9114 typeset -Uui16 i=0x100
9115 # change that to 0xFF once we can handle embedded
9116 # NUL characters in strings / here documents
9117 while (( i++ < 0x1FF )); do
9118 print -n "\u${i#16#1}"
9121 print \\xff # invalid utf-8
9122 print \\xc2 # invalid 2-byte
9123 print \\xef\\xbf\\xc0 # invalid 3-byte
9124 print \\xc0\\x80 # non-minimalistic
9125 print \\xe0\\x80\\x80 # non-minimalistic
9126 print '�' # end of range
9127 print '\0z' # embedded NUL
9129 # integer-base-one-3Ws
9130 typeset -Uui16 -Z11 pos=0
9131 typeset -Uui16 -Z7 hv
9136 while IFS= read -r line; do
9139 while (( lpos < ${#line} )); do
9140 wc=1#${line:(lpos++):1}
9141 if (( (wc < 32) || \
9142 ((wc > 126) && (wc < 160)) )); then
9144 elif (( (wc & 0xFF80) == 0xEF80 )); then
9149 if (( (pos & 7) == 7 )); then
9152 elif (( (pos & 7) == 0 )); then
9153 (( pos )) && print "$dasc|"
9154 print -n "${pos#16#} "
9158 print -n "${hv#16#} "
9159 (( (pos++ & 7) == 3 )) && \
9164 while (( pos & 7 )); do
9166 (( (pos++ & 7) == 3 )) && print -n -- '- '
9168 (( hv == 2147483647 )) || print "$dasc|"
9171 00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W|
9172 00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.こ|
9173 00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |んにちは!...|
9174 00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........|
9175 00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........|
9176 00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........|
9177 00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"|
9178 00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*|
9179 00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012|
9180 00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:|
9181 00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB|
9182 00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ|
9183 00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR|
9184 00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ|
9185 00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab|
9186 00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij|
9187 00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr|
9188 00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz|
9189 00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....|
9190 00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........|
9191 000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........|
9192 000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........|
9193 000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |..... ¡¢|
9194 000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA |£¤¥¦§¨©ª|
9195 000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 |«¬®¯°±²|
9196 000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA |³´µ¶·¸¹º|
9197 000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 |»¼½¾¿ÀÁÂ|
9198 000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA |ÃÄÅÆÇÈÉÊ|
9199 000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 |ËÌÍÎÏÐÑÒ|
9200 000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA |ÓÔÕÖ×ØÙÚ|
9201 000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 |ÛÜÝÞßàáâ|
9202 000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA |ãäåæçèéê|
9203 00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 |ëìíîïðñò|
9204 00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA |óôõö÷øùú|
9205 00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |ûüýþÿ.�.|
9206 00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |�.���.��|
9207 00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |.���.���|
9208 00000128 EFBE EFEF EFBF EFBF - 000A 007A 000A |����.z.|
9210 name: integer-base-one-3Ar
9212 some sample code for hexdumping; NUL and binary safe
9215 print 'Hello, World!\\\nこんにちは!'
9216 typeset -Uui16 i=0x100
9217 # change that to 0xFF once we can handle embedded
9218 # NUL characters in strings / here documents
9219 while (( i++ < 0x1FF )); do
9220 print -n "\x${i#16#1}"
9224 # integer-base-one-3Ar
9225 typeset -Uui16 -Z11 pos=0
9226 typeset -Uui16 -Z5 hv=2147483647
9228 if read -arN -1 line; then
9231 while (( i < ${#line[*]} )); do
9233 if (( (pos & 15) == 0 )); then
9234 (( pos )) && print "$dasc|"
9235 print -n "${pos#16#} "
9238 print -n "${hv#16#} "
9239 if (( (hv < 32) || (hv > 126) )); then
9242 dasc=$dasc${line[i-1]#1#}
9244 (( (pos++ & 15) == 7 )) && print -n -- '- '
9247 while (( pos & 15 )); do
9249 (( (pos++ & 15) == 7 )) && print -n -- '- '
9251 (( hv == 2147483647 )) || print "$dasc|"
9254 00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..|
9255 00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................|
9256 00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................|
9257 00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................|
9258 00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.|
9259 00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>|
9260 00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN|
9261 00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^|
9262 00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn|
9263 00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~|
9264 000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................|
9265 000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................|
9266 000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................|
9267 000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................|
9268 000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................|
9269 000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................|
9270 00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................|
9271 00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................|
9272 00000120 FF 00 7A 0A - |..z.|
9274 name: integer-base-one-3Wr
9276 some sample code for hexdumping Unicode; NUL and binary safe
9280 print 'Hello, World!\\\nこんにちは!'
9281 typeset -Uui16 i=0x100
9282 # change that to 0xFF once we can handle embedded
9283 # NUL characters in strings / here documents
9284 while (( i++ < 0x1FF )); do
9285 print -n "\u${i#16#1}"
9288 print \\xff # invalid utf-8
9289 print \\xc2 # invalid 2-byte
9290 print \\xef\\xbf\\xc0 # invalid 3-byte
9291 print \\xc0\\x80 # non-minimalistic
9292 print \\xe0\\x80\\x80 # non-minimalistic
9293 print '�' # end of range
9294 print '\0z' # embedded NUL
9296 # integer-base-one-3Wr
9297 typeset -Uui16 -Z11 pos=0
9298 typeset -Uui16 -Z7 hv=2147483647
9300 if read -arN -1 line; then
9303 while (( i < ${#line[*]} )); do
9305 if (( (hv < 32) || \
9306 ((hv > 126) && (hv < 160)) )); then
9308 elif (( (hv & 0xFF80) == 0xEF80 )); then
9313 if (( (pos & 7) == 7 )); then
9316 elif (( (pos & 7) == 0 )); then
9317 (( pos )) && print "$dasc|"
9318 print -n "${pos#16#} "
9321 print -n "${hv#16#} "
9322 (( (pos++ & 7) == 3 )) && \
9327 while (( pos & 7 )); do
9329 (( (pos++ & 7) == 3 )) && print -n -- '- '
9331 (( hv == 2147483647 )) || print "$dasc|"
9334 00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W|
9335 00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.こ|
9336 00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |んにちは!...|
9337 00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........|
9338 00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........|
9339 00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........|
9340 00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"|
9341 00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*|
9342 00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012|
9343 00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:|
9344 00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB|
9345 00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ|
9346 00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR|
9347 00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ|
9348 00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab|
9349 00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij|
9350 00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr|
9351 00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz|
9352 00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....|
9353 00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........|
9354 000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........|
9355 000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........|
9356 000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |..... ¡¢|
9357 000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA |£¤¥¦§¨©ª|
9358 000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 |«¬®¯°±²|
9359 000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA |³´µ¶·¸¹º|
9360 000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 |»¼½¾¿ÀÁÂ|
9361 000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA |ÃÄÅÆÇÈÉÊ|
9362 000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 |ËÌÍÎÏÐÑÒ|
9363 000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA |ÓÔÕÖ×ØÙÚ|
9364 000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 |ÛÜÝÞßàáâ|
9365 000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA |ãäåæçèéê|
9366 00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 |ëìíîïðñò|
9367 00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA |óôõö÷øùú|
9368 00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |ûüýþÿ.�.|
9369 00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |�.���.��|
9370 00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |.���.���|
9371 00000128 EFBE EFEF EFBF EFBF - 000A 0000 007A 000A |����..z.|
9373 name: integer-base-one-4
9375 Check if ksh93-style base-one integers work
9380 (echo 2f $(('aa'))) 2>&1 | sed "s/^[^']*'/2p '/"
9388 2p 'aa': multi-character character constant
9394 name: integer-base-one-5A
9396 Check to see that we’re NUL and Unicode safe
9399 print 'a\0b\xfdz' >x
9405 16#61 16#0 16#62 16#FD 16#7A .
9407 name: integer-base-one-5W
9409 Check to see that we’re NUL and Unicode safe
9418 16#61 16#0 16#62 16#20AC 16#63 .
9422 Check if we can use a specific syntax idiom for ulimit
9423 category: !os:syllable
9425 if ! x=$(ulimit -d) || [[ $x = unknown ]]; then
9426 #echo expected to fail on this OS
9429 ulimit -dS $x && echo okay
9436 Check some of the most basic invariants of I/O redirection
9441 print -u2 e$((i++)).
9466 Check if GNU bash-like I/O redirection works
9467 Part 1: this is also supported by GNU bash
9468 category: shell:legacy-no
9487 Check if GNU bash-like I/O redirection works
9488 Part 2: this is *not* supported by GNU bash
9489 category: shell:legacy-no
9508 Check if GNU bash-like I/O redirection works
9509 Part 2: this is *not* supported by GNU bash
9510 category: shell:legacy-no
9529 Check if GNU bash-like I/O redirection works
9530 Part 2: this is supported by GNU bash 4 only
9531 category: shell:legacy-no
9553 Check if GNU bash-like I/O redirection fails correctly
9554 Part 1: this is also supported by GNU bash
9555 category: shell:legacy-no
9571 expected-stderr-pattern: /.*: can't (create|overwrite) .*/
9575 Check if GNU bash-like I/O redirection fails correctly
9576 Part 2: this is *not* supported by GNU bash
9577 category: shell:legacy-no
9598 Check if GNU bash-like I/O redirection works
9599 Part 4: this is also supported by GNU bash,
9600 but failed in some mksh versions
9601 category: shell:legacy-no
9610 [[ -e bar ]] && threeout "$bf" &>foo
9623 name: bashiop-5-normal
9625 Check if GNU bash-like I/O redirection is only supported
9626 in !POSIX !sh mode as it breaks existing scripts' syntax
9627 category: shell:legacy-no
9629 :>x; echo 1 "$("$__progname" -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9630 :>x; echo 2 "$("$__progname" -o posix -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9631 :>x; echo 3 "$("$__progname" -o sh -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9637 name: bashiop-5-legacy
9639 Check if GNU bash-like I/O redirection is not parsed
9640 in lksh as it breaks existing scripts' syntax
9641 category: shell:legacy-yes
9643 :>x; echo 1 "$("$__progname" -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9644 :>x; echo 2 "$("$__progname" -o posix -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9645 :>x; echo 3 "$("$__progname" -o sh -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9653 Check for support of more than 9 file descriptors
9656 read -u10 foo 10<<< bar
9663 Check for support of more than 9 file descriptors
9679 for n in ${a#*=}; do echo 1hu ${n} .; done
9680 for n in "${a#*=}"; do echo 1hq ${n} .; done
9681 for n in ${a##*=}; do echo 2hu ${n} .; done
9682 for n in "${a##*=}"; do echo 2hq ${n} .; done
9683 for n in ${a%=*}; do echo 1pu ${n} .; done
9684 for n in "${a%=*}"; do echo 1pq ${n} .; done
9685 for n in ${a%%=*}; do echo 2pu ${n} .; done
9686 for n in "${a%%=*}"; do echo 2pq ${n} .; done
9693 name: oksh-and-list-error-1
9695 Test exit status of rightmost element in 2 element && list in -e mode
9698 echo "should not print"
9700 expected-exit: e != 0
9702 name: oksh-and-list-error-2
9704 Test exit status of rightmost element in 3 element && list in -e mode
9706 true && true && false
9707 echo "should not print"
9709 expected-exit: e != 0
9711 name: oksh-or-list-error-1
9713 Test exit status of || list in -e mode
9716 echo "should not print"
9718 expected-exit: e != 0
9720 name: oksh-longline-crash
9722 This used to cause a core dump
9725 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"
9726 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"
9727 for deplib in $deplibs; do
9730 new_libs="$deplib $new_libs"
9733 case " $specialdeplibs " in
9735 new_libs="$deplib $new_libs";;
9741 name: oksh-seterror-1
9743 The -e flag should be ignored when executing a compound list
9744 followed by an if statement.
9746 if true; then false && false; fi
9749 expected-exit: e == 0
9751 name: oksh-seterror-2
9753 The -e flag should be ignored when executing a compound list
9754 followed by an if statement.
9756 if true; then if true; then false && false; fi; fi
9759 expected-exit: e == 0
9761 name: oksh-seterror-3
9763 The -e flag should be ignored when executing a compound list
9764 followed by an elif statement.
9766 if true; then :; elif true; then false && false; fi
9768 expected-exit: e == 0
9770 name: oksh-seterror-4
9772 The -e flag should be ignored when executing a pipeline
9781 expected-exit: e == 0
9783 name: oksh-seterror-5
9785 The -e flag should be ignored when executing a pipeline
9791 expected-exit: e == 0
9793 name: oksh-seterror-6
9795 When trapping ERR and EXIT, both traps should run in -e mode
9796 when an error occurs.
9798 trap 'echo EXIT' EXIT
9805 expected-exit: e != 0
9810 name: oksh-seterror-7
9812 The -e flag within a command substitution should be honored
9814 echo $( set -e; false; echo foo )
9819 name: oksh-input-comsub
9821 A command substitution using input redirection should exit with
9822 failure if the input file does not exist.
9824 var=$(< non-existent)
9825 expected-exit: e != 0
9826 expected-stderr-pattern: /non-existent/
9828 name: oksh-empty-for-list
9830 A for list which expands to zero items should not execute the body.
9832 set foo bar baz ; for out in ; do echo $out ; done
9834 name: oksh-varfunction-mod1
9836 (Inspired by PR 2450 on OpenBSD.) Calling
9838 where f is a ksh style function, should not set FOO in the current
9839 env. If f is a Bourne style function, FOO should be set. Furthermore,
9840 the function should receive a correct value of FOO. However, differing
9841 from oksh, setting FOO in the function itself must change the value in
9842 setting FOO in the function itself should not change the value in
9845 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
9846 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
9847 done >env; chmod +x env; PATH=.:$PATH
9849 if [ x$FOO != xbar ]; then
9854 if [ "x$x" != "xFOO=bar" ]; then
9862 if [ x$FOO != xbar ]; then
9867 if [ "x$x" != "xFOO=bar" ]; then
9875 if [ $? != 0 ]; then
9878 if [ x$FOO != x ]; then
9882 if [ $? != 0 ]; then
9885 if [ x$FOO != xfoo ]; then
9890 if [ $? != 0 ]; then
9893 if [ x$FOO != xbarbar ]; then
9897 if [ $? != 0 ]; then
9900 if [ x$FOO != xfoo ]; then
9906 Verify that file descriptors > 2 are private for Korn shells
9907 AT&T ksh93 does this still, which means we must keep it as well
9908 category: shell:legacy-no
9912 open(my \$fh, ">&", 9) or die "E: open \$!";
9913 syswrite(\$fh, "Fowl\\n", 5) or die "E: write \$!";
9918 expected-exit: e != 0
9919 expected-stderr-pattern:
9924 Verify that file descriptors > 2 are not private for POSIX shells
9925 See Debian Bug #154540, Closes: #499139
9929 open(my \$fh, ">&", 9) or die "E: open \$!";
9930 syswrite(\$fh, "Fowl\\n", 5) or die "E: write \$!";
9933 test -n "$POSH_VERSION" || set -o posix
9941 Verify that file descriptors > 2 are not private for LEGACY KSH
9942 category: shell:legacy-yes
9946 open(my \$fh, ">&", 9) or die "E: open \$!";
9947 syswrite(\$fh, "Fowl\\n", 5) or die "E: write \$!";
9957 COMSUB are now parsed recursively, so this works
9958 see also regression-6: matching parenthesēs bug
9959 Fails on: pdksh bash2 bash3 zsh
9960 Passes on: bash4 ksh93 mksh(20110313+)
9962 echo 1 $(case 1 in (1) echo yes;; (2) echo no;; esac) .
9963 echo 2 $(case 1 in 1) echo yes;; 2) echo no;; esac) .
9964 TEST=1234; echo 3 ${TEST: $(case 1 in (1) echo 1;; (*) echo 2;; esac)} .
9965 TEST=5678; echo 4 ${TEST: $(case 1 in 1) echo 1;; *) echo 2;; esac)} .
9966 a=($(case 1 in (1) echo 1;; (*) echo 2;; esac)); echo 5 ${a[0]} .
9967 a=($(case 1 in 1) echo 1;; *) echo 2;; esac)); echo 6 ${a[0]} .
9978 COMSUB are now parsed recursively, so this works
9979 Fails on: pdksh bash2 bash3 bash4 zsh
9980 Passes on: ksh93 mksh(20110313+)
9982 echo 1 $(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10)) .
9983 echo 2 $(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20)) .
9984 (( a = $(case 1 in (1) echo 1;; (*) echo 2;; esac) )); echo 3 $a .
9985 (( a = $(case 1 in 1) echo 1;; *) echo 2;; esac) )); echo 4 $a .
9986 a=($(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10))); echo 5 ${a[0]} .
9987 a=($(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20))); echo 6 ${a[0]} .
9998 RedHat BZ#496791 – another case of missing recursion
9999 in parsing COMSUB expressions
10000 Fails on: pdksh bash2 bash3¹ bash4¹ zsh
10001 Passes on: ksh93 mksh(20110305+)
10002 ① bash[34] seem to choke on comment ending with backslash-newline
10004 # a comment with " ' \
10007 # a comment with " ' \
10015 Extended test for COMSUB explaining why a recursive parser
10016 is a must (a non-recursive parser cannot pass all three of
10017 these test cases, especially the ‘#’ is difficult)
10019 print '#!'"$__progname"'\necho 1234' >id; chmod +x id; PATH=.:$PATH
10020 echo $(typeset -i10 x=16#20; echo $x)
10021 echo $(typeset -Uui16 x=16#$(id -u)
10024 typeset -Uui16 a=36#foo; c=2
10025 typeset -Uui16 b=36 #foo; d=2
10034 Check the tree dump functions for !MKSH_SMALL functionality
10037 x() { case $1 in u) echo x ;;& *) echo $1 ;; esac; }
10053 Check COMSUB works with aliases (does not expand them twice)
10055 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
10057 alias echo='echo a'
10059 ./pfn "$(echo foo)"
10066 ./pfn "$(echo foo )"
10069 name: comsub-torture
10071 Check the tree dump functions work correctly
10073 if [[ -z $__progname ]]; then echo >&2 call me with __progname; exit 1; fi
10074 while IFS= read -r line; do
10075 if [[ $line = '#1' ]]; then
10078 elif [[ $line = EOFN* ]]; then
10079 fbody=$fbody$'\n'$line
10081 elif [[ $line != '#'* ]]; then
10082 fbody=$fbody$'\n\t'$line
10085 if (( lastf )); then
10086 x="inline_${nextf}() {"$fbody$'\n}\n'
10088 print -r -- "${x}typeset -f inline_$nextf" | "$__progname"
10089 x="function comsub_$nextf { x=\$("$fbody$'\n); }\n'
10091 print -r -- "${x}typeset -f comsub_$nextf" | "$__progname"
10092 x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n'
10094 print -r -- "${x}typeset -f reread_$nextf" | "$__progname"
10102 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
10103 #TPAREN_TPIPE_TLIST
10104 (echo $foo | tr -dc 0-9; echo)
10106 cmd && echo ja || echo nein
10108 select file in *; do echo "<$file>" ; break ; done
10110 time for i in {1,2,3} ; do echo $i ; done
10112 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
10113 #TIF_TBANG_TDBRACKET_TELIF
10114 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
10116 i=1; while (( i < 10 )); do echo $i; let ++i; done
10118 i=10; until (( !--i )) ; do echo $i; done
10121 #TFUNCT_TBRACE_TASYNC
10122 function korn { echo eins; echo zwei ; }
10123 bourne () { logger * & }
10126 #IOWRITE_IOCLOB_IOHERE_noIOSKIP
10130 #IOWRITE_noIOCLOB_IOHERE_IOSKIP
10135 sh 1<>/dev/console 0<&1 2>&1
10136 #COMSUB_EXPRSUB_FUNSUB_VALSUB
10137 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
10138 #QCHAR_OQUOTE_CQUOTE
10139 echo fo\ob\"a\`r\'b\$az
10140 echo "fo\ob\"a\`r\'b\$az"
10141 echo 'fo\ob\"a\`r'\''b\$az'
10142 #OSUBST_CSUBST_OPAT_SPAT_CPAT
10143 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
10146 note there must be no space between EOFN and )
10150 note the space between EOFN and ) is actually part of the here document marker
10153 x=$(sysctl -n kern.version | sed 1q)
10154 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
10155 ed -s /etc/motd 2>&1 <<-EOF
10162 EOF)" = @(?) ]] && rm -f /etc/motd
10163 if [[ ! -s /etc/motd ]]; then
10164 install -c -o root -g wheel -m 664 /dev/null /etc/motd
10165 print -- "$x\n" >/etc/motd
10175 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
10178 vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4"
10180 function comsub_TCOM { x=$(
10181 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
10183 function comsub_TCOM {
10184 x=$(vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" )
10186 function reread_TCOM { x=$((
10187 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
10189 function reread_TCOM {
10190 x=$(( vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" ) | tr u x )
10192 inline_TPAREN_TPIPE_TLIST() {
10193 (echo $foo | tr -dc 0-9; echo)
10195 inline_TPAREN_TPIPE_TLIST() {
10196 ( echo $foo | tr -dc 0-9
10199 function comsub_TPAREN_TPIPE_TLIST { x=$(
10200 (echo $foo | tr -dc 0-9; echo)
10202 function comsub_TPAREN_TPIPE_TLIST {
10203 x=$(( echo $foo | tr -dc 0-9 ; echo ) )
10205 function reread_TPAREN_TPIPE_TLIST { x=$((
10206 (echo $foo | tr -dc 0-9; echo)
10208 function reread_TPAREN_TPIPE_TLIST {
10209 x=$(( ( echo $foo | tr -dc 0-9 ; echo ) ) | tr u x )
10211 inline_TAND_TOR() {
10212 cmd && echo ja || echo nein
10214 inline_TAND_TOR() {
10215 cmd && echo ja || echo nein
10217 function comsub_TAND_TOR { x=$(
10218 cmd && echo ja || echo nein
10220 function comsub_TAND_TOR {
10221 x=$(cmd && echo ja || echo nein )
10223 function reread_TAND_TOR { x=$((
10224 cmd && echo ja || echo nein
10226 function reread_TAND_TOR {
10227 x=$(( cmd && echo ja || echo nein ) | tr u x )
10230 select file in *; do echo "<$file>" ; break ; done
10239 function comsub_TSELECT { x=$(
10240 select file in *; do echo "<$file>" ; break ; done
10242 function comsub_TSELECT {
10243 x=$(select file in * ; do echo "<$file>" ; break ; done )
10245 function reread_TSELECT { x=$((
10246 select file in *; do echo "<$file>" ; break ; done
10248 function reread_TSELECT {
10249 x=$(( select file in * ; do echo "<$file>" ; break ; done ) | tr u x )
10251 inline_TFOR_TTIME() {
10252 time for i in {1,2,3} ; do echo $i ; done
10254 inline_TFOR_TTIME() {
10255 time for i in {1,2,3}
10260 function comsub_TFOR_TTIME { x=$(
10261 time for i in {1,2,3} ; do echo $i ; done
10263 function comsub_TFOR_TTIME {
10264 x=$(time for i in {1,2,3} ; do echo $i ; done )
10266 function reread_TFOR_TTIME { x=$((
10267 time for i in {1,2,3} ; do echo $i ; done
10269 function reread_TFOR_TTIME {
10270 x=$(( time for i in {1,2,3} ; do echo $i ; done ) | tr u x )
10273 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
10284 echo kann net bis drei zählen
10288 function comsub_TCASE { x=$(
10289 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
10291 function comsub_TCASE {
10292 x=$(case $foo in (1) echo eins ;& (2) echo zwei ;| (*) echo kann net bis drei zählen ;; esac )
10294 function reread_TCASE { x=$((
10295 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
10297 function reread_TCASE {
10298 x=$(( case $foo in (1) echo eins ;& (2) echo zwei ;| (*) echo kann net bis drei zählen ;; esac ) | tr u x )
10300 inline_TIF_TBANG_TDBRACKET_TELIF() {
10301 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
10303 inline_TIF_TBANG_TDBRACKET_TELIF() {
10314 function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$(
10315 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
10317 function comsub_TIF_TBANG_TDBRACKET_TELIF {
10318 x=$(if ! [[ 1 = 1 ]] ; then echo eins ; elif [[ 1 = 2 ]] ; then echo zwei ; else echo drei ; fi )
10320 function reread_TIF_TBANG_TDBRACKET_TELIF { x=$((
10321 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
10323 function reread_TIF_TBANG_TDBRACKET_TELIF {
10324 x=$(( if ! [[ 1 = 1 ]] ; then echo eins ; elif [[ 1 = 2 ]] ; then echo zwei ; else echo drei ; fi ) | tr u x )
10327 i=1; while (( i < 10 )); do echo $i; let ++i; done
10331 while let] " i < 10 "
10337 function comsub_TWHILE { x=$(
10338 i=1; while (( i < 10 )); do echo $i; let ++i; done
10340 function comsub_TWHILE {
10341 x=$(i=1 ; while let] " i < 10 " ; do echo $i ; let ++i ; done )
10343 function reread_TWHILE { x=$((
10344 i=1; while (( i < 10 )); do echo $i; let ++i; done
10346 function reread_TWHILE {
10347 x=$(( i=1 ; while let] " i < 10 " ; do echo $i ; let ++i ; done ) | tr u x )
10350 i=10; until (( !--i )) ; do echo $i; done
10354 until let] " !--i "
10359 function comsub_TUNTIL { x=$(
10360 i=10; until (( !--i )) ; do echo $i; done
10362 function comsub_TUNTIL {
10363 x=$(i=10 ; until let] " !--i " ; do echo $i ; done )
10365 function reread_TUNTIL { x=$((
10366 i=10; until (( !--i )) ; do echo $i; done
10368 function reread_TUNTIL {
10369 x=$(( i=10 ; until let] " !--i " ; do echo $i ; done ) | tr u x )
10378 function comsub_TCOPROC { x=$(
10381 function comsub_TCOPROC {
10384 function reread_TCOPROC { x=$((
10387 function reread_TCOPROC {
10388 x=$(( cat * |& ls ) | tr u x )
10390 inline_TFUNCT_TBRACE_TASYNC() {
10391 function korn { echo eins; echo zwei ; }
10392 bourne () { logger * & }
10394 inline_TFUNCT_TBRACE_TASYNC() {
10403 function comsub_TFUNCT_TBRACE_TASYNC { x=$(
10404 function korn { echo eins; echo zwei ; }
10405 bourne () { logger * & }
10407 function comsub_TFUNCT_TBRACE_TASYNC {
10408 x=$(function korn { echo eins ; echo zwei ; } ; bourne() { logger * & } )
10410 function reread_TFUNCT_TBRACE_TASYNC { x=$((
10411 function korn { echo eins; echo zwei ; }
10412 bourne () { logger * & }
10414 function reread_TFUNCT_TBRACE_TASYNC {
10415 x=$(( function korn { echo eins ; echo zwei ; } ; bourne() { logger * & } ) | tr u x )
10417 inline_IOREAD_IOCAT() {
10420 inline_IOREAD_IOCAT() {
10423 function comsub_IOREAD_IOCAT { x=$(
10426 function comsub_IOREAD_IOCAT {
10427 x=$(tr x u <foo >>bar )
10429 function reread_IOREAD_IOCAT { x=$((
10432 function reread_IOREAD_IOCAT {
10433 x=$(( tr x u <foo >>bar ) | tr u x )
10435 inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
10440 inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
10446 function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$(
10451 function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
10452 x=$(cat >|bar <<"EOFN"
10457 function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$((
10462 function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
10463 x=$(( cat >|bar <<"EOFN"
10468 inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
10473 inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
10479 function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$(
10484 function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
10485 x=$(cat >bar <<-EOFI
10490 function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$((
10495 function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
10496 x=$(( cat >bar <<-EOFI
10501 inline_IORDWR_IODUP() {
10502 sh 1<>/dev/console 0<&1 2>&1
10504 inline_IORDWR_IODUP() {
10505 sh 1<>/dev/console <&1 2>&1
10507 function comsub_IORDWR_IODUP { x=$(
10508 sh 1<>/dev/console 0<&1 2>&1
10510 function comsub_IORDWR_IODUP {
10511 x=$(sh 1<>/dev/console <&1 2>&1 )
10513 function reread_IORDWR_IODUP { x=$((
10514 sh 1<>/dev/console 0<&1 2>&1
10516 function reread_IORDWR_IODUP {
10517 x=$(( sh 1<>/dev/console <&1 2>&1 ) | tr u x )
10519 inline_COMSUB_EXPRSUB_FUNSUB_VALSUB() {
10520 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
10522 inline_COMSUB_EXPRSUB_FUNSUB_VALSUB() {
10523 echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;}
10525 function comsub_COMSUB_EXPRSUB_FUNSUB_VALSUB { x=$(
10526 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
10528 function comsub_COMSUB_EXPRSUB_FUNSUB_VALSUB {
10529 x=$(echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;} )
10531 function reread_COMSUB_EXPRSUB_FUNSUB_VALSUB { x=$((
10532 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
10534 function reread_COMSUB_EXPRSUB_FUNSUB_VALSUB {
10535 x=$(( echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;} ) | tr u x )
10537 inline_QCHAR_OQUOTE_CQUOTE() {
10538 echo fo\ob\"a\`r\'b\$az
10539 echo "fo\ob\"a\`r\'b\$az"
10540 echo 'fo\ob\"a\`r'\''b\$az'
10542 inline_QCHAR_OQUOTE_CQUOTE() {
10543 echo fo\ob\"a\`r\'b\$az
10544 echo "fo\ob\"a\`r\'b\$az"
10545 echo "fo\\ob\\\"a\\\`r"\'"b\\\$az"
10547 function comsub_QCHAR_OQUOTE_CQUOTE { x=$(
10548 echo fo\ob\"a\`r\'b\$az
10549 echo "fo\ob\"a\`r\'b\$az"
10550 echo 'fo\ob\"a\`r'\''b\$az'
10552 function comsub_QCHAR_OQUOTE_CQUOTE {
10553 x=$(echo fo\ob\"a\`r\'b\$az ; echo "fo\ob\"a\`r\'b\$az" ; echo "fo\\ob\\\"a\\\`r"\'"b\\\$az" )
10555 function reread_QCHAR_OQUOTE_CQUOTE { x=$((
10556 echo fo\ob\"a\`r\'b\$az
10557 echo "fo\ob\"a\`r\'b\$az"
10558 echo 'fo\ob\"a\`r'\''b\$az'
10560 function reread_QCHAR_OQUOTE_CQUOTE {
10561 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 )
10563 inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() {
10564 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
10566 inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() {
10567 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
10569 function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$(
10570 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
10572 function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT {
10573 x=$([[ ${foo#bl\(u\)b} = @(bar|baz) ]] )
10575 function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$((
10576 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
10578 function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT {
10579 x=$(( [[ ${foo#bl\(u\)b} = @(bar|baz) ]] ) | tr u x )
10581 inline_heredoc_closed() {
10583 note there must be no space between EOFN and )
10586 inline_heredoc_closed() {
10588 note there must be no space between EOFN and )
10593 function comsub_heredoc_closed { x=$(
10595 note there must be no space between EOFN and )
10598 function comsub_heredoc_closed {
10600 note there must be no space between EOFN and )
10604 function reread_heredoc_closed { x=$((
10606 note there must be no space between EOFN and )
10609 function reread_heredoc_closed {
10610 x=$(( x=$(cat <<EOFN
10611 note there must be no space between EOFN and )
10613 ) ; echo $x ) | tr u x )
10615 inline_heredoc_space() {
10617 note the space between EOFN and ) is actually part of the here document marker
10620 inline_heredoc_space() {
10622 note the space between EOFN and ) is actually part of the here document marker
10627 function comsub_heredoc_space { x=$(
10629 note the space between EOFN and ) is actually part of the here document marker
10632 function comsub_heredoc_space {
10633 x=$(x=$(cat <<EOFN\
10634 note the space between EOFN and ) is actually part of the here document marker
10638 function reread_heredoc_space { x=$((
10640 note the space between EOFN and ) is actually part of the here document marker
10643 function reread_heredoc_space {
10644 x=$(( x=$(cat <<EOFN\
10645 note the space between EOFN and ) is actually part of the here document marker
10647 ) ; echo $x ) | tr u x )
10649 inline_patch_motd() {
10650 x=$(sysctl -n kern.version | sed 1q)
10651 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
10652 ed -s /etc/motd 2>&1 <<-EOF
10659 EOF)" = @(?) ]] && rm -f /etc/motd
10660 if [[ ! -s /etc/motd ]]; then
10661 install -c -o root -g wheel -m 664 /dev/null /etc/motd
10662 print -- "$x\n" >/etc/motd
10665 inline_patch_motd() {
10666 x=$(sysctl -n kern.version | sed 1q )
10667 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
10675 )" = @(?) ]] && rm -f /etc/motd
10676 if [[ ! -s /etc/motd ]]
10678 install -c -o root -g wheel -m 664 /dev/null /etc/motd
10679 print -- "$x\n" >/etc/motd
10682 function comsub_patch_motd { x=$(
10683 x=$(sysctl -n kern.version | sed 1q)
10684 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
10685 ed -s /etc/motd 2>&1 <<-EOF
10692 EOF)" = @(?) ]] && rm -f /etc/motd
10693 if [[ ! -s /etc/motd ]]; then
10694 install -c -o root -g wheel -m 664 /dev/null /etc/motd
10695 print -- "$x\n" >/etc/motd
10698 function comsub_patch_motd {
10699 x=$(x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
10707 )" = @(?) ]] && 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 )
10709 function reread_patch_motd { x=$((
10710 x=$(sysctl -n kern.version | sed 1q)
10711 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
10712 ed -s /etc/motd 2>&1 <<-EOF
10719 EOF)" = @(?) ]] && rm -f /etc/motd
10720 if [[ ! -s /etc/motd ]]; then
10721 install -c -o root -g wheel -m 664 /dev/null /etc/motd
10722 print -- "$x\n" >/etc/motd
10725 function reread_patch_motd {
10726 x=$(( x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
10734 )" = @(?) ]] && 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 )
10736 inline_wdarrassign() {
10741 inline_wdarrassign() {
10749 function comsub_wdarrassign { x=$(
10754 function comsub_wdarrassign {
10755 x=$(case x in (x) a+=b ; set -A c+ -- d e ;; esac )
10757 function reread_wdarrassign { x=$((
10762 function reread_wdarrassign {
10763 x=$(( case x in (x) a+=b ; set -A c+ -- d e ;; esac ) | tr u x )
10766 name: comsub-torture-io
10768 Check the tree dump functions work correctly with I/O redirection
10770 if [[ -z $__progname ]]; then echo >&2 call me with __progname; exit 1; fi
10771 while IFS= read -r line; do
10772 if [[ $line = '#1' ]]; then
10775 elif [[ $line = EOFN* ]]; then
10776 fbody=$fbody$'\n'$line
10778 elif [[ $line != '#'* ]]; then
10779 fbody=$fbody$'\n\t'$line
10782 if (( lastf )); then
10783 x="inline_${nextf}() {"$fbody$'\n}\n'
10785 print -r -- "${x}typeset -f inline_$nextf" | "$__progname"
10786 x="function comsub_$nextf { x=\$("$fbody$'\n); }\n'
10788 print -r -- "${x}typeset -f comsub_$nextf" | "$__progname"
10789 x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n'
10791 print -r -- "${x}typeset -f reread_$nextf" | "$__progname"
10799 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
10800 #TPAREN_TPIPE_TLIST
10801 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
10803 cmd >&3 && >&3 echo ja || echo >&3 nein
10805 select file in *; do echo "<$file>" ; break >&3 ; done >&3
10807 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
10809 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
10810 #TIF_TBANG_TDBRACKET_TELIF
10811 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
10813 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
10815 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
10817 cat * >&3 |& >&3 ls
10818 #TFUNCT_TBRACE_TASYNC
10819 function korn { echo eins; echo >&3 zwei ; }
10820 bourne () { logger * >&3 & }
10822 echo $(true >&3) $((1+ 2))
10827 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
10830 vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" >&3
10832 function comsub_TCOM { x=$(
10833 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
10835 function comsub_TCOM {
10836 x=$(vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" >&3 )
10838 function reread_TCOM { x=$((
10839 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
10841 function reread_TCOM {
10842 x=$(( vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" >&3 ) | tr u x )
10844 inline_TPAREN_TPIPE_TLIST() {
10845 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
10847 inline_TPAREN_TPIPE_TLIST() {
10848 ( echo $foo | tr -dc 0-9 >&3
10851 function comsub_TPAREN_TPIPE_TLIST { x=$(
10852 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
10854 function comsub_TPAREN_TPIPE_TLIST {
10855 x=$(( echo $foo | tr -dc 0-9 >&3 ; echo >&3 ) >&3 )
10857 function reread_TPAREN_TPIPE_TLIST { x=$((
10858 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
10860 function reread_TPAREN_TPIPE_TLIST {
10861 x=$(( ( echo $foo | tr -dc 0-9 >&3 ; echo >&3 ) >&3 ) | tr u x )
10863 inline_TAND_TOR() {
10864 cmd >&3 && >&3 echo ja || echo >&3 nein
10866 inline_TAND_TOR() {
10867 cmd >&3 && echo ja >&3 || echo nein >&3
10869 function comsub_TAND_TOR { x=$(
10870 cmd >&3 && >&3 echo ja || echo >&3 nein
10872 function comsub_TAND_TOR {
10873 x=$(cmd >&3 && echo ja >&3 || echo nein >&3 )
10875 function reread_TAND_TOR { x=$((
10876 cmd >&3 && >&3 echo ja || echo >&3 nein
10878 function reread_TAND_TOR {
10879 x=$(( cmd >&3 && echo ja >&3 || echo nein >&3 ) | tr u x )
10882 select file in *; do echo "<$file>" ; break >&3 ; done >&3
10891 function comsub_TSELECT { x=$(
10892 select file in *; do echo "<$file>" ; break >&3 ; done >&3
10894 function comsub_TSELECT {
10895 x=$(select file in * ; do echo "<$file>" ; break >&3 ; done >&3 )
10897 function reread_TSELECT { x=$((
10898 select file in *; do echo "<$file>" ; break >&3 ; done >&3
10900 function reread_TSELECT {
10901 x=$(( select file in * ; do echo "<$file>" ; break >&3 ; done >&3 ) | tr u x )
10903 inline_TFOR_TTIME() {
10904 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
10906 inline_TFOR_TTIME() {
10912 function comsub_TFOR_TTIME { x=$(
10913 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
10915 function comsub_TFOR_TTIME {
10916 x=$(for i in {1,2,3} ; do time echo $i >&3 ; done >&3 )
10918 function reread_TFOR_TTIME { x=$((
10919 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
10921 function reread_TFOR_TTIME {
10922 x=$(( for i in {1,2,3} ; do time echo $i >&3 ; done >&3 ) | tr u x )
10925 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
10936 echo kann net bis drei zählen >&3
10940 function comsub_TCASE { x=$(
10941 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
10943 function comsub_TCASE {
10944 x=$(case $foo in (1) echo eins >&3 ;& (2) echo zwei >&3 ;| (*) echo kann net bis drei zählen >&3 ;; esac >&3 )
10946 function reread_TCASE { x=$((
10947 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
10949 function reread_TCASE {
10950 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 )
10952 inline_TIF_TBANG_TDBRACKET_TELIF() {
10953 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
10955 inline_TIF_TBANG_TDBRACKET_TELIF() {
10956 if ! [[ 1 = 1 ]] >&3
10959 elif [[ 1 = 2 ]] >&3
10966 function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$(
10967 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
10969 function comsub_TIF_TBANG_TDBRACKET_TELIF {
10970 x=$(if ! [[ 1 = 1 ]] >&3 ; then echo eins ; elif [[ 1 = 2 ]] >&3 ; then echo zwei ; else echo drei ; fi >&3 )
10972 function reread_TIF_TBANG_TDBRACKET_TELIF { x=$((
10973 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
10975 function reread_TIF_TBANG_TDBRACKET_TELIF {
10976 x=$(( if ! [[ 1 = 1 ]] >&3 ; then echo eins ; elif [[ 1 = 2 ]] >&3 ; then echo zwei ; else echo drei ; fi >&3 ) | tr u x )
10979 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
10983 while let] " i < 10 " >&3
10989 function comsub_TWHILE { x=$(
10990 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
10992 function comsub_TWHILE {
10993 x=$(i=1 ; while let] " i < 10 " >&3 ; do echo $i ; let ++i ; done >&3 )
10995 function reread_TWHILE { x=$((
10996 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
10998 function reread_TWHILE {
10999 x=$(( i=1 ; while let] " i < 10 " >&3 ; do echo $i ; let ++i ; done >&3 ) | tr u x )
11002 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
11006 until let] " !--i " >&3
11011 function comsub_TUNTIL { x=$(
11012 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
11014 function comsub_TUNTIL {
11015 x=$(i=10 ; until let] " !--i " >&3 ; do echo $i ; done >&3 )
11017 function reread_TUNTIL { x=$((
11018 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
11020 function reread_TUNTIL {
11021 x=$(( i=10 ; until let] " !--i " >&3 ; do echo $i ; done >&3 ) | tr u x )
11024 cat * >&3 |& >&3 ls
11030 function comsub_TCOPROC { x=$(
11031 cat * >&3 |& >&3 ls
11033 function comsub_TCOPROC {
11034 x=$(cat * >&3 |& ls >&3 )
11036 function reread_TCOPROC { x=$((
11037 cat * >&3 |& >&3 ls
11039 function reread_TCOPROC {
11040 x=$(( cat * >&3 |& ls >&3 ) | tr u x )
11042 inline_TFUNCT_TBRACE_TASYNC() {
11043 function korn { echo eins; echo >&3 zwei ; }
11044 bourne () { logger * >&3 & }
11046 inline_TFUNCT_TBRACE_TASYNC() {
11055 function comsub_TFUNCT_TBRACE_TASYNC { x=$(
11056 function korn { echo eins; echo >&3 zwei ; }
11057 bourne () { logger * >&3 & }
11059 function comsub_TFUNCT_TBRACE_TASYNC {
11060 x=$(function korn { echo eins ; echo zwei >&3 ; } ; bourne() { logger * >&3 & } )
11062 function reread_TFUNCT_TBRACE_TASYNC { x=$((
11063 function korn { echo eins; echo >&3 zwei ; }
11064 bourne () { logger * >&3 & }
11066 function reread_TFUNCT_TBRACE_TASYNC {
11067 x=$(( function korn { echo eins ; echo zwei >&3 ; } ; bourne() { logger * >&3 & } ) | tr u x )
11069 inline_COMSUB_EXPRSUB() {
11070 echo $(true >&3) $((1+ 2))
11072 inline_COMSUB_EXPRSUB() {
11073 echo $(true >&3 ) $((1+ 2))
11075 function comsub_COMSUB_EXPRSUB { x=$(
11076 echo $(true >&3) $((1+ 2))
11078 function comsub_COMSUB_EXPRSUB {
11079 x=$(echo $(true >&3 ) $((1+ 2)) )
11081 function reread_COMSUB_EXPRSUB { x=$((
11082 echo $(true >&3) $((1+ 2))
11084 function reread_COMSUB_EXPRSUB {
11085 x=$(( echo $(true >&3 ) $((1+ 2)) ) | tr u x )
11090 Check that non-subenvironment command substitution works
11110 You can now reliably use local and return in funsubs
11113 x=q; e=1; x=${ echo a; e=2; echo x$e;}; echo 1:y$x,$e,$?.
11114 x=q; e=1; x=${ echo a; typeset e=2; echo x$e;}; echo 2:y$x,$e,$?.
11115 x=q; e=1; x=${ echo a; typeset e=2; return 3; echo x$e;}; echo 3:y$x,$e,$?.
11123 Check that "value substitutions" work as advertised
11129 echo "before: x<$x> y<$y> z<$z> R<$REPLY>"
11132 echo "begin: x<$x> y<$y> z<$z> R<$REPLY>"
11137 echo "end: x<$x> y<$y> z<$z> R<$REPLY>"
11139 echo "after: x<$x> y<$y> z<$z> R<$REPLY>"
11140 # ensure trailing newlines are kept
11141 t=${|REPLY=$'foo\n\n';}
11143 echo -n this used to segfault
11144 echo ${|true;}$(true).
11146 before: x<1> y<2> z<3> R<4>
11147 begin: x<1> y<> z<3> R<>
11148 end: x<5> y<6> z<7> R<8>
11149 after: x<8> y<2> z<7> R<4>
11150 typeset t=$'foo\n\n'
11151 this used to segfault.
11155 Check that the short form [ $x ] works
11159 rv=$?; echo $((++i)) $rv
11161 rv=$?; echo $((++i)) $rv
11163 rv=$?; echo $((++i)) $rv
11165 rv=$?; echo $((++i)) $rv
11168 rv=$?; echo $((++i)) $rv
11170 rv=$?; echo $((++i)) $rv
11172 rv=$?; echo $((++i)) $rv
11174 rv=$?; echo $((++i)) $rv
11177 rv=$?; echo $((++i)) $rv
11179 rv=$?; echo $((++i)) $rv
11181 rv=$?; echo $((++i)) $rv
11183 rv=$?; echo $((++i)) $rv
11200 Check that the short form [[ $x ]] works (ksh93 extension)
11204 rv=$?; echo $((++i)) $rv
11206 rv=$?; echo $((++i)) $rv
11208 rv=$?; echo $((++i)) $rv
11210 rv=$?; echo $((++i)) $rv
11213 rv=$?; echo $((++i)) $rv
11215 rv=$?; echo $((++i)) $rv
11217 rv=$?; echo $((++i)) $rv
11219 rv=$?; echo $((++i)) $rv
11222 rv=$?; echo $((++i)) $rv
11224 rv=$?; echo $((++i)) $rv
11226 rv=$?; echo $((++i)) $rv
11228 rv=$?; echo $((++i)) $rv
11243 name: event-subst-3
11245 Check that '!' substitution in noninteractive mode is ignored
11246 file-setup: file 755 "falsetto"
11250 file-setup: file 755 "!false"
11254 export PATH=.:$PATH
11262 ! false; then echo foo; else echo bar; fi
11271 name: event-subst-0
11273 Check that '!' substitution in interactive mode is ignored
11276 file-setup: file 755 "falsetto"
11280 file-setup: file 755 "!false"
11284 export PATH=.:$PATH
11292 ! false; then echo foo; else echo bar; fi
11300 expected-stderr-pattern:
11305 Check that "set -u" matches (future) SUSv4 requirement
11311 if [[ -n $v ]]; then
11346 (mypid=$$; try mypid)
11348 ) 2>&1 | sed -e 's/^[^]]*]//' -e 's/^[^:]*: *//'
11349 exit ${PIPESTATUS[0]}
11353 y: parameter not set
11357 y: parameter not set
11361 2: parameter not set
11363 1: parameter not set
11371 !: parameter not set
11382 Testsuite for nameref (bound variables)
11397 set|grep ^ir2|sed 's/^/s1: /'
11398 typeset|grep ' ir2'|sed -e 's/^/s2: /' -e 's/nameref/typeset -n/'
11399 set -A blub -- e1 e2 e3
11400 typeset -n ind=blub
11401 typeset -n ir2=blub[2]
11402 echo !ind[1]: ${!ind[1]}
11404 echo ind[1]: ${ind[1]}
11424 Testsuite for nameref (bound variables)
11425 Functions, argument given directly, after local
11428 typeset bar=lokal baz=auch
11460 Advanced testsuite for bound variables (ksh93 fails this)
11462 typeset -n foo=bar[i]
11463 set -A bar -- b c a
11464 for i in 0 1 2 3; do
11475 Ensure we don't run in an infinite loop
11479 typeset -n foo=fnord fnord=foo
11489 expected-stderr-pattern:
11490 /fnord: expression recurses on parameter/
11492 name: better-parens-1a
11494 Check support for ((…)) and $((…)) vs (…) and $(…)
11496 if ( (echo fubar)|tr u x); then
11505 name: better-parens-1b
11507 Check support for ((…)) and $((…)) vs (…) and $(…)
11509 echo $( (echo fubar)|tr u x) $?
11513 name: better-parens-1c
11515 Check support for ((…)) and $((…)) vs (…) and $(…)
11517 x=$( (echo fubar)|tr u x); echo $x $?
11521 name: better-parens-2a
11523 Check support for ((…)) and $((…)) vs (…) and $(…)
11525 if ((echo fubar)|tr u x); then
11534 name: better-parens-2b
11536 Check support for ((…)) and $((…)) vs (…) and $(…)
11538 echo $((echo fubar)|tr u x) $?
11542 name: better-parens-2c
11544 Check support for ((…)) and $((…)) vs (…) and $(…)
11546 x=$((echo fubar)|tr u x); echo $x $?
11550 name: better-parens-3a
11552 Check support for ((…)) and $((…)) vs (…) and $(…)
11554 if ( (echo fubar)|(tr u x)); then
11563 name: better-parens-3b
11565 Check support for ((…)) and $((…)) vs (…) and $(…)
11567 echo $( (echo fubar)|(tr u x)) $?
11571 name: better-parens-3c
11573 Check support for ((…)) and $((…)) vs (…) and $(…)
11575 x=$( (echo fubar)|(tr u x)); echo $x $?
11579 name: better-parens-4a
11581 Check support for ((…)) and $((…)) vs (…) and $(…)
11583 if ((echo fubar)|(tr u x)); then
11592 name: better-parens-4b
11594 Check support for ((…)) and $((…)) vs (…) and $(…)
11596 echo $((echo fubar)|(tr u x)) $?
11600 name: better-parens-4c
11602 Check support for ((…)) and $((…)) vs (…) and $(…)
11604 x=$((echo fubar)|(tr u x)); echo $x $?
11610 Test what the echo builtin does (mksh)
11612 echo -n 'foo\x40bar'
11619 Test what the echo builtin does (POSIX)
11620 Note: this follows Debian Policy 10.4 which mandates
11621 that -n shall be treated as an option, not XSI which
11622 mandates it shall be treated as string but escapes
11625 test -n "$POSH_VERSION" || set -o posix
11626 echo -n 'foo\x40bar'
11631 name: echo-test-3-mnbsd
11633 Test what the echo builtin does, and test a compatibility flag.
11636 "$__progname" -c 'echo -n 1=\\x40$1; echo -e \\x2E' -- foo bar
11637 "$__progname" -o posix -c 'echo -n 2=\\x40$1; echo -e \\x2E' -- foo bar
11638 "$__progname" -o sh -c 'echo -n 3=\\x40$1; echo -e \\x2E' -- foo bar
11644 name: echo-test-3-normal
11646 Test what the echo builtin does, and test a compatibility flag.
11647 category: !mnbsdash
11649 "$__progname" -c 'echo -n 1=\\x40$1; echo -e \\x2E' -- foo bar
11650 "$__progname" -o posix -c 'echo -n 2=\\x40$1; echo -e \\x2E' -- foo bar
11651 "$__progname" -o sh -c 'echo -n 3=\\x40$1; echo -e \\x2E' -- foo bar
11657 name: utilities-getopts-1
11659 getopts sets OPTIND correctly for unparsed option
11662 while getopts :a optc; do
11663 echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
11667 OPTARG=, OPTIND=2, optc=a.
11668 OPTARG=, OPTIND=3, optc=a.
11669 OPTARG=x, OPTIND=4, optc=?.
11672 name: utilities-getopts-2
11677 while getopts a: optc; do
11678 echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
11682 OPTARG=Mary, OPTIND=3, optc=a.
11683 OPTARG=, OPTIND=4, optc=?.
11685 expected-stderr-pattern: /.*-x.*option/
11689 Check the new wcswidth feature
11693 print octets: ${#s} .
11694 print 8-bit width: ${%s} .
11696 print characters: ${#s} .
11697 print columns: ${%s} .
11700 print octets: ${#s} .
11701 print 8-bit width: ${%s} .
11703 print characters: ${#s} .
11704 print columns: ${%s} .
11717 Check some corner cases
11733 Check some corner cases
11736 expected-stderr-pattern:
11742 Check some corner cases
11745 expected-stderr-pattern:
11751 Check some corner cases
11754 expected-stderr-pattern:
11760 Check some corner cases
11769 Check proper return values for realpath
11770 category: os:mirbsd
11783 x=$(realpath "$wd/$1" 2>&1); y=$?
11784 print $((++i)) "?$1" =${x##*$wd/} !$y
11810 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
11815 3 ?dir/file =dir/file !0
11816 4 ?dir/nix =dir/nix !0
11818 6 ?file/ =file/: Not a directory !20
11819 7 ?file/file =file/file: Not a directory !20
11820 8 ?file/nix =file/nix: Not a directory !20
11823 11 ?nix/file =nix/file: No such file or directory !2
11824 12 ?nix/nix =nix/nix: No such file or directory !2
11827 15 ?lndir/file =dir/file !0
11828 16 ?lndir/nix =dir/nix !0
11829 17 ?lnfile =file !0
11830 18 ?lnfile/ =lnfile/: Not a directory !20
11831 19 ?lnfile/file =lnfile/file: Not a directory !20
11832 20 ?lnfile/nix =lnfile/nix: Not a directory !20
11835 23 ?lnnix/file =lnnix/file: No such file or directory !2
11836 24 ?lnnix/nix =lnnix/nix: No such file or directory !2
11837 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
11841 Ensure that exactly two leading slashes are not collapsed
11842 POSIX guarantees this exception, e.g. for UNC paths on Cygwin
11843 category: os:mirbsd
11853 realpath /usr///bin
11862 realpath //usr/include/../bin
11879 Crashed during March 2011, fixed on vernal equinōx ☺
11880 category: os:mirbsd,os:openbsd
11882 export MALLOC_OPTIONS=FGJPRSX
11883 "$__progname" -c 'x=$(tr z r <<<baz); echo $x'
11889 Check test - bug#465250
11891 test \( ! -e \) ; echo $?
11897 Check test - bug#465250
11899 test \( -e \) ; echo $?
11905 Check test - bug#465250
11907 test ! -e ; echo $?
11913 Check test - bug#465250
11921 Check that zsh case variants work
11955 Check that case end tokens are not mixed up (Debian #220272)
11958 for value in 'x' '}' 'esac'; do
11959 print -n "$((++i))($value)bourne "
11964 print -n "$((++i))($value)korn "
11978 name: command-shift
11980 Check that 'command shift' works
11983 echo "before 0='$0' 1='$1' 2='$2'"
11985 echo "after 0='$0' 1='$1' 2='$2'"
11988 echo "before 0='$0' 1='$1' 2='$2'"
11990 echo "after 0='$0' 1='$1' 2='$2'"
11992 echo = without command
11994 echo = with command
11999 before 0='snc' 1='一' 2='二'
12000 after 0='snc' 1='二' 2=''
12002 before 0='swc' 1='一' 2='二'
12003 after 0='swc' 1='二' 2=''
12008 Check that the compiler did not optimise-break them
12009 (lex.c has got a similar one in SHEREDELIM)
12014 while (( ++i < 256 )); do
12017 s+=$'\xC2\xA0\xE2\x82\xAC\xEF\xBF\xBD\xEF\xBF\xBE\xEF\xBF\xBF\xF0\x90\x80\x80.'
12020 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.'
12022 name: stateptr-underflow
12024 This check overflows an Xrestpos stored in a short in R40
12027 function Lb64decode {
12028 [[ -o utf8-mode ]]; local u=$?
12031 [[ -n $s ]] || { s=$(cat;print x); s=${s%x}; }
12032 local -i i=0 n=${#s} p=0 v x
12035 while (( i < n )); do
12039 ([A-Z]) (( v = 1#$c - 65 )) ;;
12040 ([a-z]) (( v = 1#$c - 71 )) ;;
12041 ([0-9]) (( v = 1#$c + 4 )) ;;
12046 (( x = (x << 6) | v ))
12049 (1) (( o = (x >> 4) & 255 )) ;;
12050 (2) (( o = (x >> 2) & 255 )) ;;
12051 (3) (( o = x & 255 ))
12063 while (( ++i < 12120 )); do
12066 Lb64decode $s >/dev/null
12070 Check that "set -x" doesn't redirect too quickly
12072 print '#!'"$__progname" >bash
12074 echo 'GNU bash, version 2.05b.0(1)-release (i386-ecce-mirbsd10)
12075 Copyright (C) 2002 Free Software Foundation, Inc.'
12078 "$__progname" -xc 'foo=$(./bash --version 2>&1 | head -1); echo "=$foo="'
12080 =GNU bash, version 2.05b.0(1)-release (i386-ecce-mirbsd10)=
12081 expected-stderr-pattern:
12086 Check that "set -x" is off during PS4 expansion
12093 PS4='[(p:$-)$(f)] '
12095 set -x -o inherit-xtrace
12104 [(p:sh)(f1:sh)(f2:sh)] print '(o1:shx)'
12105 [(p:sh)(f1:sh)(f2:sh)] set +x
12107 name: fksh-flags-legacy
12109 Check that even FKSH functions share the shell flags
12111 [[ $KSH_VERSION = Version* ]] && set +B
12128 Check that !FKSH functions share the shell flags
12130 [[ $KSH_VERSION = Version* ]] && set +B