1 # $MirOS: src/bin/mksh/check.t,v 1.797 2017/08/29 13:38:29 tg Exp $
4 # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
5 # 2011, 2012, 2013, 2014, 2015, 2016, 2017
6 # mirabilos <m@mirbsd.org>
8 # Provided that these terms and disclaimer and all copyright notices
9 # are retained or reproduced in an accompanying document, permission
10 # is granted to deal in this work without restriction, including un‐
11 # limited rights to use, publicly perform, distribute, sell, modify,
12 # merge, give away, or sublicence.
14 # This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
15 # the utmost extent permitted by applicable law, neither express nor
16 # implied; without malicious intent or gross negligence. In no event
17 # may a licensor, author or contributor be held liable for indirect,
18 # direct, other damage, loss, or other issues arising in any way out
19 # of dealing in the work, even if advised of the possibility of such
20 # damage or existence of a defect, except proven that it results out
21 # of said person’s immediate fault when using the work as intended.
23 # You may also want to test IFS with the script at
24 # http://www.research.att.com/~gsf/public/ifs.sh
27 # http://svnweb.freebsd.org/base/head/bin/test/tests/legacy_test.sh?view=co&content-type=text%2Fplain
29 # Integrated testsuites from:
30 # (2013/12/02 20:39:44) http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date
33 @(#)MIRBSD KSH R56 2017/08/29
35 Check base version of full shell
37 echo ${KSH_VERSION%%' +'*}
39 category: !shell:legacy-yes
42 @(#)LEGACY KSH R56 2017/08/29
44 Check base version of legacy shell
46 echo ${KSH_VERSION%%' +'*}
47 name: KSH_VERSION-legacy
48 category: !shell:legacy-no
50 name: KSH_VERSION-ascii
52 Check that the shell version tag does not include EBCDIC
53 category: !shell:ebcdic-yes
55 for x in $KSH_VERSION; do
56 [[ $x = '+EBCDIC' ]] && exit 1
60 name: KSH_VERSION-ebcdic
62 Check that the shell version tag includes EBCDIC
63 category: !shell:ebcdic-no
65 for x in $KSH_VERSION; do
66 [[ $x = '+EBCDIC' ]] && exit 0
70 name: KSH_VERSION-binmode
72 Check that the shell version tag does not include TEXTMODE
73 category: !shell:textmode-yes
75 for x in $KSH_VERSION; do
76 [[ $x = '+TEXTMODE' ]] && exit 1
80 name: KSH_VERSION-textmode
82 Check that the shell version tag includes TEXTMODE
83 category: !shell:textmode-no
85 for x in $KSH_VERSION; do
86 [[ $x = '+TEXTMODE' ]] && exit 0
92 Regression test self-testing
100 Regression test self-testing
109 Regression test self-testing
110 env-setup: !ENV=fnord!
118 Ensure that the test run directory (default /tmp but can be changed
119 with check.pl flag -T or test.sh $TMPDIR) is not mounted noexec, as
120 we execute scripts from the scratch directory during several tests.
122 print '#!'"$__progname"'\necho tf' >lq
130 Just output the environment variables set (always fails)
135 name: selftest-direct-builtin-call
137 Check that direct builtin calls work
139 ln -s "$__progname" cat || cp "$__progname" cat
140 ln -s "$__progname" echo || cp "$__progname" echo
141 ./echo -c 'echo foo' | ./cat -u
145 name: selftest-pathsep-unix
147 Check that $PATHSEP is set correctly.
150 PATHSEP=.; export PATHSEP
151 "$__progname" -c 'print -r -- $PATHSEP'
155 name: selftest-pathsep-dospath
157 Check that $PATHSEP is set correctly.
160 PATHSEP=.; export PATHSEP
161 "$__progname" -c 'print -r -- $PATHSEP'
167 Check that recursion is detected/avoided in aliases.
172 expected-stderr-pattern:
173 /fooBar.*not found.*/
177 Check that recursion is detected/avoided in aliases.
184 expected-stderr-pattern:
185 /fooBar.*not found.*\n.*barFoo.*not found/
189 Check that recursion is detected/avoided in aliases.
203 Check that alias expansion isn't done on keywords (in keyword
208 while false; do echo hi ; done
215 Check that alias expansion done after alias with trailing space.
218 alias foo='bar stuff '
219 alias bar='Bar1 Bar2 '
228 Check that alias expansion done after alias with trailing space.
240 Check that alias expansion done after alias with trailing space
245 X Y in 'Y') echo is y ;; Z) echo is z ;; esac
251 Check that newlines in an alias don't cause the command to be lost.
271 Check that recursion is detected/avoided in aliases.
272 This check fails for slow machines or Cygwin, raise
273 the time-limit clause (e.g. to 7) if this occurs.
276 print '#!'"$__progname"'\necho tf' >lq
278 PATH=$PWD$PATHSEP$PATH
294 Check that recursion is detected/avoided in aliases.
295 Regression, introduced during an old bugfix.
297 alias foo='print hello '
298 alias bar='foo world'
305 Check that special argument handling still applies with escaped aliases
307 alias local1='\typeset'
308 alias local2='\\builtin typeset'
317 x=1 y=2; fooa 'bar - baz'
318 x=1 y=2; foob 'bar - baz'
325 Something weird from Martijn Dekker
328 x() { echo a; (echo b); x=$(echo c); }
330 alias OPEN='{' CLOSE='};'
331 { OPEN echo hi1; CLOSE }
332 var=`{ OPEN echo hi2; CLOSE }` && echo "$var"
333 var=$({ OPEN echo hi3; CLOSE }) && echo "$var"
346 Check that arithmetic expressions are compound constructs
348 { ! (( 0$(cat >&2) )) <<<1; } <<<2
354 Check that only one side of ternary operator is evaluated
359 echo $((1 ? 20 : (x+=2)))
361 echo $((0 ? (y+=2) : 30))
371 Check that assignments not done on non-evaluated side of ternary
377 echo $((1 ? 20 : (x+=2)))
379 echo $((0 ? (y+=2) : 30))
389 Check that assignments not done on non-evaluated side of ternary
390 operator and this construct is parsed correctly (Debian #445651)
400 Check that preun/postun not done on non-evaluated side of ternary
403 (( m = n = 0, 1 ? n++ : m++ ? 2 : 3 ))
405 m=0; echo $(( 0 ? ++m : 2 )); echo $m
406 m=0; echo $(( 0 ? m++ : 2 )); echo $m
414 name: arith-lazy-5-arr-n
415 description: Check lazy evaluation with side effects
417 a=0; echo "$((0&&b[a++],a))"
421 name: arith-lazy-5-arr-p
422 description: Check lazy evaluation with side effects
424 a=0; echo "$((0&&(b[a++]),a))"
428 name: arith-lazy-5-str-n
429 description: Check lazy evaluation with side effects
431 a=0 b=a++; ((0&&b)); echo $a
435 name: arith-lazy-5-str-p
436 description: Check lazy evaluation with side effects
438 a=0 b=a++; ((0&&(b))); echo $a
442 name: arith-lazy-5-tern-l-n
443 description: Check lazy evaluation with side effects
445 a=0; echo "$((0?b[a++]:999,a))"
449 name: arith-lazy-5-tern-l-p
450 description: Check lazy evaluation with side effects
452 a=0; echo "$((0?(b[a++]):999,a))"
456 name: arith-lazy-5-tern-r-n
457 description: Check lazy evaluation with side effects
459 a=0; echo "$((1?999:b[a++],a))"
463 name: arith-lazy-5-tern-r-p
464 description: Check lazy evaluation with side effects
466 a=0; echo "$((1?999:(b[a++]),a))"
470 name: arith-ternary-prec-1
472 Check precedence of ternary operator vs assignment
476 expected-exit: e != 0
477 expected-stderr-pattern:
478 /.*:.*1 \? 20 : x\+=2.*lvalue.*\n$/
480 name: arith-ternary-prec-2
482 Check precedence of ternary operator vs assignment
485 echo $((0 ? x+=2 : 20))
491 Prove arithmetic expressions with embedded parameter
492 substitutions cannot be parsed ahead of time
496 print 2 $((2 * $a)) .
501 name: arith-div-assoc-1
503 Check associativity of division operator
509 name: arith-div-byzero
511 Check division by zero errors out
517 expected-stderr-pattern:
520 name: arith-div-intmin-by-minusone
522 Check division overflow wraps around silently
525 echo signed:$((-2147483648 / -1))r$((-2147483648 % -1)).
526 echo unsigned:$((# -2147483648 / -1))r$((# -2147483648 % -1)).
528 signed:-2147483648r0.
529 unsigned:0r2147483648.
531 name: arith-div-intmin-by-minusone-64
533 Check division overflow wraps around silently
536 echo signed:$((-9223372036854775808 / -1))r$((-9223372036854775808 % -1)).
537 echo unsigned:$((# -9223372036854775808 / -1))r$((# -9223372036854775808 % -1)).
539 signed:-9223372036854775808r0.
540 unsigned:0r9223372036854775808.
542 name: arith-assop-assoc-1
544 Check associativity of assignment-operator operator
546 typeset -i i=1 j=2 k=3
547 echo $((i += j += k))
553 name: arith-mandatory
555 Passing of this test is *mandatory* for a valid mksh executable!
556 category: shell:legacy-no
561 print -r -- $((x++)):$sari=$uari. #0
563 print -r -- $((x++)):$sari=$uari. #1
564 sari=2147483647 uari=2147483647
565 print -r -- $((x++)):$sari=$uari. #2
567 print -r -- $((x++)):$sari=$uari. #3
569 let 'sari *= 2' 'uari *= 2'
571 print -r -- $((x++)):$sari=$uari. #4
573 print -r -- $((x++)):$sari=$uari. #5
574 sari=-2147483648 uari=-2147483648
575 print -r -- $((x++)):$sari=$uari. #6
577 print -r -- $((x++)):$sari=$uari. #7
579 ((# uari = -5 >> 1 ))
580 print -r -- $((x++)):$sari=$uari. #8
583 print -r -- $((x++)):$sari=$uari. #9
587 2:2147483647=2147483647.
588 3:-2147483648=2147483648.
591 6:-2147483648=2147483648.
592 7:2147483647=2147483647.
596 name: arith-unsigned-1
598 Check if unsigned arithmetics work
602 echo x1 $((-1)) $((#-1))
606 vs=4123456789; vu=4123456789
608 (( vs %= 2147483647 ))
609 (( vu %= 2147483647 ))
611 vs=4123456789; vu=4123456789
612 (( # vs %= 2147483647 ))
613 (( # vu %= 2147483647 ))
615 # make sure the calculation does not change unsigned flag
616 vs=4123456789; vu=4123456789
619 echo x6 $((# vs % 2147483647)) $((# vu % 2147483647))
624 echo x7 ${va[#4123456789%2147483647]}
625 # make sure multiple calculations don't interfere with each other
626 let '# mca = -4 % -2' ' mcb = -4 % -2'
630 x2 -171510507 4123456789
631 x3 -171510507 4123456789
632 x4 1975973142 1975973142
633 x5 -171510507 4123456789
634 x6 1975973142 1975973142
638 name: arith-limit32-1
640 Check if arithmetics are 32 bit
644 echo x1 $((-1)) $((#-1))
648 vs=2147483647; vu=2147483647
652 vs=4294967295; vu=4294967295
660 x2 2147483647 2147483647
661 x3 -2147483648 2147483648
666 name: arith-limit64-1
668 Check if arithmetics are 64 bit
672 echo x1 $((-1)) $((#-1))
676 vs=9223372036854775807; vu=9223372036854775807
680 vs=18446744073709551615; vu=18446744073709551615
687 x1 -1 18446744073709551615
688 x2 9223372036854775807 9223372036854775807
689 x3 -9223372036854775808 9223372036854775808
690 x4 -1 18446744073709551615
696 Check that \newline is not collapsed after #
706 Check that \newline is not collapsed inside single quotes
718 Check that \newline is not collapsed inside single quotes
730 Check interaction of aliases, single quotes and here-documents
731 with backslash-newline
732 (don't know what POSIX has to say about this)
754 Check what happens with backslash at end of input
755 (the old Bourne shell trashes them; so do we)
764 # Places \newline should be collapsed
768 Check that \newline is collapsed before, in the middle of, and
780 Check that \newline is collapsed in $ sequences
804 Check that \newline is collapsed in $(..) and `...` sequences
829 Check that \newline is collapsed in $((..)) sequences
840 echo $((1+2+3+4+5+6)\
851 Check that \newline is collapsed in double quoted strings
866 Check that \newline is collapsed in here document delimiters
867 (ksh93 fails second part of this)
889 Check that \newline is collapsed in double-quoted here-document
908 Check that \newline is collapsed in various 2+ character tokens
953 Check that \ at the end of an alias is collapsed when followed
955 (don't know what POSIX has to say about this)
965 Check that \newline in a keyword is collapsed
975 # Places \newline should be collapsed (ksh extensions)
979 Check that \newline is collapsed in extended globbing
996 Check that \newline is collapsed in ((...)) expressions
1011 See if break breaks out of loops
1013 for i in a b c; do echo $i; break; echo bad-$i; done
1015 for i in a b c; do echo $i; break 1; echo bad-$i; done
1026 for i in a b c; do echo $i; eval break; echo bad-$i; done
1045 See if break breaks out of nested loops
1062 What if break used outside of any loops
1063 (ksh88,ksh93 don't print error messages here)
1066 expected-stderr-pattern:
1071 What if break N used when only N-1 loops
1072 (ksh88,ksh93 don't print error messages here)
1074 for i in a b c; do echo $i; break 2; echo bad-$i; done
1079 expected-stderr-pattern:
1084 Error if break argument isn't a number
1086 for i in a b c; do echo $i; break abc; echo more-$i; done
1090 expected-exit: e != 0
1091 expected-stderr-pattern:
1096 See if continue continues loops
1098 for i in a b c; do echo $i; continue; echo bad-$i ; done
1100 for i in a b c; do echo $i; continue 1; echo bad-$i; done
1111 for i in a b c; do echo $i; eval continue; echo bad-$i ; done
1142 See if continue breaks out of nested loops
1161 What if continue used outside of any loops
1162 (ksh88,ksh93 don't print error messages here)
1165 expected-stderr-pattern:
1170 What if continue N used when only N-1 loops
1171 (ksh88,ksh93 don't print error messages here)
1173 for i in a b c; do echo $i; continue 2; echo bad-$i; done
1180 expected-stderr-pattern:
1185 Error if continue argument isn't a number
1187 for i in a b c; do echo $i; continue abc; echo more-$i; done
1191 expected-exit: e != 0
1192 expected-stderr-pattern:
1197 Test someone's CD history package (uses arrays)
1199 # go to known place before doing anything
1213 if [ "$CDHISTFILE" -a -r "$CDHISTFILE" ] # if directory history exists
1217 while read -r t # read directory history file
1223 if [ "${CDHIST[0]}" != "$PWD" -a "$PWD" != "" ]
1225 _cdins # insert $PWD into cd history
1228 cdlen=${#CDHIST[*]} # number of elements in history
1232 if [ "$OLDPWD" = "" ] && ((cdlen>1))
1234 'print' ${CDHIST[1]}
1242 -l) # print directory list
1245 while (((i=i-1)>=0))
1248 'print' "$num ${CDHIST[i]}"
1252 -[0-9]|-[0-9][0-9]) # cd to dir in list
1253 if (((i=${1#-})<cdlen))
1255 'print' ${CDHIST[i]}
1263 -*) # cd to matched dir in list
1268 case ${CDHIST[i]} in
1270 'print' ${CDHIST[i]}
1290 _cdins # insert $PWD into cd history
1292 if [ "$CDHISTFILE" ]
1294 cdlen=${#CDHIST[*]} # number of elements in history
1299 'print' -r ${CDHIST[i]} # update directory history
1305 function _cdins # insert $PWD into cd history
1306 { # meant to be called only by _cd
1310 while ((i<${#CDHIST[*]})) # see if dir is already in list
1312 if [ "${CDHIST[$i]}" = "$PWD" ]
1319 if ((i>22)) # limit max size of list
1324 while (((i=i-1)>=0)) # bump old dirs in list
1326 CDHIST[i+1]=${CDHIST[i]}
1329 CDHIST[0]=$PWD # insert new directory in list
1357 Check package for cd -Pe
1359 # the mv command fails on Cygwin and z/OS
1360 # Hurd aborts the testsuite (permission denied)
1361 # QNX does not find subdir to cd into
1362 category: !os:cygwin,!os:gnu,!os:msys,!os:nto,!os:os390,!nosymlink
1363 file-setup: file 644 "x"
1364 mkdir noread noread/target noread/target/subdir
1371 echo 1=$?,${PWD#$bwd/}
1372 epwd=$($TSHELL -c pwd 2>/dev/null)
1373 # This unexpectedly succeeds on GNU/Linux and MidnightBSD
1376 mv ../../noread ../../renamed
1378 echo 2=$?,${PWD#$bwd/}
1380 chmod 755 noread renamed 2>/dev/null
1381 rm -rf noread link renamed
1383 export TSHELL="$__progname"
1390 2=0,noread/target/subdir
1394 2=1,noread/target/subdir
1398 Check that prompt not printed when processing ENV
1399 env-setup: !ENV=./foo!
1400 file-setup: file 644 "foo"
1415 Check that weird ${foo+bar} constructs are parsed correctly
1417 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
1418 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "<$x> "; done' >pfs
1420 (echo 1 ${IFS+'}'z}) 2>/dev/null || echo failed in 1
1421 (echo 2 "${IFS+'}'z}") 2>/dev/null || echo failed in 2
1422 (echo 3 "foo ${IFS+'bar} baz") 2>/dev/null || echo failed in 3
1423 (echo -n '4 '; ./pfn "foo ${IFS+"b c"} baz") 2>/dev/null || echo failed in 4
1424 (echo -n '5 '; ./pfn "foo ${IFS+b c} baz") 2>/dev/null || echo failed in 5
1425 (echo 6 ${IFS+"}"z}) 2>/dev/null || echo failed in 6
1426 (echo 7 "${IFS+"}"z}") 2>/dev/null || echo failed in 7
1427 (echo 8 "${IFS+\"}\"z}") 2>/dev/null || echo failed in 8
1428 (echo 9 "${IFS+\"\}\"z}") 2>/dev/null || echo failed in 9
1429 (echo 10 foo ${IFS+'bar} baz'}) 2>/dev/null || echo failed in 10
1430 (echo 11 "$(echo "${IFS+'}'z}")") 2>/dev/null || echo failed in 11
1431 (echo 12 "$(echo ${IFS+'}'z})") 2>/dev/null || echo failed in 12
1432 (echo 13 ${IFS+\}z}) 2>/dev/null || echo failed in 13
1433 (echo 14 "${IFS+\}z}") 2>/dev/null || echo failed in 14
1434 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
1435 l=t; (echo 16 ${IFS+h`echo -n i ${IFS+$l}h`ere}) 2>/dev/null || echo failed in 16
1436 l=t; (echo 17 ${IFS+h$(echo -n i ${IFS+$l}h)ere}) 2>/dev/null || echo failed in 17
1437 l=t; (echo 18 "${IFS+h`echo -n i ${IFS+$l}h`ere}") 2>/dev/null || echo failed in 18
1438 l=t; (echo 19 "${IFS+h$(echo -n i ${IFS+$l}h)ere}") 2>/dev/null || echo failed in 19
1439 l=t; (echo 20 ${IFS+h`echo -n i "${IFS+$l}"h`ere}) 2>/dev/null || echo failed in 20
1440 l=t; (echo 21 ${IFS+h$(echo -n i "${IFS+$l}"h)ere}) 2>/dev/null || echo failed in 21
1441 l=t; (echo 22 "${IFS+h`echo -n i "${IFS+$l}"h`ere}") 2>/dev/null || echo failed in 22
1442 l=t; (echo 23 "${IFS+h$(echo -n i "${IFS+$l}"h)ere}") 2>/dev/null || echo failed in 23
1443 key=value; (echo -n '24 '; ./pfn "${IFS+'$key'}") 2>/dev/null || echo failed in 24
1444 key=value; (echo -n '25 '; ./pfn "${IFS+"'$key'"}") 2>/dev/null || echo failed in 25 # ksh93: “'$key'”
1445 key=value; (echo -n '26 '; ./pfn ${IFS+'$key'}) 2>/dev/null || echo failed in 26
1446 key=value; (echo -n '27 '; ./pfn ${IFS+"'$key'"}) 2>/dev/null || echo failed in 27
1447 (echo -n '28 '; ./pfn "${IFS+"'"x ~ x'}'x"'}"x}" #') 2>/dev/null || echo failed in 28
1448 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
1449 (echo -n '30 '; ./pfs ${IFS+foo 'b\
1450 ar' baz}; echo .) 2>/dev/null || (echo failed in 30; echo failed in 31)
1451 (echo -n '32 '; ./pfs ${IFS+foo "b\
1452 ar" baz}; echo .) 2>/dev/null || echo failed in 32
1453 (echo -n '33 '; ./pfs "${IFS+foo 'b\
1454 ar' baz}"; echo .) 2>/dev/null || echo failed in 33
1455 (echo -n '34 '; ./pfs "${IFS+foo "b\
1456 ar" baz}"; echo .) 2>/dev/null || echo failed in 34
1457 (echo -n '35 '; ./pfs ${v=a\ b} x ${v=c\ d}; echo .) 2>/dev/null || echo failed in 35
1458 (echo -n '36 '; ./pfs "${v=a\ b}" x "${v=c\ d}"; echo .) 2>/dev/null || echo failed in 36
1459 (echo -n '37 '; ./pfs ${v-a\ b} x ${v-c\ d}; echo .) 2>/dev/null || echo failed in 37
1460 (echo 38 ${IFS+x'a'y} / "${IFS+x'a'y}" .) 2>/dev/null || echo failed in 38
1461 foo="x'a'y"; (echo 39 ${foo%*'a'*} / "${foo%*'a'*}" .) 2>/dev/null || echo failed in 39
1462 foo="a b c"; (echo -n '40 '; ./pfs "${foo#a}"; echo .) 2>/dev/null || echo failed in 40
1463 (foo() { return 100; }; foo; echo 41 ${#+${#:+${#?}}\ \}\}\}}) 2>/dev/null || echo failed in 41
1479 15 <foo abx{ {{{}b c d{} bar> <}> <baz> .
1493 29 <foo> <abx{ {{> <{}b> <c> <d{}> <bar> <}> <baz> .
1496 32 <foo> <bar> <baz> .
1497 33 <foo 'bar' baz> .
1499 35 <a> <b> <x> <a> <b> .
1500 36 <a\ b> <x> <a\ b> .
1501 37 <a b> <x> <c d> .
1507 name: expand-unglob-dblq
1509 Check that regular "${foo+bar}" constructs are parsed correctly
1514 test x"$v" = x"-" && unset v
1515 (echo "$1 plus norm foo ${v+'bar'} baz")
1516 (echo "$1 dash norm foo ${v-'bar'} baz")
1517 (echo "$1 eqal norm foo ${v='bar'} baz")
1518 (echo "$1 qstn norm foo ${v?'bar'} baz") 2>/dev/null || \
1519 echo "$1 qstn norm -> error"
1520 (echo "$1 PLUS norm foo ${v:+'bar'} baz")
1521 (echo "$1 DASH norm foo ${v:-'bar'} baz")
1522 (echo "$1 EQAL norm foo ${v:='bar'} baz")
1523 (echo "$1 QSTN norm foo ${v:?'bar'} baz") 2>/dev/null || \
1524 echo "$1 QSTN norm -> error"
1528 test x"$v" = x"-" && unset v
1529 (echo "$1 plus parn foo ${v+(bar)} baz")
1530 (echo "$1 dash parn foo ${v-(bar)} baz")
1531 (echo "$1 eqal parn foo ${v=(bar)} baz")
1532 (echo "$1 qstn parn foo ${v?(bar)} baz") 2>/dev/null || \
1533 echo "$1 qstn parn -> error"
1534 (echo "$1 PLUS parn foo ${v:+(bar)} baz")
1535 (echo "$1 DASH parn foo ${v:-(bar)} baz")
1536 (echo "$1 EQAL parn foo ${v:=(bar)} baz")
1537 (echo "$1 QSTN parn foo ${v:?(bar)} baz") 2>/dev/null || \
1538 echo "$1 QSTN parn -> error"
1542 test x"$v" = x"-" && unset v
1543 (echo "$1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz")
1544 (echo "$1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz")
1545 (echo "$1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz")
1546 (echo "$1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz") 2>/dev/null || \
1547 echo "$1 qstn brac -> error"
1548 (echo "$1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz")
1549 (echo "$1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz")
1550 (echo "$1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz")
1551 (echo "$1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz") 2>/dev/null || \
1552 echo "$1 QSTN brac -> error"
1554 : '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' '}}}'
1566 1 dash norm foo 'bar' baz
1567 1 eqal norm foo 'bar' baz
1568 1 qstn norm -> error
1570 1 DASH norm foo 'bar' baz
1571 1 EQAL norm foo 'bar' baz
1572 1 QSTN norm -> error
1573 2 plus norm foo 'bar' baz
1578 2 DASH norm foo 'bar' baz
1579 2 EQAL norm foo 'bar' baz
1580 2 QSTN norm -> error
1581 3 plus norm foo 'bar' baz
1582 3 dash norm foo x baz
1583 3 eqal norm foo x baz
1584 3 qstn norm foo x baz
1585 3 PLUS norm foo 'bar' baz
1586 3 DASH norm foo x baz
1587 3 EQAL norm foo x baz
1588 3 QSTN norm foo x baz
1590 4 dash parn foo (bar) baz
1591 4 eqal parn foo (bar) baz
1592 4 qstn parn -> error
1594 4 DASH parn foo (bar) baz
1595 4 EQAL parn foo (bar) baz
1596 4 QSTN parn -> error
1597 5 plus parn foo (bar) baz
1602 5 DASH parn foo (bar) baz
1603 5 EQAL parn foo (bar) baz
1604 5 QSTN parn -> error
1605 6 plus parn foo (bar) baz
1606 6 dash parn foo x baz
1607 6 eqal parn foo x baz
1608 6 qstn parn foo x baz
1609 6 PLUS parn foo (bar) baz
1610 6 DASH parn foo x baz
1611 6 EQAL parn foo x baz
1612 6 QSTN parn foo x baz
1613 7 plus brac foo c } baz
1614 7 dash brac foo ax{{{}b c d{} baz
1615 7 eqal brac foo ax{{{}b c ax{{{}b} baz
1616 7 qstn brac -> error
1617 7 PLUS brac foo c } baz
1618 7 DASH brac foo ax{{{}b c d{} baz
1619 7 EQAL brac foo ax{{{}b c ax{{{}b} baz
1620 7 QSTN brac -> error
1621 8 plus brac foo ax{{{}b c d{} baz
1622 8 dash brac foo c } baz
1623 8 eqal brac foo c } baz
1624 8 qstn brac foo c } baz
1625 8 PLUS brac foo c } baz
1626 8 DASH brac foo ax{{{}b c d{} baz
1627 8 EQAL brac foo ax{{{}b c ax{{{}b} baz
1628 8 QSTN brac -> error
1629 9 plus brac foo ax{{{}b c d{} baz
1630 9 dash brac foo x c x} baz
1631 9 eqal brac foo x c x} baz
1632 9 qstn brac foo x c x} baz
1633 9 PLUS brac foo ax{{{}b c d{} baz
1634 9 DASH brac foo x c x} baz
1635 9 EQAL brac foo x c x} baz
1636 9 QSTN brac foo x c x} baz
1638 name: expand-unglob-unq
1640 Check that regular ${foo+bar} constructs are parsed correctly
1645 test x"$v" = x"-" && unset v
1646 (echo $1 plus norm foo ${v+'bar'} baz)
1647 (echo $1 dash norm foo ${v-'bar'} baz)
1648 (echo $1 eqal norm foo ${v='bar'} baz)
1649 (echo $1 qstn norm foo ${v?'bar'} baz) 2>/dev/null || \
1650 echo "$1 qstn norm -> error"
1651 (echo $1 PLUS norm foo ${v:+'bar'} baz)
1652 (echo $1 DASH norm foo ${v:-'bar'} baz)
1653 (echo $1 EQAL norm foo ${v:='bar'} baz)
1654 (echo $1 QSTN norm foo ${v:?'bar'} baz) 2>/dev/null || \
1655 echo "$1 QSTN norm -> error"
1659 test x"$v" = x"-" && unset v
1660 (echo $1 plus parn foo ${v+\(bar')'} baz)
1661 (echo $1 dash parn foo ${v-\(bar')'} baz)
1662 (echo $1 eqal parn foo ${v=\(bar')'} baz)
1663 (echo $1 qstn parn foo ${v?\(bar')'} baz) 2>/dev/null || \
1664 echo "$1 qstn parn -> error"
1665 (echo $1 PLUS parn foo ${v:+\(bar')'} baz)
1666 (echo $1 DASH parn foo ${v:-\(bar')'} baz)
1667 (echo $1 EQAL parn foo ${v:=\(bar')'} baz)
1668 (echo $1 QSTN parn foo ${v:?\(bar')'} baz) 2>/dev/null || \
1669 echo "$1 QSTN parn -> error"
1673 test x"$v" = x"-" && unset v
1674 (echo $1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz)
1675 (echo $1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz)
1676 (echo $1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz)
1677 (echo $1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz) 2>/dev/null || \
1678 echo "$1 qstn brac -> error"
1679 (echo $1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz)
1680 (echo $1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz)
1681 (echo $1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz)
1682 (echo $1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz) 2>/dev/null || \
1683 echo "$1 QSTN brac -> error"
1685 : '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' '}}}'
1697 1 dash norm foo bar baz
1698 1 eqal norm foo bar baz
1699 1 qstn norm -> error
1701 1 DASH norm foo bar baz
1702 1 EQAL norm foo bar baz
1703 1 QSTN norm -> error
1704 2 plus norm foo bar baz
1709 2 DASH norm foo bar baz
1710 2 EQAL norm foo bar baz
1711 2 QSTN norm -> error
1712 3 plus norm foo bar baz
1713 3 dash norm foo x baz
1714 3 eqal norm foo x baz
1715 3 qstn norm foo x baz
1716 3 PLUS norm foo bar baz
1717 3 DASH norm foo x baz
1718 3 EQAL norm foo x baz
1719 3 QSTN norm foo x baz
1721 4 dash parn foo (bar) baz
1722 4 eqal parn foo (bar) baz
1723 4 qstn parn -> error
1725 4 DASH parn foo (bar) baz
1726 4 EQAL parn foo (bar) baz
1727 4 QSTN parn -> error
1728 5 plus parn foo (bar) baz
1733 5 DASH parn foo (bar) baz
1734 5 EQAL parn foo (bar) baz
1735 5 QSTN parn -> error
1736 6 plus parn foo (bar) baz
1737 6 dash parn foo x baz
1738 6 eqal parn foo x baz
1739 6 qstn parn foo x baz
1740 6 PLUS parn foo (bar) baz
1741 6 DASH parn foo x baz
1742 6 EQAL parn foo x baz
1743 6 QSTN parn foo x baz
1744 7 plus brac foo c } baz
1745 7 dash brac foo ax{{{}b c d{} baz
1746 7 eqal brac foo ax{{{}b c ax{{{}b} baz
1747 7 qstn brac -> error
1748 7 PLUS brac foo c } baz
1749 7 DASH brac foo ax{{{}b c d{} baz
1750 7 EQAL brac foo ax{{{}b c ax{{{}b} baz
1751 7 QSTN brac -> error
1752 8 plus brac foo ax{{{}b c d{} baz
1753 8 dash brac foo c } baz
1754 8 eqal brac foo c } baz
1755 8 qstn brac foo c } baz
1756 8 PLUS brac foo c } baz
1757 8 DASH brac foo ax{{{}b c d{} baz
1758 8 EQAL brac foo ax{{{}b c ax{{{}b} baz
1759 8 QSTN brac -> error
1760 9 plus brac foo ax{{{}b c d{} baz
1761 9 dash brac foo x c x} baz
1762 9 eqal brac foo x c x} baz
1763 9 qstn brac foo x c x} baz
1764 9 PLUS brac foo ax{{{}b c d{} baz
1765 9 DASH brac foo x c x} baz
1766 9 EQAL brac foo x c x} baz
1767 9 QSTN brac foo x c x} baz
1769 name: expand-threecolons-dblq
1771 Check for a particular thing that used to segfault
1774 echo "${TEST:1:2:3}"
1775 echo $? but still living
1776 expected-stderr-pattern:
1780 name: expand-threecolons-unq
1782 Check for a particular thing that used to not error out
1786 echo $? but still living
1787 expected-stderr-pattern:
1791 name: expand-weird-1
1793 Check corner cases of trim expansion vs. $# vs. ${#var} vs. ${var?}
1795 set 1 2 3 4 5 6 7 8 9 10 11
1796 echo ${#} # value of $#
1797 echo ${##} # length of $#
1798 echo ${##1} # $# trimmed 1
1799 set 1 2 3 4 5 6 7 8 9 10 11 12
1813 name: expand-weird-2
1815 Check more substitution and extension corner cases
1817 :& set -C; pid=$$; sub=$!; flg=$-; set -- i; exec 3>x.tmp
1818 #echo "D: !=$! #=$# \$=$$ -=$- ?=$?"
1819 echo >&3 3 = s^${!-word} , ${#-word} , p^${$-word} , f^${--word} , ${?-word} .
1820 echo >&3 4 = ${!+word} , ${#+word} , ${$+word} , ${-+word} , ${?+word} .
1821 echo >&3 5 = s^${!=word} , ${#=word} , p^${$=word} , f^${-=word} , ${?=word} .
1822 echo >&3 6 = s^${!?word} , ${#?word} , p^${$?word} , f^${-?word} , ${??word} .
1823 echo >&3 7 = sl^${#!} , ${##} , pl^${#$} , fl^${#-} , ${#?} .
1824 echo >&3 8 = sw^${%!} , ${%#} , pw^${%$} , fw^${%-} , ${%?} .
1825 echo >&3 9 = ${!!} , s^${!#} , ${!$} , s^${!-} , s^${!?} .
1826 echo >&3 10 = s^${!#pattern} , ${##pattern} , p^${$#pattern} , f^${-#pattern} , ${?#pattern} .
1827 echo >&3 11 = s^${!%pattern} , ${#%pattern} , p^${$%pattern} , f^${-%pattern} , ${?%pattern} .
1828 echo >&3 12 = $# : ${##} , ${##1} .
1830 echo >&3 14 = $# : ${##} , ${##1} .
1832 echo >&3 16 = $# : ${##} , ${##1} .
1833 set -- 1 2 3 4 5 6 7 8 9 a b c d e
1834 echo >&3 18 = $# : ${##} , ${##1} .
1837 -e "s/ pl^${#pid} / PID /g" -e "s/ sl^${#sub} / SUB /g" -e "s/ fl^${#flg} / FLG /g" \
1838 -e "s/ pw^${%pid} / PID /g" -e "s/ sw^${%sub} / SUB /g" -e "s/ fw^${%flg} / FLG /g" \
1839 -e "s/ p^$pid / PID /g" -e "s/ s^$sub / SUB /g" -e "s/ f^$flg / FLG /g"
1841 3 = SUB , 1 , PID , FLG , 0 .
1842 4 = word , word , word , word , word .
1843 5 = SUB , 1 , PID , FLG , 0 .
1844 6 = SUB , 1 , PID , FLG , 0 .
1845 7 = SUB , 1 , PID , FLG , 1 .
1846 8 = SUB , 1 , PID , FLG , 1 .
1847 9 = ! , SUB , $ , SUB , SUB .
1848 10 = SUB , 1 , PID , FLG , 0 .
1849 11 = SUB , 1 , PID , FLG , 0 .
1855 name: expand-weird-3
1857 Check that trimming works with positional parameters (Debian #48453)
1868 name: expand-weird-4
1870 Check that tilde expansion is enabled in ${x#~}
1871 and cases that are modelled after it (${x/~/~})
1875 echo "<${a#~}> <${a#\~}> <${b:-~}> <${b:-\~}> <${c:=~}><$c> <${a/~}> <${a/x/~}> <${a/x/\~}>"
1877 <~/x> </x> <~> <\~> <~><~> <~/x> <~//etc> <~/~>
1881 Check corner case of ${!?} with ! being var vs. op
1885 expected-stderr-pattern: /not set/
1889 Check corner case of ${!var} vs. ${var op} with var=!
1895 # get an at least three-digit bg pid
1899 if [[ $x != +([0-9]) ]]; then
1900 echo >&2 "cannot test, pid '$x' not numeric"
1901 echo >&2 report this with as many details as possible
1904 [[ $x = [0-9][0-9][0-9]* ]] && break
1907 t=$!; [[ $t = $x ]]; echo 5 $? .
1908 t=${!#}; [[ $t = $x ]]; echo 6 $? .
1909 t=${!#[0-9]}; [[ $t = $y ]]; echo 7 $? .
1910 t=${!-foo}; [[ $t = $x ]]; echo 8 $? .
1911 t=${!?bar}; [[ $t = $x ]]; echo 9 $? .
1923 name: expand-number-1
1925 Check that positional arguments do not overflow
1927 echo "1 ${12345678901234567890} ."
1931 name: expand-slashes-1
1933 Check that side effects in substring replacement are handled correctly
1938 echo 1 ${foo//n$((n++))/[$((++i))]} .
1944 name: expand-slashes-2
1946 Check that side effects in substring replacement are handled correctly
1951 echo 1 ${foo@/n$((n++))/[$((++i))]} .
1957 name: expand-slashes-3
1959 Check that we can access the replaced string
1962 echo 1 ${foo@/n[12]/[$KSH_MATCH]} .
1964 1 [n1][n1][n1][n2]n3 .
1968 Check that globbing isn't done when glob has syntax error
1969 category: !os:cygwin,!os:msys,!os:os2
1970 file-setup: file 644 "@(a[b|)c]foo"
1978 Check that globbing isn't done when glob has syntax error
1979 (AT&T ksh fails this test)
1980 file-setup: file 644 "abcx"
1981 file-setup: file 644 "abcz"
1982 file-setup: file 644 "bbc"
1988 name: eglob-infinite-plus
1990 Check that shell doesn't go into infinite loop expanding +(...)
1992 file-setup: file 644 "abc"
2007 Check that eglobbing isn't done on substitution results
2008 file-setup: file 644 "abc"
2015 name: eglob-nomatch-1
2017 Check that the pattern doesn't match
2019 echo 1: no-file+(a|b)stuff
2020 echo 2: no-file+(a*(c)|b)stuff
2021 echo 3: no-file+((((c)))|b)stuff
2023 1: no-file+(a|b)stuff
2024 2: no-file+(a*(c)|b)stuff
2025 3: no-file+((((c)))|b)stuff
2029 Check that the pattern matches correctly
2030 file-setup: file 644 "abd"
2031 file-setup: file 644 "acd"
2032 file-setup: file 644 "abac"
2036 echo 3: *(a(b|c)) # (...|...) can be used within X(..)
2037 echo 4: a[b*(foo|bar)]d # patterns not special inside [...]
2046 Simple negation tests
2048 case foo in !(foo|bar)) echo yes;; *) echo no;; esac
2049 case bar in !(foo|bar)) echo yes;; *) echo no;; esac
2058 case foo in *(a|b[)) echo yes;; *) echo no;; esac
2059 case foo in *(a|b[)|f*) echo yes;; *) echo no;; esac
2060 case '*(a|b[)' in *(a|b[)) echo yes;; *) echo no;; esac
2061 case 'aab[b[ab[a' in *(a|b[)) echo yes;; *) echo no;; esac
2070 Eglobbing in trim expressions...
2071 (AT&T ksh fails this - docs say # matches shortest string, ## matches
2087 Check eglobbing works in trims...
2090 echo 1: ${x#*(a|b)cd}
2091 echo 2: "${x#*(a|b)cd}"
2092 echo 3: ${x#"*(a|b)cd"}
2102 Check eglobbing works in trims, for Korn Shell
2103 Ensure eglobbing does not work for reduced-feature /bin/sh
2109 echo "<${x%bar|baz},${y%bar|baz},${z%\?}>"
2110 echo "<${x%ba(r|z)},${y%ba(r|z)}>"
2112 echo "<${x%bar|baz},${y%bar|baz},${z%\?}>"
2118 <foobar,foobaz,fooba>
2121 name: eglob-substrpl-1
2123 Check eglobbing works in substs... and they work at all
2125 [[ -n $BASH_VERSION ]] && shopt -s extglob
2126 x=1222321_ab/cde_b/c_1221
2128 echo 1: ${x/2} . ${x/}
2135 echo 8: ${x//+(2)/4}
2136 echo 9: ${x/b/c/e/f}
2137 echo 10: ${x/b\/c/e/f}
2138 echo 11: ${x/b\/c/e\/f}
2139 echo 12: ${x/b\/c/e\\/f}
2140 echo 13: ${x/b\\/c/e\\/f}
2141 echo 14: ${x//b/c/e/f}
2142 echo 15: ${x//b\/c/e/f}
2143 echo 16: ${x//b\/c/e\/f}
2144 echo 17: ${x//b\/c/e\\/f}
2145 echo 18: ${x//b\\/c/e\\/f}
2146 echo 19: ${x/b\/*\/c/x}
2154 echo 27: ${x//\%1/9}
2155 echo 28: ${x//\\%1/9}
2157 echo 30: ${x//\\a/9}
2160 1: 122321_ab/cde_b/c_1221 . 1222321_ab/cde_b/c_1221
2161 2: 131_ab/cde_b/c_11
2162 3: 1321_ab/cde_b/c_1221
2163 4: 131_ab/cde_b/c_11
2164 5: 1422321_ab/cde_b/c_1221
2165 6: 1444341_ab/cde_b/c_1441
2166 7: 14321_ab/cde_b/c_1221
2167 8: 14341_ab/cde_b/c_141
2168 9: 1222321_ac/e/f/cde_b/c_1221
2169 10: 1222321_ae/fde_b/c_1221
2170 11: 1222321_ae/fde_b/c_1221
2171 12: 1222321_ae\/fde_b/c_1221
2172 13: 1222321_ab/cde_b/c_1221
2173 14: 1222321_ac/e/f/cde_c/e/f/c_1221
2174 15: 1222321_ae/fde_e/f_1221
2175 16: 1222321_ae/fde_e/f_1221
2176 17: 1222321_ae\/fde_e\/f_1221
2177 18: 1222321_ab/cde_b/c_1221
2179 20: 1222321_ab.cde_b/c_1221
2180 21: 1222321_ab.cde_b.c_1221
2181 22: 1222321_ab/cde_b/c_1221
2182 23: 9222321_ab/cde_b/c_1221
2183 24: 1222321_ab/cde_b/c_1221
2184 25: 1222321_ab/cde_b/c_1229
2185 26: 1222321_ab/cde_b/c_1221
2186 27: 1222321_ab/cde_b/c_1221
2187 28: 1222321_ab/cde_b/c_1221
2188 29: 1222321_9b/cde_b/c_1221
2189 30: 1222321_ab/cde_b/c_1221
2190 31: 1xyz22321_ab/cde_b/c_1221
2192 name: eglob-substrpl-2
2194 Check anchored substring replacement works, corner cases
2211 name: eglob-substrpl-3a
2213 Check substring replacement works with variables and slashes, too
2218 echo "${wd/#$pfx/~}"
2219 echo "${wd/#\$pfx/~}"
2220 echo "${wd/#"$pfx"/~}"
2221 echo "${wd/#'$pfx'/~}"
2222 echo "${wd/#"\$pfx"/~}"
2223 echo "${wd/#'\$pfx'/~}"
2232 name: eglob-substrpl-3b
2234 More of this, bash fails it (bash4 passes)
2239 echo "${wd/#$(echo /home/user)/~}"
2240 echo "${wd/#"$(echo /home/user)"/~}"
2241 echo "${wd/#'$(echo /home/user)'/~}"
2247 name: eglob-substrpl-3c
2249 Even more weird cases
2254 echo 1: ${wd/#$pfx/~}
2255 echo 2: ${wd/#\$pfx/~}
2256 echo 3: ${wd/#"$pfx"/~}
2257 echo 4: ${wd/#'$pfx'/~}
2258 echo 5: ${wd/#"\$pfx"/~}
2259 echo 6: ${wd/#'\$pfx'/~}
2260 ts='a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)'
2263 [[ -n $BASH_VERSION ]] && shopt -s extglob
2264 echo 7: ${ts/a\/b/$tr}
2265 echo 8: ${ts/a\/b/\$tr}
2266 echo 9: ${ts/$tp/$tr}
2267 echo 10: ${ts/\$tp/$tr}
2268 echo 11: ${ts/\\$tp/$tr}
2269 echo 12: ${ts/$tp/c/d}
2270 echo 13: ${ts/$tp/c\/d}
2271 echo 14: ${ts/$tp/c\\/d}
2272 echo 15: ${ts/+(a\/b)/$tr}
2273 echo 16: ${ts/+(a\/b)/\$tr}
2274 echo 17: ${ts/+($tp)/$tr}
2275 echo 18: ${ts/+($tp)/c/d}
2276 echo 19: ${ts/+($tp)/c\/d}
2277 echo 20: ${ts//a\/b/$tr}
2278 echo 21: ${ts//a\/b/\$tr}
2279 echo 22: ${ts//$tp/$tr}
2280 echo 23: ${ts//$tp/c/d}
2281 echo 24: ${ts//$tp/c\/d}
2282 echo 25: ${ts//+(a\/b)/$tr}
2283 echo 26: ${ts//+(a\/b)/\$tr}
2284 echo 27: ${ts//+($tp)/$tr}
2285 echo 28: ${ts//+($tp)/c/d}
2286 echo 29: ${ts//+($tp)/c\/d}
2288 echo 30: ${ts/$tp/$tr}
2289 echo 31: ${ts//$tp/$tr}
2297 7: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2298 8: $tra/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2299 9: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2300 10: a/ba/bc/d$tp_a/b$tp_*(a/b)_*($tp)
2301 11: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2302 12: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2303 13: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2304 14: c\/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2305 15: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2306 16: $tr$tp$tp_a/b$tp_*(a/b)_*($tp)
2307 17: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2308 18: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2309 19: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2310 20: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2311 21: $tr$tr$tp$tp_$tr$tp_*($tr)_*($tp)
2312 22: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2313 23: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2314 24: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2315 25: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2316 26: $tr$tp$tp_$tr$tp_*($tr)_*($tp)
2317 27: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2318 28: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2319 29: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2320 30: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2321 31: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2322 # This is what GNU bash does:
2323 # 30: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2324 # 31: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2328 UTF-8 mode differences for eglobbing
2329 category: !shell:ebcdic-yes
2334 print 2: ${s/b???d/x} .
2337 print 4: ${s/b??d/x} .
2339 print 5: ${x%?} ${x%%?} .
2341 print 6: ${x#?} ${x##?} .
2343 print 7: ${x%?} ${x%%?} .
2345 print 8: ${x%?} ${x%%?} .
2347 print 9: ${x%?} ${x%%?} .
2361 Check that [ matches itself if it's not a valid bracket expr
2362 but does not prevent globbing, while backslash-escaping does
2363 file-setup: dir 755 "[x"
2364 file-setup: file 644 "[x/foo"
2384 Check that symbolic links aren't stat()'d
2385 # breaks on Dell UNIX 4.0 R2.2 (SVR4) where unlink also fails
2386 # breaks on FreeMiNT (cannot unlink dangling symlinks)
2387 # breaks on MSYS, OS/2 (do not support symlinks)
2388 category: !os:mint,!os:msys,!os:svr4.0,!nosymlink
2389 file-setup: dir 755 "dir"
2390 file-setup: symlink 644 "dir/abc"
2401 Check that the slash is parsed before the glob
2404 (cd 'a[b'; echo ok >'c]d')
2414 file-setup: file 644 ".bc"
2415 file-setup: file 644 "abc"
2416 file-setup: file 644 "bbc"
2417 file-setup: file 644 "cbc"
2418 file-setup: file 644 "-bc"
2419 file-setup: file 644 "!bc"
2420 file-setup: file 644 "^bc"
2421 file-setup: file 644 "+bc"
2422 file-setup: file 644 ",bc"
2423 file-setup: file 644 "0bc"
2424 file-setup: file 644 "1bc"
2438 !bc +bc ,bc 0bc 1bc ^bc cbc
2439 !bc +bc ,bc -bc 0bc 1bc ^bc cbc
2448 (AT&T ksh fails this; POSIX says invalid)
2449 file-setup: file 644 "abc"
2457 Check that globbing matches the right things...
2458 # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
2459 # breaks on Cygwin 1.7 (files are now UTF-16 or something)
2460 # breaks on QNX 6.4.1 (says RT)
2461 category: !os:cygwin,!os:darwin,!os:msys,!os:nto,!os:os2,!os:os390
2463 file-setup: file 644 "aÂc"
2471 Results unspecified according to POSIX
2472 file-setup: file 644 ".bc"
2480 Results unspecified according to POSIX
2481 (AT&T ksh treats this like [a-cc-e]*)
2482 file-setup: file 644 "abc"
2483 file-setup: file 644 "bbc"
2484 file-setup: file 644 "cbc"
2485 file-setup: file 644 "dbc"
2486 file-setup: file 644 "ebc"
2487 file-setup: file 644 "-bc"
2488 file-setup: file 644 "@bc"
2498 Check BSD word boundary matches
2500 t() { [[ $1 = *[[:\<:]]bar[[:\>:]]* ]]; echo =$?; }
2517 Check against a regression from fixing IFS-subst-2
2520 print -r "before='$x'"
2522 print -r "after ='$x'"
2529 Check ordering/content of redundent here documents.
2541 Check quoted here-doc is protected.
2560 Check that newline isn't needed after heredoc-delimiter marker.
2572 Check that an error occurs if the heredoc-delimiter is missing.
2577 expected-exit: e > 0
2578 expected-stderr-pattern: /.*/
2582 Check that an error occurs if the heredoc-delimiter is missing.
2588 expected-exit: e > 0
2589 expected-stderr-pattern: /.*/
2593 Check that an error occurs if the heredoc is missing.
2596 expected-exit: e > 0
2597 expected-stderr-pattern: /.*/
2601 Check that an error occurs if the heredoc is missing.
2605 expected-exit: e > 0
2606 expected-stderr-pattern: /.*/
2610 Check that backslash quotes a $, ` and \ and kills a \newline
2617 th\`echo not-run\`ere
2618 th\\`echo is-run`ere
2635 Check that \newline in initial here-delim word doesn't imply
2650 Check that double quoted $ expressions in here delimiters are
2651 not expanded and match the delimiter.
2652 POSIX says only quote removal is applied to the delimiter.
2669 Check that double quoted escaped $ expressions in here
2670 delimiters are not expanded and match the delimiter.
2671 POSIX says only quote removal is applied to the delimiter
2672 (\ counts as a quote).
2693 Check that here strings work.
2697 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo
2698 "$__progname" -c "tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo"
2699 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$bar"
2700 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<'$bar'
2701 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$bar
2702 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<-foo
2703 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$(echo "foo bar")"
2704 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"A $(echo "foo bar") B"
2705 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$b\$b$bar
2721 Check that a corner case of here strings works like bash
2726 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
2733 Check that a corner case of here strings works like ksh93, zsh
2738 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
2745 Check another corner case of here strings
2747 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<< bar
2753 Check here string related regression with multiple iops
2755 echo $(tr r z <<<'bar' 2>/dev/null)
2761 Check long here strings
2769 Check direct here document assignment
2770 category: !shell:ebcdic-yes
2784 fnd=$(typeset -f foo)
2792 # rather nonsensical, but…
2795 vf=<<<$'=f $x \x40='
2797 print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} ve={$ve} vf={$vf} |"
2805 print -r -- "| ${v//$'\n'/^} |"
2823 name: heredoc-10-ebcdic
2825 Check direct here document assignment
2826 category: !shell:ebcdic-no
2840 fnd=$(typeset -f foo)
2848 # rather nonsensical, but…
2851 vf=<<<$'=f $x \x7C='
2853 print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} ve={$ve} vf={$vf} |"
2861 print -r -- "| ${v//$'\n'/^} |"
2881 Check here documents with no or empty delimiter
2898 fnd=$(typeset -f foo)
2906 print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} |"
2910 print -r -- "| vc={$vc} vd={$vd} |"
2918 print -r -- "| ${v//$'\n'/^} |"
2953 Check here documents can use $* and $@; note shells vary:
2954 • pdksh 5.2.14 acts the same
2955 • dash has 1 and 2 the same but 3 lacks the space
2956 • ksh93, bash4 differ in 2 by using space ipv colon
2998 Check that using multiple here documents works
3001 echo "got $(cat) on stdin"
3002 echo "got $(cat <&4) on fd#4"
3003 echo "got $(cat <&5) on fd#5"
3006 foo 4<<-a <<-b 5<<-c
3017 [[ $x = "$y" ]]; echo $?
3023 \foo 4<<-a <<-b 5<<-c
3036 name: heredoc-comsub-1
3038 Tests for here documents in COMSUB, taken from Austin ML
3045 = here is the text =
3047 name: heredoc-comsub-2
3049 Tests for here documents in COMSUB, taken from Austin ML
3051 unbalanced=$(cat <<EOF
3052 this paren ) is a problem
3054 echo = $unbalanced =
3056 = this paren ) is a problem =
3058 name: heredoc-comsub-3
3060 Tests for here documents in COMSUB, taken from Austin ML
3062 balanced=$(cat <<EOF
3063 these parens ( ) are not a problem
3067 = these parens ( ) are not a problem =
3069 name: heredoc-comsub-4
3071 Tests for here documents in COMSUB, taken from Austin ML
3073 balanced=$(cat <<EOF
3074 these parens \( ) are a problem
3078 = these parens \( ) are a problem =
3080 name: heredoc-comsub-5
3082 Check heredoc and COMSUB mixture in input
3084 prefix() { sed -e "s/^/$1:/"; }
3085 XXX() { echo x-en; }
3086 YYY() { echo y-es; }
3088 prefix A <<XXX && echo "$(prefix B <<XXX
3091 echo line 2)" && prefix C <<YYY
3106 name: heredoc-comsub-6
3108 Check here documents and here strings can be used
3109 without a specific command, like $(<…) (extension)
3117 $foo) is not a problem
3126 bar) is not a problem>
3128 name: heredoc-subshell-1
3130 Tests for here documents in subshells, taken from Austin ML
3140 name: heredoc-subshell-2
3142 Tests for here documents in subshells, taken from Austin ML
3153 name: heredoc-subshell-3
3155 Tests for here documents in subshells, taken from Austin ML
3165 name: heredoc-weird-1
3167 Tests for here documents, taken from Austin ML
3168 Documents current state in mksh, *NOT* necessarily correct!
3181 name: heredoc-weird-2
3183 Tests for here documents, taken from Austin ML
3193 name: heredoc-weird-4
3195 Tests for here documents, taken from Austin ML
3196 Documents current state in mksh, *NOT* necessarily correct!
3207 name: heredoc-weird-5
3209 Tests for here documents, taken from Austin ML
3210 Documents current state in mksh, *NOT* necessarily correct!
3222 name: heredoc-tmpfile-1
3224 Check that heredoc temp files aren't removed too soon or too late.
3225 Heredoc in simple command.
3246 name: heredoc-tmpfile-2
3248 Check that heredoc temp files aren't removed too soon or too late.
3249 Heredoc in function, multiple calls to function.
3268 name: heredoc-tmpfile-3
3270 Check that heredoc temp files aren't removed too soon or too late.
3271 Heredoc in function in loop, multiple calls to function.
3298 name: heredoc-tmpfile-4
3300 Check that heredoc temp files aren't removed too soon or too late.
3301 Backgrounded simple command with here doc
3315 name: heredoc-tmpfile-5
3317 Check that heredoc temp files aren't removed too soon or too late.
3318 Backgrounded subshell command with here doc
3323 sleep 1 # so parent exits
3339 name: heredoc-tmpfile-6
3341 Check that heredoc temp files aren't removed too soon or too late.
3342 Heredoc in pipeline.
3346 cat <<- EOF | sed "s/hi/HI/"
3356 name: heredoc-tmpfile-7
3358 Check that heredoc temp files aren't removed too soon or too late.
3359 Heredoc in backgrounded pipeline.
3363 cat <<- EOF | sed 's/hi/HI/' &
3373 name: heredoc-tmpfile-8
3375 Check that heredoc temp files aren't removed too soon or too
3376 late. Heredoc in function, backgrounded call to function.
3377 This check can fail on slow machines (<100 MHz), or Cygwin,
3382 # Background eval so main shell doesn't do parsing
3390 # sleep so eval can die
3404 name: heredoc-quoting-unsubst
3406 Check for correct handling of quoted characters in
3407 here documents without substitution (marker is quoted).
3411 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
3414 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
3416 name: heredoc-quoting-subst
3418 Check for correct handling of quoted characters in
3419 here documents with substitution (marker is not quoted).
3423 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
3426 x " \" \ \ $ $ baz `echo baz` bar $foo x
3428 name: single-quotes-in-braces
3430 Check that single quotes inside unquoted {} are treated as quotes
3433 echo ${foo:+'blah $foo'}
3437 name: single-quotes-in-quoted-braces
3439 Check that single quotes inside quoted {} are treated as
3443 echo "${foo:+'blah $foo'}"
3447 name: single-quotes-in-braces-nested
3449 Check that single quotes inside unquoted {} are treated as quotes,
3450 even if that's inside a double-quoted command expansion
3453 echo "$( echo ${foo:+'blah $foo'})"
3457 name: single-quotes-in-brace-pattern
3459 Check that single quotes inside {} pattern are treated as quotes
3462 echo ${foo%'2'*} "${foo%'2'*}" ${foo%2'*'} "${foo%2'*'}"
3466 name: single-quotes-in-heredoc-braces
3468 Check that single quotes inside {} in heredoc are treated
3478 name: single-quotes-in-nested-braces
3480 Check that single quotes inside nested unquoted {} are
3484 echo ${foo:+${foo:+'blah $foo'}}
3488 name: single-quotes-in-nested-quoted-braces
3490 Check that single quotes inside nested quoted {} are treated
3494 echo "${foo:+${foo:+'blah $foo'}}"
3498 name: single-quotes-in-nested-braces-nested
3500 Check that single quotes inside nested unquoted {} are treated
3501 as quotes, even if that's inside a double-quoted command expansion
3504 echo "$( echo ${foo:+${foo:+'blah $foo'}})"
3508 name: single-quotes-in-nested-brace-pattern
3510 Check that single quotes inside nested {} pattern are treated as quotes
3513 echo ${foo:+${foo%'2'*}} "${foo:+${foo%'2'*}}" ${foo:+${foo%2'*'}} "${foo:+${foo%2'*'}}"
3517 name: single-quotes-in-heredoc-nested-braces
3519 Check that single quotes inside nested {} in heredoc are treated
3524 ${foo:+${foo:+'blah $foo'}}
3531 See if we can test history at all
3534 env-setup: !ENV=./Env!HISTFILE=hist.file!
3535 file-setup: file 644 "Env"
3543 expected-stderr-pattern:
3548 Verify duplicates and spaces are not entered
3551 env-setup: !ENV=./Env!HISTFILE=hist.file!
3552 file-setup: file 644 "Env"
3564 expected-stderr-pattern:
3567 name: history-unlink
3569 Check if broken HISTFILEs do not cause trouble
3572 env-setup: !ENV=./Env!HISTFILE=foo/hist.file!
3573 file-setup: file 644 "Env"
3575 file-setup: dir 755 "foo"
3576 file-setup: file 644 "foo/hist.file"
3579 perl-setup: chmod(0555, "foo");
3587 expected-stderr-pattern:
3588 /(.*can't unlink HISTFILE.*\n)?X*$/
3590 name: history-multiline
3592 Check correct multiline history, Debian #783978
3595 env-setup: !ENV=./Env!
3596 file-setup: file 644 "Env"
3618 expected-stderr-pattern:
3621 name: history-e-minus-1
3623 Check if more recent command is executed
3626 env-setup: !ENV=./Env!HISTFILE=hist.file!
3627 file-setup: file 644 "Env"
3637 expected-stderr-pattern:
3638 /^X*echo there\nX*$/
3640 name: history-e-minus-2
3642 Check that repeated command is printed before command
3646 env-setup: !ENV=./Env!HISTFILE=hist.file!
3647 file-setup: file 644 "Env"
3654 expected-stdout-pattern:
3655 /X*hi\nX*there\nX*echo there\nthere\nX*/
3656 expected-stderr-pattern:
3659 name: history-e-minus-3
3661 fc -e - fails when there is no history
3662 (ksh93 has a bug that causes this to fail)
3663 (ksh88 loops on this)
3666 env-setup: !ENV=./Env!HISTFILE=hist.file!
3667 file-setup: file 644 "Env"
3674 expected-stderr-pattern:
3675 /^X*.*:.*history.*\nX*$/
3677 name: history-e-minus-4
3679 Check if "fc -e -" command output goes to stdout.
3682 env-setup: !ENV=./Env!HISTFILE=hist.file!
3683 file-setup: file 644 "Env"
3687 fc -e - | (read x; echo "A $x")
3693 expected-stderr-pattern:
3696 name: history-e-minus-5
3698 fc is replaced in history by new command.
3701 env-setup: !ENV=./Env!HISTFILE=hist.file!
3702 file-setup: file 644 "Env"
3718 expected-stderr-pattern:
3719 /^X*echo ghi jkl\nX*$/
3721 name: history-list-1
3723 List lists correct range
3724 (ksh88 fails 'cause it lists the fc command)
3727 env-setup: !ENV=./Env!HISTFILE=hist.file!
3728 file-setup: file 644 "Env"
3741 expected-stderr-pattern:
3744 name: history-list-2
3746 Lists oldest history if given pre-historic number
3747 (ksh93 has a bug that causes this to fail)
3748 (ksh88 fails 'cause it lists the fc command)
3751 env-setup: !ENV=./Env!HISTFILE=hist.file!
3752 file-setup: file 644 "Env"
3766 expected-stderr-pattern:
3769 name: history-list-3
3771 Can give number 'options' to fc
3774 env-setup: !ENV=./Env!HISTFILE=hist.file!
3775 file-setup: file 644 "Env"
3790 expected-stderr-pattern:
3793 name: history-list-4
3795 -1 refers to previous command
3798 env-setup: !ENV=./Env!HISTFILE=hist.file!
3799 file-setup: file 644 "Env"
3813 expected-stderr-pattern:
3816 name: history-list-5
3818 List command stays in history
3821 env-setup: !ENV=./Env!HISTFILE=hist.file!
3822 file-setup: file 644 "Env"
3839 expected-stderr-pattern:
3842 name: history-list-6
3844 HISTSIZE limits about of history kept.
3845 (ksh88 fails 'cause it lists the fc command)
3848 env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3!
3849 file-setup: file 644 "Env"
3866 expected-stderr-pattern:
3869 name: history-list-7
3871 fc allows too old/new errors in range specification
3874 env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3!
3875 file-setup: file 644 "Env"
3893 expected-stderr-pattern:
3896 name: history-list-r-1
3898 test -r flag in history
3901 env-setup: !ENV=./Env!HISTFILE=hist.file!
3902 file-setup: file 644 "Env"
3920 expected-stderr-pattern:
3923 name: history-list-r-2
3925 If first is newer than last, -r is implied.
3928 env-setup: !ENV=./Env!HISTFILE=hist.file!
3929 file-setup: file 644 "Env"
3947 expected-stderr-pattern:
3950 name: history-list-r-3
3952 If first is newer than last, -r is cancelled.
3955 env-setup: !ENV=./Env!HISTFILE=hist.file!
3956 file-setup: file 644 "Env"
3974 expected-stderr-pattern:
3977 name: history-subst-1
3982 env-setup: !ENV=./Env!HISTFILE=hist.file!
3983 file-setup: file 644 "Env"
3988 fc -e - abc=AB 'echo a'
3993 expected-stderr-pattern:
3994 /^X*echo AB def\nX*$/
3996 name: history-subst-2
3998 Does subst find previous command?
4001 env-setup: !ENV=./Env!HISTFILE=hist.file!
4002 file-setup: file 644 "Env"
4007 fc -e - jkl=XYZQRT 'echo g'
4012 expected-stderr-pattern:
4013 /^X*echo ghi XYZQRT\nX*$/
4015 name: history-subst-3
4017 Does subst find previous command when no arguments given
4020 env-setup: !ENV=./Env!HISTFILE=hist.file!
4021 file-setup: file 644 "Env"
4031 expected-stderr-pattern:
4032 /^X*echo ghi XYZQRT\nX*$/
4034 name: history-subst-4
4036 Global substitutions work
4037 (ksh88 and ksh93 do not have -g option)
4040 env-setup: !ENV=./Env!HISTFILE=hist.file!
4041 file-setup: file 644 "Env"
4044 echo abc def asjj sadjhasdjh asdjhasd
4047 abc def asjj sadjhasdjh asdjhasd
4048 FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd
4049 expected-stderr-pattern:
4050 /^X*echo FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd\nX*$/
4052 name: history-subst-5
4054 Make sure searches don't find current (fc) command
4055 (ksh88/ksh93 don't have the ? prefix thing so they fail this test)
4058 env-setup: !ENV=./Env!HISTFILE=hist.file!
4059 file-setup: file 644 "Env"
4064 fc -e - abc=AB \?abc
4069 expected-stderr-pattern:
4070 /^X*echo AB def\nX*$/
4072 name: history-ed-1-old
4074 Basic (ed) editing works (assumes you have generic ed editor
4075 that prints no prompts). This is for oldish ed(1) which write
4076 the character count to stdout.
4081 env-setup: !ENV=./Env!HISTFILE=hist.file!
4082 file-setup: file 644 "Env"
4095 expected-stderr-pattern:
4096 /^X*echo FOOBAR def\nX*$/
4098 name: history-ed-2-old
4100 Correct command is edited when number given
4105 env-setup: !ENV=./Env!HISTFILE=hist.file!
4106 file-setup: file 644 "Env"
4114 s/is here/is changed/
4125 expected-stderr-pattern:
4126 /^X*echo line 2 is changed\nX*$/
4128 name: history-ed-3-old
4130 Newly created multi line commands show up as single command
4132 (ksh88 fails 'cause it lists the fc command)
4137 env-setup: !ENV=./Env!HISTFILE=hist.file!
4138 file-setup: file 644 "Env"
4159 expected-stderr-pattern:
4160 /^X*echo FOOBAR def\necho a new line\nX*$/
4164 Basic (ed) editing works (assumes you have generic ed editor
4165 that prints no prompts). This is for newish ed(1) and stderr.
4166 category: !no-stderr-ed
4170 env-setup: !ENV=./Env!HISTFILE=hist.file!
4171 file-setup: file 644 "Env"
4182 expected-stderr-pattern:
4183 /^X*13\n16\necho FOOBAR def\nX*$/
4187 Correct command is edited when number given
4188 category: !no-stderr-ed
4192 env-setup: !ENV=./Env!HISTFILE=hist.file!
4193 file-setup: file 644 "Env"
4201 s/is here/is changed/
4210 expected-stderr-pattern:
4211 /^X*20\n23\necho line 2 is changed\nX*$/
4215 Newly created multi line commands show up as single command
4217 category: !no-stderr-ed
4221 env-setup: !ENV=./Env!HISTFILE=hist.file!
4222 file-setup: file 644 "Env"
4241 expected-stderr-pattern:
4242 /^X*13\n32\necho FOOBAR def\necho a new line\nX*$/
4246 Simple test, default IFS
4248 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4264 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4281 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4294 name: IFS-space-colon-1
4296 Simple test, IFS=<white-space>:
4298 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4313 name: IFS-space-colon-2
4315 Simple test, IFS=<white-space>:
4316 AT&T ksh fails this, POSIX says the test is correct.
4318 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4325 name: IFS-space-colon-4
4327 Simple test, IFS=<white-space>:
4329 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4336 name: IFS-space-colon-5
4338 Simple test, IFS=<white-space>:
4339 Don't know what POSIX thinks of this. AT&T ksh does not do this.
4341 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4350 Simple test, IFS=<white-space>:
4352 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4355 echo -n '1:'; for i in $x ; do echo -n " [$i]" ; done ; echo
4356 echo -n '2:'; for i in :b:: ; do echo -n " [$i]" ; done ; echo
4360 echo -n '5:'; for i in $x ; do echo -n " [$i]" ; done ; echo
4363 echo -n '7:'; for i in $x ; do echo -n " [$i]" ; done ; echo
4365 echo -n '9:'; for i in ${FOO-`echo -n h:i`th:ere} ; do echo -n " [$i]" ; done ; echo
4366 showargs 10 ${FOO-`echo -n h:i`th:ere}
4367 showargs 11 "${FOO-`echo -n h:i`th:ere}"
4369 echo -n '12:'; for i in $x ; do echo -n " [$i]" ; done ; echo
4381 <10> <h> <ith> <ere> .
4384 <13> <A> <B> <> <D> .
4388 Check leading whitespace after trim does not make a field
4390 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4392 showargs 1 shift ${x#X}
4394 <1> <shift> <1> <2> .
4396 name: IFS-subst-3-arr
4398 Check leading IFS non-whitespace after trim does make a field
4399 but leading IFS whitespace does not, nor empty replacements
4401 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4404 showargs 1 ${-+:foo:bar}
4406 showargs 2 ${-+ foo bar}
4409 <1> <> <foo> <bar> .
4412 name: IFS-subst-3-ass
4414 Check non-field semantics
4416 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4419 showargs 1 x=${-+:foo:bar}
4421 showargs 2 x=${-+ foo bar}
4424 <1> <x=> <foo> <bar> .
4425 <2> <x=> <foo> <bar> .
4427 name: IFS-subst-3-lcl
4429 Check non-field semantics, smaller corner case (LP#1381965)
4434 expected-exit: e != 0
4435 expected-stderr-pattern:
4440 reported by mikeserv
4442 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4443 a='space divded argument
4446 IFS= ; q="$*" ; nq=$*
4447 pfn "$*" $* "$q" "$nq"
4448 [ "$q" = "$nq" ] && echo =true || echo =false
4450 <spacedivdedargument
4456 <spacedivdedargument
4458 <spacedivdedargument
4464 extended testsuite based on problem by mikeserv
4466 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4467 a='space divded argument
4470 IFS= ; q="$@" ; nq=$@
4471 pfn "$*" $* "$q" "$nq"
4472 [ "$q" = "$nq" ] && echo =true || echo =false
4474 <spacedivdedargument
4480 <space divded argument
4482 <space divded argument
4488 extended testsuite based on problem by mikeserv
4490 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4491 a='space divded argument
4493 IFS=\ ; set -- $a; IFS=
4498 print -nr -- '= qs '; pfn "$qs"
4499 print -nr -- '=nqs '; pfn "$nqs"
4500 print -nr -- '= qk '; pfn "$qk"
4501 print -nr -- '=nqk '; pfn "$nqk"
4502 print -nr -- '~ qs '; pfn "$*"
4503 print -nr -- '~nqs '; pfn $*
4504 print -nr -- '~ qk '; pfn "$@"
4505 print -nr -- '~nqk '; pfn $@
4507 = qs <spacedivdedargument
4509 =nqs <spacedivdedargument
4511 = qk <space divded argument
4513 =nqk <space divded argument
4515 ~ qs <spacedivdedargument
4532 extended testsuite based on problem by mikeserv
4534 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4535 a='space divded argument
4537 IFS=\ ; set -- $a; IFS=
4539 print -nr -- '= qs '; pfn "$qs"
4540 print -nr -- '~ qs '; pfn "$*"
4542 print -nr -- '=nqs '; pfn "$nqs"
4543 print -nr -- '~nqs '; pfn $*
4545 print -nr -- '= qk '; pfn "$qk"
4546 print -nr -- '~ qk '; pfn "$@"
4548 print -nr -- '=nqk '; pfn "$nqk"
4549 print -nr -- '~nqk '; pfn $@
4551 = qs <spacedivdedargument
4553 ~ qs <spacedivdedargument
4555 =nqs <spacedivdedargument
4561 = qk <space divded argument
4567 =nqk <space divded argument
4574 name: IFS-subst-4-4p
4576 extended testsuite based on problem by mikeserv
4578 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4579 a='space divded argument
4581 IFS=\ ; set -- $a; IFS=
4584 print -nr -- '= qs '; pfn "$qs"
4585 print -nr -- '~ qs '; pfn ${v:-"$*"}
4587 print -nr -- '=nqs '; pfn "$nqs"
4588 print -nr -- '~nqs '; pfn ${v:-$*}
4590 print -nr -- '= qk '; pfn "$qk"
4591 print -nr -- '~ qk '; pfn ${v:-"$@"}
4593 print -nr -- '=nqk '; pfn "$nqk"
4594 print -nr -- '~nqk '; pfn ${v:-$@}
4596 = qs <spacedivdedargument
4598 ~ qs <spacedivdedargument
4600 =nqs <spacedivdedargument
4606 = qk <space divded argument
4612 =nqk <space divded argument
4621 extended testsuite based on problem by mikeserv
4623 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4624 a='space divded argument
4626 IFS=\ ; set -- $a; IFS=,
4628 print -nr -- '= qs '; pfn "$qs"
4629 print -nr -- '~ qs '; pfn "$*"
4631 print -nr -- '=nqs '; pfn "$nqs"
4632 print -nr -- '~nqs '; pfn $*
4634 print -nr -- '= qk '; pfn "$qk"
4635 print -nr -- '~ qk '; pfn "$@"
4637 print -nr -- '=nqk '; pfn "$nqk"
4638 print -nr -- '~nqk '; pfn $@
4640 = qs <space,divded,argument
4642 ~ qs <space,divded,argument
4644 =nqs <space,divded,argument
4650 = qk <space divded argument
4656 =nqk <space divded argument
4663 name: IFS-subst-4-5p
4665 extended testsuite based on problem by mikeserv
4667 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }
4668 a='space divded argument
4670 IFS=\ ; set -- $a; IFS=,
4673 print -nr -- '= qs '; pfn "$qs"
4674 print -nr -- '~ qs '; pfn ${v:-"$*"}
4676 print -nr -- '=nqs '; pfn "$nqs"
4677 print -nr -- '~nqs '; pfn ${v:-$*}
4679 print -nr -- '= qk '; pfn "$qk"
4680 print -nr -- '~ qk '; pfn ${v:-"$@"}
4682 print -nr -- '=nqk '; pfn "$nqk"
4683 print -nr -- '~nqk '; pfn ${v:-$@}
4685 = qs <space,divded,argument
4687 ~ qs <space,divded,argument
4689 =nqs <space,divded,argument
4695 = qk <space divded argument
4701 =nqk <space divded argument
4710 extended testsuite based on IFS-subst-3
4711 differs slightly from ksh93:
4712 - omit trailing field in a3zna, a7ina (unquoted $@ expansion)
4713 - has extra middle fields in b5ins, b7ina (IFS_NWS unquoted expansion)
4714 differs slightly from bash:
4715 - omit leading field in a5ins, a7ina (IFS_NWS unquoted expansion)
4716 differs slightly from zsh:
4717 - differs in assignment, not expansion; probably zsh bug
4718 - has extra middle fields in b5ins, b7ina (IFS_NWS unquoted expansion)
4719 'emulate sh' zsh has extra fields in
4720 - a5ins (IFS_NWS unquoted $*)
4721 - b5ins, matching mksh’s
4722 !!WARNING!! more to come: http://austingroupbugs.net/view.php?id=888
4724 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4725 IFS=; set -- "" 2 ""; pfb $*; x=$*; pfn "$x"'
4727 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4728 IFS=; set -- "" 2 ""; pfb "$*"; x="$*"; pfn "$x"'
4730 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4731 IFS=; set -- "" 2 ""; pfb $@; x=$@; pfn "$x"'
4733 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4734 IFS=; set -- "" 2 ""; pfb "$@"; x="$@"; pfn "$x"'
4736 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4737 IFS=,; set -- "" 2 ""; pfb $*; x=$*; pfn "$x"'
4739 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4740 IFS=,; set -- "" 2 ""; pfb "$*"; x="$*"; pfn "$x"'
4742 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4743 IFS=,; set -- "" 2 ""; pfb $@; x=$@; pfn "$x"'
4745 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4746 IFS=,; set -- "" 2 ""; pfb "$@"; x="$@"; pfn "$x"'
4748 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4749 IFS=; set -- A B "" "" C; pfb $*; x=$*; pfn "$x"'
4751 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4752 IFS=; set -- A B "" "" C; pfb "$*"; x="$*"; pfn "$x"'
4754 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4755 IFS=; set -- A B "" "" C; pfb $@; x=$@; pfn "$x"'
4757 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4758 IFS=; set -- A B "" "" C; pfb "$@"; x="$@"; pfn "$x"'
4760 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4761 IFS=,; set -- A B "" "" C; pfb $*; x=$*; pfn "$x"'
4763 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4764 IFS=,; set -- A B "" "" C; pfb "$*"; x="$*"; pfn "$x"'
4766 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4767 IFS=,; set -- A B "" "" C; pfb $@; x=$@; pfn "$x"'
4769 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; };
4770 IFS=,; set -- A B "" "" C; pfb "$@"; x="$@"; pfn "$x"'
4848 Regression wrt. vector expansion in trim
4850 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4860 ksh93 bug wrt. vector expansion in trim
4862 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4866 showargs "$*" ${a##"$*"}
4872 http://austingroupbugs.net/view.php?id=221
4874 n() { echo "$#"; }; n "${foo-$@}"
4880 Scalar context for $*/$@ in [[ and case
4882 "$__progname" -c 'IFS=; set a b; [[ $* = "$1$2" ]]; echo 1 $?' sh a b
4883 "$__progname" -c 'IFS=; [[ $* = ab ]]; echo 2 "$?"' sh a b
4884 "$__progname" -c 'IFS=; [[ "$*" = ab ]]; echo 3 "$?"' sh a b
4885 "$__progname" -c 'IFS=; [[ $* = a ]]; echo 4 "$?"' sh a b
4886 "$__progname" -c 'IFS=; [[ "$*" = a ]]; echo 5 "$?"' sh a b
4887 "$__progname" -c 'IFS=; [[ "$@" = a ]]; echo 6 "$?"' sh a b
4888 "$__progname" -c 'IFS=; case "$@" in a) echo 7 a;; ab) echo 7 b;; a\ b) echo 7 ok;; esac' sh a b
4889 "$__progname" -c 'IFS=; case $* in a) echo 8 a;; ab) echo 8 ok;; esac' sh a b
4890 "$__progname" -c 'pfsp() { for s_arg in "$@"; do print -nr -- "<$s_arg> "; done; print .; }; IFS=; star=$* at="$@"; pfsp 9 "$star" "$at"' sh a b
4904 Scalar context in ${var=$subst}
4906 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4907 set -- one "two three" four
4916 var=onetwo threefour
4917 <onetwo threefour> .
4921 http://austingroupbugs.net/view.php?id=832
4923 ${ZSH_VERSION+false} || emulate sh
4924 ${BASH_VERSION+set -o posix}
4925 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
4927 showargs $((1230456))
4931 name: integer-base-err-1
4933 Can't have 0 base (causes shell to exit)
4934 expected-exit: e != 0
4940 expected-stderr-pattern:
4943 name: integer-base-err-2
4945 Can't have multiple bases in a 'constant' (causes shell to exit)
4946 (ksh88 fails this test)
4947 expected-exit: e != 0
4953 expected-stderr-pattern:
4954 /^.*:.*2#110#11.*\n$/
4956 name: integer-base-err-3
4958 Syntax errors in expressions and effects on bases
4959 (interactive so errors don't cause exits)
4960 (ksh88 fails this test - shell exits, even with -i)
4964 PS1= # minimise prompt hassles
4971 expected-stderr-pattern:
4972 /^([#\$] )?.*:.*2+.*\n.*:.*2+.*\n$/
4977 name: integer-base-err-4
4979 Are invalid digits (according to base) errors?
4980 (ksh93 fails this test)
4981 expected-exit: e != 0
4985 expected-stderr-pattern:
4986 /^([#\$] )?.*:.*3#4.*\n$/
4988 name: integer-base-1
4990 Missing number after base is treated as 0.
4999 name: integer-base-2
5001 Check 'stickyness' of base in various situations
5052 name: integer-base-3
5054 More base parsing (hmm doesn't test much..)
5074 name: integer-base-4
5076 Check that things not declared as integers are not made integers,
5077 also, check if base is not reset by -i with no arguments.
5078 (ksh93 fails - prints 10#20 - go figure)
5082 typeset -i | grep '^xx='
5089 name: integer-base-5
5105 for l in 1 2+3 4; do echo $l; done
5117 name: integer-base-6
5119 Even more base stuff
5120 (ksh93 fails this test - prints 0)
5128 name: integer-base-7
5130 Check that non-integer parameters don't get bases assigned
5132 echo $(( zz = 8#100 ))
5138 name: integer-base-8
5140 Check that base-36 works (full span)
5142 echo 1:$((36#109AZ)).
5143 typeset -i36 x=1691675
5152 name: integer-base-check-flat
5154 Check behaviour does not match POSuX (except if set -o posix),
5155 because a not type-safe scripting language has *no* business
5156 interpreting the string "010" as octal number eight (dangerous).
5158 echo 1 "$("$__progname" -c 'echo :$((10))/$((010)),$((0x10)):')" .
5159 echo 2 "$("$__progname" -o posix -c 'echo :$((10))/$((010)),$((0x10)):')" .
5160 echo 3 "$("$__progname" -o sh -c 'echo :$((10))/$((010)),$((0x10)):')" .
5166 name: integer-base-check-numeric-from-1
5168 Check behaviour for base one
5169 category: !shell:ebcdic-yes
5175 name: integer-base-check-numeric-from-1-ebcdic
5177 Check behaviour for base one
5178 category: !shell:ebcdic-no
5184 name: integer-base-check-numeric-from-2
5186 Check behaviour for base two to 36, and that 37 degrades to 10
5189 while (( ++i <= 37 )); do
5190 eval 'echo '$i':$(('$i'#10)).'
5192 echo 37:$($__progname -c 'echo $((37#10))').$?:
5232 name: integer-base-check-numeric-to-1
5234 Check behaviour for base one
5235 category: !shell:ebcdic-yes
5238 typeset -Uui$i x=0x40
5239 eval "typeset -i10 y=$x"
5244 name: integer-base-check-numeric-to-1-ebcdic
5246 Check behaviour for base one
5247 category: !shell:ebcdic-no
5250 typeset -Uui$i x=0x7C
5251 eval "typeset -i10 y=$x"
5256 name: integer-base-check-numeric-to-2
5258 Check behaviour for base two to 36, and that 37 degrades to 10
5261 while (( ++i <= 37 )); do
5262 typeset -Uui$i x=0x40
5263 eval "typeset -i10 y=$x"
5304 name: integer-arithmetic-span
5306 Check wraparound and size that is defined in mksh
5309 echo s:$((2147483647+1)).$(((2147483647*2)+1)).$(((2147483647*2)+2)).
5310 echo u:$((#2147483647+1)).$((#(2147483647*2)+1)).$((#(2147483647*2)+2)).
5313 u:2147483648.4294967295.0.
5315 name: integer-arithmetic-span-64
5317 Check wraparound and size that is defined in mksh
5320 echo s:$((9223372036854775807+1)).$(((9223372036854775807*2)+1)).$(((9223372036854775807*2)+2)).
5321 echo u:$((#9223372036854775807+1)).$((#(9223372036854775807*2)+1)).$((#(9223372036854775807*2)+2)).
5323 s:-9223372036854775808.-1.0.
5324 u:9223372036854775808.18446744073709551615.0.
5326 name: integer-size-FAIL-to-detect
5328 Notify the user that their ints are not 32 or 64 bit
5335 See if $LINENO is updated and can be modified.
5348 See if $LINENO is set for .'d files.
5349 file-setup: file 644 "dotfile"
5367 See if $LINENO is set for commands in a function.
5386 See if unsetting LINENO makes it non-magic.
5387 file-setup: file 644 "dotfile"
5410 name: lineno-unset-use
5412 See if unsetting LINENO makes it non-magic even
5414 file-setup: file 644 "dotfile"
5440 Check if LINENO is tracked in traps
5446 trap 'fail $LINENO' INT ERR
5452 name: lineno-eval-alias
5454 Check if LINENO is trapped in eval and aliases
5456 ${ZSH_VERSION+false} || emulate sh; echo $LINENO
5472 Ensure unknown traps are not a syntax error
5475 trap "echo trap 1 executed" UNKNOWNSIGNAL || echo "foo"
5477 trap "echo trap 2 executed" UNKNOWNSIGNAL EXIT 999999 FNORD
5479 ) 2>&1 | sed "s
\ 1^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]
\ 1PROG
\ 1"
5481 PROG: trap: bad signal 'UNKNOWNSIGNAL'
5484 PROG: trap: bad signal 'UNKNOWNSIGNAL'
5485 PROG: trap: bad signal '999999'
5486 PROG: trap: bad signal 'FNORD'
5492 Simple test, default IFS
5497 echo 1: "x[$x] y[$y] z[$z]"
5498 echo 1a: ${z-z not set}
5508 Complex tests, IFS either colon (IFS-NWS) or backslash (tricky)
5511 showargs() { print -nr "$1"; shift; for s_arg in "$@"; do print -nr -- " [$s_arg]"; done; print; }
5512 (IFS=\\ a=\<\\\>; showargs 3 $a)
5513 (IFS=: b=\<:\>; showargs 4 $b)
5514 print -r '<\>' | (IFS=\\ read f g; showargs 5 "$f" "$g")
5515 print -r '<\\>' | (IFS=\\ read f g; showargs 6 "$f" "$g")
5516 print '<\\\n>' | (IFS=\\ read f g; showargs 7 "$f" "$g")
5517 print -r '<\>' | (IFS=\\ read f; showargs 8 "$f")
5518 print -r '<\\>' | (IFS=\\ read f; showargs 9 "$f")
5519 print '<\\\n>' | (IFS=\\ read f; showargs 10 "$f")
5520 print -r '<\>' | (IFS=\\ read -r f g; showargs 11 "$f" "$g")
5521 print -r '<\\>' | (IFS=\\ read -r f g; showargs 12 "$f" "$g")
5522 print '<\\\n>' | (IFS=\\ read -r f g; showargs 13 "$f" "$g")
5523 print -r '<\>' | (IFS=\\ read -r f; showargs 14 "$f")
5524 print -r '<\\>' | (IFS=\\ read -r f; showargs 15 "$f")
5525 print '<\\\n>' | (IFS=\\ read -r f; showargs 16 "$f")
5526 print -r '<:>' | (IFS=: read f g; showargs 17 "$f" "$g")
5527 print -r '<::>' | (IFS=: read f g; showargs 18 "$f" "$g")
5528 print '<:\n>' | (IFS=: read f g; showargs 19 "$f" "$g")
5529 print -r '<:>' | (IFS=: read f; showargs 20 "$f")
5530 print -r '<::>' | (IFS=: read f; showargs 21 "$f")
5531 print '<:\n>' | (IFS=: read f; showargs 22 "$f")
5532 print -r '<:>' | (IFS=: read -r f g; showargs 23 "$f" "$g")
5533 print -r '<::>' | (IFS=: read -r f g; showargs 24 "$f" "$g")
5534 print '<:\n>' | (IFS=: read -r f g; showargs 25 "$f" "$g")
5535 print -r '<:>' | (IFS=: read -r f; showargs 26 "$f")
5536 print -r '<::>' | (IFS=: read -r f; showargs 27 "$f")
5537 print '<:\n>' | (IFS=: read -r f; showargs 28 "$f")
5568 If no var specified, REPLY is used
5576 name: read-regress-1
5578 Check a regression of read
5579 file-setup: file 644 "foo"
5584 while read a b c; do
5588 echo "<$a|$b|$c><$d>"
5594 Check read with delimiters
5597 print -n 'foo bar\tbaz\nblah \0blub\tblech\nmyok meck \0'
5599 emit | while IFS= read -d "" foo; do print -r -- "<$foo>"; done
5600 emit | while read -d "" foo; do print -r -- "<$foo>"; done
5601 emit | while read -d "eh?" foo; do print -r -- "<$foo>"; done
5618 Check read with number of bytes specified, and -A
5620 print 'foo\nbar' >x1
5622 print 'foo\\ bar baz' >x3
5624 x1b=u; read -N-1 x1b <x1
5625 x2a=u; read x2a <x2; r2a=$?
5626 x2b=u; read -N2 x2c <x2; r2b=$?
5627 x2c=u; read -n2 x2c <x2; r2c=$?
5628 x3a=u; read -A x3a <x3
5629 print -r "x1a=<$x1a>"
5630 print -r "x1b=<$x1b>"
5631 print -r "x2a=$r2a<$x2a>"
5632 print -r "x2b=$r2b<$x2b>"
5633 print -r "x2c=$r2c<$x2c>"
5634 print -r "x3a=<${x3a[0]}|${x3a[1]}|${x3a[2]}>"
5646 Lex array code had problems with this.
5657 When PATH is set before running a command, the new path is
5658 not used in doing the path search
5659 $ echo echo hi > /tmp/q ; chmod a+rx /tmp/q
5663 in comexec() the two lines
5665 (void) typeset(*vp++, xxx, 0);
5666 need to be moved out of the switch to before findcom() is
5667 called - I don't know what this will break.
5669 : "${PWD:-`pwd 2> /dev/null`}"
5670 : "${PWD:?"PWD not set - cannot do test"}"
5672 cat > Y/xxxscript << EOF
5674 # Need to restore path so echo can be found (some shells don't have
5680 chmod a+rx Y/xxxscript
5681 export OLDPATH="$PATH"
5682 PATH=$PWD/Y xxxscript
5689 Parsing of $(..) expressions is non-optimal. It is
5690 impossible to have any parentheses inside the expression.
5692 $ ksh -c 'echo $(echo \( )'
5694 $ ksh -c 'echo $(echo "(" )'
5697 The solution is to hack the parsing clode in lex.c, the
5698 question is how to hack it: should any parentheses be
5699 escaped by a backslash, or should recursive parsing be done
5700 (so quotes could also be used to hide hem). The former is
5701 easier, the later better...
5711 Continue in a for loop does not work right:
5713 if [ $i = b ] ; then
5722 if [ $i = b ] ; then
5723 if [ $first = no ] ; then
5724 echo 'continue in for loop broken'
5725 break # hope break isn't broken too :-)
5740 should print 0 according to POSIX (dash, bash, ksh93, posh)
5741 but not 0 according to the getopt(1) manual page, ksh88, and
5742 Bourne sh (such as /bin/sh on Solaris).
5743 We honour POSIX except when -o sh is set.
5744 category: shell:legacy-no
5747 [[ -o posix ]]; FPOSIX=$((1-$?))
5748 [[ -o sh ]]; FSH=$((1-$?))
5749 echo -n "FPOSIX=$FPOSIX FSH=$FSH "
5773 name: regression-10-legacy
5778 should print 0 according to POSIX (dash, bash, ksh93, posh)
5779 but not 0 according to the getopt(1) manual page, ksh88, and
5780 Bourne sh (such as /bin/sh on Solaris).
5781 category: shell:legacy-yes
5784 [[ -o posix ]]; FPOSIX=$((1-$?))
5785 [[ -o sh ]]; FSH=$((1-$?))
5786 echo -n "FPOSIX=$FPOSIX FSH=$FSH "
5815 should echo blah but on some machines echos /foo/bar/blah.
5824 Both of the following echos produce the same output under sh/ksh.att:
5827 echo "`echo \"$x\"`"
5829 pdksh produces different output for the former (foo instead of foo\tbar)
5832 echo "`echo \"$x\"`"
5840 The following command hangs forever:
5841 $ (: ; cat /etc/termcap) | sleep 2
5842 This is because the shell forks a shell to run the (..) command
5843 and this shell has the pipe open. When the sleep dies, the cat
5844 doesn't get a SIGPIPE 'cause a process (ie, the second shell)
5845 still has the pipe open.
5847 NOTE: this test provokes a bizarre bug in ksh93 (shell starts reading
5848 commands from /etc/termcap..)
5851 echo A line of text that will be duplicated quite a number of times.> t1
5852 cat t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 > t2
5853 cat t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 > t1
5854 cat t1 t1 t1 t1 > t2
5855 (: ; cat t2 2>/dev/null) | sleep 1
5860 $ (foobar) 2> /dev/null
5861 generates no output under /bin/sh, but pdksh produces the error
5864 $ foobar 2> /dev/null
5865 generates an error under /bin/sh and pdksh, but AT&T ksh88 produces
5866 no error (redirected to /dev/null).
5868 (you/should/not/see/this/error/1) 2> /dev/null
5869 you/should/not/see/this/error/2 2> /dev/null
5876 generates a blank line under pdksh and sets the exit status to 0.
5877 AT&T ksh88 generates no output and sets the exit status to 1. Also,
5880 generates no output under AT&T ksh88 (pdksh generates a blank line
5883 whence does/not/exist > /dev/null
5885 echo 2: $(whence does/not/exist | wc -l)
5886 echo 3: $(whence does/not/exist cat | wc -l)
5894 ${var%%expr} seems to be broken in many places. On the mips
5896 $ read line < /etc/passwd
5904 change the value of line. On sun4s & pas, the echo ${line%%:*} doesn't
5905 work. Haven't checked elsewhere...
5912 root:asdjhasdasjhs:0:1:Root:/:/bin/sh
5915 root:asdjhasdasjhs:0:1:Root:/:/bin/sh
5921 should set the exit status to non-zero (sh and AT&T ksh88 do).
5922 XXX doting a non existent file is a fatal error for a script
5925 expected-exit: e != 0
5926 expected-stderr-pattern: /.?/
5930 Both of the following echos should produce the same thing, but don't:
5944 backslash does not work as expected in case labels:
5963 Quoting backquotes inside backquotes doesn't work:
5964 $ echo `echo hi \`echo there\` folks`
5965 asks for more info. sh and AT&T ksh88 both echo
5968 echo `echo hi \`echo there\` folks`
5974 )) is not treated `correctly':
5975 $ (echo hi ; (echo there ; echo folks))
5978 instead of (as sh and ksh.att)
5979 $ (echo hi ; (echo there ; echo folks))
5985 ( : ; ( : ; echo hi))
5991 Check reading stdin in a while loop. The read should only read
5992 a single line, not a whole stdio buffer; the cat should get
5995 (echo a; echo b) | while read x ; do
6004 Check reading stdin in a while loop. The read should read both
6005 lines, not just the first.
6008 while [ "$a" != xxx ] ; do
6011 cat /dev/null | sed 's/x/y/'
6025 should cause a script to exit.
6029 expected-exit: e != 0
6030 expected-stderr-pattern: /does\/not\/exist/
6034 variable assignements not detected well
6037 expected-exit: e != 0
6038 expected-stderr-pattern: /a\.x=1/
6042 alias expansion different from AT&T ksh88
6044 alias a='for ' b='i in'
6045 a b hi ; do echo $i ; done
6051 strange characters allowed inside ${...}
6054 expected-exit: e != 0
6055 expected-stderr-pattern: /.?/
6059 Does read handle partial lines correctly
6062 while [ "$a" != xxx ] ; do
6079 Does read set variables to null at eof?
6082 while [ "$a" != xxx ] ; do
6086 echo 1: ${x-x not set} ${y-y not set} ${z-z not set}
6087 echo 2: ${x:+x not null} ${y:+y not null} ${z:+z not null}
6097 Does umask print a leading 0 when umask is 3 digits?
6099 # on MiNT, the first umask call seems to fail
6101 # now, the test proper
6109 Tempory files used for here-docs in functions get trashed after
6110 the function is parsed (before it is executed)
6133 Command substitution breaks reading in while loop
6134 (test from <sjg@void.zen.oz.au>)
6136 (echo abcdef; echo; echo 123) |
6139 # the following line breaks it
6140 c=`echo $line | wc -c`
6150 Machines with broken times() (reported by <sjg@void.zen.oz.au>)
6151 time does not report correct real time
6154 expected-stderr-pattern: !/^\s*0\.0[\s\d]+real|^\s*real[\s]+0+\.0/
6158 set -e doesn't ignore exit codes for if/while/until/&&/||/!.
6161 if false; then echo hi ; fi
6164 while false; do echo hi; done
6171 Only posh and oksh(2013-07) say “hi” below; FreeBSD sh,
6172 GNU bash in POSIX mode, dash, ksh93, mksh don’t. All of
6173 them exit 0. The POSIX behaviour is needed by BSD make.
6176 echo `false; echo hi` $(<this-file-does-not-exist)
6181 expected-stderr-pattern: /this-file-does-not-exist/
6185 This used to cause a core dump
6186 env-setup: !RANDOM=12!
6194 foo should be set to bar (should not be empty)
6204 Can't use command line assignments to assign readonly parameters.
6206 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
6207 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
6208 done >env; chmod +x env; PATH=.$PATHSEP$PATH
6211 foo=stuff env | grep '^foo'
6212 expected-exit: e != 0
6213 expected-stderr-pattern:
6218 Can subshells be prefixed by redirections (historical shells allow
6221 < /dev/null (sed 's/^/X/')
6225 Parameter assignments with [] recognised correctly
6243 Check that alias expansion works in command substitutions and
6256 Check that aliases are fully read.
6269 Check that (here doc) temp files are not left behind after an exec.
6272 TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
6274 sed 's/^/X /' << E_O_F
6281 echo=echo; [ -x /bin/echo ] && echo=/bin/echo
6282 exec $echo subtest-1 hi
6284 echo subtest-1 foo/*
6285 TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
6286 echo=echo; [ -x /bin/echo ] && echo=/bin/echo
6287 sed 's/^/X /' << E_O_F; exec $echo subtest-2 hi
6293 echo subtest-2 foo/*
6305 Check that unset params with attributes are reported by set, those
6306 sans attributes are not.
6322 Check that aliases do not use continuation prompt after trailing
6324 file-setup: file 644 "envf"
6327 env-setup: !ENV=./envf!
6331 alias foo='echo hi ; '
6343 Check that set allows both +o and -o options on same command line.
6346 set -o noglob +o allexport
6353 Check that globbing works in pipelined commands
6354 file-setup: file 644 "envf"
6356 file-setup: file 644 "abc"
6358 env-setup: !ENV=./envf!
6364 sed 's/^/X /' < ab* | sed 's/^/Y /'
6376 Check that getopts works in functions
6379 echo bfunc: enter "(args: $*; OPTIND=$OPTIND)"
6380 while getopts B oc; do
6383 echo bfunc: B option
6386 echo bfunc: odd option "($oc)"
6394 echo kfunc: enter "(args: $*; OPTIND=$OPTIND)"
6395 while getopts K oc; do
6398 echo kfunc: K option
6401 echo bfunc: odd option "($oc)"
6409 echo "line 1: OPTIND=$OPTIND"
6411 echo "line 2: ret=$?, optc=$optc, OPTIND=$OPTIND"
6413 echo "line 3: OPTIND=$OPTIND"
6415 echo "line 4: ret=$?, optc=$optc, OPTIND=$OPTIND"
6417 echo "line 5: OPTIND=$OPTIND"
6419 echo "line 6: ret=$?, optc=$optc, OPTIND=$OPTIND"
6424 echo "line 10: OPTIND=$OPTIND"
6426 echo "line 20: ret=$?, optc=$optc, OPTIND=$OPTIND"
6428 echo "line 30: OPTIND=$OPTIND"
6430 echo "line 40: ret=$?, optc=$optc, OPTIND=$OPTIND"
6432 echo "line 50: OPTIND=$OPTIND"
6434 echo "line 60: ret=$?, optc=$optc, OPTIND=$OPTIND"
6437 line 2: ret=0, optc=f, OPTIND=2
6438 bfunc: enter (args: -BBB blah; OPTIND=2)
6443 line 4: ret=0, optc=b, OPTIND=3
6444 kfunc: enter (args: -KKK blah; OPTIND=1)
6450 line 6: ret=0, optc=k, OPTIND=4
6453 line 20: ret=0, optc=f, OPTIND=2
6454 bfunc: enter (args: -BBB blah; OPTIND=2)
6459 line 40: ret=1, optc=?, OPTIND=2
6460 kfunc: enter (args: -KKK blah; OPTIND=1)
6466 line 60: ret=1, optc=?, OPTIND=2
6470 Check that ; is not required before the then in if (( ... )) then ...
6484 Check ${foo:%bar} is allowed (ksh88 allows it...)
6507 Check if typeset output is correct for
6508 uninitialised array elements.
6512 typeset -i | grep xxx | sed 's/^/ /'
6514 typeset | grep xxx | sed 's/^/ /'
6518 typeset -i | grep xxx | sed 's/^/ /'
6520 typeset | grep xxx | sed 's/^/ /'
6534 Check if trap exit is ok (exit not mistaken for signal name)
6543 Check if ${#array[*]} is calculated correctly.
6553 Check if default exit status is previous command
6559 ( (exit 103) ; exit)
6568 Check if EXIT trap is executed for sub shells.
6570 trap 'echo parent exit' EXIT
6572 (echo A; echo A last)
6574 (echo C; trap 'echo sub exit' EXIT; echo C last)
6589 Check if test -nt/-ot succeeds if second(first) file is missing.
6592 test a -nt b && echo nt OK || echo nt BAD
6593 test b -ot a && echo ot OK || echo ot BAD
6600 Check if typeset, export, and readonly work
6612 integer FNORD_E FNORD_F FNORD_G FNORD_H
6613 export FNORD_C FNORD_D FNORD_G FNORD_H
6614 readonly FNORD_B FNORD_D FNORD_F FNORD_H
6660 typeset -x -r FNORD_D
6662 typeset -i -r FNORD_F
6663 typeset -i -x FNORD_G
6664 typeset -i -x -r FNORD_H
6667 typeset -r FNORD_B=2
6668 typeset -x FNORD_C=3
6669 typeset -x -r FNORD_D=4
6670 typeset -i FNORD_E=5
6671 typeset -i -r FNORD_F=6
6672 typeset -i -x FNORD_G=7
6673 typeset -i -x -r FNORD_H=8
6691 Check that we can redefine functions calling time builtin
6703 check for a regression with sleep builtin and signal mask
6709 while read -p line; do :; done
6716 Check that quoting is sane
6724 while IFS= read -pr line; do
6725 if [[ $line = *space* ]]; then
6731 for line in "${lines[@]}"; do
6740 Check that we can both break and use source on the same line
6742 for s in s; do break; done; print -s s
6746 Check that all common arithmetic operators work as expected
6748 echo 1 $(( a = 5 )) .
6749 echo 2 $(( ++a )) , $(( a++ )) , $(( a )) .
6750 echo 3 $(( --a )) , $(( a-- )) , $(( a )) .
6751 echo 4 $(( a == 5 )) , $(( a == 6 )) .
6752 echo 5 $(( a != 5 )) , $(( a != 6 )) .
6753 echo 6 $(( a *= 3 )) .
6754 echo 7 $(( a /= 5 )) .
6755 echo 8 $(( a %= 2 )) .
6756 echo 9 $(( a += 9 )) .
6757 echo 10 $(( a -= 4 )) .
6758 echo 11 $(( a <<= 1 )) .
6759 echo 12 $(( a >>= 1 )) .
6760 echo 13 $(( a &= 4 )) .
6761 echo 14 $(( a ^= a )) .
6762 echo 15 $(( a |= 5 )) .
6763 echo 16 $(( 5 << 1 )) .
6764 echo 17 $(( 5 >> 1 )) .
6765 echo 18 $(( 5 <= 6 )) , $(( 5 <= 5 )) , $(( 5 <= 4 )) .
6766 echo 19 $(( 5 >= 6 )) , $(( 5 >= 5 )) , $(( 5 >= 4 )) .
6767 echo 20 $(( 5 < 6 )) , $(( 5 < 5 )) , $(( 5 < 4 )) .
6768 echo 21 $(( 5 > 6 )) , $(( 5 > 5 )) , $(( 5 > 4 )) .
6769 echo 22 $(( 0 && 0 )) , $(( 0 && 1 )) , $(( 1 && 0 )) , $(( 1 && 1 )) .
6770 echo 23 $(( 0 || 0 )) , $(( 0 || 1 )) , $(( 1 || 0 )) , $(( 1 || 1 )) .
6771 echo 24 $(( 5 * 3 )) .
6772 echo 25 $(( 7 / 2 )) .
6773 echo 26 $(( 5 % 5 )) , $(( 5 % 4 )) , $(( 5 % 1 )) , $(( 5 % -1 )) , $(( 5 % -2 )) .
6774 echo 27 $(( 5 + 2 )) , $(( 5 + 0 )) , $(( 5 + -2 )) .
6775 echo 28 $(( 5 - 2 )) , $(( 5 - 0 )) , $(( 5 - -2 )) .
6776 echo 29 $(( 6 & 4 )) , $(( 6 & 8 )) .
6777 echo 30 $(( 4 ^ 2 )) , $(( 4 ^ 4 )) .
6778 echo 31 $(( 4 | 2 )) , $(( 4 | 4 )) , $(( 4 | 0 )) .
6779 echo 32 $(( 0 ? 1 : 2 )) , $(( 3 ? 4 : 5 )) .
6780 echo 33 $(( 5 , 2 , 3 )) .
6781 echo 34 $(( ~0 )) , $(( ~1 )) , $(( ~~1 )) , $(( ~~2 )) .
6782 echo 35 $(( !0 )) , $(( !1 )) , $(( !!1 )) , $(( !!2 )) .
6783 echo 36 $(( (5) )) .
6810 26 0 , 1 , 0 , 0 , 1 .
6818 34 -1 , -2 , 1 , 2 .
6824 Check that all non-lksh arithmetic operators work as expected
6825 category: shell:legacy-no
6828 echo 1 $(( a ^<= 1 )) , $(( b ^<= 1 )) .
6829 echo 2 $(( a ^>= 2 )) , $(( b ^>= 2 )) .
6830 echo 3 $(( 5 ^< 1 )) .
6831 echo 4 $(( 5 ^> 1 )) .
6834 2 -2147483646 , -1073741822 .
6840 Ensure readonly is honoured for assignments and unset
6842 "$__progname" -c 'u=x; echo $? $u .' || echo aborted, $?
6844 "$__progname" -c 'readonly u; u=x; echo $? $u .' || echo aborted, $?
6846 "$__progname" -c 'u=x; readonly u; unset u; echo $? $u .' || echo aborted, $?
6853 expected-stderr-pattern:
6858 http://austingroupbugs.net/view.php?id=367 for export
6860 "$__progname" -c 'readonly foo; export foo=a; echo $?' || echo aborted, $?
6863 expected-stderr-pattern:
6868 Check that getopts works as intended, for readonly-2b to be valid
6870 "$__progname" -c 'set -- -a b; getopts a c; echo $? $c .; getopts a c; echo $? $c .' || echo aborted, $?
6877 http://austingroupbugs.net/view.php?id=367 for getopts
6879 "$__progname" -c 'readonly c; set -- -a b; getopts a c; echo $? $c .' || echo aborted, $?
6882 expected-stderr-pattern:
6887 http://austingroupbugs.net/view.php?id=367 for read
6889 echo x | "$__progname" -c 'read s; echo $? $s .' || echo aborted, $?
6890 echo y | "$__progname" -c 'readonly s; read s; echo $? $s .' || echo aborted, $?
6894 expected-stderr-pattern:
6899 Do not permit bypassing readonly for first array item
6901 set -A arr -- foo bar
6904 print -r -- "${arr[@]}"
6905 expected-exit: e != 0
6906 expected-stderr-pattern:
6911 Ensure readonly is idempotent
6918 Check that lone ampersand is a syntax error
6921 expected-exit: e != 0
6922 expected-stderr-pattern:
6925 name: xxx-quoted-newline-1
6927 Check that \<newline> works inside of ${}
6935 name: xxx-quoted-newline-2
6937 Check that \<newline> works at the start of a here document
6946 name: xxx-quoted-newline-3
6948 Check that \<newline> works at the end of a here document
6957 name: xxx-multi-assignment-cmd
6959 Check that assignments in a command affect subsequent assignments
6968 name: xxx-multi-assignment-posix-cmd
6970 Check that the behaviour for multiple assignments with a
6971 command name matches POSIX. See:
6972 http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925
6974 X=a Y=b; X=$Y Y=$X "$__progname" -c 'echo 1 $X $Y .'; echo 2 $X $Y .
6976 X=a Y=${X=b} Z=$X "$__progname" -c 'echo 3 $Z .'
6978 X=a Y=${X=b} Z=$X; echo 4 $Z .
6985 name: xxx-multi-assignment-posix-nocmd
6987 Check that the behaviour for multiple assignments with no
6988 command name matches POSIX (Debian #334182). See:
6989 http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925
6991 X=a Y=b; X=$Y Y=$X; echo 1 $X $Y .
6995 name: xxx-multi-assignment-posix-subassign
6997 Check that the behaviour for multiple assignments matches POSIX:
6998 - The assignment words shall be expanded in the current execution
7000 - The assignments happen in the temporary execution environment.
7003 Z=a Y=${X:=b} sh -c 'echo +$X+ +$Y+ +$Z+'
7005 # Now for the special case:
7007 X= Y=${X:=b} sh -c 'echo +$X+ +$Y+'
7015 name: xxx-exec-environment-1
7017 Check to see if exec sets it's environment correctly
7019 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
7020 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
7021 done >env; chmod +x env; PATH=.$PATHSEP$PATH
7023 expected-stdout-pattern:
7026 name: xxx-exec-environment-2
7028 Check to make sure exec doesn't change environment if a program
7031 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
7032 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
7033 done >env; chmod +x env; PATH=.$PATHSEP$PATH
7035 FOO=bar exec; env >bar2
7038 name: exec-function-environment-1
7040 Check assignments in function calls and whether they affect
7041 the current execution environment (ksh93, SUSv4)
7043 f() { a=2; }; g() { b=3; echo y$c-; }; a=1 f; b=2; c=1 g
7049 name: exec-modern-korn-shell
7051 Check that exec can execute any command that makes it
7052 through syntax and parser
7054 print '#!'"$__progname"'\necho tf' >lq
7058 foo() { print two; }
7067 expected-stdout-pattern:
7068 /=1\none\n=2\ntwo\n=3\n.*: ls: not found\n=4\ntf\n/
7072 Check that exec only executes after a PATH search
7073 arguments: !-o!posix!
7075 print '#!'"$__progname"'\necho tf' >lq
7079 foo() { print two; }
7088 expected-stdout-pattern:
7089 /=1\n.*: print: not found\n=2\n.*: foo: not found\n=3\n.*: ls: not found\n=4\ntf\n/
7091 name: xxx-what-do-you-call-this-1
7097 name: xxx-prefix-strip-1
7104 name: xxx-prefix-strip-2
7112 name: xxx-variable-syntax-1
7115 expected-stderr-pattern:
7119 name: xxx-variable-syntax-2
7123 expected-stderr-pattern:
7127 name: xxx-variable-syntax-3
7131 expected-stderr-pattern:
7135 name: xxx-variable-syntax-4
7137 Not all kinds of trims are currently impossible, check those who do
7140 echo "<$*> X${*:+ }X"
7170 name: xxx-substitution-eval-order
7172 Check order of evaluation of expressions
7175 set -A A abc def GHI j G k
7176 echo ${A[x=(i+=1)]#${A[y=(i+=2)]}}
7182 name: xxx-set-option-1
7184 Check option parsing in set
7186 set -vsA foo -- A 1 3 2
7195 Check that exec exits for built-ins
7203 expected-stderr-pattern: /.*/
7207 Check the return value of while loops
7208 XXX need to do same for for/select/until loops
7211 while [ $i != xxx ] ; do
7213 if [ $i = xxx ] ; then
7221 while [ $i != xxx ] ; do
7223 if [ $i = xxx ] ; then
7231 while [ $i != xxx ] ; do
7243 Check that blank lines don't clear $?
7256 expected-stderr-pattern: /.*/
7260 Check that $? is preserved in subshells, includes, traps.
7269 echo 'echo include: $?' > foo
7273 trap 'echo trap: $?' ERR
7283 name: xxx-clean-chars-1
7285 Check MAGIC character is stuffed correctly
7291 name: xxx-param-subst-qmark-1
7293 Check suppresion of error message with null string. According to
7294 POSIX, it shouldn't print the error as 'word' isn't ommitted.
7295 ksh88/93, Solaris /bin/sh and /usr/xpg4/bin/sh all print the error.
7301 expected-stderr-pattern: !/not set/
7303 name: xxx-param-subst-qmark-namespec
7305 Check special names are output correctly
7308 "$__progname" -c "$@" >o1 2>o2
7311 sed -e "s
\ 1^${__progname%.exe}\.*e*x*e*:
\ 1PROG:
\ 1" -e 's/^/STDOUT: /g' <o1
7312 sed -e "s
\ 1^${__progname%.exe}\.*e*x*e*:
\ 1PROG:
\ 1" -e 's/^/STDERR: /g' <o2
7319 doit -u 'echo ${*:?}' foo ""
7322 STDERR: PROG: ${1x}: bad substitution
7324 STDERR: PROG: ${1x}: bad substitution
7326 STDERR: PROG: 1: parameter null or not set
7328 STDERR: PROG: 19: parameter null or not set
7330 STDERR: PROG: !: parameter null or not set
7332 STDERR: foo: ${*:?}: bad substitution
7335 # fails due to weirdness of execv stuff
7336 category: !os:uwin-nt
7338 Check c flag is set.
7339 arguments: !-c!echo "[$-]"!
7340 expected-stdout-pattern: /^\[.*c.*\]$/
7342 name: tilde-expand-1
7344 Check tilde expansion after equal signs
7345 env-setup: !HOME=/sweet!
7347 echo ${A=a=}~ b=~ c=d~ ~
7349 command command export g=~ h=d~
7354 echo ${A=a=}~ b=~ c=d~ ~
7356 command command export g=~ h=d~
7360 a=/sweet b=/sweet c=d~ /sweet
7367 name: tilde-expand-2
7369 Check tilde expansion works
7370 env-setup: !HOME=/sweet!
7375 x=typeset; $x d=[ab]
7379 plus=$(print -r -- ~+)
7380 minus=$(print -r -- ~-)
7381 nix=$(print -r -- ~)
7382 [[ $plus = / ]]; echo one $? .
7383 [[ $minus = "$wd" ]]; echo two $? .
7384 [[ $nix = /sweet ]]; echo nix $? .
7391 name: tilde-expand-3
7393 Check mostly Austin 351 stuff
7395 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
7398 showargs 1 "$a" "$b" "$c" "$d"
7404 \\builtin export e=~
7405 showargs 2 "$a" "$b" "$c" "$d" "$e" ksh
7411 \\builtin export e=~
7412 showargs 3 "$a" "$b" "$c" "$d" "$e" posix
7416 showargs 4 "$a" "$b" ksh
7420 showargs 6 "$a" "$b" ksh
7424 showargs 7 "$a" "$b" posix
7426 showargs 8 a=$1 posix
7428 showargs 9 "$a" "$b" posix
7431 command echo 10 ksh a=~
7432 command command export a=~
7436 command echo 12 posix a=~
7437 command command export a=~
7440 # unspecified whether /tmp or ~
7441 var=export; command $var a=~
7443 echo 'echo "<$foo>"' >bar
7451 command -- export a=~
7458 showargs 19 "${bla[1]}" a=~ "$gbl" "$lcl" "$ro" "$g2" "$l2" "$r2"
7460 echo "20 some arbitrary stuff "=~
7462 echo "21 some arbitrary stuff "=~
7464 <1> <1 b=2> <> <3> <4> .
7465 <2> </tmp> </tmp> </tmp> </tmp> </tmp> <ksh> .
7466 <3> <~> </tmp> </tmp> <~> </tmp> <posix> .
7467 <4> <1 b=2> <> <ksh> .
7468 <5> <a=1> <b=2> <ksh> .
7470 <7> <1 b=2> <> <posix> .
7471 <8> <a=1> <b=2> <posix> .
7472 <9> <1> <2> <posix> .
7482 <19> </tmp:/tmp> <a=~> </tmp> </tmp> </tmp> <1 b=2> <1 b=2> <1 b=2> .
7483 20 some arbitrary stuff =/tmp
7484 21 some arbitrary stuff =~
7488 Check some "exit on error" conditions
7490 print '#!'"$__progname"'\nexec "$1"' >env
7491 print '#!'"$__progname"'\nexit 1' >false
7495 env false && echo something
7505 Check some "exit on error" edge conditions (POSIXly)
7507 print '#!'"$__progname"'\nexec "$1"' >env
7508 print '#!'"$__progname"'\nexit 1' >false
7509 print '#!'"$__progname"'\nexit 0' >true
7514 env false && echo something
7526 pdksh regression which AT&T ksh does right
7527 TFM says: [set] -e | errexit
7528 Exit (after executing the ERR trap) ...
7530 trap 'echo EXIT' EXIT
7533 cd /XXXXX 2>/dev/null
7539 expected-exit: e != 0
7543 "set -e" test suite (POSIX)
7557 "set -e" test suite (POSIX)
7563 [ "$1" = "$E" ] && { shift ; continue 2 ; }
7580 "set -e" test suite (BSD make)
7584 print 'all:\n\t@echo eins\n\t@exit 42\n' >zd/a/Makefile
7585 print 'all:\n\t@echo zwei\n' >zd/b/Makefile
7588 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"
7594 Stop in WD/zd/a (line 2 of Makefile).
7598 "set -e" regression (LP#1104543)
7602 [ -x $PWD/nonexistant ] && $PWD/nonexistant
7613 "set -e" regression (Debian #700526)
7616 _db_cmd() { return $1; }
7617 db_input() { _db_cmd 30; }
7618 db_go() { _db_cmd 0; }
7625 "set -e" versus bang pipelines
7638 SUSv4 says that the shell should exit with 126/127 in some situations
7642 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
7643 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
7645 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
7646 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
7648 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
7649 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
7660 Check eval vs substitution exit codes (ksh93 alike)
7672 eval "eval $(false)"
7675 eval 'eval '"$(false)"
7679 eval $(echo :; false)
7697 Check that "exit" with no arguments behaves SUSv4 conformant.
7699 trap 'echo hi; exit' EXIT
7707 Check that ERR and EXIT traps are run just like ksh93 does.
7708 GNU bash does not run ERtrap in ±e eval-undef but runs it
7709 twice (bug?) in +e eval-false, so does ksh93 (bug?), which
7710 also has a bug to continue execution (echoing "and out" and
7711 returning 0) in +e eval-undef.
7712 file-setup: file 644 "x"
7714 trap 'echo EXtrap' EXIT
7715 trap 'echo ERtrap' ERR
7720 file-setup: file 644 "xt"
7722 trap 'echo EXtrap' EXIT
7723 trap 'echo ERtrap' ERR
7728 file-setup: file 644 "xf"
7730 trap 'echo EXtrap' EXIT
7731 trap 'echo ERtrap' ERR
7733 echo 'and run false'
7736 file-setup: file 644 "xu"
7738 trap 'echo EXtrap' EXIT
7739 trap 'echo ERtrap' ERR
7741 echo 'and run ${v?}'
7751 -e 's/parameter not set/parameter null or not set/' \
7752 -e 's/[[]6]//' -e 's/: eval: line 1//' -e 's/: line 6//' \
7753 -e "s
\ 1^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]
\ 1PROG
\ 1"
7758 echo = eval-true $(<rc) .
7760 echo = eval-false $(<rc) .
7761 runtest x $xe '${v?}'
7762 echo = eval-undef $(<rc) .
7764 echo = noeval-true $(<rc) .
7766 echo = noeval-false $(<rc) .
7768 echo = noeval-undef $(<rc) .
7772 echo = eval-true $(<rc) .
7774 echo = eval-false $(<rc) .
7775 runtest x $xe '${v?}'
7776 echo = eval-undef $(<rc) .
7778 echo = noeval-true $(<rc) .
7780 echo = noeval-false $(<rc) .
7782 echo = noeval-undef $(<rc) .
7794 x: v: parameter null or not set
7807 xu: v: parameter null or not set
7821 x: v: parameter null or not set
7835 xu: v: parameter null or not set
7839 name: exit-trap-interactive
7841 Check that interactive shell doesn't exit via EXIT trap on syntax error
7846 echo 'After error 1'
7847 trap 'echo Exit trap' EXIT
7849 echo 'After error 2'
7850 trap 'echo Exit trap' EXIT
7857 expected-stderr-pattern:
7858 /syntax error: unexpected 'newline'/
7862 Check that test also can handle string1 < string2 etc.
7864 test 2005/10/08 '<' 2005/08/21 && echo ja || echo nein
7865 test 2005/08/21 \< 2005/10/08 && echo ja || echo nein
7866 test 2005/10/08 '>' 2005/08/21 && echo ja || echo nein
7867 test 2005/08/21 \> 2005/10/08 && echo ja || echo nein
7873 expected-stderr-pattern: !/unexpected op/
7875 name: test-precedence-1
7877 Check a weird precedence case (and POSIX echo)
7887 Test the test -o operator
7892 [[ -o $1 ]]; echo $?
7895 test -o $1 -o -o !$1; echo $?
7896 [ -o $1 -o -o !$1 ]; echo $?
7897 [[ -o $1 || -o !$1 ]]; echo $?
7898 test -o ?$1; echo $?
7900 echo 0y $(if_test utf8-mode) =
7901 echo 0n $(if_test utf8-hack) =
7902 echo 1= $(runtest utf8-hack) =
7903 echo 2= $(runtest !utf8-hack) =
7904 echo 3= $(runtest ?utf8-hack) =
7906 echo 1+ $(runtest utf8-mode) =
7907 echo 2+ $(runtest !utf8-mode) =
7908 echo 3+ $(runtest ?utf8-mode) =
7910 echo 1- $(runtest utf8-mode) =
7911 echo 2- $(runtest !utf8-mode) =
7912 echo 3- $(runtest ?utf8-mode) =
7913 echo = short flags =
7914 echo 0y $(if_test -U) =
7915 echo 0y $(if_test +U) =
7916 echo 0n $(if_test -_) =
7917 echo 0n $(if_test -U-) =
7918 echo 1= $(runtest -_) =
7919 echo 2= $(runtest !-_) =
7920 echo 3= $(runtest ?-_) =
7922 echo 1+ $(runtest -U) =
7923 echo 2+ $(runtest !-U) =
7924 echo 3+ $(runtest ?-U) =
7925 echo 1+ $(runtest +U) =
7926 echo 2+ $(runtest !+U) =
7927 echo 3+ $(runtest ?+U) =
7929 echo 1- $(runtest -U) =
7930 echo 2- $(runtest !-U) =
7931 echo 3- $(runtest ?-U) =
7932 echo 1- $(runtest +U) =
7933 echo 2- $(runtest !+U) =
7934 echo 3- $(runtest ?+U) =
7970 Test the test -v operator
7973 rv=$?; echo $((++i)) $rv
7976 rv=$?; echo $((++i)) $rv
7979 rv=$?; echo $((++i)) $rv
7982 rv=$?; echo $((++i)) $rv
7985 rv=$?; echo $((++i)) $rv
7988 rv=$?; echo $((++i)) $rv
7991 rv=$?; echo $((++i)) $rv
7993 rv=$?; echo $((++i)) $rv
7995 rv=$?; echo $((++i)) $rv
7997 rv=$?; echo $((++i)) $rv
8012 test -v works only on scalars
8016 expected-exit: e != 0
8017 expected-stderr-pattern:
8022 Check that the short form [ $x ] works
8026 rv=$?; echo $((++i)) $rv
8028 rv=$?; echo $((++i)) $rv
8030 rv=$?; echo $((++i)) $rv
8032 rv=$?; echo $((++i)) $rv
8035 rv=$?; echo $((++i)) $rv
8037 rv=$?; echo $((++i)) $rv
8039 rv=$?; echo $((++i)) $rv
8041 rv=$?; echo $((++i)) $rv
8044 rv=$?; echo $((++i)) $rv
8046 rv=$?; echo $((++i)) $rv
8048 rv=$?; echo $((++i)) $rv
8050 rv=$?; echo $((++i)) $rv
8067 Check that the short form [[ $x ]] works (ksh93 extension)
8071 rv=$?; echo $((++i)) $rv
8073 rv=$?; echo $((++i)) $rv
8075 rv=$?; echo $((++i)) $rv
8077 rv=$?; echo $((++i)) $rv
8080 rv=$?; echo $((++i)) $rv
8082 rv=$?; echo $((++i)) $rv
8084 rv=$?; echo $((++i)) $rv
8086 rv=$?; echo $((++i)) $rv
8089 rv=$?; echo $((++i)) $rv
8091 rv=$?; echo $((++i)) $rv
8093 rv=$?; echo $((++i)) $rv
8095 rv=$?; echo $((++i)) $rv
8112 Check numeric -eq works (R40d regression); spotted by Martijn Dekker
8117 (0) echo yepp 0 \#"$*" ;;
8118 (1) echo nope 1 \#"$*" ;;
8119 (2) echo terr 2 \#"$*" ;;
8120 (*) echo wtf\? $? \#"$*" ;;
8123 tst 1 'test 2 -eq 2'
8124 tst 2 'test 2 -eq 2a'
8125 tst 3 'test 2 -eq 3'
8126 tst 4 'test 2 -ne 2'
8127 tst 5 'test 2 -ne 2a'
8128 tst 6 'test 2 -ne 3'
8129 tst 7 'test \! 2 -eq 2'
8130 tst 8 'test \! 2 -eq 2a'
8131 tst 9 'test \! 2 -eq 3'
8133 yepp 0 #1 test 2 -eq 2
8134 terr 2 #2 test 2 -eq 2a
8135 nope 1 #3 test 2 -eq 3
8136 nope 1 #4 test 2 -ne 2
8137 terr 2 #5 test 2 -ne 2a
8138 yepp 0 #6 test 2 -ne 3
8139 nope 1 #7 test \! 2 -eq 2
8140 terr 2 #8 test \! 2 -eq 2a
8141 yepp 0 #9 test \! 2 -eq 3
8142 expected-stderr-pattern:
8147 Check that ~/.mkshrc works correctly.
8148 Part 1: verify user environment is not read (internal)
8156 Check that ~/.mkshrc works correctly.
8157 Part 2: verify mkshrc is not read (non-interactive shells)
8158 file-setup: file 644 ".mkshrc"
8160 env-setup: !HOME=.!ENV=!
8168 Check that ~/.mkshrc works correctly.
8169 Part 2: verify mkshrc can be read (interactive shells)
8170 file-setup: file 644 ".mkshrc"
8174 env-setup: !HOME=.!ENV=!PS1=!
8179 expected-stderr-pattern:
8184 Check that ~/.mkshrc works correctly.
8185 Part 3: verify mkshrc can be turned off
8186 file-setup: file 644 ".mkshrc"
8188 env-setup: !HOME=.!ENV=nonexistant!
8196 Check that sh mode turns braceexpand off
8197 and that that works correctly
8201 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
8202 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
8210 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
8211 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
8214 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
8215 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
8231 Check that posix or sh mode is *not* automatically turned on
8234 ln -s "$__progname" ksh || cp "$__progname" ksh
8235 ln -s "$__progname" sh || cp "$__progname" sh
8236 ln -s "$__progname" ./-ksh || cp "$__progname" ./-ksh
8237 ln -s "$__progname" ./-sh || cp "$__progname" ./-sh
8238 for shell in {,-}{,k}sh; do
8239 print -- $shell $(./$shell +l -c \
8240 '[[ $(set +o) == *"-o "@(sh|posix)@(| *) ]] && echo sh || echo nosh')
8250 Check that posix or sh mode *is* automatically turned on
8253 ln -s "$__progname" ksh || cp "$__progname" ksh
8254 ln -s "$__progname" sh || cp "$__progname" sh
8255 ln -s "$__progname" ./-ksh || cp "$__progname" ./-ksh
8256 ln -s "$__progname" ./-sh || cp "$__progname" ./-sh
8257 for shell in {,-}{,k}sh; do
8258 print -- $shell $(./$shell +l -c \
8259 '[[ $(set +o) == *"-o "@(sh|posix)@(| *) ]] && echo sh || echo nosh')
8269 pdksh bug: last command of a pipeline is executed in a
8270 subshell - make sure it still is, scripts depend on it
8271 file-setup: file 644 "abcx"
8272 file-setup: file 644 "abcy"
8275 echo a | while read d; do
8295 check that co-processes work with TCOMs, TPIPEs and TPARENs
8298 "$__progname" -c 'i=100; echo hi |& while read -p line; do echo "$((i++)) $line"; done'
8299 "$__progname" -c 'i=200; echo hi | cat |& while read -p line; do echo "$((i++)) $line"; done'
8300 "$__progname" -c 'i=300; (echo hi | cat) |& while read -p line; do echo "$((i++)) $line"; done'
8308 Check that PIPESTATUS does what it's supposed to
8310 echo 1 $PIPESTATUS .
8311 echo 2 ${PIPESTATUS[0]} .
8312 echo 3 ${PIPESTATUS[1]} .
8313 (echo x; exit 12) | (cat; exit 23) | (cat; exit 42)
8314 echo 5 $? , $PIPESTATUS , ${PIPESTATUS[0]} , ${PIPESTATUS[1]} , ${PIPESTATUS[2]} , ${PIPESTATUS[3]} .
8315 echo 6 ${PIPESTATUS[0]} .
8316 set | fgrep PIPESTATUS
8317 echo 8 $(set | fgrep PIPESTATUS) .
8323 5 42 , 12 , 12 , 23 , 42 , .
8326 8 PIPESTATUS[0]=0 PIPESTATUS[1]=0 .
8330 Check that "set -o pipefail" does what it's supposed to
8332 echo 1 "$("$__progname" -c '(exit 12) | (exit 23) | (exit 42); echo $?')" .
8333 echo 2 "$("$__progname" -c '! (exit 12) | (exit 23) | (exit 42); echo $?')" .
8334 echo 3 "$("$__progname" -o pipefail -c '(exit 12) | (exit 23) | (exit 42); echo $?')" .
8335 echo 4 "$("$__progname" -o pipefail -c '! (exit 12) | (exit 23) | (exit 42); echo $?')" .
8336 echo 5 "$("$__progname" -c '(exit 23) | (exit 42) | :; echo $?')" .
8337 echo 6 "$("$__progname" -c '! (exit 23) | (exit 42) | :; echo $?')" .
8338 echo 7 "$("$__progname" -o pipefail -c '(exit 23) | (exit 42) | :; echo $?')" .
8339 echo 8 "$("$__progname" -o pipefail -c '! (exit 23) | (exit 42) | :; echo $?')" .
8340 echo 9 "$("$__progname" -o pipefail -c 'x=$( (exit 23) | (exit 42) | :); echo $?')" .
8352 name: persist-history-1
8354 Check if persistent history saving works
8355 category: !no-histfile
8358 env-setup: !ENV=./Env!HISTFILE=hist.file!
8359 file-setup: file 644 "Env"
8363 expected-stdout-pattern:
8365 expected-stderr-pattern:
8370 Check that typeset -g works correctly
8374 typeset -g -Uui16 arrfoo[*]
8376 echo before ${arrfoo[0]} .
8378 echo after ${arrfoo[0]} .
8381 echo inside before ${arrbar[0]} .
8383 echo inside changed ${arrbar[0]} .
8384 typeset -g -Uui16 arrbar[*]
8385 echo inside typeset ${arrbar[0]} .
8387 echo inside changed ${arrbar[0]} .
8389 echo before ${arrbar[0]} .
8391 echo after ${arrbar[0]} .
8398 inside typeset 16#61 .
8399 inside changed 16#30 .
8404 Check that typeset -p on arrays works correctly
8420 name: typeset-padding-1
8422 Check if left/right justification works as per TFM
8424 typeset -L10 ln=0hall0
8425 typeset -R10 rn=0hall0
8426 typeset -ZL10 lz=0hall0
8427 typeset -ZR10 rz=0hall0
8428 typeset -Z10 rx=" hallo "
8429 echo "<$ln> <$rn> <$lz> <$rz> <$rx>"
8431 <0hall0 > < 0hall0> <hall0 > <00000hall0> <0000 hallo>
8433 name: typeset-padding-2
8435 Check if base-!10 integers are padded right
8437 typeset -Uui16 -L9 ln=16#1
8438 typeset -Uui16 -R9 rn=16#1
8439 typeset -Uui16 -Z9 zn=16#1
8443 echo "<$ln> <$rn> <$zn> <$ls> <$rs> <$zs>"
8445 <16#1 > < 16#1> <16#000001> <16#1 > < 16#1> <0000016#1>
8449 Check that the UTF-8 Byte Order Mark is ignored as the first
8450 multibyte character of the shell input (with -c, from standard
8451 input, as file, or as eval argument), but nowhere else
8452 # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
8453 category: !os:darwin,!shell:ebcdic-yes
8456 print '#!/bin/sh\necho ohne' >foo/fnord
8457 print '#!/bin/sh\necho mit' >foo/fnord
8458 print 'fnord\nfnord\nfnord\nfnord' >foo/bar
8459 print eval \''fnord\nfnord\nfnord\nfnord'\' >foo/zoo
8460 set -A anzahl -- foo/*
8461 echo got ${#anzahl[*]} files
8463 export PATH=$(pwd)/foo$PATHSEP$PATH
8464 "$__progname" -c 'fnord'
8466 "$__progname" -c 'fnord; fnord; fnord; fnord'
8468 "$__progname" foo/bar
8470 "$__progname" <foo/bar
8472 "$__progname" foo/zoo
8474 "$__progname" -c 'echo : $(fnord)'
8504 Check that we can execute BOM-shebangs (failures not fatal)
8505 XXX if the OS can already execute them, we lose
8506 note: cygwin execve(2) doesn't return to us with ENOEXEC, we lose
8507 note: Ultrix perl5 t4 returns 65280 (exit-code 255) and no text
8508 XXX fails when LD_PRELOAD is set with -e and Perl chokes it (ASan)
8510 category: !os:cygwin,!os:msys,!os:ultrix,!os:uwin-nt,!smksh
8511 env-setup: !FOO=BAR!
8513 print '#!'"$__progname"'\nprint "1 a=$ENV{FOO}";' >t1
8514 print '#!'"$__progname"'\nprint "2 a=$ENV{FOO}";' >t2
8515 print '#!'"$__perlname"'\nprint "3 a=$ENV{FOO}\n";' >t3
8516 print '#!'"$__perlname"'\nprint "4 a=$ENV{FOO}\n";' >t4
8523 1 a=/nonexistant{FOO}
8524 2 a=/nonexistant{FOO}
8527 expected-stderr-pattern:
8528 /(Unrecognized character .... ignored at \..t4 line 1)*/
8532 Check that the utf8-mode flag is not set at non-interactive startup
8533 env-setup: !PS1=!PS2=!LC_CTYPE=@utflocale@!
8535 if [[ $- = *U* ]]; then
8545 Check that the utf8-mode flag is set at interactive startup.
8546 If your OS is old, try passing HAVE_SETLOCALE_CTYPE=0 to Build.sh
8551 env-setup: !PS1=!PS2=!LC_CTYPE=@utflocale@!
8553 if [[ $- = *U* ]]; then
8560 expected-stderr-pattern:
8565 Ensure ±U on the command line is honoured
8566 (these two tests may pass falsely depending on CPPFLAGS)
8569 code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi'
8570 let i++; "$__progname" -U -c "$code"
8571 let i++; "$__progname" +U -c "$code"
8580 Ensure ±U on the command line is honoured, interactive shells
8584 code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi'
8585 let i++; "$__progname" -U -ic "$code"
8586 let i++; "$__progname" +U -ic "$code"
8595 Ensure trailing combining characters are not lost
8616 Check if built-in shell aliases are okay
8621 autoload='\\builtin typeset -fu'
8622 functions='\\builtin typeset -f'
8623 hash='\\builtin alias -t'
8624 history='\\builtin fc -l'
8625 integer='\\builtin typeset -i'
8626 local='\\builtin typeset'
8627 login='\\builtin exec login'
8628 nameref='\\builtin typeset -n'
8630 r='\\builtin fc -e -'
8631 type='\\builtin whence -v'
8635 Check if “set -o sh” does not influence built-in aliases
8641 autoload='\\builtin typeset -fu'
8642 functions='\\builtin typeset -f'
8643 hash='\\builtin alias -t'
8644 history='\\builtin fc -l'
8645 integer='\\builtin typeset -i'
8646 local='\\builtin typeset'
8647 login='\\builtin exec login'
8648 nameref='\\builtin typeset -n'
8650 r='\\builtin fc -e -'
8651 type='\\builtin whence -v'
8655 Check if running as sh does not influence built-in aliases
8658 ./sh -c 'alias; typeset -f'
8661 autoload='\\builtin typeset -fu'
8662 functions='\\builtin typeset -f'
8663 hash='\\builtin alias -t'
8664 history='\\builtin fc -l'
8665 integer='\\builtin typeset -i'
8666 local='\\builtin typeset'
8667 login='\\builtin exec login'
8668 nameref='\\builtin typeset -n'
8670 r='\\builtin fc -e -'
8671 type='\\builtin whence -v'
8673 name: aliases-cmdline
8675 Check that aliases work from the command line (Debian #517009)
8676 Note that due to the nature of the lexing process, defining
8677 aliases in COMSUBs then immediately using them, and things
8678 like 'alias foo=bar && foo', still fail.
8680 "$__progname" -c $'alias a="echo OK"\na'
8684 name: aliases-funcdef-1
8686 Check if POSIX functions take precedences over aliases
8688 alias foo='echo makro'
8696 name: aliases-funcdef-2
8698 Check if POSIX functions take precedences over aliases
8700 alias foo='echo makro'
8708 name: aliases-funcdef-3
8710 Check if aliases take precedences over Korn functions
8712 alias foo='echo makro'
8720 name: aliases-funcdef-4
8722 Functions should only take over if actually being defined
8728 local='\\builtin typeset'
8729 local='\\builtin typeset'
8733 Check if Korn Shell arrays work as expected
8736 set -A foo -- a \$v "$v" '$v' b
8737 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
8743 Check if bash-style arrays work as expected
8746 foo=(a \$v "$v" '$v' b)
8747 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
8753 Check if bash-style arrays work as expected, with newlines
8755 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "$x|"; done' >pfp
8757 test -n "$ZSH_VERSION" && setopt KSH_ARRAYS
8763 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
8768 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
8773 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
8775 7|a|bc|d|$v|e f|$v|g|
8776 7|a|bc|d|$v|e f|$v|g|
8777 6|abc\|d|$v|e f|$v|g||
8781 Check if array bounds are uint32_t
8788 echo ${foo[4294967295]} g ${foo[*]}
8795 Check if Korn Shell arrays with specified indices work as expected
8798 set -A foo -- [1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b
8799 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|"
8800 # we don't want this at all:
8802 set -A arr "[5]=meh"
8803 echo "<${arr[0]}><${arr[5]}>"
8805 5|[1]=$v|[2]=c d|[4]=$v|[0]=a|[5]=b||
8810 Check if bash-style arrays with specified indices work as expected
8811 (taken out temporarily to fix arrays-4; see also arrays-9a comment)
8815 foo=([1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b)
8816 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|"
8817 x=([128]=foo bar baz)
8820 # Check that we do not break this by globbing
8825 echo "<${arr[0]}><${arr[5]}>"
8834 Check if we can get the array keys (indices) for indexed arrays,
8840 echo -n "$((i++))<$x>"
8851 echo a $(of ${foo[*]}) = $(of ${bar[*]}) a
8852 echo b $(of "${foo[*]}") = $(of "${bar[*]}") b
8853 echo c $(of ${foo[@]}) = $(of ${bar[@]}) c
8854 echo d $(of "${foo[@]}") = $(of "${bar[@]}") d
8855 echo e $(of ${!foo[*]}) = $(of ${!bar[*]}) e
8856 echo f $(of "${!foo[*]}") = $(of "${!bar[*]}") f
8857 echo g $(of ${!foo[@]}) = $(of ${!bar[@]}) g
8858 echo h $(of "${!foo[@]}") = $(of "${!bar[@]}") h
8866 a 0<zwei>1<eins>2<drei> = a
8867 b 0<zwei eins drei> = 0<> b
8868 c 0<zwei>1<eins>2<drei> = c
8869 d 0<zwei>1<eins>2<drei> = d
8877 Check if we can get the array keys (indices) for indexed arrays,
8878 Korn shell style, in some corner cases
8881 echo !arz[0]: ${!arz[0]}
8882 echo !arz[1]: ${!arz[1]}
8885 echo !arz[0]: ${!arz[0]}
8886 echo !arz[1]: ${!arz[1]}
8889 echo !arz[0]: ${!arz[0]}
8890 echo !arz[1]: ${!arz[1]}
8904 Check some behavioural rules for arrays.
8942 typeset -Z3 aa ab ac ad ae af ag
8987 Check that we can concatenate arrays
8989 unset foo; foo=(bar); foo+=(baz); echo 1 ${!foo[*]} : ${foo[*]} .
8990 unset foo; foo=(foo bar); foo+=(baz); echo 2 ${!foo[*]} : ${foo[*]} .
8991 # unset foo; foo=([2]=foo [0]=bar); foo+=(baz [5]=quux); echo 3 ${!foo[*]} : ${foo[*]} .
8994 2 0 1 2 : foo bar baz .
8995 # 3 0 2 3 5 : bar foo baz quux .
8999 Check that we can concatenate parameters too
9001 unset foo; foo=bar; foo+=baz; echo 1 $foo .
9002 unset foo; typeset -i16 foo=10; foo+=20; echo 2 $foo .
9007 name: arrassign-basic
9009 Check basic whitespace conserving properties of wdarrassign
9017 c+=("$(echo "c d")")
9019 echo ".a:${a[0]}.${a[1]}.${a[2]}.${a[3]}:"
9020 echo ".b:${b[0]}.${b[1]}.${b[2]}.${b[3]}:"
9021 echo ".c:${c[0]}.${c[1]}.${c[2]}.${c[3]}:"
9022 echo ".d:${d[0]}.${d[1]}.${d[2]}.${d[3]}:"
9029 name: arrassign-fnc-none
9031 Check locality of array access inside a function
9035 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
9038 if [[ -n $BASH_VERSION ]]; then
9044 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
9048 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
9050 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
9052 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
9053 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
9055 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
9057 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
9070 name: arrassign-fnc-local
9072 Check locality of array access inside a function
9073 with the bash/mksh/ksh93 local/typeset keyword
9074 (note: ksh93 has no local; typeset works only in FKSH)
9079 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
9082 if [[ -n $BASH_VERSION ]]; then
9089 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
9093 if [[ -n $BASH_VERSION ]]; then
9099 echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
9104 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
9106 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
9108 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
9109 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
9111 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
9113 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
9114 echo ".f0r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
9116 echo ".f1r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
9118 echo ".f2r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
9136 name: arrassign-fnc-global
9138 Check locality of array access inside a function
9139 with the bash4/mksh/yash/zsh typeset -g keyword
9144 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
9150 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
9156 echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
9161 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
9163 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
9165 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
9166 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
9168 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
9170 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
9171 echo ".f0r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
9173 echo ".f1r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
9175 echo ".f2r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
9193 name: strassign-fnc-none
9195 Check locality of string access inside a function
9230 name: strassign-fnc-local
9232 Check locality of string access inside a function
9233 with the bash/mksh/ksh93 local/typeset keyword
9234 (note: ksh93 has no local; typeset works only in FKSH)
9288 name: strassign-fnc-global
9290 Check locality of string access inside a function
9291 with the bash4/mksh/yash/zsh typeset -g keyword
9345 name: unset-fnc-local-ksh
9347 Check that “unset” removes a previous “local”
9348 (ksh93 syntax compatible version); apparently,
9349 there are shells which fail this?
9375 name: unset-fnc-local-sh
9377 Check that “unset” removes a previous “local”
9378 (Debian Policy §10.4 sh version); apparently,
9379 there are shells which fail this?
9405 name: varexpand-substr-1
9407 Check if bash-style substring expansion works
9408 when using positive numerics
9411 typeset -i y=123456789
9412 typeset -i 16 z=123456789 # 16#75bcd15
9413 echo a t${x:2:2} ${y:2:3} ${z:2:3} a
9414 echo b ${x::3} ${y::3} ${z::3} b
9415 echo c ${x:2:} ${y:2:} ${z:2:} c
9416 echo d ${x:2} ${y:2} ${z:2} d
9417 echo e ${x:2:6} ${y:2:6} ${z:2:7} e
9418 echo f ${x:2:7} ${y:2:7} ${z:2:8} f
9419 echo g ${x:2:8} ${y:2:8} ${z:2:9} g
9424 d cdefghi 3456789 #75bcd15 d
9425 e cdefgh 345678 #75bcd1 e
9426 f cdefghi 3456789 #75bcd15 f
9427 g cdefghi 3456789 #75bcd15 g
9429 name: varexpand-substr-2
9431 Check if bash-style substring expansion works
9432 when using negative numerics or expressions
9435 typeset -i y=123456789
9436 typeset -i 16 z=123456789 # 16#75bcd15
9438 echo a ${x:$n:3} ${y:$n:3} ${z:$n:3} a
9439 echo b ${x:(n):3} ${y:(n):3} ${z:(n):3} b
9440 echo c ${x:(-2):1} ${y:(-2):1} ${z:(-2):1} c
9441 echo d t${x: n:2} ${y: n:3} ${z: n:3} d
9448 name: varexpand-substr-3
9450 Check that some things that work in bash fail.
9451 This is by design. Oh and vice versa, nowadays.
9453 export x=abcdefghi n=2
9454 "$__progname" -c 'echo v${x:(n)}x'
9455 "$__progname" -c 'echo w${x: n}x'
9456 "$__progname" -c 'echo x${x:n}x'
9457 "$__progname" -c 'echo y${x:}x'
9458 "$__progname" -c 'echo z${x}x'
9459 # next fails only in bash
9460 "$__progname" -c 'x=abcdef;y=123;echo ${x:${y:2:1}:2}' >/dev/null 2>&1; echo $?
9466 expected-stderr-pattern:
9467 /x:n.*bad substitution.*\n.*bad substitution/
9469 name: varexpand-substr-4
9471 Check corner cases for substring expansion
9475 echo a ${x:(y == 1 ? 2 : 3):4} a
9479 name: varexpand-substr-5A
9481 Check that substring expansions work on characters
9485 echo a ${x::1} ${x: -1} a
9486 echo b ${x::3} ${x: -3} b
9487 echo c ${x:1:2} ${x: -3:2} c
9495 name: varexpand-substr-5W
9497 Check that substring expansions work on characters
9501 echo a ${x::1} ${x: -1} a
9502 echo b ${x::2} ${x: -2} b
9503 echo c ${x:1:1} ${x: -2:1} c
9511 name: varexpand-substr-6
9513 Check that string substitution works correctly
9518 echo a ${baz: foo: bar}
9519 echo b ${baz: foo: $bar}
9520 echo c ${baz: $foo: bar}
9521 echo d ${baz: $foo: $bar}
9528 name: varexpand-special-hash
9530 Check special ${var@x} expansion for x=hash
9531 category: !shell:ebcdic-yes
9536 print ${foo@#} ${bar@#} ${baz@#} .
9538 9B15FBFB CFBDD32B 00000000 .
9540 name: varexpand-special-hash-ebcdic
9542 Check special ${var@x} expansion for x=hash
9543 category: !shell:ebcdic-no
9548 print ${foo@#} ${bar@#} ${baz@#} .
9550 016AE33D 9769C4AF 00000000 .
9552 name: varexpand-special-quote
9554 Check special ${var@Q} expansion for quoted strings
9555 category: !shell:faux-ebcdic
9562 print -r -- "<i=$i j=$j k=$k>"
9563 s="u=${i@Q} v=${j@Q} w=${k@Q}"
9564 print -r -- "s=\"$s\""
9570 s="u=x v='a b' w=$'c\nd\240e\u20ACf'"
9573 typeset w=$'c\nd\240e\u20ACf'
9575 name: varexpand-special-quote-faux-EBCDIC
9577 Check special ${var@Q} expansion for quoted strings
9578 category: shell:faux-ebcdic
9585 print -r -- "<i=$i j=$j k=$k>"
9586 s="u=${i@Q} v=${j@Q} w=${k@Q}"
9587 print -r -- "s=\"$s\""
9593 s="u=x v='a b' w=$'c\nd e\u20ACf'"
9596 typeset w=$'c\nd e\u20ACf'
9598 name: varexpand-null-1
9600 Ensure empty strings expand emptily
9602 print s ${a} . ${b} S
9603 print t ${a#?} . ${b%?} T
9604 print r ${a=} . ${b/c/d} R
9606 print s "${a}" . "${b}" S
9607 print t "${a#?}" . "${b%?}" T
9608 print r "${a=}" . "${b/c/d}" R
9618 name: varexpand-null-2
9620 Ensure empty strings, when quoted, are expanded as empty strings
9622 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "<$x> "; done' >pfs
9624 ./pfs 1 "${a}" 2 "${a#?}" + "${b%?}" 3 "${a=}" + "${b/c/d}"
9627 <1> <> <2> <> <+> <> <3> <> <+> <> .
9629 name: varexpand-null-3
9631 Ensure concatenating behaviour matches other shells
9633 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; }
9635 x=; showargs 1 "$x"$@
9636 set A; showargs 2 "${@:+}"
9670 name: varexpand-funny-chars
9672 Check some characters
9673 XXX \uEF80 is asymmetric, possibly buggy so we don’t check this
9675 x=$'<\x00>'; typeset -p x
9676 x=$'<\x01>'; typeset -p x
9677 x=$'<\u0000>'; typeset -p x
9678 x=$'<\u0001>'; typeset -p x
9685 name: print-funny-chars
9687 Check print builtin's capability to output designated characters
9690 print '<\0144\0344\xDB\u00DB\u20AC\uDB\x40>'
9696 # integer-base-one-3Ar
9697 typeset -Uui16 -Z11 pos=0
9698 typeset -Uui16 -Z5 hv=2147483647
9700 if read -arN -1 line; then
9703 while (( i < ${#line[*]} )); do
9705 if (( (pos & 15) == 0 )); then
9706 (( pos )) && print -r -- "$dasc|"
9707 print -n "${pos#16#} "
9710 print -n "${hv#16#} "
9711 if (( (hv < 32) || (hv > 126) )); then
9714 dasc=$dasc${line[i-1]#1#}
9716 (( (pos++ & 15) == 7 )) && print -n -- '- '
9719 while (( pos & 15 )); do
9721 (( (pos++ & 15) == 7 )) && print -n -- '- '
9723 (( hv == 2147483647 )) || print -r -- "$dasc|"
9726 00000000 3C 64 E4 DB C3 9B E2 82 - AC C3 9B 40 3E 0A 3C 00 |<d.........@>.<.|
9727 00000010 3E 0A 3C 01 3E 0A 3C 00 - 3E 0A 3C 01 3E 0A |>.<.>.<.>.<.>.|
9731 Check print builtin's \c escape
9733 print '\ca'; print b
9739 Check that CR+LF is not collapsed into LF as some MSYS shells wrongly do
9741 echo '#!'"$__progname" >foo
9743 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'
9748 ./foo | while IFS= read -r line; do
9749 print -r -- "{$line}"
9752 [220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT
\r
9753 220->> Bitte keine Werbung einwerfen! <<
\r\r
9754 220 Who do you wanna pretend to be today?
\r]
9755 {220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT
\r}
9756 {220->> Bitte keine Werbung einwerfen! <<
\r\r}
9757 {220 Who do you wanna pretend to be today?
\r}
9761 Check that CR+LF is shown and read as-is
9762 category: shell:textmode-no
9768 if test x"$KSH_VERSION" = x""; then #
\r
9769 printf '<%s>' "$x" #
\r
9771 print -nr -- "<$x>" #
\r
9774 echo "[$("$__progname" foo)]"
9775 "$__progname" foo | while IFS= read -r line; do
9776 print -r -- "{$line}"
9785 name: print-crlf-textmode
9787 Check that CR+LF is treated as newline
9788 category: shell:textmode-yes
9794 if test x"$KSH_VERSION" = x""; then #
\r
9795 printf '<%s>' "$x" #
\r
9797 print -nr -- "<$x>" #
\r
9800 echo "[$("$__progname" foo)]"
9801 "$__progname" foo | while IFS= read -r line; do
9802 print -r -- "{$line}"
9813 Check that LF-only is shown and read as-is
9819 if test x"$KSH_VERSION" = x""; then #
9820 printf '<%s>' "$x" #
9822 print -nr -- "<$x>" #
9825 echo "[$("$__progname" foo)]"
9826 "$__progname" foo | while IFS= read -r line; do
9827 print -r -- "{$line}"
9836 name: print-nul-chars
9838 Check handling of NUL characters for print and COMSUB
9841 print $(($(print '<\0>' | wc -c))) $(($(print "$x" | wc -c))) \
9843 expected-stdout-pattern:
9848 Check that print -A works as expected
9850 print -An 0x20AC 0xC3 0xBC 8#101
9852 print -A 0x20AC 0xC3 0xBC 8#102
9858 Check backslash expansion by the print builtin
9860 print '\ \!\"\#\$\%\&'\\\''\(\)\*\+\,\-\.\/\0\1\2\3\4\5\6\7\8' \
9861 '\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T' \
9862 '\U\V\W\X\Y\Z\[\\\]\^\_\`\a\b \d\e\f\g\h\i\j\k\l\m\n\o\p' \
9863 '\q\r\s\t\u\v\w\x\y\z\{\|\}\~' '\u20acd' '\U20acd' '\x123' \
9864 '\0x' '\0123' '\01234' | {
9865 # integer-base-one-3As
9866 typeset -Uui16 -Z11 pos=0
9867 typeset -Uui16 -Z5 hv=2147483647
9871 while IFS= read -r line; do
9873 while [[ -n $line ]]; do
9875 if (( (pos & 15) == 0 )); then
9876 (( pos )) && print -r -- "$dasc|"
9877 print -n "${pos#16#} "
9880 print -n "${hv#16#} "
9881 if (( (hv < 32) || (hv > 126) )); then
9884 dasc=$dasc${line::1}
9886 (( (pos++ & 15) == 7 )) && print -n -- '- '
9890 while (( pos & 15 )); do
9892 (( (pos++ & 15) == 7 )) && print -n -- '- '
9894 (( hv == 2147483647 )) || print -r -- "$dasc|"
9897 00000000 5C 20 5C 21 5C 22 5C 23 - 5C 24 5C 25 5C 26 5C 27 |\ \!\"\#\$\%\&\'|
9898 00000010 5C 28 5C 29 5C 2A 5C 2B - 5C 2C 5C 2D 5C 2E 5C 2F |\(\)\*\+\,\-\.\/|
9899 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|
9900 00000030 20 5C 39 5C 3A 5C 3B 5C - 3C 5C 3D 5C 3E 5C 3F 5C | \9\:\;\<\=\>\?\|
9901 00000040 40 5C 41 5C 42 5C 43 5C - 44 1B 5C 46 5C 47 5C 48 |@\A\B\C\D.\F\G\H|
9902 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|
9903 00000060 5C 51 5C 52 5C 53 5C 54 - 20 5C 55 5C 56 5C 57 5C |\Q\R\S\T \U\V\W\|
9904 00000070 58 5C 59 5C 5A 5C 5B 5C - 5C 5D 5C 5E 5C 5F 5C 60 |X\Y\Z\[\\]\^\_\`|
9905 00000080 07 08 20 20 5C 64 1B 0C - 5C 67 5C 68 5C 69 5C 6A |.. \d..\g\h\i\j|
9906 00000090 5C 6B 5C 6C 5C 6D 0A 5C - 6F 5C 70 20 5C 71 0D 5C |\k\l\m.\o\p \q.\|
9907 000000A0 73 09 5C 75 0B 5C 77 5C - 78 5C 79 5C 7A 5C 7B 5C |s.\u.\w\x\y\z\{\|
9908 000000B0 7C 5C 7D 5C 7E 20 E2 82 - AC 64 20 EF BF BD 20 12 ||\}\~ ...d ... .|
9909 000000C0 33 20 78 20 53 20 53 34 - 0A |3 x S S4.|
9911 name: dollar-doublequoted-strings
9913 Check that a $ preceding "…" is ignored
9915 echo $"Localise me!"
9920 I do not take a $V for a V!
9925 I do not take a $V for a V!
9927 name: dollar-quoted-strings
9929 Check backslash expansion by $'…' strings
9931 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
9933 ./pfn $'\ \!\"\#\$\%\&\'\(\)\*\+\,\-\.\/ \1\2\3\4\5\6' \
9934 $'a\0b' $'a\01b' $'\7\8\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I' \
9935 $'\J\K\L\M\N\O\P\Q\R\S\T\U1\V\W\X\Y\Z\[\\\]\^\_\`\a\b\d\e' \
9936 $'\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u1\v\w\x1\y\z\{\|\}\~ $x' \
9937 $'\u20acd' $'\U20acd' $'\x123' $'fn\x0rd' $'\0234' $'\234' \
9938 $'\2345' $'\ca' $'\c!' $'\c?' $'\c…' $'a\
9940 # integer-base-one-3As
9941 typeset -Uui16 -Z11 pos=0
9942 typeset -Uui16 -Z5 hv=2147483647
9946 while IFS= read -r line; do
9948 while [[ -n $line ]]; do
9950 if (( (pos & 15) == 0 )); then
9951 (( pos )) && print -r -- "$dasc|"
9952 print -n "${pos#16#} "
9955 print -n "${hv#16#} "
9956 if (( (hv < 32) || (hv > 126) )); then
9959 dasc=$dasc${line::1}
9961 (( (pos++ & 15) == 7 )) && print -n -- '- '
9965 while (( pos & 15 )); do
9967 (( (pos++ & 15) == 7 )) && print -n -- '- '
9969 (( hv == 2147483647 )) || print -r -- "$dasc|"
9972 00000000 20 21 22 23 24 25 26 27 - 28 29 2A 2B 2C 2D 2E 2F | !"#$%&'()*+,-./|
9973 00000010 20 01 02 03 04 05 06 0A - 61 0A 61 01 62 0A 07 38 | .......a.a.b..8|
9974 00000020 39 3A 3B 3C 3D 3E 3F 40 - 41 42 43 44 1B 46 47 48 |9:;<=>?@ABCD.FGH|
9975 00000030 49 0A 4A 4B 4C 4D 4E 4F - 50 51 52 53 54 01 56 57 |I.JKLMNOPQRST.VW|
9976 00000040 58 59 5A 5B 5C 5D 5E 5F - 60 07 08 64 1B 0A 0C 67 |XYZ[\]^_`..d...g|
9977 00000050 68 69 6A 6B 6C 6D 0A 6F - 70 71 0D 73 09 01 0B 77 |hijklm.opq.s...w|
9978 00000060 01 79 7A 7B 7C 7D 7E 20 - 24 78 0A E2 82 AC 64 0A |.yz{|}~ $x....d.|
9979 00000070 EF BF BD 0A C4 A3 0A 66 - 6E 0A 13 34 0A 9C 0A 9C |.......fn..4....|
9980 00000080 35 0A 01 0A 01 0A 7F 0A - 82 80 A6 0A 61 0A 62 0A |5...........a.b.|
9982 name: dollar-quotes-in-heredocs-strings
9984 They are, however, not parsed in here documents, here strings
9985 (outside of string delimiters) or regular strings, but in
9986 parameter substitutions.
9989 dollar = strchr(s, '$'); /* ' */
9995 cat <<<"dollar = strchr(s, '$'); /* ' */"
9996 cat <<<'dollar = strchr(s, '\''$'\''); /* '\'' */'
9997 x="dollar = strchr(s, '$'); /* ' */"
10000 unset nl; print -r -- "x${nl:=$'\n'}y"
10006 # probably never reached for here strings?
10007 cat <<<"3 foo\"bar"
10008 cat <<<"4 foo\\\"bar"
10009 cat <<<'5 foo\"bar'
10010 # old scripts use this (e.g. ncurses)
10012 # make sure this works, outside of quotes
10015 dollar = strchr(s, '$'); /* ' */
10018 dollar = strchr(s, '$'); /* ' */
10019 dollar = strchr(s, '$'); /* ' */
10020 dollar = strchr(s, '$'); /* ' */
10032 name: dot-needs-argument
10034 check Debian #415167 solution: '.' without arguments should fail
10037 "$__progname" -c source
10038 expected-exit: e != 0
10039 expected-stderr-pattern:
10040 /\.: missing argument.*\n.*source: missing argument/
10042 name: dot-errorlevel
10044 Ensure dot resets $?
10053 name: alias-function-no-conflict
10055 make aliases not conflict with function definitions
10057 # POSIX function can be defined, but alias overrides it
10058 alias foo='echo bar'
10065 foo 2>/dev/null || echo rab
10066 # alias overrides ksh function
10067 alias korn='echo bar'
10073 # alias temporarily overrides POSIX function
10078 alias bla='echo bal'
10092 name: bash-function-parens
10094 ensure the keyword function is ignored when preceding
10095 POSIX style function declarations (bashism)
10098 echo '#!'"$__progname"
10100 echo ' echo "bar='\''$0'\'\"
10102 print -r -- "${2:-foo}"
10104 mk 'function foo' >f-korn
10105 mk 'foo ()' >f-dash
10106 mk 'function foo ()' >f-bash
10107 print '#!'"$__progname"'\nprint -r -- "${0%/f-argh}"' >f-argh
10110 x="korn: $(./f-korn)"; echo "${x/@("$u")/.}"
10111 x="dash: $(./f-dash)"; echo "${x/@("$u")/.}"
10112 x="bash: $(./f-bash)"; echo "${x/@("$u")/.}"
10115 dash: bar='./f-dash'
10116 bash: bar='./f-bash'
10118 name: integer-base-one-1
10120 check if the use of fake integer base 1 works
10123 typeset -Uui16 i0=1#ï i1=1#â
\82¬
10125 typeset -i1 o1a=0x263A
10126 typeset -Uui1 o0b=0x7E
10127 typeset -Uui1 o1b=0xFDD0
10128 integer px=0xCAFE 'p0=1# ' p1=1#… pl=1#f
10129 echo "in <$i0> <$i1>"
10130 echo "out <${o0a#1#}|${o0b#1#}> <${o1a#1#}|${o1b#1#}>"
10131 typeset -Uui1 i0 i1
10132 echo "pass <$px> <$p0> <$p1> <$pl> <${i0#1#}|${i1#1#}>"
10133 typeset -Uui16 tv1=1#~ tv2=1#
\7f tv3=1#
\80 tv4=1#
\81 tv5=1#À tv6=1#Á tv7=1#Â tv8=1#Â
\80
10134 echo "specX <${tv1#16#}> <${tv2#16#}> <${tv3#16#}> <${tv4#16#}> <${tv5#16#}> <${tv6#16#}> <${tv7#16#}> <${tv8#16#}>"
10135 typeset -i1 tv1 tv2 tv3 tv4 tv5 tv6 tv7 tv8
10136 echo "specW <${tv1#1#}> <${tv2#1#}> <${tv3#1#}> <${tv4#1#}> <${tv5#1#}> <${tv6#1#}> <${tv7#1#}> <${tv8#1#}>"
10137 typeset -i1 xs1=0xEF7F xs2=0xEF80 xs3=0xFDD0
10138 echo "specU <${xs1#1#}> <${xs2#1#}> <${xs3#1#}>"
10140 in <16#EFEF> <16#20AC>
10142 pass <16#cafe> <1# > <1#â
\80¦> <1#f> <ï|â
\82¬>
10143 specX <7E> <7F> <EF80> <EF81> <EFC0> <EFC1> <A0> <80>
10144 specW <~> <
\7f> <
\80> <
\81> <À> <Á> <Â > <Â
\80>
10145 specU <> <
\80> <ï·
\90>
10147 name: integer-base-one-2a
10149 check if the use of fake integer base 1 stops at correct characters
10154 expected-stderr-pattern:
10155 /1#foo: unexpected 'oo'/
10156 expected-exit: e != 0
10158 name: integer-base-one-2b
10160 check if the use of fake integer base 1 stops at correct characters
10165 expected-stderr-pattern:
10166 /1#À
\80: unexpected '
\80'/
10167 expected-exit: e != 0
10169 name: integer-base-one-2c1
10171 check if the use of fake integer base 1 stops at correct characters
10179 name: integer-base-one-2c2
10181 check if the use of fake integer base 1 stops at correct characters
10186 expected-stderr-pattern:
10187 /1#â
\80¦: unexpected '
\80'/
10188 expected-exit: e != 0
10190 name: integer-base-one-2d1
10192 check if the use of fake integer base 1 handles octets okay
10196 echo /$x/ # invalid utf-8
10200 name: integer-base-one-2d2
10202 check if the use of fake integer base 1 handles octets
10206 echo /$x/ # invalid 2-byte
10210 name: integer-base-one-2d3
10212 check if the use of fake integer base 1 handles octets
10216 echo /$x/ # invalid 2-byte
10220 name: integer-base-one-2d4
10222 check if the use of fake integer base 1 stops at invalid input
10225 typeset -i16 x=1#ï¿À
10226 echo /$x/ # invalid 3-byte
10227 expected-stderr-pattern:
10228 /1#ï¿À: unexpected '¿'/
10229 expected-exit: e != 0
10231 name: integer-base-one-2d5
10233 check if the use of fake integer base 1 stops at invalid input
10236 typeset -i16 x=1#À
\80
10237 echo /$x/ # non-minimalistic
10238 expected-stderr-pattern:
10239 /1#À
\80: unexpected '
\80'/
10240 expected-exit: e != 0
10242 name: integer-base-one-2d6
10244 check if the use of fake integer base 1 stops at invalid input
10247 typeset -i16 x=1#à
\80\80
10248 echo /$x/ # non-minimalistic
10249 expected-stderr-pattern:
10250 /1#à
\80\80: unexpected '
\80'/
10251 expected-exit: e != 0
10253 name: integer-base-one-3As
10255 some sample code for hexdumping
10256 not NUL safe; input lines must be NL terminated
10259 print 'Hello, World!\\\nこんにちは!'
10260 typeset -Uui16 i=0x100
10261 # change that to 0xFF once we can handle embedded
10262 # NUL characters in strings / here documents
10263 while (( i++ < 0x1FF )); do
10264 print -n "\x${i#16#1}"
10268 # integer-base-one-3As
10269 typeset -Uui16 -Z11 pos=0
10270 typeset -Uui16 -Z5 hv=2147483647
10271 typeset -i1 wc=0x0A
10274 while IFS= read -r line; do
10276 while [[ -n $line ]]; do
10278 if (( (pos & 15) == 0 )); then
10279 (( pos )) && print -r -- "$dasc|"
10280 print -n "${pos#16#} "
10283 print -n "${hv#16#} "
10284 if (( (hv < 32) || (hv > 126) )); then
10287 dasc=$dasc${line::1}
10289 (( (pos++ & 15) == 7 )) && print -n -- '- '
10293 while (( pos & 15 )); do
10295 (( (pos++ & 15) == 7 )) && print -n -- '- '
10297 (( hv == 2147483647 )) || print -r -- "$dasc|"
10300 00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..|
10301 00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................|
10302 00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................|
10303 00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................|
10304 00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.|
10305 00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>|
10306 00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN|
10307 00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^|
10308 00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn|
10309 00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~|
10310 000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................|
10311 000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................|
10312 000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................|
10313 000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................|
10314 000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................|
10315 000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................|
10316 00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................|
10317 00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................|
10318 00000120 FF 7A 0A - |.z.|
10320 name: integer-base-one-3Ws
10322 some sample code for hexdumping Unicode
10323 not NUL safe; input lines must be NL terminated
10327 print 'Hello, World!\\\nこんにちは!'
10328 typeset -Uui16 i=0x100
10329 # change that to 0xFF once we can handle embedded
10330 # NUL characters in strings / here documents
10331 while (( i++ < 0x1FF )); do
10332 print -n "\u${i#16#1}"
10335 print \\xff # invalid utf-8
10336 print \\xc2 # invalid 2-byte
10337 print \\xef\\xbf\\xc0 # invalid 3-byte
10338 print \\xc0\\x80 # non-minimalistic
10339 print \\xe0\\x80\\x80 # non-minimalistic
10340 print '�' # end of range
10341 print '\0z' # embedded NUL
10343 # integer-base-one-3Ws
10344 typeset -Uui16 -Z11 pos=0
10345 typeset -Uui16 -Z7 hv
10346 typeset -i1 wc=0x0A
10350 while IFS= read -r line; do
10353 while (( lpos < ${#line} )); do
10354 wc=1#${line:(lpos++):1}
10355 if (( (wc < 32) || \
10356 ((wc > 126) && (wc < 160)) )); then
10358 elif (( (wc & 0xFF80) == 0xEF80 )); then
10363 if (( (pos & 7) == 7 )); then
10366 elif (( (pos & 7) == 0 )); then
10367 (( pos )) && print -r -- "$dasc|"
10368 print -n "${pos#16#} "
10372 print -n "${hv#16#} "
10373 (( (pos++ & 7) == 3 )) && \
10378 while (( pos & 7 )); do
10380 (( (pos++ & 7) == 3 )) && print -n -- '- '
10382 (( hv == 2147483647 )) || print -r -- "$dasc|"
10385 00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W|
10386 00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.こ|
10387 00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |んにちは!...|
10388 00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........|
10389 00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........|
10390 00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........|
10391 00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"|
10392 00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*|
10393 00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012|
10394 00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:|
10395 00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB|
10396 00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ|
10397 00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR|
10398 00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ|
10399 00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab|
10400 00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij|
10401 00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr|
10402 00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz|
10403 00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....|
10404 00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........|
10405 000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........|
10406 000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........|
10407 000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |..... ¡¢|
10408 000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA |£¤¥¦§¨©ª|
10409 000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 |«¬®¯°±²|
10410 000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA |³´µ¶·¸¹º|
10411 000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 |»¼½¾¿ÀÁÂ|
10412 000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA |ÃÄÅÆÇÈÉÊ|
10413 000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 |ËÌÍÎÏÐÑÒ|
10414 000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA |ÓÔÕÖ×ØÙÚ|
10415 000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 |ÛÜÝÞßàáâ|
10416 000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA |ãäåæçèéê|
10417 00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 |ëìíîïðñò|
10418 00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA |óôõö÷øùú|
10419 00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |ûüýþÿ.�.|
10420 00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |�.���.��|
10421 00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |.���.���|
10422 00000128 EFBE EFEF EFBF EFBF - 000A 007A 000A |����.z.|
10424 name: integer-base-one-3Ar
10426 some sample code for hexdumping; NUL and binary safe
10429 print 'Hello, World!\\\nこんにちは!'
10430 typeset -Uui16 i=0x100
10431 # change that to 0xFF once we can handle embedded
10432 # NUL characters in strings / here documents
10433 while (( i++ < 0x1FF )); do
10434 print -n "\x${i#16#1}"
10438 # integer-base-one-3Ar
10439 typeset -Uui16 -Z11 pos=0
10440 typeset -Uui16 -Z5 hv=2147483647
10442 if read -arN -1 line; then
10445 while (( i < ${#line[*]} )); do
10447 if (( (pos & 15) == 0 )); then
10448 (( pos )) && print -r -- "$dasc|"
10449 print -n "${pos#16#} "
10452 print -n "${hv#16#} "
10453 if (( (hv < 32) || (hv > 126) )); then
10456 dasc=$dasc${line[i-1]#1#}
10458 (( (pos++ & 15) == 7 )) && print -n -- '- '
10461 while (( pos & 15 )); do
10463 (( (pos++ & 15) == 7 )) && print -n -- '- '
10465 (( hv == 2147483647 )) || print -r -- "$dasc|"
10468 00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..|
10469 00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................|
10470 00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................|
10471 00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................|
10472 00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.|
10473 00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>|
10474 00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN|
10475 00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^|
10476 00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn|
10477 00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~|
10478 000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................|
10479 000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................|
10480 000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................|
10481 000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................|
10482 000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................|
10483 000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................|
10484 00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................|
10485 00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................|
10486 00000120 FF 00 7A 0A - |..z.|
10488 name: integer-base-one-3Wr
10490 some sample code for hexdumping Unicode; NUL and binary safe
10494 print 'Hello, World!\\\nこんにちは!'
10495 typeset -Uui16 i=0x100
10496 # change that to 0xFF once we can handle embedded
10497 # NUL characters in strings / here documents
10498 while (( i++ < 0x1FF )); do
10499 print -n "\u${i#16#1}"
10502 print \\xff # invalid utf-8
10503 print \\xc2 # invalid 2-byte
10504 print \\xef\\xbf\\xc0 # invalid 3-byte
10505 print \\xc0\\x80 # non-minimalistic
10506 print \\xe0\\x80\\x80 # non-minimalistic
10507 print '�' # end of range
10508 print '\0z' # embedded NUL
10510 # integer-base-one-3Wr
10511 typeset -Uui16 -Z11 pos=0
10512 typeset -Uui16 -Z7 hv=2147483647
10514 if read -arN -1 line; then
10517 while (( i < ${#line[*]} )); do
10519 if (( (hv < 32) || \
10520 ((hv > 126) && (hv < 160)) )); then
10522 elif (( (hv & 0xFF80) == 0xEF80 )); then
10525 dch=${line[i-1]#1#}
10527 if (( (pos & 7) == 7 )); then
10530 elif (( (pos & 7) == 0 )); then
10531 (( pos )) && print -r -- "$dasc|"
10532 print -n "${pos#16#} "
10535 print -n "${hv#16#} "
10536 (( (pos++ & 7) == 3 )) && \
10541 while (( pos & 7 )); do
10543 (( (pos++ & 7) == 3 )) && print -n -- '- '
10545 (( hv == 2147483647 )) || print -r -- "$dasc|"
10548 00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W|
10549 00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.こ|
10550 00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |んにちは!...|
10551 00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........|
10552 00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........|
10553 00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........|
10554 00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"|
10555 00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*|
10556 00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012|
10557 00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:|
10558 00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB|
10559 00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ|
10560 00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR|
10561 00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ|
10562 00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab|
10563 00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij|
10564 00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr|
10565 00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz|
10566 00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....|
10567 00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........|
10568 000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........|
10569 000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........|
10570 000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |..... ¡¢|
10571 000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA |£¤¥¦§¨©ª|
10572 000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 |«¬®¯°±²|
10573 000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA |³´µ¶·¸¹º|
10574 000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 |»¼½¾¿ÀÁÂ|
10575 000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA |ÃÄÅÆÇÈÉÊ|
10576 000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 |ËÌÍÎÏÐÑÒ|
10577 000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA |ÓÔÕÖ×ØÙÚ|
10578 000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 |ÛÜÝÞßàáâ|
10579 000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA |ãäåæçèéê|
10580 00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 |ëìíîïðñò|
10581 00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA |óôõö÷øùú|
10582 00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |ûüýþÿ.�.|
10583 00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |�.���.��|
10584 00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |.���.���|
10585 00000128 EFBE EFEF EFBF EFBF - 000A 0000 007A 000A |����..z.|
10587 name: integer-base-one-4
10589 Check if ksh93-style base-one integers work
10594 (echo 2f $(('aa'))) 2>&1 | sed "s/^[^']*'/2p '/"
10602 2p 'aa': multi-character character constant
10608 name: integer-base-one-5A
10610 Check to see that we’re NUL and Unicode safe
10611 category: !shell:ebcdic-yes
10614 print 'a\0b\xfdz' >x
10620 16#61 16#0 16#62 16#FD 16#7A .
10622 name: integer-base-one-5E
10624 Check to see that we’re NUL and Unicode safe
10625 category: !shell:ebcdic-no
10628 print 'a\0b\xfdz' >x
10634 16#81 16#0 16#82 16#FD 16#A9 .
10636 name: integer-base-one-5W
10638 Check to see that we’re NUL and Unicode safe
10647 16#61 16#0 16#62 16#20AC 16#63 .
10651 Check that ulimit as used in dot.mksh works or is stubbed
10657 Check if we can use a specific syntax idiom for ulimit
10658 XXX Haiku works, but only for -n and -V
10659 category: !os:haiku,!os:syllable
10661 if ! x=$(ulimit -d) || [[ $x = unknown ]]; then
10662 #echo expected to fail on this OS
10665 ulimit -dS $x && echo okay
10672 Check some of the most basic invariants of I/O redirection
10677 print -u2 e$((i++)).
10702 Check if GNU bash-like I/O redirection works
10703 Part 1: this is also supported by GNU bash
10706 function threeout {
10722 Check if GNU bash-like I/O redirection works
10723 Part 2: this is *not* supported by GNU bash
10726 function threeout {
10742 Check if GNU bash-like I/O redirection works
10743 Part 2: this is *not* supported by GNU bash
10746 function threeout {
10751 threeout 3>foo &>&3
10762 Check if GNU bash-like I/O redirection works
10763 Part 2: this is supported by GNU bash 4 only
10768 function threeout {
10785 Check if GNU bash-like I/O redirection fails correctly
10786 Part 1: this is also supported by GNU bash
10791 function threeout {
10802 expected-stderr-pattern: /.*: can't (create|overwrite) .*/
10806 Check if GNU bash-like I/O redirection fails correctly
10807 Part 2: this is *not* supported by GNU bash
10812 function threeout {
10828 Check if GNU bash-like I/O redirection works
10829 Part 4: this is also supported by GNU bash,
10830 but failed in some mksh versions
10833 function threeout {
10839 [[ -e bar ]] && threeout "$bf" &>foo
10854 Check if GNU bash-like I/O redirection is only supported
10855 in !POSIX !sh mode as it breaks existing scripts' syntax
10857 :>x; echo 1 "$("$__progname" -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
10858 :>x; echo 2 "$("$__progname" -o posix -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
10859 :>x; echo 3 "$("$__progname" -o sh -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
10870 for n in ${a#*=}; do echo 1hu ${n} .; done
10871 for n in "${a#*=}"; do echo 1hq ${n} .; done
10872 for n in ${a##*=}; do echo 2hu ${n} .; done
10873 for n in "${a##*=}"; do echo 2hq ${n} .; done
10874 for n in ${a%=*}; do echo 1pu ${n} .; done
10875 for n in "${a%=*}"; do echo 1pq ${n} .; done
10876 for n in ${a%%=*}; do echo 2pu ${n} .; done
10877 for n in "${a%%=*}"; do echo 2pq ${n} .; done
10884 name: oksh-and-list-error-1
10886 Test exit status of rightmost element in 2 element && list in -e mode
10889 echo "should not print"
10891 expected-exit: e != 0
10893 name: oksh-and-list-error-2
10895 Test exit status of rightmost element in 3 element && list in -e mode
10897 true && true && false
10898 echo "should not print"
10900 expected-exit: e != 0
10902 name: oksh-or-list-error-1
10904 Test exit status of || list in -e mode
10907 echo "should not print"
10909 expected-exit: e != 0
10911 name: oksh-longline-crash
10913 This used to cause a core dump
10916 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"
10917 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"
10918 for deplib in $deplibs; do
10921 new_libs="$deplib $new_libs"
10924 case " $specialdeplibs " in
10926 new_libs="$deplib $new_libs";;
10932 name: oksh-seterror-1
10934 The -e flag should be ignored when executing a compound list
10935 followed by an if statement.
10937 if true; then false && false; fi
10940 expected-exit: e == 0
10942 name: oksh-seterror-2
10944 The -e flag should be ignored when executing a compound list
10945 followed by an if statement.
10947 if true; then if true; then false && false; fi; fi
10950 expected-exit: e == 0
10952 name: oksh-seterror-3
10954 The -e flag should be ignored when executing a compound list
10955 followed by an elif statement.
10957 if true; then :; elif true; then false && false; fi
10959 expected-exit: e == 0
10961 name: oksh-seterror-4
10963 The -e flag should be ignored when executing a pipeline
10972 expected-exit: e == 0
10974 name: oksh-seterror-5
10976 The -e flag should be ignored when executing a pipeline
10982 expected-exit: e == 0
10984 name: oksh-seterror-6
10986 When trapping ERR and EXIT, both traps should run in -e mode
10987 when an error occurs.
10989 trap 'echo EXIT' EXIT
10990 trap 'echo ERR' ERR
10996 expected-exit: e != 0
11001 name: oksh-seterror-7
11003 The -e flag within a command substitution should be honored
11005 echo $( set -e; false; echo foo )
11010 name: oksh-input-comsub
11012 A command substitution using input redirection should exit with
11013 failure if the input file does not exist.
11015 var=$(< non-existent)
11016 expected-exit: e != 0
11017 expected-stderr-pattern: /non-existent/
11019 name: oksh-empty-for-list
11021 A for list which expands to zero items should not execute the body.
11023 set foo bar baz ; for out in ; do echo $out ; done
11025 name: oksh-varfunction-mod1
11027 (Inspired by PR 2450 on OpenBSD.) Calling
11029 where f is a ksh style function, should not set FOO in the current
11030 env. If f is a Bourne style function, FOO should be set. Furthermore,
11031 the function should receive a correct value of FOO. However, differing
11032 from oksh, setting FOO in the function itself must change the value in
11033 setting FOO in the function itself should not change the value in
11034 global environment.
11036 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
11037 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
11038 done >env; chmod +x env; PATH=.$PATHSEP$PATH
11040 if [ x$FOO != xbar ]; then
11044 x=$(env | grep FOO)
11045 if [ "x$x" != "xFOO=bar" ]; then
11053 if [ x$FOO != xbar ]; then
11057 x=$(env | grep FOO)
11058 if [ "x$x" != "xFOO=bar" ]; then
11066 if [ $? != 0 ]; then
11069 if [ x$FOO != x ]; then
11073 if [ $? != 0 ]; then
11076 if [ x$FOO != xfoo ]; then
11081 if [ $? != 0 ]; then
11084 if [ x$FOO != xbarbar ]; then
11088 if [ $? != 0 ]; then
11091 if [ x$FOO != xfoo ]; then
11097 Verify that file descriptors > 2 are private for Korn shells
11098 AT&T ksh93 does this still, which means we must keep it as well
11099 XXX fails on some old Perl installations
11104 open(my \$fh, ">&", 9) or die "E: open \$!";
11105 syswrite(\$fh, "Fowl\\n", 5) or die "E: write \$!";
11110 expected-exit: e != 0
11111 expected-stderr-pattern:
11116 Verify that file descriptors > 2 are not private for POSIX shells
11117 See Debian Bug #154540, Closes: #499139
11118 XXX fails on some old Perl installations
11123 open(my \$fh, ">&", 9) or die "E: open \$!";
11124 syswrite(\$fh, "Fowl\\n", 5) or die "E: write \$!";
11127 test -n "$POSH_VERSION" || set -o posix
11135 COMSUB are now parsed recursively, so this works
11136 see also regression-6: matching parenthesēs bug
11137 Fails on: pdksh bash2 bash3 zsh
11138 Passes on: bash4 ksh93 mksh(20110313+)
11140 echo 1 $(case 1 in (1) echo yes;; (2) echo no;; esac) .
11141 echo 2 $(case 1 in 1) echo yes;; 2) echo no;; esac) .
11142 TEST=1234; echo 3 ${TEST: $(case 1 in (1) echo 1;; (*) echo 2;; esac)} .
11143 TEST=5678; echo 4 ${TEST: $(case 1 in 1) echo 1;; *) echo 2;; esac)} .
11144 a=($(case 1 in (1) echo 1;; (*) echo 2;; esac)); echo 5 ${a[0]} .
11145 a=($(case 1 in 1) echo 1;; *) echo 2;; esac)); echo 6 ${a[0]} .
11156 COMSUB are now parsed recursively, so this works
11157 Fails on: pdksh bash2 bash3 bash4 zsh
11158 Passes on: ksh93 mksh(20110313+)
11160 echo 1 $(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10)) .
11161 echo 2 $(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20)) .
11162 (( a = $(case 1 in (1) echo 1;; (*) echo 2;; esac) )); echo 3 $a .
11163 (( a = $(case 1 in 1) echo 1;; *) echo 2;; esac) )); echo 4 $a .
11164 a=($(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10))); echo 5 ${a[0]} .
11165 a=($(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20))); echo 6 ${a[0]} .
11176 RedHat BZ#496791 – another case of missing recursion
11177 in parsing COMSUB expressions
11178 Fails on: pdksh bash2 bash3¹ bash4¹ zsh
11179 Passes on: ksh93 mksh(20110305+)
11180 ① bash[34] seem to choke on comment ending with backslash-newline
11182 # a comment with " ' \
11185 # a comment with " ' \
11193 Extended test for COMSUB explaining why a recursive parser
11194 is a must (a non-recursive parser cannot pass all three of
11195 these test cases, especially the ‘#’ is difficult)
11197 print '#!'"$__progname"'\necho 1234' >id; chmod +x id; PATH=.$PATHSEP$PATH
11198 echo $(typeset -i10 x=16#20; echo $x)
11199 echo $(typeset -Uui16 x=16#$(id -u)
11202 typeset -Uui16 a=36#foo; c=2
11203 typeset -Uui16 b=36 #foo; d=2
11212 Check the tree dump functions for !MKSH_SMALL functionality
11215 x() { case $1 in u) echo x ;;& *) echo $1 ;; esac; }
11231 Check COMSUB works with aliases (does not expand them twice)
11232 and reentrancy safety
11234 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
11236 alias echo='echo a'
11239 ./pfn "$(echo foo)"
11252 ./pfn "$(\echo a foo )"
11258 ./pfn "$(\echo a foo )"
11263 name: comsub-torture
11265 Check the tree dump functions work correctly
11267 if [[ -z $__progname ]]; then echo >&2 call me with __progname; exit 1; fi
11268 while IFS= read -r line; do
11269 if [[ $line = '#1' ]]; then
11272 elif [[ $line = EOFN* ]]; then
11273 fbody=$fbody$'\n'$line
11275 elif [[ $line != '#'* ]]; then
11276 fbody=$fbody$'\n\t'$line
11279 if (( lastf )); then
11280 x="inline_${nextf}() {"$fbody$'\n}\n'
11282 print -r -- "${x}typeset -f inline_$nextf" | "$__progname"
11283 x="function comsub_$nextf { x=\$("$fbody$'\n); }\n'
11285 print -r -- "${x}typeset -f comsub_$nextf" | "$__progname"
11286 x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n'
11288 print -r -- "${x}typeset -f reread_$nextf" | "$__progname"
11296 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
11297 #TPAREN_TPIPE_TLIST
11298 (echo $foo | tr -dc 0-9; echo)
11300 cmd && echo ja || echo nein
11302 select file in *; do echo "<$file>" ; break ; done
11304 time for i in {1,2,3} ; do echo $i ; done
11306 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
11307 #TIF_TBANG_TDBRACKET_TELIF
11308 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
11310 i=1; while (( i < 10 )); do echo $i; let ++i; done
11312 i=10; until (( !--i )) ; do echo $i; done
11315 #TFUNCT_TBRACE_TASYNC
11316 function korn { echo eins; echo zwei ; }
11317 bourne () { logger * & }
11320 #IOWRITE_IOCLOB_IOHERE_noIOSKIP
11324 #IOWRITE_noIOCLOB_IOHERE_IOSKIP
11329 sh 1<>/dev/console 0<&1 2>&1
11330 #COMSUB_EXPRSUB_FUNSUB_VALSUB
11331 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
11332 #QCHAR_OQUOTE_CQUOTE
11333 echo fo\ob\"a\`r\'b\$az
11334 echo "fo\ob\"a\`r\'b\$az"
11335 echo 'fo\ob\"a\`r'\''b\$az'
11336 #OSUBST_CSUBST_OPAT_SPAT_CPAT
11337 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
11340 note there must be no space between EOFN and )
11344 note the space between EOFN and ) is actually part of the here document marker
11347 x=$(sysctl -n kern.version | sed 1q)
11348 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
11349 ed -s /etc/motd 2>&1 <<-EOF
11356 EOF)" = @(?) ]] && rm -f /etc/motd
11357 if [[ ! -s /etc/motd ]]; then
11358 install -c -o root -g wheel -m 664 /dev/null /etc/motd
11359 print -- "$x\n" >/etc/motd
11369 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
11372 vara=1 varb="2 3" \cmd arg1 $arg2 "$arg3 4"
11374 function comsub_TCOM { x=$(
11375 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
11377 function comsub_TCOM {
11378 x=$(vara=1 varb="2 3" \cmd arg1 $arg2 "$arg3 4" )
11380 function reread_TCOM { x=$((
11381 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
11383 function reread_TCOM {
11384 x=$( ( vara=1 varb="2 3" \cmd arg1 $arg2 "$arg3 4" ) | \tr u x )
11386 inline_TPAREN_TPIPE_TLIST() {
11387 (echo $foo | tr -dc 0-9; echo)
11389 inline_TPAREN_TPIPE_TLIST() {
11390 ( \echo $foo | \tr -dc 0-9
11393 function comsub_TPAREN_TPIPE_TLIST { x=$(
11394 (echo $foo | tr -dc 0-9; echo)
11396 function comsub_TPAREN_TPIPE_TLIST {
11397 x=$( ( \echo $foo | \tr -dc 0-9 ; \echo ) )
11399 function reread_TPAREN_TPIPE_TLIST { x=$((
11400 (echo $foo | tr -dc 0-9; echo)
11402 function reread_TPAREN_TPIPE_TLIST {
11403 x=$( ( ( \echo $foo | \tr -dc 0-9 ; \echo ) ) | \tr u x )
11405 inline_TAND_TOR() {
11406 cmd && echo ja || echo nein
11408 inline_TAND_TOR() {
11409 \cmd && \echo ja || \echo nein
11411 function comsub_TAND_TOR { x=$(
11412 cmd && echo ja || echo nein
11414 function comsub_TAND_TOR {
11415 x=$(\cmd && \echo ja || \echo nein )
11417 function reread_TAND_TOR { x=$((
11418 cmd && echo ja || echo nein
11420 function reread_TAND_TOR {
11421 x=$( ( \cmd && \echo ja || \echo nein ) | \tr u x )
11424 select file in *; do echo "<$file>" ; break ; done
11433 function comsub_TSELECT { x=$(
11434 select file in *; do echo "<$file>" ; break ; done
11436 function comsub_TSELECT {
11437 x=$(select file in * ; do \echo "<$file>" ; \break ; done )
11439 function reread_TSELECT { x=$((
11440 select file in *; do echo "<$file>" ; break ; done
11442 function reread_TSELECT {
11443 x=$( ( select file in * ; do \echo "<$file>" ; \break ; done ) | \tr u x )
11445 inline_TFOR_TTIME() {
11446 time for i in {1,2,3} ; do echo $i ; done
11448 inline_TFOR_TTIME() {
11449 time for i in {1,2,3}
11454 function comsub_TFOR_TTIME { x=$(
11455 time for i in {1,2,3} ; do echo $i ; done
11457 function comsub_TFOR_TTIME {
11458 x=$(time for i in {1,2,3} ; do \echo $i ; done )
11460 function reread_TFOR_TTIME { x=$((
11461 time for i in {1,2,3} ; do echo $i ; done
11463 function reread_TFOR_TTIME {
11464 x=$( ( time for i in {1,2,3} ; do \echo $i ; done ) | \tr u x )
11467 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
11478 \echo kann net bis drei zählen
11482 function comsub_TCASE { x=$(
11483 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
11485 function comsub_TCASE {
11486 x=$(case $foo in (1) \echo eins ;& (2) \echo zwei ;| (*) \echo kann net bis drei zählen ;; esac )
11488 function reread_TCASE { x=$((
11489 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
11491 function reread_TCASE {
11492 x=$( ( case $foo in (1) \echo eins ;& (2) \echo zwei ;| (*) \echo kann net bis drei zählen ;; esac ) | \tr u x )
11494 inline_TIF_TBANG_TDBRACKET_TELIF() {
11495 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
11497 inline_TIF_TBANG_TDBRACKET_TELIF() {
11508 function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$(
11509 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
11511 function comsub_TIF_TBANG_TDBRACKET_TELIF {
11512 x=$(if ! [[ 1 = 1 ]] ; then \echo eins ; elif [[ 1 = 2 ]] ; then \echo zwei ; else \echo drei ; fi )
11514 function reread_TIF_TBANG_TDBRACKET_TELIF { x=$((
11515 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
11517 function reread_TIF_TBANG_TDBRACKET_TELIF {
11518 x=$( ( if ! [[ 1 = 1 ]] ; then \echo eins ; elif [[ 1 = 2 ]] ; then \echo zwei ; else \echo drei ; fi ) | \tr u x )
11521 i=1; while (( i < 10 )); do echo $i; let ++i; done
11526 \\builtin let " i < 10 "
11533 function comsub_TWHILE { x=$(
11534 i=1; while (( i < 10 )); do echo $i; let ++i; done
11536 function comsub_TWHILE {
11537 x=$(i=1 ; while { \\builtin let " i < 10 " ; } ; do \echo $i ; \let ++i ; done )
11539 function reread_TWHILE { x=$((
11540 i=1; while (( i < 10 )); do echo $i; let ++i; done
11542 function reread_TWHILE {
11543 x=$( ( i=1 ; while { \\builtin let " i < 10 " ; } ; do \echo $i ; \let ++i ; done ) | \tr u x )
11546 i=10; until (( !--i )) ; do echo $i; done
11551 \\builtin let " !--i "
11557 function comsub_TUNTIL { x=$(
11558 i=10; until (( !--i )) ; do echo $i; done
11560 function comsub_TUNTIL {
11561 x=$(i=10 ; until { \\builtin let " !--i " ; } ; do \echo $i ; done )
11563 function reread_TUNTIL { x=$((
11564 i=10; until (( !--i )) ; do echo $i; done
11566 function reread_TUNTIL {
11567 x=$( ( i=10 ; until { \\builtin let " !--i " ; } ; do \echo $i ; done ) | \tr u x )
11576 function comsub_TCOPROC { x=$(
11579 function comsub_TCOPROC {
11580 x=$(\cat * |& \ls )
11582 function reread_TCOPROC { x=$((
11585 function reread_TCOPROC {
11586 x=$( ( \cat * |& \ls ) | \tr u x )
11588 inline_TFUNCT_TBRACE_TASYNC() {
11589 function korn { echo eins; echo zwei ; }
11590 bourne () { logger * & }
11592 inline_TFUNCT_TBRACE_TASYNC() {
11601 function comsub_TFUNCT_TBRACE_TASYNC { x=$(
11602 function korn { echo eins; echo zwei ; }
11603 bourne () { logger * & }
11605 function comsub_TFUNCT_TBRACE_TASYNC {
11606 x=$(function korn { \echo eins ; \echo zwei ; } ; bourne() { \logger * & } )
11608 function reread_TFUNCT_TBRACE_TASYNC { x=$((
11609 function korn { echo eins; echo zwei ; }
11610 bourne () { logger * & }
11612 function reread_TFUNCT_TBRACE_TASYNC {
11613 x=$( ( function korn { \echo eins ; \echo zwei ; } ; bourne() { \logger * & } ) | \tr u x )
11615 inline_IOREAD_IOCAT() {
11618 inline_IOREAD_IOCAT() {
11621 function comsub_IOREAD_IOCAT { x=$(
11624 function comsub_IOREAD_IOCAT {
11625 x=$(\tr x u <foo >>bar )
11627 function reread_IOREAD_IOCAT { x=$((
11630 function reread_IOREAD_IOCAT {
11631 x=$( ( \tr x u <foo >>bar ) | \tr u x )
11633 inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
11638 inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
11639 \cat >|bar <<"EOFN"
11644 function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$(
11649 function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
11650 x=$(\cat >|bar <<"EOFN"
11655 function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$((
11660 function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
11661 x=$( ( \cat >|bar <<"EOFN"
11666 inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
11671 inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
11677 function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$(
11682 function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
11683 x=$(\cat >bar <<-EOFI
11688 function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$((
11693 function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
11694 x=$( ( \cat >bar <<-EOFI
11699 inline_IORDWR_IODUP() {
11700 sh 1<>/dev/console 0<&1 2>&1
11702 inline_IORDWR_IODUP() {
11703 \sh 1<>/dev/console <&1 2>&1
11705 function comsub_IORDWR_IODUP { x=$(
11706 sh 1<>/dev/console 0<&1 2>&1
11708 function comsub_IORDWR_IODUP {
11709 x=$(\sh 1<>/dev/console <&1 2>&1 )
11711 function reread_IORDWR_IODUP { x=$((
11712 sh 1<>/dev/console 0<&1 2>&1
11714 function reread_IORDWR_IODUP {
11715 x=$( ( \sh 1<>/dev/console <&1 2>&1 ) | \tr u x )
11717 inline_COMSUB_EXPRSUB_FUNSUB_VALSUB() {
11718 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
11720 inline_COMSUB_EXPRSUB_FUNSUB_VALSUB() {
11721 \echo $(\true ) $((1+ 2)) ${ \: ;} ${|REPLY=x ;}
11723 function comsub_COMSUB_EXPRSUB_FUNSUB_VALSUB { x=$(
11724 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
11726 function comsub_COMSUB_EXPRSUB_FUNSUB_VALSUB {
11727 x=$(\echo $(\true ) $((1+ 2)) ${ \: ;} ${|REPLY=x ;} )
11729 function reread_COMSUB_EXPRSUB_FUNSUB_VALSUB { x=$((
11730 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
11732 function reread_COMSUB_EXPRSUB_FUNSUB_VALSUB {
11733 x=$( ( \echo $(\true ) $((1+ 2)) ${ \: ;} ${|REPLY=x ;} ) | \tr u x )
11735 inline_QCHAR_OQUOTE_CQUOTE() {
11736 echo fo\ob\"a\`r\'b\$az
11737 echo "fo\ob\"a\`r\'b\$az"
11738 echo 'fo\ob\"a\`r'\''b\$az'
11740 inline_QCHAR_OQUOTE_CQUOTE() {
11741 \echo fo\ob\"a\`r\'b\$az
11742 \echo "fo\ob\"a\`r\'b\$az"
11743 \echo "fo\\ob\\\"a\\\`r"\'"b\\\$az"
11745 function comsub_QCHAR_OQUOTE_CQUOTE { x=$(
11746 echo fo\ob\"a\`r\'b\$az
11747 echo "fo\ob\"a\`r\'b\$az"
11748 echo 'fo\ob\"a\`r'\''b\$az'
11750 function comsub_QCHAR_OQUOTE_CQUOTE {
11751 x=$(\echo fo\ob\"a\`r\'b\$az ; \echo "fo\ob\"a\`r\'b\$az" ; \echo "fo\\ob\\\"a\\\`r"\'"b\\\$az" )
11753 function reread_QCHAR_OQUOTE_CQUOTE { x=$((
11754 echo fo\ob\"a\`r\'b\$az
11755 echo "fo\ob\"a\`r\'b\$az"
11756 echo 'fo\ob\"a\`r'\''b\$az'
11758 function reread_QCHAR_OQUOTE_CQUOTE {
11759 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 )
11761 inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() {
11762 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
11764 inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() {
11765 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
11767 function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$(
11768 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
11770 function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT {
11771 x=$([[ ${foo#bl\(u\)b} = @(bar|baz) ]] )
11773 function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$((
11774 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
11776 function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT {
11777 x=$( ( [[ ${foo#bl\(u\)b} = @(bar|baz) ]] ) | \tr u x )
11779 inline_heredoc_closed() {
11781 note there must be no space between EOFN and )
11784 inline_heredoc_closed() {
11786 note there must be no space between EOFN and )
11791 function comsub_heredoc_closed { x=$(
11793 note there must be no space between EOFN and )
11796 function comsub_heredoc_closed {
11797 x=$(x=$(\cat <<EOFN
11798 note there must be no space between EOFN and )
11802 function reread_heredoc_closed { x=$((
11804 note there must be no space between EOFN and )
11807 function reread_heredoc_closed {
11808 x=$( ( x=$(\cat <<EOFN
11809 note there must be no space between EOFN and )
11811 ) ; \echo $x ) | \tr u x )
11813 inline_heredoc_space() {
11815 note the space between EOFN and ) is actually part of the here document marker
11818 inline_heredoc_space() {
11820 note the space between EOFN and ) is actually part of the here document marker
11825 function comsub_heredoc_space { x=$(
11827 note the space between EOFN and ) is actually part of the here document marker
11830 function comsub_heredoc_space {
11831 x=$(x=$(\cat <<EOFN\
11832 note the space between EOFN and ) is actually part of the here document marker
11836 function reread_heredoc_space { x=$((
11838 note the space between EOFN and ) is actually part of the here document marker
11841 function reread_heredoc_space {
11842 x=$( ( x=$(\cat <<EOFN\
11843 note the space between EOFN and ) is actually part of the here document marker
11845 ) ; \echo $x ) | \tr u x )
11847 inline_patch_motd() {
11848 x=$(sysctl -n kern.version | sed 1q)
11849 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
11850 ed -s /etc/motd 2>&1 <<-EOF
11857 EOF)" = @(?) ]] && rm -f /etc/motd
11858 if [[ ! -s /etc/motd ]]; then
11859 install -c -o root -g wheel -m 664 /dev/null /etc/motd
11860 print -- "$x\n" >/etc/motd
11863 inline_patch_motd() {
11864 x=$(\sysctl -n kern.version | \sed 1q )
11865 [[ -s /etc/motd && "$([[ "$(\head -1 /etc/motd )" != $x ]] && \ed -s /etc/motd 2>&1 <<-EOF
11873 )" = @(?) ]] && \rm -f /etc/motd
11874 if [[ ! -s /etc/motd ]]
11876 \install -c -o root -g wheel -m 664 /dev/null /etc/motd
11877 \print -- "$x\n" >/etc/motd
11880 function comsub_patch_motd { x=$(
11881 x=$(sysctl -n kern.version | sed 1q)
11882 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
11883 ed -s /etc/motd 2>&1 <<-EOF
11890 EOF)" = @(?) ]] && rm -f /etc/motd
11891 if [[ ! -s /etc/motd ]]; then
11892 install -c -o root -g wheel -m 664 /dev/null /etc/motd
11893 print -- "$x\n" >/etc/motd
11896 function comsub_patch_motd {
11897 x=$(x=$(\sysctl -n kern.version | \sed 1q ) ; [[ -s /etc/motd && "$([[ "$(\head -1 /etc/motd )" != $x ]] && \ed -s /etc/motd 2>&1 <<-EOF
11905 )" = @(?) ]] && \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 )
11907 function reread_patch_motd { x=$((
11908 x=$(sysctl -n kern.version | sed 1q)
11909 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
11910 ed -s /etc/motd 2>&1 <<-EOF
11917 EOF)" = @(?) ]] && rm -f /etc/motd
11918 if [[ ! -s /etc/motd ]]; then
11919 install -c -o root -g wheel -m 664 /dev/null /etc/motd
11920 print -- "$x\n" >/etc/motd
11923 function reread_patch_motd {
11924 x=$( ( x=$(\sysctl -n kern.version | \sed 1q ) ; [[ -s /etc/motd && "$([[ "$(\head -1 /etc/motd )" != $x ]] && \ed -s /etc/motd 2>&1 <<-EOF
11932 )" = @(?) ]] && \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 )
11934 inline_wdarrassign() {
11939 inline_wdarrassign() {
11943 \\builtin set -A c+ -- d e
11947 function comsub_wdarrassign { x=$(
11952 function comsub_wdarrassign {
11953 x=$(case x in (x) a+=b ; \\builtin set -A c+ -- d e ;; esac )
11955 function reread_wdarrassign { x=$((
11960 function reread_wdarrassign {
11961 x=$( ( case x in (x) a+=b ; \\builtin set -A c+ -- d e ;; esac ) | \tr u x )
11964 name: comsub-torture-io
11966 Check the tree dump functions work correctly with I/O redirection
11968 if [[ -z $__progname ]]; then echo >&2 call me with __progname; exit 1; fi
11969 while IFS= read -r line; do
11970 if [[ $line = '#1' ]]; then
11973 elif [[ $line = EOFN* ]]; then
11974 fbody=$fbody$'\n'$line
11976 elif [[ $line != '#'* ]]; then
11977 fbody=$fbody$'\n\t'$line
11980 if (( lastf )); then
11981 x="inline_${nextf}() {"$fbody$'\n}\n'
11983 print -r -- "${x}typeset -f inline_$nextf" | "$__progname"
11984 x="function comsub_$nextf { x=\$("$fbody$'\n); }\n'
11986 print -r -- "${x}typeset -f comsub_$nextf" | "$__progname"
11987 x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n'
11989 print -r -- "${x}typeset -f reread_$nextf" | "$__progname"
11997 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
11998 #TPAREN_TPIPE_TLIST
11999 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
12001 cmd >&3 && >&3 echo ja || echo >&3 nein
12003 select file in *; do echo "<$file>" ; break >&3 ; done >&3
12005 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
12007 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
12008 #TIF_TBANG_TDBRACKET_TELIF
12009 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
12011 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
12013 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
12015 cat * >&3 |& >&3 ls
12016 #TFUNCT_TBRACE_TASYNC
12017 function korn { echo eins; echo >&3 zwei ; }
12018 bourne () { logger * >&3 & }
12020 echo $(true >&3) $((1+ 2))
12025 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
12028 vara=1 varb="2 3" \cmd arg1 $arg2 "$arg3 4" >&3
12030 function comsub_TCOM { x=$(
12031 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
12033 function comsub_TCOM {
12034 x=$(vara=1 varb="2 3" \cmd arg1 $arg2 "$arg3 4" >&3 )
12036 function reread_TCOM { x=$((
12037 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
12039 function reread_TCOM {
12040 x=$( ( vara=1 varb="2 3" \cmd arg1 $arg2 "$arg3 4" >&3 ) | \tr u x )
12042 inline_TPAREN_TPIPE_TLIST() {
12043 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
12045 inline_TPAREN_TPIPE_TLIST() {
12046 ( \echo $foo | \tr -dc 0-9 >&3
12049 function comsub_TPAREN_TPIPE_TLIST { x=$(
12050 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
12052 function comsub_TPAREN_TPIPE_TLIST {
12053 x=$( ( \echo $foo | \tr -dc 0-9 >&3 ; \echo >&3 ) >&3 )
12055 function reread_TPAREN_TPIPE_TLIST { x=$((
12056 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
12058 function reread_TPAREN_TPIPE_TLIST {
12059 x=$( ( ( \echo $foo | \tr -dc 0-9 >&3 ; \echo >&3 ) >&3 ) | \tr u x )
12061 inline_TAND_TOR() {
12062 cmd >&3 && >&3 echo ja || echo >&3 nein
12064 inline_TAND_TOR() {
12065 \cmd >&3 && \echo ja >&3 || \echo nein >&3
12067 function comsub_TAND_TOR { x=$(
12068 cmd >&3 && >&3 echo ja || echo >&3 nein
12070 function comsub_TAND_TOR {
12071 x=$(\cmd >&3 && \echo ja >&3 || \echo nein >&3 )
12073 function reread_TAND_TOR { x=$((
12074 cmd >&3 && >&3 echo ja || echo >&3 nein
12076 function reread_TAND_TOR {
12077 x=$( ( \cmd >&3 && \echo ja >&3 || \echo nein >&3 ) | \tr u x )
12080 select file in *; do echo "<$file>" ; break >&3 ; done >&3
12089 function comsub_TSELECT { x=$(
12090 select file in *; do echo "<$file>" ; break >&3 ; done >&3
12092 function comsub_TSELECT {
12093 x=$(select file in * ; do \echo "<$file>" ; \break >&3 ; done >&3 )
12095 function reread_TSELECT { x=$((
12096 select file in *; do echo "<$file>" ; break >&3 ; done >&3
12098 function reread_TSELECT {
12099 x=$( ( select file in * ; do \echo "<$file>" ; \break >&3 ; done >&3 ) | \tr u x )
12101 inline_TFOR_TTIME() {
12102 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
12104 inline_TFOR_TTIME() {
12110 function comsub_TFOR_TTIME { x=$(
12111 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
12113 function comsub_TFOR_TTIME {
12114 x=$(for i in {1,2,3} ; do time \echo $i >&3 ; done >&3 )
12116 function reread_TFOR_TTIME { x=$((
12117 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
12119 function reread_TFOR_TTIME {
12120 x=$( ( for i in {1,2,3} ; do time \echo $i >&3 ; done >&3 ) | \tr u x )
12123 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
12134 \echo kann net bis drei zählen >&3
12138 function comsub_TCASE { x=$(
12139 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
12141 function comsub_TCASE {
12142 x=$(case $foo in (1) \echo eins >&3 ;& (2) \echo zwei >&3 ;| (*) \echo kann net bis drei zählen >&3 ;; esac >&3 )
12144 function reread_TCASE { x=$((
12145 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
12147 function reread_TCASE {
12148 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 )
12150 inline_TIF_TBANG_TDBRACKET_TELIF() {
12151 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
12153 inline_TIF_TBANG_TDBRACKET_TELIF() {
12154 if ! [[ 1 = 1 ]] >&3
12157 elif [[ 1 = 2 ]] >&3
12164 function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$(
12165 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
12167 function comsub_TIF_TBANG_TDBRACKET_TELIF {
12168 x=$(if ! [[ 1 = 1 ]] >&3 ; then \echo eins ; elif [[ 1 = 2 ]] >&3 ; then \echo zwei ; else \echo drei ; fi >&3 )
12170 function reread_TIF_TBANG_TDBRACKET_TELIF { x=$((
12171 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
12173 function reread_TIF_TBANG_TDBRACKET_TELIF {
12174 x=$( ( if ! [[ 1 = 1 ]] >&3 ; then \echo eins ; elif [[ 1 = 2 ]] >&3 ; then \echo zwei ; else \echo drei ; fi >&3 ) | \tr u x )
12177 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
12182 \\builtin let " i < 10 "
12189 function comsub_TWHILE { x=$(
12190 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
12192 function comsub_TWHILE {
12193 x=$(i=1 ; while { \\builtin let " i < 10 " ; } >&3 ; do \echo $i ; \let ++i ; done >&3 )
12195 function reread_TWHILE { x=$((
12196 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
12198 function reread_TWHILE {
12199 x=$( ( i=1 ; while { \\builtin let " i < 10 " ; } >&3 ; do \echo $i ; \let ++i ; done >&3 ) | \tr u x )
12202 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
12207 \\builtin let " !--i "
12213 function comsub_TUNTIL { x=$(
12214 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
12216 function comsub_TUNTIL {
12217 x=$(i=10 ; until { \\builtin let " !--i " ; } >&3 ; do \echo $i ; done >&3 )
12219 function reread_TUNTIL { x=$((
12220 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
12222 function reread_TUNTIL {
12223 x=$( ( i=10 ; until { \\builtin let " !--i " ; } >&3 ; do \echo $i ; done >&3 ) | \tr u x )
12226 cat * >&3 |& >&3 ls
12232 function comsub_TCOPROC { x=$(
12233 cat * >&3 |& >&3 ls
12235 function comsub_TCOPROC {
12236 x=$(\cat * >&3 |& \ls >&3 )
12238 function reread_TCOPROC { x=$((
12239 cat * >&3 |& >&3 ls
12241 function reread_TCOPROC {
12242 x=$( ( \cat * >&3 |& \ls >&3 ) | \tr u x )
12244 inline_TFUNCT_TBRACE_TASYNC() {
12245 function korn { echo eins; echo >&3 zwei ; }
12246 bourne () { logger * >&3 & }
12248 inline_TFUNCT_TBRACE_TASYNC() {
12257 function comsub_TFUNCT_TBRACE_TASYNC { x=$(
12258 function korn { echo eins; echo >&3 zwei ; }
12259 bourne () { logger * >&3 & }
12261 function comsub_TFUNCT_TBRACE_TASYNC {
12262 x=$(function korn { \echo eins ; \echo zwei >&3 ; } ; bourne() { \logger * >&3 & } )
12264 function reread_TFUNCT_TBRACE_TASYNC { x=$((
12265 function korn { echo eins; echo >&3 zwei ; }
12266 bourne () { logger * >&3 & }
12268 function reread_TFUNCT_TBRACE_TASYNC {
12269 x=$( ( function korn { \echo eins ; \echo zwei >&3 ; } ; bourne() { \logger * >&3 & } ) | \tr u x )
12271 inline_COMSUB_EXPRSUB() {
12272 echo $(true >&3) $((1+ 2))
12274 inline_COMSUB_EXPRSUB() {
12275 \echo $(\true >&3 ) $((1+ 2))
12277 function comsub_COMSUB_EXPRSUB { x=$(
12278 echo $(true >&3) $((1+ 2))
12280 function comsub_COMSUB_EXPRSUB {
12281 x=$(\echo $(\true >&3 ) $((1+ 2)) )
12283 function reread_COMSUB_EXPRSUB { x=$((
12284 echo $(true >&3) $((1+ 2))
12286 function reread_COMSUB_EXPRSUB {
12287 x=$( ( \echo $(\true >&3 ) $((1+ 2)) ) | \tr u x )
12292 Check that non-subenvironment command substitution works
12312 You can now reliably use local and return in funsubs
12315 x=q; e=1; x=${ echo a; e=2; echo x$e;}; echo 1:y$x,$e,$?.
12316 x=q; e=1; x=${ echo a; typeset e=2; echo x$e;}; echo 2:y$x,$e,$?.
12317 x=q; e=1; x=${ echo a; typeset e=2; return 3; echo x$e;}; echo 3:y$x,$e,$?.
12325 Check that "value substitutions" work as advertised
12331 echo "before: x<$x> y<$y> z<$z> R<$REPLY>"
12334 echo "start: x<$x> y<$y> z<$z> R<$REPLY>"
12339 echo "end: x<$x> y<$y> z<$z> R<$REPLY>"
12341 echo "after: x<$x> y<$y> z<$z> R<$REPLY>"
12342 # ensure trailing newlines are kept
12343 t=${|REPLY=$'foo\n\n';}
12345 echo -n this used to segfault
12346 echo ${|true;}$(true).
12348 before: x<1> y<2> z<3> R<4>
12349 start: x<1> y<> z<3> R<>
12350 end: x<5> y<6> z<7> R<8>
12351 after: x<8> y<2> z<7> R<4>
12352 typeset t=$'foo\n\n'
12353 this used to segfault.
12355 name: event-subst-3
12357 Check that '!' substitution in noninteractive mode is ignored
12358 file-setup: file 755 "falsetto"
12362 file-setup: file 755 "!false"
12366 export PATH=.$PATHSEP$PATH
12374 ! false; then echo foo; else echo bar; fi
12383 name: event-subst-0
12385 Check that '!' substitution in interactive mode is ignored
12388 file-setup: file 755 "falsetto"
12392 file-setup: file 755 "!false"
12396 export PATH=.$PATHSEP$PATH
12404 ! false; then echo foo; else echo bar; fi
12412 expected-stderr-pattern:
12417 Check that "set -u" matches (future) SUSv4 requirement
12423 if [[ -n $v ]]; then
12458 (mypid=$$; try mypid)
12460 ) 2>&1 | sed -e 's/^[^]]*]//' -e 's/^[^:]*: *//'
12461 exit ${PIPESTATUS[0]}
12465 y: parameter not set
12469 y: parameter not set
12473 2: parameter not set
12475 1: parameter not set
12483 !: parameter not set
12494 Testsuite for nameref (bound variables)
12509 set|grep ^ir2|sed 's/^/s1: /'
12510 typeset|grep ' ir2'|sed -e 's/^/s2: /' -e 's/nameref/typeset -n/'
12511 set -A blub -- e1 e2 e3
12512 typeset -n ind=blub
12513 typeset -n ir2=blub[2]
12514 echo !ind[1]: ${!ind[1]}
12516 echo ind[1]: ${ind[1]}
12536 Testsuite for nameref (bound variables)
12537 Functions, argument given directly, after local
12540 typeset bar=lokal baz=auch
12572 Advanced testsuite for bound variables (ksh93 fails this)
12574 typeset -n foo=bar[i]
12575 set -A bar -- b c a
12576 for i in 0 1 2 3; do
12587 Ensure we don't run in an infinite loop
12591 typeset -n foo=fnord fnord=foo
12601 expected-stderr-pattern:
12602 /fnord: expression recurses on parameter/
12604 name: better-parens-1a
12606 Check support for ((…)) and $((…)) vs (…) and $(…)
12608 if ( (echo fubar)|tr u x); then
12617 name: better-parens-1b
12619 Check support for ((…)) and $((…)) vs (…) and $(…)
12621 echo $( (echo fubar)|tr u x) $?
12625 name: better-parens-1c
12627 Check support for ((…)) and $((…)) vs (…) and $(…)
12629 x=$( (echo fubar)|tr u x); echo $x $?
12633 name: better-parens-2a
12635 Check support for ((…)) and $((…)) vs (…) and $(…)
12637 if ((echo fubar)|tr u x); then
12646 name: better-parens-2b
12648 Check support for ((…)) and $((…)) vs (…) and $(…)
12650 echo $((echo fubar)|tr u x) $?
12654 name: better-parens-2c
12656 Check support for ((…)) and $((…)) vs (…) and $(…)
12658 x=$((echo fubar)|tr u x); echo $x $?
12662 name: better-parens-3a
12664 Check support for ((…)) and $((…)) vs (…) and $(…)
12666 if ( (echo fubar)|(tr u x)); then
12675 name: better-parens-3b
12677 Check support for ((…)) and $((…)) vs (…) and $(…)
12679 echo $( (echo fubar)|(tr u x)) $?
12683 name: better-parens-3c
12685 Check support for ((…)) and $((…)) vs (…) and $(…)
12687 x=$( (echo fubar)|(tr u x)); echo $x $?
12691 name: better-parens-4a
12693 Check support for ((…)) and $((…)) vs (…) and $(…)
12695 if ((echo fubar)|(tr u x)); then
12704 name: better-parens-4b
12706 Check support for ((…)) and $((…)) vs (…) and $(…)
12708 echo $((echo fubar)|(tr u x)) $?
12712 name: better-parens-4c
12714 Check support for ((…)) and $((…)) vs (…) and $(…)
12716 x=$((echo fubar)|(tr u x)); echo $x $?
12720 name: better-parens-5
12722 Another corner case
12724 ( (echo 'fo o$bar' "baz\$bla\"" m\$eh) | tr a A)
12725 ((echo 'fo o$bar' "baz\$bla\"" m\$eh) | tr a A)
12727 fo o$bAr bAz$blA" m$eh
12728 fo o$bAr bAz$blA" m$eh
12732 Test what the echo builtin does (mksh)
12733 category: !shell:ebcdic-yes
12735 echo -n 'foo\x40bar'
12740 name: echo-test-1-ebcdic
12742 Test what the echo builtin does (mksh)
12743 category: !shell:ebcdic-no
12745 echo -n 'foo\x7Cbar'
12752 Test what the echo builtin does (POSIX)
12753 Note: this follows Debian Policy 10.4 which mandates
12754 that -n shall be treated as an option, not XSI which
12755 mandates it shall be treated as string but escapes
12758 test -n "$POSH_VERSION" || set -o posix
12759 echo -n 'foo\x40bar'
12764 name: echo-test-3-mnbsd
12766 Test what the echo builtin does, and test a compatibility flag.
12769 "$__progname" -c 'echo -n 1=\\x40$1; echo -e \\x2E' -- foo bar
12770 "$__progname" -o posix -c 'echo -n 2=\\x40$1; echo -e \\x2E' -- foo bar
12771 "$__progname" -o sh -c 'echo -n 3=\\x40$1; echo -e \\x2E' -- foo bar
12777 name: echo-test-3-normal
12779 Test what the echo builtin does, and test a compatibility flag.
12780 category: !mnbsdash,!shell:ebcdic-yes
12782 "$__progname" -c 'echo -n 1=\\x40$1; echo -e \\x2E' -- foo bar
12783 "$__progname" -o posix -c 'echo -n 2=\\x40$1; echo -e \\x2E' -- foo bar
12784 "$__progname" -o sh -c 'echo -n 3=\\x40$1; echo -e \\x2E' -- foo bar
12790 name: echo-test-3-ebcdic
12792 Test what the echo builtin does, and test a compatibility flag.
12793 category: !mnbsdash,!shell:ebcdic-no
12795 "$__progname" -c 'echo -n 1=\\x7C$1; echo -e \\x4B' -- foo bar
12796 "$__progname" -o posix -c 'echo -n 2=\\x7C$1; echo -e \\x4B' -- foo bar
12797 "$__progname" -o sh -c 'echo -n 3=\\x7C$1; echo -e \\x4B' -- foo bar
12803 name: utilities-getopts-1
12805 getopts sets OPTIND correctly for unparsed option
12808 while getopts :a optc; do
12809 echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
12813 OPTARG=, OPTIND=2, optc=a.
12814 OPTARG=, OPTIND=3, optc=a.
12815 OPTARG=x, OPTIND=4, optc=?.
12818 name: utilities-getopts-2
12823 while getopts a: optc; do
12824 echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
12828 OPTARG=Mary, OPTIND=3, optc=a.
12829 OPTARG=, OPTIND=4, optc=?.
12831 expected-stderr-pattern: /.*-x.*option/
12833 name: utilities-getopts-3
12835 Check unsetting OPTARG
12838 getopts x:y opt && echo "${OPTARG-unset}"
12839 getopts x:y opt && echo "${OPTARG-unset}"
12846 Check the new wcswidth feature
12850 print octets: ${#s} .
12851 print 8-bit width: ${%s} .
12853 print characters: ${#s} .
12854 print columns: ${%s} .
12857 print octets: ${#s} .
12858 print 8-bit width: ${%s} .
12860 print characters: ${#s} .
12861 print columns: ${%s} .
12874 Check some corner cases
12890 Check some corner cases
12893 expected-stderr-pattern:
12899 Check some corner cases
12902 expected-stderr-pattern:
12908 Check some corner cases
12911 expected-stderr-pattern:
12917 Check some corner cases
12926 Check proper return values for realpath
12927 category: os:mirbsd
12940 x=$(realpath "$wd/$1" 2>&1); y=$?
12941 print $((++i)) "?$1" =${x##*$wd/} !$y
12967 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
12972 3 ?dir/file =dir/file !0
12973 4 ?dir/nix =dir/nix !0
12975 6 ?file/ =file/: Not a directory !20
12976 7 ?file/file =file/file: Not a directory !20
12977 8 ?file/nix =file/nix: Not a directory !20
12980 11 ?nix/file =nix/file: No such file or directory !2
12981 12 ?nix/nix =nix/nix: No such file or directory !2
12984 15 ?lndir/file =dir/file !0
12985 16 ?lndir/nix =dir/nix !0
12986 17 ?lnfile =file !0
12987 18 ?lnfile/ =lnfile/: Not a directory !20
12988 19 ?lnfile/file =lnfile/file: Not a directory !20
12989 20 ?lnfile/nix =lnfile/nix: Not a directory !20
12992 23 ?lnnix/file =lnnix/file: No such file or directory !2
12993 24 ?lnnix/nix =lnnix/nix: No such file or directory !2
12994 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
12998 Ensure that exactly two leading slashes are not collapsed
12999 POSIX guarantees this exception, e.g. for UNC paths on Cygwin
13000 category: os:mirbsd
13010 realpath /usr///bin
13019 realpath //usr/include/../bin
13036 Crashed during March 2011, fixed on vernal equinōx ☺
13037 category: os:mirbsd,os:openbsd
13039 export MALLOC_OPTIONS=FGJPRSX
13040 "$__progname" -c 'x=$(tr z r <<<baz); echo $x'
13046 Check test - bug#465250
13048 test \( ! -e \) ; echo $?
13054 Check test - bug#465250
13056 test \( -e \) ; echo $?
13062 Check test - bug#465250
13064 test ! -e ; echo $?
13070 Check test - bug#465250
13078 Check that zsh case variants work
13112 Check that case end tokens are not mixed up (Debian #220272)
13115 for value in 'x' '}' 'esac'; do
13116 print -n "$((++i))($value)bourne "
13121 print -n "$((++i))($value)korn "
13135 name: command-shift
13137 Check that 'command shift' works
13140 echo "before 0='$0' 1='$1' 2='$2'"
13142 echo "after 0='$0' 1='$1' 2='$2'"
13145 echo "before 0='$0' 1='$1' 2='$2'"
13147 echo "after 0='$0' 1='$1' 2='$2'"
13149 echo = without command
13151 echo = with command
13156 before 0='snc' 1='一' 2='二'
13157 after 0='snc' 1='二' 2=''
13159 before 0='swc' 1='一' 2='二'
13160 after 0='swc' 1='二' 2=''
13163 name: command-pvV-posix-priorities
13165 For POSIX compatibility, command -v should find aliases and reserved
13166 words, and command -p[vV] should find aliases, reserved words, and
13167 builtins over external commands.
13170 alias foo="bar baz"
13172 for word in 'if' 'foo' 'bar' 'set' 'true'; do
13174 command -pv "$word"
13176 command -pV "$word"
13181 if is a reserved word
13182 if is a reserved word
13183 alias foo='bar baz'
13184 alias foo='bar baz'
13185 foo is an alias for 'bar baz'
13186 foo is an alias for 'bar baz'
13193 set is a special shell builtin
13194 set is a special shell builtin
13197 true is a shell builtin
13198 true is a shell builtin
13200 name: whence-preserve-tradition
13202 This regression test is to ensure that the POSIX compatibility
13203 changes for 'command' (see previous test) do not affect traditional
13204 'whence' behaviour.
13205 category: os:mirbsd
13208 alias foo="bar baz"
13210 for word in 'if' 'foo' 'bar' 'set' 'true'; do
13218 if is a reserved word
13221 foo is an alias for 'bar baz'
13227 set is a special shell builtin
13231 true is a shell builtin
13232 true is a tracked alias for /bin/true
13236 Check that the compiler did not optimise-break them
13237 (lex.c has got a similar one in SHEREDELIM)
13238 category: !shell:faux-ebcdic,!shell:ebcdic-yes
13243 while (( ++i < 256 )); do
13246 s+=$'\xC2\xA0\xE2\x82\xAC\xEF\xBF\xBD\xEF\xBF\xBE\xEF\xBF\xBF\xF0\x90\x80\x80.'
13249 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.'
13251 name: duffs-device-ebcdic
13253 Check that the compiler did not optimise-break them
13254 category: !shell:ebcdic-no
13259 while (( ++i < 256 )); do
13262 #s+=$'\xC2\xA0\xE2\x82\xAC\xEF\xBF\xBD\xEF\xBF\xBE\xEF\xBF\xBF\xF0\x90\x80\x80.' #XXX
13265 typeset s=$'\001\002\003\004\t\006\007\010\011\012\v\f\r\016\017\020\021\022\023\024\n\b\027\030\031\032\033\034\035\036\037\040\041\042\043\044\045\046\E\050\051\052\053\054\055\056\a\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077 âäàáãåçñ¢.<(+|&éêëèíîïìß!$*);^-/ÂÄÀÁÃÅÇѦ,%_>?øÉÊËÈÍÎÏÌ`:#@\175="Øabcdefghi«»ðýþ±°jklmnopqrªºæ¸Æ¤µ~stuvwxyz¡¿Ð[Þ®¬£¥·©§¶¼½¾Ý¨¯]´×{ABCDEFGHIôöòóõ}JKLMNOPQR¹ûüùúÿ\\÷STUVWXYZ²ÔÖÒÓÕ0123456789³ÛÜÙÚ\377'
13267 name: duffs-device-faux-EBCDIC
13269 Check that the compiler did not optimise-break them
13270 category: shell:faux-ebcdic
13275 while (( ++i < 256 )); do
13278 s+=$'\xC2\xA0\xE2\x82\xAC\xEF\xBF\xBD\xEF\xBF\xBE\xEF\xBF\xBF\xF0\x90\x80\x80.'
13281 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 ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ\u00A0\u20AC\uFFFD￾￿ð\220\200\200.'
13283 name: stateptr-underflow
13285 This check overflows an Xrestpos stored in a short in R40
13288 function Lb64decode {
13289 [[ -o utf8-mode ]]; local u=$?
13292 [[ -n $s ]] || { s=$(cat;print x); s=${s%x}; }
13293 local -i i=0 n=${#s} p=0 v x
13296 while (( i < n )); do
13300 ([A-Z]) (( v = 1#$c - 65 )) ;;
13301 ([a-z]) (( v = 1#$c - 71 )) ;;
13302 ([0-9]) (( v = 1#$c + 4 )) ;;
13307 (( x = (x << 6) | v ))
13310 (1) (( o = (x >> 4) & 255 )) ;;
13311 (2) (( o = (x >> 2) & 255 )) ;;
13312 (3) (( o = x & 255 ))
13324 while (( ++i < 12120 )); do
13327 Lb64decode $s >/dev/null
13331 Check that "set -x" doesn't redirect too quickly
13333 print '#!'"$__progname" >bash
13335 echo 'GNU bash, version 2.05b.0(1)-release (i386-ecce-mirbsd10)
13336 Copyright (C) 2002 Free Software Foundation, Inc.'
13339 "$__progname" -xc 'foo=$(./bash --version 2>&1 | sed q); echo "=$foo="'
13341 =GNU bash, version 2.05b.0(1)-release (i386-ecce-mirbsd10)=
13342 expected-stderr-pattern:
13347 Check that "set -x" is off during PS4 expansion
13354 PS4='[(p:$-)$(f)] '
13356 set -x -o inherit-xtrace
13365 [(p:sh)(f1:sh)(f2:sh)] print '(o1:shx)'
13366 [(p:sh)(f1:sh)(f2:sh)] set +x
13370 Check that FKSH functions have their own shell flags
13371 category: shell:legacy-no
13373 [[ $KSH_VERSION = Version* ]] && set +B
13388 name: fksh-flags-legacy
13390 Check that even FKSH functions share the shell flags
13391 category: shell:legacy-yes
13393 [[ $KSH_VERSION = Version* ]] && set +B
13410 Check that !FKSH functions share the shell flags
13412 [[ $KSH_VERSION = Version* ]] && set +B