1 # $MirOS: src/bin/mksh/check.t,v 1.661 2014/10/07 15:22:14 tg Exp $
2 # OpenBSD src/regress/bin/ksh updated: 2013/12/02 20:39:44
4 # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
5 # 2011, 2012, 2013, 2014
6 # Thorsten Glaser <tg@mirbsd.org>
8 # Provided that these terms and disclaimer and all copyright notices
9 # are retained or reproduced in an accompanying document, permission
10 # is granted to deal in this work without restriction, including un‐
11 # limited rights to use, publicly perform, distribute, sell, modify,
12 # merge, give away, or sublicence.
14 # This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
15 # the utmost extent permitted by applicable law, neither express nor
16 # implied; without malicious intent or gross negligence. In no event
17 # may a licensor, author or contributor be held liable for indirect,
18 # direct, other damage, loss, or other issues arising in any way out
19 # of dealing in the work, even if advised of the possibility of such
20 # damage or existence of a defect, except proven that it results out
21 # of said person’s immediate fault when using the work as intended.
23 # You may also want to test IFS with the script at
24 # http://www.research.att.com/~gsf/public/ifs.sh
27 # http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD
30 @(#)MIRBSD KSH R50 2014/10/07
32 Check version of shell.
36 category: shell:legacy-no
39 @(#)LEGACY KSH R50 2014/10/07
41 Check version of legacy shell.
44 name: KSH_VERSION-legacy
45 category: shell:legacy-yes
49 Regression test self-testing
57 Regression test self-testing
66 Regression test self-testing
67 env-setup: !ENV=fnord!
75 Ensure that the test run directory (default /tmp but can be changed
76 with check.pl flag -T or test.sh $TMPDIR) is not mounted noexec, as
77 we execute scripts from the scratch directory during several tests.
79 print '#!'"$__progname"'\necho tf' >lq
87 Just output the environment variables set (always fails)
94 Check some things in the LEGACY KSH
95 category: shell:legacy-yes
99 [[ "$(set +o) -o" = *"-o emacs -o"* ]] && echo 1=emacs
100 [[ "$(set +o) -o" = *"-o vi -o"* ]] && echo 1=vi
103 [[ "$(set +o) -o" = *"-o emacs -o"* ]] && echo 2=emacs
104 [[ "$(set +o) -o" = *"-o vi -o"* ]] && echo 2=vi
109 name: selftest-direct-builtin-call
111 Check that direct builtin calls work
113 ln -s "$__progname" cat || cp "$__progname" cat
114 ln -s "$__progname" echo || cp "$__progname" echo
115 ./echo -c 'echo foo' | ./cat -u
121 Check that recursion is detected/avoided in aliases.
126 expected-stderr-pattern:
127 /fooBar.*not found.*/
131 Check that recursion is detected/avoided in aliases.
138 expected-stderr-pattern:
139 /fooBar.*not found.*\n.*barFoo.*not found/
143 Check that recursion is detected/avoided in aliases.
157 Check that alias expansion isn't done on keywords (in keyword
162 while false; do echo hi ; done
169 Check that alias expansion done after alias with trailing space.
172 alias foo='bar stuff '
173 alias bar='Bar1 Bar2 '
182 Check that alias expansion done after alias with trailing space.
194 Check that alias expansion done after alias with trailing space
199 X Y in 'Y') echo is y ;; Z) echo is z ; esac
205 Check that newlines in an alias don't cause the command to be lost.
225 Check that recursion is detected/avoided in aliases.
226 This check fails for slow machines or Cygwin, raise
227 the time-limit clause (e.g. to 7) if this occurs.
230 print '#!'"$__progname"'\necho tf' >lq
248 Check that recursion is detected/avoided in aliases.
249 Regression, introduced during an old bugfix.
251 alias foo='print hello '
252 alias bar='foo world'
259 Check that only one side of ternary operator is evaluated
264 echo $((1 ? 20 : (x+=2)))
266 echo $((0 ? (y+=2) : 30))
276 Check that assignments not done on non-evaluated side of ternary
282 echo $((1 ? 20 : (x+=2)))
284 echo $((0 ? (y+=2) : 30))
294 Check that assignments not done on non-evaluated side of ternary
295 operator and this construct is parsed correctly (Debian #445651)
305 Check that preun/postun not done on non-evaluated side of ternary
308 (( m = n = 0, 1 ? n++ : m++ ? 2 : 3 ))
310 m=0; echo $(( 0 ? ++m : 2 )); echo $m
311 m=0; echo $(( 0 ? m++ : 2 )); echo $m
319 name: arith-ternary-prec-1
321 Check precedence of ternary operator vs assignment
325 expected-exit: e != 0
326 expected-stderr-pattern:
327 /.*:.*1 \? 20 : x\+=2.*lvalue.*\n$/
329 name: arith-ternary-prec-2
331 Check precedence of ternary operator vs assignment
334 echo $((0 ? x+=2 : 20))
338 name: arith-div-assoc-1
340 Check associativity of division operator
346 name: arith-div-byzero
348 Check division by zero errors out
354 expected-stderr-pattern:
357 name: arith-div-intmin-by-minusone
359 Check division overflow wraps around silently
362 echo signed:$((-2147483648 / -1))r$((-2147483648 % -1)).
363 echo unsigned:$((# -2147483648 / -1))r$((# -2147483648 % -1)).
365 signed:-2147483648r0.
366 unsigned:0r2147483648.
368 name: arith-div-intmin-by-minusone-64
370 Check division overflow wraps around silently
373 echo signed:$((-9223372036854775808 / -1))r$((-9223372036854775808 % -1)).
374 echo unsigned:$((# -9223372036854775808 / -1))r$((# -9223372036854775808 % -1)).
376 signed:-9223372036854775808r0.
377 unsigned:0r9223372036854775808.
379 name: arith-assop-assoc-1
381 Check associativity of assignment-operator operator
383 typeset -i i=1 j=2 k=3
384 echo $((i += j += k))
390 name: arith-mandatory
392 Passing of this test is *mandatory* for a valid mksh executable!
393 category: shell:legacy-no
398 print -r -- $((x++)):$sari=$uari. #0
400 print -r -- $((x++)):$sari=$uari. #1
401 sari=2147483647 uari=2147483647
402 print -r -- $((x++)):$sari=$uari. #2
404 print -r -- $((x++)):$sari=$uari. #3
406 let 'sari *= 2' 'uari *= 2'
408 print -r -- $((x++)):$sari=$uari. #4
410 print -r -- $((x++)):$sari=$uari. #5
411 sari=-2147483648 uari=-2147483648
412 print -r -- $((x++)):$sari=$uari. #6
414 print -r -- $((x++)):$sari=$uari. #7
416 ((# uari = -5 >> 1 ))
417 print -r -- $((x++)):$sari=$uari. #8
420 print -r -- $((x++)):$sari=$uari. #9
424 2:2147483647=2147483647.
425 3:-2147483648=2147483648.
428 6:-2147483648=2147483648.
429 7:2147483647=2147483647.
433 name: arith-unsigned-1
435 Check if unsigned arithmetics work
439 echo x1 $((-1)) $((#-1))
443 vs=4123456789; vu=4123456789
445 (( vs %= 2147483647 ))
446 (( vu %= 2147483647 ))
448 vs=4123456789; vu=4123456789
449 (( # vs %= 2147483647 ))
450 (( # vu %= 2147483647 ))
452 # make sure the calculation does not change unsigned flag
453 vs=4123456789; vu=4123456789
456 echo x6 $((# vs % 2147483647)) $((# vu % 2147483647))
461 echo x7 ${va[#4123456789%2147483647]}
464 x2 -171510507 4123456789
465 x3 -171510507 4123456789
466 x4 1975973142 1975973142
467 x5 -171510507 4123456789
468 x6 1975973142 1975973142
471 name: arith-limit32-1
473 Check if arithmetics are 32 bit
477 echo x1 $((-1)) $((#-1))
481 vs=2147483647; vu=2147483647
485 vs=4294967295; vu=4294967295
493 x2 2147483647 2147483647
494 x3 -2147483648 2147483648
499 name: arith-limit64-1
501 Check if arithmetics are 64 bit
505 echo x1 $((-1)) $((#-1))
509 vs=9223372036854775807; vu=9223372036854775807
513 vs=18446744073709551615; vu=18446744073709551615
520 x1 -1 18446744073709551615
521 x2 9223372036854775807 9223372036854775807
522 x3 -9223372036854775808 9223372036854775808
523 x4 -1 18446744073709551615
529 Check that \newline is not collapsed after #
539 Check that \newline is not collapsed inside single quotes
551 Check that \newline is not collapsed inside single quotes
563 Check interaction of aliases, single quotes and here-documents
564 with backslash-newline
565 (don't know what POSIX has to say about this)
587 Check what happens with backslash at end of input
588 (the old Bourne shell trashes them; so do we)
597 # Places \newline should be collapsed
601 Check that \newline is collapsed before, in the middle of, and
613 Check that \newline is collapsed in $ sequences
637 Check that \newline is collapsed in $(..) and `...` sequences
662 Check that \newline is collapsed in $((..)) sequences
673 echo $((1+2+3+4+5+6)\
684 Check that \newline is collapsed in double quoted strings
699 Check that \newline is collapsed in here document delimiters
700 (ksh93 fails second part of this)
722 Check that \newline is collapsed in double-quoted here-document
741 Check that \newline is collapsed in various 2+ character tokens
786 Check that \ at the end of an alias is collapsed when followed
788 (don't know what POSIX has to say about this)
798 Check that \newline in a keyword is collapsed
808 # Places \newline should be collapsed (ksh extensions)
812 Check that \newline is collapsed in extended globbing
829 Check that \newline is collapsed in ((...)) expressions
844 See if break breaks out of loops
846 for i in a b c; do echo $i; break; echo bad-$i; done
848 for i in a b c; do echo $i; break 1; echo bad-$i; done
874 See if break breaks out of nested loops
891 What if break used outside of any loops
892 (ksh88,ksh93 don't print error messages here)
895 expected-stderr-pattern:
900 What if break N used when only N-1 loops
901 (ksh88,ksh93 don't print error messages here)
903 for i in a b c; do echo $i; break 2; echo bad-$i; done
908 expected-stderr-pattern:
913 Error if break argument isn't a number
915 for i in a b c; do echo $i; break abc; echo more-$i; done
919 expected-exit: e != 0
920 expected-stderr-pattern:
925 See if continue continues loops
927 for i in a b c; do echo $i; continue; echo bad-$i ; done
929 for i in a b c; do echo $i; continue 1; echo bad-$i; done
965 See if continue breaks out of nested loops
984 What if continue used outside of any loops
985 (ksh88,ksh93 don't print error messages here)
988 expected-stderr-pattern:
993 What if continue N used when only N-1 loops
994 (ksh88,ksh93 don't print error messages here)
996 for i in a b c; do echo $i; continue 2; echo bad-$i; done
1003 expected-stderr-pattern:
1008 Error if continue argument isn't a number
1010 for i in a b c; do echo $i; continue abc; echo more-$i; done
1014 expected-exit: e != 0
1015 expected-stderr-pattern:
1020 Test someone's CD history package (uses arrays)
1022 # go to known place before doing anything
1036 if [ "$CDHISTFILE" -a -r "$CDHISTFILE" ] # if directory history exists
1040 while read -r t # read directory history file
1046 if [ "${CDHIST[0]}" != "$PWD" -a "$PWD" != "" ]
1048 _cdins # insert $PWD into cd history
1051 cdlen=${#CDHIST[*]} # number of elements in history
1055 if [ "$OLDPWD" = "" ] && ((cdlen>1))
1057 'print' ${CDHIST[1]}
1065 -l) # print directory list
1068 while (((i=i-1)>=0))
1071 'print' "$num ${CDHIST[i]}"
1075 -[0-9]|-[0-9][0-9]) # cd to dir in list
1076 if (((i=${1#-})<cdlen))
1078 'print' ${CDHIST[i]}
1086 -*) # cd to matched dir in list
1091 case ${CDHIST[i]} in
1093 'print' ${CDHIST[i]}
1113 _cdins # insert $PWD into cd history
1115 if [ "$CDHISTFILE" ]
1117 cdlen=${#CDHIST[*]} # number of elements in history
1122 'print' -r ${CDHIST[i]} # update directory history
1128 function _cdins # insert $PWD into cd history
1129 { # meant to be called only by _cd
1133 while ((i<${#CDHIST[*]})) # see if dir is already in list
1135 if [ "${CDHIST[$i]}" = "$PWD" ]
1142 if ((i>22)) # limit max size of list
1147 while (((i=i-1)>=0)) # bump old dirs in list
1149 CDHIST[i+1]=${CDHIST[i]}
1152 CDHIST[0]=$PWD # insert new directory in list
1180 Check package for cd -Pe
1182 # the mv command fails on Cygwin
1183 # Hurd aborts the testsuite (permission denied)
1184 # QNX does not find subdir to cd into
1185 category: !os:cygwin,!os:gnu,!os:msys,!os:nto,!nosymlink
1186 file-setup: file 644 "x"
1187 mkdir noread noread/target noread/target/subdir
1194 echo 1=$?,${PWD#$bwd/}
1195 epwd=$($TSHELL -c pwd 2>/dev/null)
1196 # This unexpectedly succeeds on GNU/Linux and MidnightBSD
1199 mv ../../noread ../../renamed
1201 echo 2=$?,${PWD#$bwd/}
1204 rm -rf noread link renamed
1206 export TSHELL="$__progname"
1213 2=0,noread/target/subdir
1217 2=1,noread/target/subdir
1221 Check that prompt not printed when processing ENV
1222 env-setup: !ENV=./foo!
1223 file-setup: file 644 "foo"
1238 Check that weird ${foo+bar} constructs are parsed correctly
1240 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
1241 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "<$x> "; done' >pfs
1243 (echo 1 ${IFS+'}'z}) 2>/dev/null || echo failed in 1
1244 (echo 2 "${IFS+'}'z}") 2>/dev/null || echo failed in 2
1245 (echo 3 "foo ${IFS+'bar} baz") 2>/dev/null || echo failed in 3
1246 (echo -n '4 '; ./pfn "foo ${IFS+"b c"} baz") 2>/dev/null || echo failed in 4
1247 (echo -n '5 '; ./pfn "foo ${IFS+b c} baz") 2>/dev/null || echo failed in 5
1248 (echo 6 ${IFS+"}"z}) 2>/dev/null || echo failed in 6
1249 (echo 7 "${IFS+"}"z}") 2>/dev/null || echo failed in 7
1250 (echo 8 "${IFS+\"}\"z}") 2>/dev/null || echo failed in 8
1251 (echo 9 "${IFS+\"\}\"z}") 2>/dev/null || echo failed in 9
1252 (echo 10 foo ${IFS+'bar} baz'}) 2>/dev/null || echo failed in 10
1253 (echo 11 "$(echo "${IFS+'}'z}")") 2>/dev/null || echo failed in 11
1254 (echo 12 "$(echo ${IFS+'}'z})") 2>/dev/null || echo failed in 12
1255 (echo 13 ${IFS+\}z}) 2>/dev/null || echo failed in 13
1256 (echo 14 "${IFS+\}z}") 2>/dev/null || echo failed in 14
1257 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
1258 l=t; (echo 16 ${IFS+h`echo -n i ${IFS+$l}h`ere}) 2>/dev/null || echo failed in 16
1259 l=t; (echo 17 ${IFS+h$(echo -n i ${IFS+$l}h)ere}) 2>/dev/null || echo failed in 17
1260 l=t; (echo 18 "${IFS+h`echo -n i ${IFS+$l}h`ere}") 2>/dev/null || echo failed in 18
1261 l=t; (echo 19 "${IFS+h$(echo -n i ${IFS+$l}h)ere}") 2>/dev/null || echo failed in 19
1262 l=t; (echo 20 ${IFS+h`echo -n i "${IFS+$l}"h`ere}) 2>/dev/null || echo failed in 20
1263 l=t; (echo 21 ${IFS+h$(echo -n i "${IFS+$l}"h)ere}) 2>/dev/null || echo failed in 21
1264 l=t; (echo 22 "${IFS+h`echo -n i "${IFS+$l}"h`ere}") 2>/dev/null || echo failed in 22
1265 l=t; (echo 23 "${IFS+h$(echo -n i "${IFS+$l}"h)ere}") 2>/dev/null || echo failed in 23
1266 key=value; (echo -n '24 '; ./pfn "${IFS+'$key'}") 2>/dev/null || echo failed in 24
1267 key=value; (echo -n '25 '; ./pfn "${IFS+"'$key'"}") 2>/dev/null || echo failed in 25 # ksh93: “'$key'”
1268 key=value; (echo -n '26 '; ./pfn ${IFS+'$key'}) 2>/dev/null || echo failed in 26
1269 key=value; (echo -n '27 '; ./pfn ${IFS+"'$key'"}) 2>/dev/null || echo failed in 27
1270 (echo -n '28 '; ./pfn "${IFS+"'"x ~ x'}'x"'}"x}" #') 2>/dev/null || echo failed in 28
1271 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
1272 (echo -n '30 '; ./pfs ${IFS+foo 'b\
1273 ar' baz}; echo .) 2>/dev/null || (echo failed in 30; echo failed in 31)
1274 (echo -n '32 '; ./pfs ${IFS+foo "b\
1275 ar" baz}; echo .) 2>/dev/null || echo failed in 32
1276 (echo -n '33 '; ./pfs "${IFS+foo 'b\
1277 ar' baz}"; echo .) 2>/dev/null || echo failed in 33
1278 (echo -n '34 '; ./pfs "${IFS+foo "b\
1279 ar" baz}"; echo .) 2>/dev/null || echo failed in 34
1280 (echo -n '35 '; ./pfs ${v=a\ b} x ${v=c\ d}; echo .) 2>/dev/null || echo failed in 35
1281 (echo -n '36 '; ./pfs "${v=a\ b}" x "${v=c\ d}"; echo .) 2>/dev/null || echo failed in 36
1282 (echo -n '37 '; ./pfs ${v-a\ b} x ${v-c\ d}; echo .) 2>/dev/null || echo failed in 37
1283 (echo 38 ${IFS+x'a'y} / "${IFS+x'a'y}" .) 2>/dev/null || echo failed in 38
1284 foo="x'a'y"; (echo 39 ${foo%*'a'*} / "${foo%*'a'*}" .) 2>/dev/null || echo failed in 39
1285 foo="a b c"; (echo -n '40 '; ./pfs "${foo#a}"; echo .) 2>/dev/null || echo failed in 40
1301 15 <foo abx{ {{{}b c d{} bar> <}> <baz> .
1315 29 <foo> <abx{ {{> <{}b> <c> <d{}> <bar> <}> <baz> .
1318 32 <foo> <bar> <baz> .
1319 33 <foo 'bar' baz> .
1321 35 <a> <b> <x> <a> <b> .
1322 36 <a\ b> <x> <a\ b> .
1323 37 <a b> <x> <c d> .
1328 name: expand-unglob-dblq
1330 Check that regular "${foo+bar}" constructs are parsed correctly
1335 test x"$v" = x"-" && unset v
1336 (echo "$1 plus norm foo ${v+'bar'} baz")
1337 (echo "$1 dash norm foo ${v-'bar'} baz")
1338 (echo "$1 eqal norm foo ${v='bar'} baz")
1339 (echo "$1 qstn norm foo ${v?'bar'} baz") 2>/dev/null || \
1340 echo "$1 qstn norm -> error"
1341 (echo "$1 PLUS norm foo ${v:+'bar'} baz")
1342 (echo "$1 DASH norm foo ${v:-'bar'} baz")
1343 (echo "$1 EQAL norm foo ${v:='bar'} baz")
1344 (echo "$1 QSTN norm foo ${v:?'bar'} baz") 2>/dev/null || \
1345 echo "$1 QSTN norm -> error"
1349 test x"$v" = x"-" && unset v
1350 (echo "$1 plus parn foo ${v+(bar)} baz")
1351 (echo "$1 dash parn foo ${v-(bar)} baz")
1352 (echo "$1 eqal parn foo ${v=(bar)} baz")
1353 (echo "$1 qstn parn foo ${v?(bar)} baz") 2>/dev/null || \
1354 echo "$1 qstn parn -> error"
1355 (echo "$1 PLUS parn foo ${v:+(bar)} baz")
1356 (echo "$1 DASH parn foo ${v:-(bar)} baz")
1357 (echo "$1 EQAL parn foo ${v:=(bar)} baz")
1358 (echo "$1 QSTN parn foo ${v:?(bar)} baz") 2>/dev/null || \
1359 echo "$1 QSTN parn -> error"
1363 test x"$v" = x"-" && unset v
1364 (echo "$1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz")
1365 (echo "$1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz")
1366 (echo "$1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz")
1367 (echo "$1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz") 2>/dev/null || \
1368 echo "$1 qstn brac -> error"
1369 (echo "$1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz")
1370 (echo "$1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz")
1371 (echo "$1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz")
1372 (echo "$1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz") 2>/dev/null || \
1373 echo "$1 QSTN brac -> error"
1386 1 dash norm foo 'bar' baz
1387 1 eqal norm foo 'bar' baz
1388 1 qstn norm -> error
1390 1 DASH norm foo 'bar' baz
1391 1 EQAL norm foo 'bar' baz
1392 1 QSTN norm -> error
1393 2 plus norm foo 'bar' baz
1398 2 DASH norm foo 'bar' baz
1399 2 EQAL norm foo 'bar' baz
1400 2 QSTN norm -> error
1401 3 plus norm foo 'bar' baz
1402 3 dash norm foo x baz
1403 3 eqal norm foo x baz
1404 3 qstn norm foo x baz
1405 3 PLUS norm foo 'bar' baz
1406 3 DASH norm foo x baz
1407 3 EQAL norm foo x baz
1408 3 QSTN norm foo x baz
1410 4 dash parn foo (bar) baz
1411 4 eqal parn foo (bar) baz
1412 4 qstn parn -> error
1414 4 DASH parn foo (bar) baz
1415 4 EQAL parn foo (bar) baz
1416 4 QSTN parn -> error
1417 5 plus parn foo (bar) baz
1422 5 DASH parn foo (bar) baz
1423 5 EQAL parn foo (bar) baz
1424 5 QSTN parn -> error
1425 6 plus parn foo (bar) baz
1426 6 dash parn foo x baz
1427 6 eqal parn foo x baz
1428 6 qstn parn foo x baz
1429 6 PLUS parn foo (bar) baz
1430 6 DASH parn foo x baz
1431 6 EQAL parn foo x baz
1432 6 QSTN parn foo x baz
1433 7 plus brac foo c } baz
1434 7 dash brac foo ax{{{}b c d{} baz
1435 7 eqal brac foo ax{{{}b c ax{{{}b} baz
1436 7 qstn brac -> error
1437 7 PLUS brac foo c } baz
1438 7 DASH brac foo ax{{{}b c d{} baz
1439 7 EQAL brac foo ax{{{}b c ax{{{}b} baz
1440 7 QSTN brac -> error
1441 8 plus brac foo ax{{{}b c d{} baz
1442 8 dash brac foo c } baz
1443 8 eqal brac foo c } baz
1444 8 qstn brac foo c } baz
1445 8 PLUS brac foo c } baz
1446 8 DASH brac foo ax{{{}b c d{} baz
1447 8 EQAL brac foo ax{{{}b c ax{{{}b} baz
1448 8 QSTN brac -> error
1449 9 plus brac foo ax{{{}b c d{} baz
1450 9 dash brac foo x c x} baz
1451 9 eqal brac foo x c x} baz
1452 9 qstn brac foo x c x} baz
1453 9 PLUS brac foo ax{{{}b c d{} baz
1454 9 DASH brac foo x c x} baz
1455 9 EQAL brac foo x c x} baz
1456 9 QSTN brac foo x c x} baz
1458 name: expand-unglob-unq
1460 Check that regular ${foo+bar} constructs are parsed correctly
1465 test x"$v" = x"-" && unset v
1466 (echo $1 plus norm foo ${v+'bar'} baz)
1467 (echo $1 dash norm foo ${v-'bar'} baz)
1468 (echo $1 eqal norm foo ${v='bar'} baz)
1469 (echo $1 qstn norm foo ${v?'bar'} baz) 2>/dev/null || \
1470 echo "$1 qstn norm -> error"
1471 (echo $1 PLUS norm foo ${v:+'bar'} baz)
1472 (echo $1 DASH norm foo ${v:-'bar'} baz)
1473 (echo $1 EQAL norm foo ${v:='bar'} baz)
1474 (echo $1 QSTN norm foo ${v:?'bar'} baz) 2>/dev/null || \
1475 echo "$1 QSTN norm -> error"
1479 test x"$v" = x"-" && unset v
1480 (echo $1 plus parn foo ${v+\(bar')'} baz)
1481 (echo $1 dash parn foo ${v-\(bar')'} baz)
1482 (echo $1 eqal parn foo ${v=\(bar')'} baz)
1483 (echo $1 qstn parn foo ${v?\(bar')'} baz) 2>/dev/null || \
1484 echo "$1 qstn parn -> error"
1485 (echo $1 PLUS parn foo ${v:+\(bar')'} baz)
1486 (echo $1 DASH parn foo ${v:-\(bar')'} baz)
1487 (echo $1 EQAL parn foo ${v:=\(bar')'} baz)
1488 (echo $1 QSTN parn foo ${v:?\(bar')'} baz) 2>/dev/null || \
1489 echo "$1 QSTN parn -> error"
1493 test x"$v" = x"-" && unset v
1494 (echo $1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz)
1495 (echo $1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz)
1496 (echo $1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz)
1497 (echo $1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz) 2>/dev/null || \
1498 echo "$1 qstn brac -> error"
1499 (echo $1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz)
1500 (echo $1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz)
1501 (echo $1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz)
1502 (echo $1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz) 2>/dev/null || \
1503 echo "$1 QSTN brac -> error"
1516 1 dash norm foo bar baz
1517 1 eqal norm foo bar baz
1518 1 qstn norm -> error
1520 1 DASH norm foo bar baz
1521 1 EQAL norm foo bar baz
1522 1 QSTN norm -> error
1523 2 plus norm foo bar baz
1528 2 DASH norm foo bar baz
1529 2 EQAL norm foo bar baz
1530 2 QSTN norm -> error
1531 3 plus norm foo bar baz
1532 3 dash norm foo x baz
1533 3 eqal norm foo x baz
1534 3 qstn norm foo x baz
1535 3 PLUS norm foo bar baz
1536 3 DASH norm foo x baz
1537 3 EQAL norm foo x baz
1538 3 QSTN norm foo x baz
1540 4 dash parn foo (bar) baz
1541 4 eqal parn foo (bar) baz
1542 4 qstn parn -> error
1544 4 DASH parn foo (bar) baz
1545 4 EQAL parn foo (bar) baz
1546 4 QSTN parn -> error
1547 5 plus parn foo (bar) baz
1552 5 DASH parn foo (bar) baz
1553 5 EQAL parn foo (bar) baz
1554 5 QSTN parn -> error
1555 6 plus parn foo (bar) baz
1556 6 dash parn foo x baz
1557 6 eqal parn foo x baz
1558 6 qstn parn foo x baz
1559 6 PLUS parn foo (bar) baz
1560 6 DASH parn foo x baz
1561 6 EQAL parn foo x baz
1562 6 QSTN parn foo x baz
1563 7 plus brac foo c } baz
1564 7 dash brac foo ax{{{}b c d{} baz
1565 7 eqal brac foo ax{{{}b c ax{{{}b} baz
1566 7 qstn brac -> error
1567 7 PLUS brac foo c } baz
1568 7 DASH brac foo ax{{{}b c d{} baz
1569 7 EQAL brac foo ax{{{}b c ax{{{}b} baz
1570 7 QSTN brac -> error
1571 8 plus brac foo ax{{{}b c d{} baz
1572 8 dash brac foo c } baz
1573 8 eqal brac foo c } baz
1574 8 qstn brac foo c } baz
1575 8 PLUS brac foo c } baz
1576 8 DASH brac foo ax{{{}b c d{} baz
1577 8 EQAL brac foo ax{{{}b c ax{{{}b} baz
1578 8 QSTN brac -> error
1579 9 plus brac foo ax{{{}b c d{} baz
1580 9 dash brac foo x c x} baz
1581 9 eqal brac foo x c x} baz
1582 9 qstn brac foo x c x} baz
1583 9 PLUS brac foo ax{{{}b c d{} baz
1584 9 DASH brac foo x c x} baz
1585 9 EQAL brac foo x c x} baz
1586 9 QSTN brac foo x c x} baz
1588 name: expand-threecolons-dblq
1590 Check for a particular thing that used to segfault
1593 echo "${TEST:1:2:3}"
1594 echo $? but still living
1595 expected-stderr-pattern:
1599 name: expand-threecolons-unq
1601 Check for a particular thing that used to not error out
1605 echo $? but still living
1606 expected-stderr-pattern:
1610 name: expand-weird-1
1612 Check corner case of trim expansion vs. $# vs. ${#var}
1614 set 1 2 3 4 5 6 7 8 9 10 11
1615 echo ${#} # value of $#
1616 echo ${##} # length of $#
1617 echo ${##1} # $# trimmed 1
1618 set 1 2 3 4 5 6 7 8 9 10 11 12
1626 name: expand-weird-2
1628 Check corner case of ${var?} vs. ${#var}
1638 name: expand-weird-3
1640 Check that trimming works with positional parameters (Debian #48453)
1651 name: expand-number-1
1653 Check that positional arguments do not overflow
1655 echo "1 ${12345678901234567890} ."
1661 Check that globbing isn't done when glob has syntax error
1662 file-setup: file 644 "abcx"
1663 file-setup: file 644 "abcz"
1664 file-setup: file 644 "bbc"
1674 Check that globbing isn't done when glob has syntax error
1675 (AT&T ksh fails this test)
1676 file-setup: file 644 "abcx"
1677 file-setup: file 644 "abcz"
1678 file-setup: file 644 "bbc"
1684 name: eglob-infinite-plus
1686 Check that shell doesn't go into infinite loop expanding +(...)
1688 file-setup: file 644 "abc"
1703 Check that eglobbing isn't done on substitution results
1704 file-setup: file 644 "abc"
1711 name: eglob-nomatch-1
1713 Check that the pattern doesn't match
1715 echo 1: no-file+(a|b)stuff
1716 echo 2: no-file+(a*(c)|b)stuff
1717 echo 3: no-file+((((c)))|b)stuff
1719 1: no-file+(a|b)stuff
1720 2: no-file+(a*(c)|b)stuff
1721 3: no-file+((((c)))|b)stuff
1725 Check that the pattern matches correctly
1726 file-setup: file 644 "abd"
1727 file-setup: file 644 "acd"
1728 file-setup: file 644 "abac"
1732 echo 3: *(a(b|c)) # (...|...) can be used within X(..)
1733 echo 4: a[b*(foo|bar)]d # patterns not special inside [...]
1742 Simple negation tests
1744 case foo in !(foo|bar)) echo yes;; *) echo no;; esac
1745 case bar in !(foo|bar)) echo yes;; *) echo no;; esac
1754 case foo in *(a|b[)) echo yes;; *) echo no;; esac
1755 case foo in *(a|b[)|f*) echo yes;; *) echo no;; esac
1756 case '*(a|b[)' in *(a|b[)) echo yes;; *) echo no;; esac
1764 Eglobbing in trim expressions...
1765 (AT&T ksh fails this - docs say # matches shortest string, ## matches
1781 Check eglobbing works in trims...
1784 echo 1: ${x#*(a|b)cd}
1785 echo 2: "${x#*(a|b)cd}"
1786 echo 3: ${x#"*(a|b)cd"}
1796 Check eglobbing works in trims, for Korn Shell
1797 Ensure eglobbing does not work for reduced-feature /bin/sh
1803 echo "<${x%bar|baz},${y%bar|baz},${z%\?}>"
1804 echo "<${x%ba(r|z)},${y%ba(r|z)}>"
1806 echo "<${x%bar|baz},${y%bar|baz},${z%\?}>"
1812 <foobar,foobaz,fooba>
1815 name: eglob-substrpl-1
1817 Check eglobbing works in substs... and they work at all
1819 [[ -n $BASH_VERSION ]] && shopt -s extglob
1820 x=1222321_ab/cde_b/c_1221
1829 echo 8: ${x//+(2)/4}
1830 echo 9: ${x/b/c/e/f}
1831 echo 10: ${x/b\/c/e/f}
1832 echo 11: ${x/b\/c/e\/f}
1833 echo 12: ${x/b\/c/e\\/f}
1834 echo 13: ${x/b\\/c/e\\/f}
1835 echo 14: ${x//b/c/e/f}
1836 echo 15: ${x//b\/c/e/f}
1837 echo 16: ${x//b\/c/e\/f}
1838 echo 17: ${x//b\/c/e\\/f}
1839 echo 18: ${x//b\\/c/e\\/f}
1840 echo 19: ${x/b\/*\/c/x}
1846 echo 25: ${x//\%1/9}
1847 echo 26: ${x//\\%1/9}
1849 echo 28: ${x//\\a/9}
1852 1: 122321_ab/cde_b/c_1221
1853 2: 131_ab/cde_b/c_11
1854 3: 1321_ab/cde_b/c_1221
1855 4: 131_ab/cde_b/c_11
1856 5: 1422321_ab/cde_b/c_1221
1857 6: 1444341_ab/cde_b/c_1441
1858 7: 14321_ab/cde_b/c_1221
1859 8: 14341_ab/cde_b/c_141
1860 9: 1222321_ac/e/f/cde_b/c_1221
1861 10: 1222321_ae/fde_b/c_1221
1862 11: 1222321_ae/fde_b/c_1221
1863 12: 1222321_ae\/fde_b/c_1221
1864 13: 1222321_ab/cde_b/c_1221
1865 14: 1222321_ac/e/f/cde_c/e/f/c_1221
1866 15: 1222321_ae/fde_e/f_1221
1867 16: 1222321_ae/fde_e/f_1221
1868 17: 1222321_ae\/fde_e\/f_1221
1869 18: 1222321_ab/cde_b/c_1221
1871 20: 1222321_ab.cde_b/c_1221
1872 21: 1222321_ab.cde_b.c_1221
1873 22: 1222321_ab/cde_b/c_1221
1874 23: 9222321_ab/cde_b/c_1221
1875 24: 1222321_ab/cde_b/c_1229
1876 25: 1222321_ab/cde_b/c_1229
1877 26: 1222321_ab/cde_b/c_1221
1878 27: 1222321_9b/cde_b/c_1221
1879 28: 1222321_9b/cde_b/c_1221
1880 29: 1xyz22321_ab/cde_b/c_1221
1882 name: eglob-substrpl-2
1884 Check anchored substring replacement works, corner cases
1901 name: eglob-substrpl-3a
1903 Check substring replacement works with variables and slashes, too
1907 echo "${wd/#$pfx/~}"
1908 echo "${wd/#\$pfx/~}"
1909 echo "${wd/#"$pfx"/~}"
1910 echo "${wd/#'$pfx'/~}"
1911 echo "${wd/#"\$pfx"/~}"
1912 echo "${wd/#'\$pfx'/~}"
1921 name: eglob-substrpl-3b
1923 More of this, bash fails it (bash4 passes)
1927 echo "${wd/#$(echo /home/user)/~}"
1928 echo "${wd/#"$(echo /home/user)"/~}"
1929 echo "${wd/#'$(echo /home/user)'/~}"
1935 name: eglob-substrpl-3c
1937 Even more weird cases
1941 echo 1: ${wd/#$pfx/~}
1942 echo 2: ${wd/#\$pfx/~}
1943 echo 3: ${wd/#"$pfx"/~}
1944 echo 4: ${wd/#'$pfx'/~}
1945 echo 5: ${wd/#"\$pfx"/~}
1946 echo 6: ${wd/#'\$pfx'/~}
1947 ts='a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)'
1950 [[ -n $BASH_VERSION ]] && shopt -s extglob
1951 echo 7: ${ts/a\/b/$tr}
1952 echo 8: ${ts/a\/b/\$tr}
1953 echo 9: ${ts/$tp/$tr}
1954 echo 10: ${ts/\$tp/$tr}
1955 echo 11: ${ts/\\$tp/$tr}
1956 echo 12: ${ts/$tp/c/d}
1957 echo 13: ${ts/$tp/c\/d}
1958 echo 14: ${ts/$tp/c\\/d}
1959 echo 15: ${ts/+(a\/b)/$tr}
1960 echo 16: ${ts/+(a\/b)/\$tr}
1961 echo 17: ${ts/+($tp)/$tr}
1962 echo 18: ${ts/+($tp)/c/d}
1963 echo 19: ${ts/+($tp)/c\/d}
1964 echo 25: ${ts//a\/b/$tr}
1965 echo 26: ${ts//a\/b/\$tr}
1966 echo 27: ${ts//$tp/$tr}
1967 echo 28: ${ts//$tp/c/d}
1968 echo 29: ${ts//$tp/c\/d}
1969 echo 30: ${ts//+(a\/b)/$tr}
1970 echo 31: ${ts//+(a\/b)/\$tr}
1971 echo 32: ${ts//+($tp)/$tr}
1972 echo 33: ${ts//+($tp)/c/d}
1973 echo 34: ${ts//+($tp)/c\/d}
1975 echo 40: ${ts/$tp/$tr}
1976 echo 41: ${ts//$tp/$tr}
1984 7: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1985 8: $tra/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1986 9: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1987 10: a/ba/bc/d$tp_a/b$tp_*(a/b)_*($tp)
1988 11: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1989 12: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1990 13: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1991 14: c\/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1992 15: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
1993 16: $tr$tp$tp_a/b$tp_*(a/b)_*($tp)
1994 17: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
1995 18: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
1996 19: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
1997 25: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1998 26: $tr$tr$tp$tp_$tr$tp_*($tr)_*($tp)
1999 27: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2000 28: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2001 29: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2002 30: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2003 31: $tr$tp$tp_$tr$tp_*($tr)_*($tp)
2004 32: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2005 33: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2006 34: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2007 40: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2008 41: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
2009 # This is what GNU bash does:
2010 # 40: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
2011 # 41: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
2015 UTF-8 mode differences for eglobbing
2020 print 2: ${s/b???d/x} .
2023 print 4: ${s/b??d/x} .
2025 print 5: ${x%?} ${x%%?} .
2027 print 6: ${x#?} ${x##?} .
2029 print 7: ${x%?} ${x%%?} .
2031 print 8: ${x%?} ${x%%?} .
2033 print 9: ${x%?} ${x%%?} .
2047 Check that globbing isn't done when glob has syntax error
2048 file-setup: dir 755 "[x"
2049 file-setup: file 644 "[x/foo"
2061 Check that symbolic links aren't stat()'d
2062 # breaks on FreeMiNT (cannot unlink dangling symlinks)
2063 # breaks on MSYS (does not support symlinks)
2064 # breaks on Dell UNIX 4.0 R2.2 (SVR4) where unlink also fails
2065 category: !os:mint,!os:msys,!os:svr4.0,!nosymlink
2066 file-setup: dir 755 "dir"
2067 file-setup: symlink 644 "dir/abc"
2079 file-setup: file 644 ".bc"
2080 file-setup: file 644 "abc"
2081 file-setup: file 644 "bbc"
2082 file-setup: file 644 "cbc"
2083 file-setup: file 644 "-bc"
2106 (AT&T ksh fails this; POSIX says invalid)
2107 file-setup: file 644 "abc"
2115 Check that globbing matches the right things...
2116 # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
2117 # breaks on Cygwin 1.7 (files are now UTF-16 or something)
2118 # breaks on QNX 6.4.1 (says RT)
2119 category: !os:cygwin,!os:darwin,!os:msys,!os:nto
2121 file-setup: file 644 "aÂc"
2129 Results unspecified according to POSIX
2130 file-setup: file 644 ".bc"
2138 Results unspecified according to POSIX
2139 (AT&T ksh treats this like [a-cc-e]*)
2140 file-setup: file 644 "abc"
2141 file-setup: file 644 "bbc"
2142 file-setup: file 644 "cbc"
2143 file-setup: file 644 "dbc"
2144 file-setup: file 644 "ebc"
2145 file-setup: file 644 "-bc"
2153 Check against a regression from fixing IFS-subst-2
2156 print -r "before='$x'"
2158 print -r "after ='$x'"
2165 Check ordering/content of redundent here documents.
2177 Check quoted here-doc is protected.
2196 Check that newline isn't needed after heredoc-delimiter marker.
2208 Check that an error occurs if the heredoc-delimiter is missing.
2213 expected-exit: e > 0
2214 expected-stderr-pattern: /.*/
2218 Check that backslash quotes a $, ` and \ and kills a \newline
2225 th\`echo not-run\`ere
2226 th\\`echo is-run`ere
2243 Check that \newline in initial here-delim word doesn't imply
2258 Check that double quoted $ expressions in here delimiters are
2259 not expanded and match the delimiter.
2260 POSIX says only quote removal is applied to the delimiter.
2277 Check that double quoted escaped $ expressions in here
2278 delimiters are not expanded and match the delimiter.
2279 POSIX says only quote removal is applied to the delimiter
2280 (\ counts as a quote).
2301 Check that here strings work.
2305 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo
2306 "$__progname" -c "tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo"
2307 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$bar"
2308 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<'$bar'
2309 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$bar
2310 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<-foo
2311 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$(echo "foo bar")"
2324 Check that a corner case of here strings works like bash
2329 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
2336 Check that a corner case of here strings works like ksh93, zsh
2341 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
2348 Check another corner case of here strings
2350 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<< bar
2356 Check here string related regression with multiple iops
2358 echo $(tr r z <<<'bar' 2>/dev/null)
2364 Check direct here document assignment
2378 fnd=$(typeset -f foo)
2386 # rather nonsensical, but…
2389 vf=<<<$'=f $x \x40='
2391 print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} ve={$ve} vf={$vf} |"
2410 Check here documents with no or empty delimiter
2427 fnd=$(typeset -f foo)
2435 print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} |"
2454 name: heredoc-comsub-1
2456 Tests for here documents in COMSUB, taken from Austin ML
2463 = here is the text =
2465 name: heredoc-comsub-2
2467 Tests for here documents in COMSUB, taken from Austin ML
2469 unbalanced=$(cat <<EOF
2470 this paren ) is a problem
2472 echo = $unbalanced =
2474 = this paren ) is a problem =
2476 name: heredoc-comsub-3
2478 Tests for here documents in COMSUB, taken from Austin ML
2480 balanced=$(cat <<EOF
2481 these parens ( ) are not a problem
2485 = these parens ( ) are not a problem =
2487 name: heredoc-comsub-4
2489 Tests for here documents in COMSUB, taken from Austin ML
2491 balanced=$(cat <<EOF
2492 these parens \( ) are a problem
2496 = these parens \( ) are a problem =
2498 name: heredoc-subshell-1
2500 Tests for here documents in subshells, taken from Austin ML
2510 name: heredoc-subshell-2
2512 Tests for here documents in subshells, taken from Austin ML
2523 name: heredoc-subshell-3
2525 Tests for here documents in subshells, taken from Austin ML
2535 name: heredoc-weird-1
2537 Tests for here documents, taken from Austin ML
2538 Documents current state in mksh, *NOT* necessarily correct!
2551 name: heredoc-weird-2
2553 Tests for here documents, taken from Austin ML
2563 name: heredoc-weird-4
2565 Tests for here documents, taken from Austin ML
2566 Documents current state in mksh, *NOT* necessarily correct!
2577 name: heredoc-weird-5
2579 Tests for here documents, taken from Austin ML
2580 Documents current state in mksh, *NOT* necessarily correct!
2592 name: heredoc-tmpfile-1
2594 Check that heredoc temp files aren't removed too soon or too late.
2595 Heredoc in simple command.
2616 name: heredoc-tmpfile-2
2618 Check that heredoc temp files aren't removed too soon or too late.
2619 Heredoc in function, multiple calls to function.
2638 name: heredoc-tmpfile-3
2640 Check that heredoc temp files aren't removed too soon or too late.
2641 Heredoc in function in loop, multiple calls to function.
2668 name: heredoc-tmpfile-4
2670 Check that heredoc temp files aren't removed too soon or too late.
2671 Backgrounded simple command with here doc
2685 name: heredoc-tmpfile-5
2687 Check that heredoc temp files aren't removed too soon or too late.
2688 Backgrounded subshell command with here doc
2693 sleep 1 # so parent exits
2709 name: heredoc-tmpfile-6
2711 Check that heredoc temp files aren't removed too soon or too late.
2712 Heredoc in pipeline.
2716 cat <<- EOF | sed "s/hi/HI/"
2726 name: heredoc-tmpfile-7
2728 Check that heredoc temp files aren't removed too soon or too late.
2729 Heredoc in backgrounded pipeline.
2733 cat <<- EOF | sed 's/hi/HI/' &
2743 name: heredoc-tmpfile-8
2745 Check that heredoc temp files aren't removed too soon or too
2746 late. Heredoc in function, backgrounded call to function.
2747 This check can fail on slow machines (<100 MHz), or Cygwin,
2752 # Background eval so main shell doesn't do parsing
2760 # sleep so eval can die
2774 name: heredoc-quoting-unsubst
2776 Check for correct handling of quoted characters in
2777 here documents without substitution (marker is quoted).
2781 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
2784 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
2786 name: heredoc-quoting-subst
2788 Check for correct handling of quoted characters in
2789 here documents with substitution (marker is not quoted).
2793 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
2796 x " \" \ \ $ $ baz `echo baz` bar $foo x
2798 name: single-quotes-in-braces
2800 Check that single quotes inside unquoted {} are treated as quotes
2803 echo ${foo:+'blah $foo'}
2807 name: single-quotes-in-quoted-braces
2809 Check that single quotes inside quoted {} are treated as
2813 echo "${foo:+'blah $foo'}"
2817 name: single-quotes-in-braces-nested
2819 Check that single quotes inside unquoted {} are treated as quotes,
2820 even if that's inside a double-quoted command expansion
2823 echo "$( echo ${foo:+'blah $foo'})"
2827 name: single-quotes-in-brace-pattern
2829 Check that single quotes inside {} pattern are treated as quotes
2832 echo ${foo%'2'*} "${foo%'2'*}" ${foo%2'*'} "${foo%2'*'}"
2836 name: single-quotes-in-heredoc-braces
2838 Check that single quotes inside {} in heredoc are treated
2848 name: single-quotes-in-nested-braces
2850 Check that single quotes inside nested unquoted {} are
2854 echo ${foo:+${foo:+'blah $foo'}}
2858 name: single-quotes-in-nested-quoted-braces
2860 Check that single quotes inside nested quoted {} are treated
2864 echo "${foo:+${foo:+'blah $foo'}}"
2868 name: single-quotes-in-nested-braces-nested
2870 Check that single quotes inside nested unquoted {} are treated
2871 as quotes, even if that's inside a double-quoted command expansion
2874 echo "$( echo ${foo:+${foo:+'blah $foo'}})"
2878 name: single-quotes-in-nested-brace-pattern
2880 Check that single quotes inside nested {} pattern are treated as quotes
2883 echo ${foo:+${foo%'2'*}} "${foo:+${foo%'2'*}}" ${foo:+${foo%2'*'}} "${foo:+${foo%2'*'}}"
2887 name: single-quotes-in-heredoc-nested-braces
2889 Check that single quotes inside nested {} in heredoc are treated
2894 ${foo:+${foo:+'blah $foo'}}
2901 See if we can test history at all
2904 env-setup: !ENV=./Env!HISTFILE=hist.file!
2905 file-setup: file 644 "Env"
2913 expected-stderr-pattern:
2918 Verify duplicates and spaces are not entered
2921 env-setup: !ENV=./Env!HISTFILE=hist.file!
2922 file-setup: file 644 "Env"
2934 expected-stderr-pattern:
2937 name: history-unlink
2939 Check if broken HISTFILEs do not cause trouble
2942 env-setup: !ENV=./Env!HISTFILE=foo/hist.file!
2943 file-setup: file 644 "Env"
2945 file-setup: dir 755 "foo"
2946 file-setup: file 644 "foo/hist.file"
2949 perl-setup: chmod(0555, "foo");
2957 expected-stderr-pattern:
2958 /(.*can't unlink HISTFILE.*\n)?X*$/
2960 name: history-e-minus-1
2962 Check if more recent command is executed
2965 env-setup: !ENV=./Env!HISTFILE=hist.file!
2966 file-setup: file 644 "Env"
2976 expected-stderr-pattern:
2977 /^X*echo there\nX*$/
2979 name: history-e-minus-2
2981 Check that repeated command is printed before command
2985 env-setup: !ENV=./Env!HISTFILE=hist.file!
2986 file-setup: file 644 "Env"
2993 expected-stdout-pattern:
2994 /X*hi\nX*there\nX*echo there\nthere\nX*/
2995 expected-stderr-pattern:
2998 name: history-e-minus-3
3000 fc -e - fails when there is no history
3001 (ksh93 has a bug that causes this to fail)
3002 (ksh88 loops on this)
3005 env-setup: !ENV=./Env!HISTFILE=hist.file!
3006 file-setup: file 644 "Env"
3013 expected-stderr-pattern:
3014 /^X*.*:.*history.*\nX*$/
3016 name: history-e-minus-4
3018 Check if "fc -e -" command output goes to stdout.
3021 env-setup: !ENV=./Env!HISTFILE=hist.file!
3022 file-setup: file 644 "Env"
3026 fc -e - | (read x; echo "A $x")
3032 expected-stderr-pattern:
3035 name: history-e-minus-5
3037 fc is replaced in history by new command.
3040 env-setup: !ENV=./Env!HISTFILE=hist.file!
3041 file-setup: file 644 "Env"
3057 expected-stderr-pattern:
3058 /^X*echo ghi jkl\nX*$/
3060 name: history-list-1
3062 List lists correct range
3063 (ksh88 fails 'cause it lists the fc command)
3066 env-setup: !ENV=./Env!HISTFILE=hist.file!
3067 file-setup: file 644 "Env"
3080 expected-stderr-pattern:
3083 name: history-list-2
3085 Lists oldest history if given pre-historic number
3086 (ksh93 has a bug that causes this to fail)
3087 (ksh88 fails 'cause it lists the fc command)
3090 env-setup: !ENV=./Env!HISTFILE=hist.file!
3091 file-setup: file 644 "Env"
3105 expected-stderr-pattern:
3108 name: history-list-3
3110 Can give number 'options' to fc
3113 env-setup: !ENV=./Env!HISTFILE=hist.file!
3114 file-setup: file 644 "Env"
3129 expected-stderr-pattern:
3132 name: history-list-4
3134 -1 refers to previous command
3137 env-setup: !ENV=./Env!HISTFILE=hist.file!
3138 file-setup: file 644 "Env"
3152 expected-stderr-pattern:
3155 name: history-list-5
3157 List command stays in history
3160 env-setup: !ENV=./Env!HISTFILE=hist.file!
3161 file-setup: file 644 "Env"
3178 expected-stderr-pattern:
3181 name: history-list-6
3183 HISTSIZE limits about of history kept.
3184 (ksh88 fails 'cause it lists the fc command)
3187 env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3!
3188 file-setup: file 644 "Env"
3205 expected-stderr-pattern:
3208 name: history-list-7
3210 fc allows too old/new errors in range specification
3213 env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3!
3214 file-setup: file 644 "Env"
3232 expected-stderr-pattern:
3235 name: history-list-r-1
3237 test -r flag in history
3240 env-setup: !ENV=./Env!HISTFILE=hist.file!
3241 file-setup: file 644 "Env"
3259 expected-stderr-pattern:
3262 name: history-list-r-2
3264 If first is newer than last, -r is implied.
3267 env-setup: !ENV=./Env!HISTFILE=hist.file!
3268 file-setup: file 644 "Env"
3286 expected-stderr-pattern:
3289 name: history-list-r-3
3291 If first is newer than last, -r is cancelled.
3294 env-setup: !ENV=./Env!HISTFILE=hist.file!
3295 file-setup: file 644 "Env"
3313 expected-stderr-pattern:
3316 name: history-subst-1
3321 env-setup: !ENV=./Env!HISTFILE=hist.file!
3322 file-setup: file 644 "Env"
3327 fc -e - abc=AB 'echo a'
3332 expected-stderr-pattern:
3333 /^X*echo AB def\nX*$/
3335 name: history-subst-2
3337 Does subst find previous command?
3340 env-setup: !ENV=./Env!HISTFILE=hist.file!
3341 file-setup: file 644 "Env"
3346 fc -e - jkl=XYZQRT 'echo g'
3351 expected-stderr-pattern:
3352 /^X*echo ghi XYZQRT\nX*$/
3354 name: history-subst-3
3356 Does subst find previous command when no arguments given
3359 env-setup: !ENV=./Env!HISTFILE=hist.file!
3360 file-setup: file 644 "Env"
3370 expected-stderr-pattern:
3371 /^X*echo ghi XYZQRT\nX*$/
3373 name: history-subst-4
3375 Global substitutions work
3376 (ksh88 and ksh93 do not have -g option)
3379 env-setup: !ENV=./Env!HISTFILE=hist.file!
3380 file-setup: file 644 "Env"
3383 echo abc def asjj sadjhasdjh asdjhasd
3386 abc def asjj sadjhasdjh asdjhasd
3387 FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd
3388 expected-stderr-pattern:
3389 /^X*echo FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd\nX*$/
3391 name: history-subst-5
3393 Make sure searches don't find current (fc) command
3394 (ksh88/ksh93 don't have the ? prefix thing so they fail this test)
3397 env-setup: !ENV=./Env!HISTFILE=hist.file!
3398 file-setup: file 644 "Env"
3403 fc -e - abc=AB \?abc
3408 expected-stderr-pattern:
3409 /^X*echo AB def\nX*$/
3411 name: history-ed-1-old
3413 Basic (ed) editing works (assumes you have generic ed editor
3414 that prints no prompts). This is for oldish ed(1) which write
3415 the character count to stdout.
3420 env-setup: !ENV=./Env!HISTFILE=hist.file!
3421 file-setup: file 644 "Env"
3434 expected-stderr-pattern:
3435 /^X*echo FOOBAR def\nX*$/
3437 name: history-ed-2-old
3439 Correct command is edited when number given
3444 env-setup: !ENV=./Env!HISTFILE=hist.file!
3445 file-setup: file 644 "Env"
3453 s/is here/is changed/
3464 expected-stderr-pattern:
3465 /^X*echo line 2 is changed\nX*$/
3467 name: history-ed-3-old
3469 Newly created multi line commands show up as single command
3471 (NOTE: adjusted for COMPLEX HISTORY compile time option)
3472 (ksh88 fails 'cause it lists the fc command)
3477 env-setup: !ENV=./Env!HISTFILE=hist.file!
3478 file-setup: file 644 "Env"
3499 expected-stderr-pattern:
3500 /^X*echo FOOBAR def\necho a new line\nX*$/
3504 Basic (ed) editing works (assumes you have generic ed editor
3505 that prints no prompts). This is for newish ed(1) and stderr.
3506 category: !no-stderr-ed
3510 env-setup: !ENV=./Env!HISTFILE=hist.file!
3511 file-setup: file 644 "Env"
3522 expected-stderr-pattern:
3523 /^X*13\n16\necho FOOBAR def\nX*$/
3527 Correct command is edited when number given
3528 category: !no-stderr-ed
3532 env-setup: !ENV=./Env!HISTFILE=hist.file!
3533 file-setup: file 644 "Env"
3541 s/is here/is changed/
3550 expected-stderr-pattern:
3551 /^X*20\n23\necho line 2 is changed\nX*$/
3555 Newly created multi line commands show up as single command
3557 category: !no-stderr-ed
3561 env-setup: !ENV=./Env!HISTFILE=hist.file!
3562 file-setup: file 644 "Env"
3581 expected-stderr-pattern:
3582 /^X*13\n32\necho FOOBAR def\necho a new line\nX*$/
3586 Simple test, default IFS
3588 showargs() { for i; do echo -n " <$i>"; done; echo; }
3604 showargs() { for i; do echo -n " <$i>"; done; echo; }
3621 showargs() { for i; do echo -n " <$i>"; done; echo; }
3634 name: IFS-space-colon-1
3636 Simple test, IFS=<white-space>:
3638 showargs() { for i; do echo -n " <$i>"; done; echo; }
3653 name: IFS-space-colon-2
3655 Simple test, IFS=<white-space>:
3656 AT&T ksh fails this, POSIX says the test is correct.
3658 showargs() { for i; do echo -n " <$i>"; done; echo; }
3665 name: IFS-space-colon-4
3667 Simple test, IFS=<white-space>:
3669 showargs() { for i; do echo -n " <$i>"; done; echo; }
3676 name: IFS-space-colon-5
3678 Simple test, IFS=<white-space>:
3679 Don't know what POSIX thinks of this. AT&T ksh does not do this.
3681 showargs() { for i; do echo -n " <$i>"; done; echo; }
3690 Simple test, IFS=<white-space>:
3692 showargs() { for i; do echo -n " <$i>"; done; echo; }
3695 echo -n '1:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3696 echo -n '2:'; for i in :b:: ; do echo -n " [$i]" ; done ; echo
3700 echo -n '5:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3703 echo -n '7:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3705 echo -n '9:'; for i in ${FOO-`echo -n h:i`th:ere} ; do echo -n " [$i]" ; done ; echo
3706 showargs 10 ${FOO-`echo -n h:i`th:ere}
3707 showargs 11 "${FOO-`echo -n h:i`th:ere}"
3709 echo -n '12:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3721 <10> <h> <ith> <ere>
3728 Check leading whitespace after trim does not make a field
3730 showargs() { for i; do echo -n " <$i>"; done; echo; }
3732 showargs 1 shift ${x#X}
3738 Check leading IFS non-whitespace after trim does make a field
3739 but leading IFS whitespace does not, nor empty replacements
3741 showargs() { for i; do echo -n " <$i>"; done; echo; }
3744 showargs 1 ${-+:foo:bar}
3746 showargs 2 ${-+ foo bar}
3754 reported by mikeserv
3756 a='space divded argument
3759 IFS= ; q="$*" ; nq=$*
3760 printf '<%s>\n' "$*" $* "$q" "$nq"
3761 [ "$q" = "$nq" ] && echo =true || echo =false
3763 <spacedivdedargument
3769 <spacedivdedargument
3771 <spacedivdedargument
3777 extended testsuite based on problem by mikeserv
3779 a='space divded argument
3782 IFS= ; q="$@" ; nq=$@
3783 printf '<%s>\n' "$*" $* "$q" "$nq"
3784 [ "$q" = "$nq" ] && echo =true || echo =false
3786 <spacedivdedargument
3792 <space divded argument
3794 <space divded argument
3800 extended testsuite based on problem by mikeserv
3802 a='space divded argument
3804 IFS=\ ; set -- $a; IFS=
3809 printf '= qs '; printf '<%s>\n' "$qs"
3810 printf '=nqs '; printf '<%s>\n' "$nqs"
3811 printf '= qk '; printf '<%s>\n' "$qk"
3812 printf '=nqk '; printf '<%s>\n' "$nqk"
3813 printf '~ qs '; printf '<%s>\n' "$*"
3814 printf '~nqs '; printf '<%s>\n' $*
3815 printf '~ qk '; printf '<%s>\n' "$@"
3816 printf '~nqk '; printf '<%s>\n' $@
3818 = qs <spacedivdedargument
3820 =nqs <spacedivdedargument
3822 = qk <space divded argument
3824 =nqk <space divded argument
3826 ~ qs <spacedivdedargument
3843 extended testsuite based on problem by mikeserv
3845 a='space divded argument
3847 IFS=\ ; set -- $a; IFS=
3849 printf '= qs '; printf '<%s>\n' "$qs"
3850 printf '~ qs '; printf '<%s>\n' "$*"
3852 printf '=nqs '; printf '<%s>\n' "$nqs"
3853 printf '~nqs '; printf '<%s>\n' $*
3855 printf '= qk '; printf '<%s>\n' "$qk"
3856 printf '~ qk '; printf '<%s>\n' "$@"
3858 printf '=nqk '; printf '<%s>\n' "$nqk"
3859 printf '~nqk '; printf '<%s>\n' $@
3861 = qs <spacedivdedargument
3863 ~ qs <spacedivdedargument
3865 =nqs <spacedivdedargument
3871 = qk <space divded argument
3877 =nqk <space divded argument
3884 name: IFS-subst-4-4p
3886 extended testsuite based on problem by mikeserv
3888 a='space divded argument
3890 IFS=\ ; set -- $a; IFS=
3893 printf '= qs '; printf '<%s>\n' "$qs"
3894 printf '~ qs '; printf '<%s>\n' ${v:-"$*"}
3896 printf '=nqs '; printf '<%s>\n' "$nqs"
3897 printf '~nqs '; printf '<%s>\n' ${v:-$*}
3899 printf '= qk '; printf '<%s>\n' "$qk"
3900 printf '~ qk '; printf '<%s>\n' ${v:-"$@"}
3902 printf '=nqk '; printf '<%s>\n' "$nqk"
3903 printf '~nqk '; printf '<%s>\n' ${v:-$@}
3905 = qs <spacedivdedargument
3907 ~ qs <spacedivdedargument
3909 =nqs <spacedivdedargument
3915 = qk <space divded argument
3921 =nqk <space divded argument
3930 extended testsuite based on problem by mikeserv
3932 a='space divded argument
3934 IFS=\ ; set -- $a; IFS=,
3936 printf '= qs '; printf '<%s>\n' "$qs"
3937 printf '~ qs '; printf '<%s>\n' "$*"
3939 printf '=nqs '; printf '<%s>\n' "$nqs"
3940 printf '~nqs '; printf '<%s>\n' $*
3942 printf '= qk '; printf '<%s>\n' "$qk"
3943 printf '~ qk '; printf '<%s>\n' "$@"
3945 printf '=nqk '; printf '<%s>\n' "$nqk"
3946 printf '~nqk '; printf '<%s>\n' $@
3948 = qs <space,divded,argument
3950 ~ qs <space,divded,argument
3952 =nqs <space,divded,argument
3958 = qk <space divded argument
3964 =nqk <space divded argument
3971 name: IFS-subst-4-5p
3973 extended testsuite based on problem by mikeserv
3975 a='space divded argument
3977 IFS=\ ; set -- $a; IFS=,
3980 printf '= qs '; printf '<%s>\n' "$qs"
3981 printf '~ qs '; printf '<%s>\n' ${v:-"$*"}
3983 printf '=nqs '; printf '<%s>\n' "$nqs"
3984 printf '~nqs '; printf '<%s>\n' ${v:-$*}
3986 printf '= qk '; printf '<%s>\n' "$qk"
3987 printf '~ qk '; printf '<%s>\n' ${v:-"$@"}
3989 printf '=nqk '; printf '<%s>\n' "$nqk"
3990 printf '~nqk '; printf '<%s>\n' ${v:-$@}
3992 = qs <space,divded,argument
3994 ~ qs <space,divded,argument
3996 =nqs <space,divded,argument
4002 = qk <space divded argument
4008 =nqk <space divded argument
4017 extended testsuite based on IFS-subst-3
4018 differs slightly from ksh93:
4019 - omit trailing field in a3zna, a7ina (unquoted $@ expansion)
4020 - has extra middle fields in b5ins, b7ina (IFS_NWS unquoted expansion)
4021 differs slightly from bash:
4022 - omit leading field in a5ins, a7ina (IFS_NWS unquoted expansion)
4023 differs slightly from zsh:
4024 - differs in assignment, not expansion; probably zsh bug
4025 - has extra middle fields in b5ins, b7ina (IFS_NWS unquoted expansion)
4026 'emulate sh' zsh has extra fields in
4027 - a5ins (IFS_NWS unquoted $*)
4028 - b5ins, matching mksh’s
4030 "$__progname" -c 'IFS=; set -- "" 2 ""; printf "[%s]\n" $*; x=$*; printf "<%s>\n" "$x"'
4032 "$__progname" -c 'IFS=; set -- "" 2 ""; printf "[%s]\n" "$*"; x="$*"; printf "<%s>\n" "$x"'
4034 "$__progname" -c 'IFS=; set -- "" 2 ""; printf "[%s]\n" $@; x=$@; printf "<%s>\n" "$x"'
4036 "$__progname" -c 'IFS=; set -- "" 2 ""; printf "[%s]\n" "$@"; x="$@"; printf "<%s>\n" "$x"'
4038 "$__progname" -c 'IFS=,; set -- "" 2 ""; printf "[%s]\n" $*; x=$*; printf "<%s>\n" "$x"'
4040 "$__progname" -c 'IFS=,; set -- "" 2 ""; printf "[%s]\n" "$*"; x="$*"; printf "<%s>\n" "$x"'
4042 "$__progname" -c 'IFS=,; set -- "" 2 ""; printf "[%s]\n" $@; x=$@; printf "<%s>\n" "$x"'
4044 "$__progname" -c 'IFS=,; set -- "" 2 ""; printf "[%s]\n" "$@"; x="$@"; printf "<%s>\n" "$x"'
4046 "$__progname" -c 'IFS=; set -- A B "" "" C; printf "[%s]\n" $*; x=$*; printf "<%s>\n" "$x"'
4048 "$__progname" -c 'IFS=; set -- A B "" "" C; printf "[%s]\n" "$*"; x="$*"; printf "<%s>\n" "$x"'
4050 "$__progname" -c 'IFS=; set -- A B "" "" C; printf "[%s]\n" $@; x=$@; printf "<%s>\n" "$x"'
4052 "$__progname" -c 'IFS=; set -- A B "" "" C; printf "[%s]\n" "$@"; x="$@"; printf "<%s>\n" "$x"'
4054 "$__progname" -c 'IFS=,; set -- A B "" "" C; printf "[%s]\n" $*; x=$*; printf "<%s>\n" "$x"'
4056 "$__progname" -c 'IFS=,; set -- A B "" "" C; printf "[%s]\n" "$*"; x="$*"; printf "<%s>\n" "$x"'
4058 "$__progname" -c 'IFS=,; set -- A B "" "" C; printf "[%s]\n" $@; x=$@; printf "<%s>\n" "$x"'
4060 "$__progname" -c 'IFS=,; set -- A B "" "" C; printf "[%s]\n" "$@"; x="$@"; printf "<%s>\n" "$x"'
4138 http://austingroupbugs.net/view.php?id=832
4140 ${ZSH_VERSION+false} || emulate sh
4141 ${BASH_VERSION+set -o posix}
4142 showargs() { for x in "$@"; do echo -n "<$x> "; done; echo .; }
4144 showargs $((1230456))
4148 name: integer-base-err-1
4150 Can't have 0 base (causes shell to exit)
4151 expected-exit: e != 0
4157 expected-stderr-pattern:
4160 name: integer-base-err-2
4162 Can't have multiple bases in a 'constant' (causes shell to exit)
4163 (ksh88 fails this test)
4164 expected-exit: e != 0
4170 expected-stderr-pattern:
4171 /^.*:.*2#110#11.*\n$/
4173 name: integer-base-err-3
4175 Syntax errors in expressions and effects on bases
4176 (interactive so errors don't cause exits)
4177 (ksh88 fails this test - shell exits, even with -i)
4181 PS1= # minimise prompt hassles
4188 expected-stderr-pattern:
4189 /^([#\$] )?.*:.*2+.*\n.*:.*2+.*\n$/
4194 name: integer-base-err-4
4196 Are invalid digits (according to base) errors?
4197 (ksh93 fails this test)
4198 expected-exit: e != 0
4202 expected-stderr-pattern:
4203 /^([#\$] )?.*:.*3#4.*\n$/
4205 name: integer-base-1
4207 Missing number after base is treated as 0.
4216 name: integer-base-2
4218 Check 'stickyness' of base in various situations
4269 name: integer-base-3
4271 More base parsing (hmm doesn't test much..)
4291 name: integer-base-4
4293 Check that things not declared as integers are not made integers,
4294 also, check if base is not reset by -i with no arguments.
4295 (ksh93 fails - prints 10#20 - go figure)
4299 typeset -i | grep '^xx='
4306 name: integer-base-5
4322 for l in 1 2+3 4; do echo $l; done
4334 name: integer-base-6
4336 Even more base stuff
4337 (ksh93 fails this test - prints 0)
4345 name: integer-base-7
4347 Check that non-integer parameters don't get bases assigned
4349 echo $(( zz = 8#100 ))
4355 name: integer-base-check-flat
4357 Check behaviour does not match POSuX (except if set -o posix),
4358 because a not type-safe scripting language has *no* business
4359 interpreting the string "010" as octal numer eight (dangerous).
4361 echo 1 "$("$__progname" -c 'echo :$((10))/$((010)),$((0x10)):')" .
4362 echo 2 "$("$__progname" -o posix -c 'echo :$((10))/$((010)),$((0x10)):')" .
4363 echo 3 "$("$__progname" -o sh -c 'echo :$((10))/$((010)),$((0x10)):')" .
4369 name: integer-base-check-numeric-from
4371 Check behaviour for base one to 36, and that 37 errors out
4375 while (( ++i <= 36 )); do
4376 eval 'echo '$i':$(('$i'#10)).'
4378 echo 37:$($__progname -c 'echo $((37#10))').$?:
4417 expected-stderr-pattern:
4418 /.*bad number '37#10'/
4420 name: integer-base-check-numeric-to
4422 Check behaviour for base one to 36, and that 37 errors out
4425 while (( ++i <= 37 )); do
4426 typeset -Uui$i x=0x40
4427 eval "typeset -i10 y=$x"
4468 expected-stderr-pattern:
4469 /.*bad integer base: 37/
4471 name: integer-arithmetic-span
4473 Check wraparound and size that is defined in mksh
4476 echo s:$((2147483647+1)).$(((2147483647*2)+1)).$(((2147483647*2)+2)).
4477 echo u:$((#2147483647+1)).$((#(2147483647*2)+1)).$((#(2147483647*2)+2)).
4480 u:2147483648.4294967295.0.
4482 name: integer-arithmetic-span-64
4484 Check wraparound and size that is defined in mksh
4487 echo s:$((9223372036854775807+1)).$(((9223372036854775807*2)+1)).$(((9223372036854775807*2)+2)).
4488 echo u:$((#9223372036854775807+1)).$((#(9223372036854775807*2)+1)).$((#(9223372036854775807*2)+2)).
4490 s:-9223372036854775808.-1.0.
4491 u:9223372036854775808.18446744073709551615.0.
4493 name: integer-size-FAIL-to-detect
4495 Notify the user that their ints are not 32 or 64 bit
4502 See if $LINENO is updated and can be modified.
4515 See if $LINENO is set for .'d files.
4516 file-setup: file 644 "dotfile"
4534 See if $LINENO is set for commands in a function.
4553 See if unsetting LINENO makes it non-magic.
4554 file-setup: file 644 "dotfile"
4577 name: lineno-unset-use
4579 See if unsetting LINENO makes it non-magic even
4581 file-setup: file 644 "dotfile"
4607 Check if LINENO is tracked in traps
4613 trap 'fail $LINENO' INT ERR
4621 Ensure unknown traps are not a syntax error
4624 trap "echo trap 1 executed" UNKNOWNSIGNAL || echo "foo"
4626 trap "echo trap 2 executed" UNKNOWNSIGNAL EXIT 999999 FNORD
4628 ) 2>&1 | sed "s
\ 1^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]
\ 1PROG
\ 1"
4630 PROG: trap: bad signal 'UNKNOWNSIGNAL'
4633 PROG: trap: bad signal 'UNKNOWNSIGNAL'
4634 PROG: trap: bad signal '999999'
4635 PROG: trap: bad signal 'FNORD'
4641 Simple test, default IFS
4646 echo 1: "x[$x] y[$y] z[$z]"
4647 echo 1a: ${z-z not set}
4657 If no var specified, REPLY is used
4665 name: read-regress-1
4667 Check a regression of read
4668 file-setup: file 644 "foo"
4673 while read a b c; do
4677 echo "<$a|$b|$c><$d>"
4683 Check read with delimiters
4686 print -n 'foo bar\tbaz\nblah \0blub\tblech\nmyok meck \0'
4688 emit | while IFS= read -d "" foo; do print -r -- "<$foo>"; done
4689 emit | while read -d "" foo; do print -r -- "<$foo>"; done
4690 emit | while read -d "eh?" foo; do print -r -- "<$foo>"; done
4707 Check read with number of bytes specified, and -A
4709 print 'foo\nbar' >x1
4711 print 'foo\\ bar baz' >x3
4713 x1b=u; read -N-1 x1b <x1
4714 x2a=u; read x2a <x2; r2a=$?
4715 x2b=u; read -N2 x2c <x2; r2b=$?
4716 x2c=u; read -n2 x2c <x2; r2c=$?
4717 x3a=u; read -A x3a <x3
4718 print -r "x1a=<$x1a>"
4719 print -r "x1b=<$x1b>"
4720 print -r "x2a=$r2a<$x2a>"
4721 print -r "x2b=$r2b<$x2b>"
4722 print -r "x2c=$r2c<$x2c>"
4723 print -r "x3a=<${x3a[0]}|${x3a[1]}|${x3a[2]}>"
4735 Lex array code had problems with this.
4746 When PATH is set before running a command, the new path is
4747 not used in doing the path search
4748 $ echo echo hi > /tmp/q ; chmod a+rx /tmp/q
4752 in comexec() the two lines
4754 (void) typeset(*vp++, xxx, 0);
4755 need to be moved out of the switch to before findcom() is
4756 called - I don't know what this will break.
4758 : ${PWD:-`pwd 2> /dev/null`}
4759 : ${PWD:?"PWD not set - can't do test"}
4761 cat > Y/xxxscript << EOF
4763 # Need to restore path so echo can be found (some shells don't have
4769 chmod a+rx Y/xxxscript
4770 export OLDPATH="$PATH"
4771 PATH=$PWD/Y xxxscript
4778 Parsing of $(..) expressions is non-optimal. It is
4779 impossible to have any parentheses inside the expression.
4781 $ ksh -c 'echo $(echo \( )'
4783 $ ksh -c 'echo $(echo "(" )'
4786 The solution is to hack the parsing clode in lex.c, the
4787 question is how to hack it: should any parentheses be
4788 escaped by a backslash, or should recursive parsing be done
4789 (so quotes could also be used to hide hem). The former is
4790 easier, the later better...
4800 Continue in a for loop does not work right:
4802 if [ $i = b ] ; then
4811 if [ $i = b ] ; then
4812 if [ $first = no ] ; then
4813 echo 'continue in for loop broken'
4814 break # hope break isn't broken too :-)
4829 should print 0 according to POSIX (dash, bash, ksh93, posh)
4830 but not 0 according to the getopt(1) manual page, ksh88, and
4831 Bourne sh (such as /bin/sh on Solaris).
4832 We honour POSIX except when -o sh is set.
4833 category: shell:legacy-no
4836 [[ -o posix ]]; FPOSIX=$((1-$?))
4837 [[ -o sh ]]; FSH=$((1-$?))
4838 echo -n "FPOSIX=$FPOSIX FSH=$FSH "
4862 name: regression-10-legacy
4867 should print 0 according to POSIX (dash, bash, ksh93, posh)
4868 but not 0 according to the getopt(1) manual page, ksh88, and
4869 Bourne sh (such as /bin/sh on Solaris).
4870 category: shell:legacy-yes
4873 [[ -o posix ]]; FPOSIX=$((1-$?))
4874 [[ -o sh ]]; FSH=$((1-$?))
4875 echo -n "FPOSIX=$FPOSIX FSH=$FSH "
4904 should echo blah but on some machines echos /foo/bar/blah.
4913 Both of the following echos produce the same output under sh/ksh.att:
4916 echo "`echo \"$x\"`"
4918 pdksh produces different output for the former (foo instead of foo\tbar)
4921 echo "`echo \"$x\"`"
4929 The following command hangs forever:
4930 $ (: ; cat /etc/termcap) | sleep 2
4931 This is because the shell forks a shell to run the (..) command
4932 and this shell has the pipe open. When the sleep dies, the cat
4933 doesn't get a SIGPIPE 'cause a process (ie, the second shell)
4934 still has the pipe open.
4936 NOTE: this test provokes a bizarre bug in ksh93 (shell starts reading
4937 commands from /etc/termcap..)
4940 echo A line of text that will be duplicated quite a number of times.> t1
4941 cat t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 > t2
4942 cat t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 > t1
4943 cat t1 t1 t1 t1 > t2
4944 (: ; cat t2 2>/dev/null) | sleep 1
4949 $ (foobar) 2> /dev/null
4950 generates no output under /bin/sh, but pdksh produces the error
4953 $ foobar 2> /dev/null
4954 generates an error under /bin/sh and pdksh, but AT&T ksh88 produces
4955 no error (redirected to /dev/null).
4957 (you/should/not/see/this/error/1) 2> /dev/null
4958 you/should/not/see/this/error/2 2> /dev/null
4965 generates a blank line under pdksh and sets the exit status to 0.
4966 AT&T ksh88 generates no output and sets the exit status to 1. Also,
4969 generates no output under AT&T ksh88 (pdksh generates a blank line
4972 whence does/not/exist > /dev/null
4974 echo 2: $(whence does/not/exist | wc -l)
4975 echo 3: $(whence does/not/exist cat | wc -l)
4983 ${var%%expr} seems to be broken in many places. On the mips
4985 $ read line < /etc/passwd
4993 change the value of line. On sun4s & pas, the echo ${line%%:*} doesn't
4994 work. Haven't checked elsewhere...
5001 root:asdjhasdasjhs:0:1:Root:/:/bin/sh
5004 root:asdjhasdasjhs:0:1:Root:/:/bin/sh
5010 should set the exit status to non-zero (sh and AT&T ksh88 do).
5011 XXX doting a non existent file is a fatal error for a script
5014 expected-exit: e != 0
5015 expected-stderr-pattern: /.?/
5019 Both of the following echos should produce the same thing, but don't:
5033 backslash does not work as expected in case labels:
5052 Quoting backquotes inside backquotes doesn't work:
5053 $ echo `echo hi \`echo there\` folks`
5054 asks for more info. sh and AT&T ksh88 both echo
5057 echo `echo hi \`echo there\` folks`
5063 )) is not treated `correctly':
5064 $ (echo hi ; (echo there ; echo folks))
5067 instead of (as sh and ksh.att)
5068 $ (echo hi ; (echo there ; echo folks))
5074 ( : ; ( : ; echo hi))
5080 Check reading stdin in a while loop. The read should only read
5081 a single line, not a whole stdio buffer; the cat should get
5084 (echo a; echo b) | while read x ; do
5093 Check reading stdin in a while loop. The read should read both
5094 lines, not just the first.
5097 while [ "$a" != xxx ] ; do
5100 cat /dev/null | sed 's/x/y/'
5114 should cause a script to exit.
5118 expected-exit: e != 0
5119 expected-stderr-pattern: /does\/not\/exist/
5123 variable assignements not detected well
5126 expected-exit: e != 0
5127 expected-stderr-pattern: /a\.x=1/
5131 alias expansion different from AT&T ksh88
5133 alias a='for ' b='i in'
5134 a b hi ; do echo $i ; done
5140 strange characters allowed inside ${...}
5143 expected-exit: e != 0
5144 expected-stderr-pattern: /.?/
5148 Does read handle partial lines correctly
5151 while [ "$a" != xxx ] ; do
5168 Does read set variables to null at eof?
5171 while [ "$a" != xxx ] ; do
5175 echo 1: ${x-x not set} ${y-y not set} ${z-z not set}
5176 echo 2: ${x:+x not null} ${y:+y not null} ${z:+z not null}
5186 Does umask print a leading 0 when umask is 3 digits?
5188 # on MiNT, the first umask call seems to fail
5190 # now, the test proper
5198 Tempory files used for here-docs in functions get trashed after
5199 the function is parsed (before it is executed)
5222 Command substitution breaks reading in while loop
5223 (test from <sjg@void.zen.oz.au>)
5225 (echo abcdef; echo; echo 123) |
5228 # the following line breaks it
5229 c=`echo $line | wc -c`
5239 Machines with broken times() (reported by <sjg@void.zen.oz.au>)
5240 time does not report correct real time
5243 expected-stderr-pattern: !/^\s*0\.0[\s\d]+real|^\s*real[\s]+0+\.0/
5247 set -e doesn't ignore exit codes for if/while/until/&&/||/!.
5250 if false; then echo hi ; fi
5253 while false; do echo hi; done
5260 Only posh and oksh(2013-07) say “hi” below; FreeBSD sh,
5261 GNU bash in POSIX mode, dash, ksh93, mksh don’t. All of
5262 them exit 0. The POSIX behaviour is needed by BSD make.
5265 echo `false; echo hi` $(<this-file-does-not-exist)
5270 expected-stderr-pattern: /this-file-does-not-exist/
5274 This used to cause a core dump
5275 env-setup: !RANDOM=12!
5283 foo should be set to bar (should not be empty)
5293 Can't use command line assignments to assign readonly parameters.
5295 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
5296 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
5297 done >env; chmod +x env; PATH=.:$PATH
5300 foo=stuff env | grep '^foo'
5301 expected-exit: e != 0
5302 expected-stderr-pattern:
5307 Can subshells be prefixed by redirections (historical shells allow
5310 < /dev/null (sed 's/^/X/')
5314 Parameter assignments with [] recognised correctly
5332 Check that alias expansion works in command substitutions and
5345 Check that aliases are fully read.
5358 Check that (here doc) temp files are not left behind after an exec.
5361 TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
5363 sed 's/^/X /' << E_O_F
5370 echo=echo; [ -x /bin/echo ] && echo=/bin/echo
5371 exec $echo subtest-1 hi
5373 echo subtest-1 foo/*
5374 TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
5375 echo=echo; [ -x /bin/echo ] && echo=/bin/echo
5376 sed 's/^/X /' << E_O_F; exec $echo subtest-2 hi
5382 echo subtest-2 foo/*
5394 Check that unset params with attributes are reported by set, those
5395 sans attributes are not.
5411 Check that aliases do not use continuation prompt after trailing
5413 file-setup: file 644 "envf"
5416 env-setup: !ENV=./envf!
5420 alias foo='echo hi ; '
5432 Check that set allows both +o and -o options on same command line.
5435 set -o noglob +o allexport
5442 Check that globbing works in pipelined commands
5443 file-setup: file 644 "envf"
5445 file-setup: file 644 "abc"
5447 env-setup: !ENV=./envf!
5453 sed 's/^/X /' < ab* | sed 's/^/Y /'
5465 Check that getopts works in functions
5468 echo bfunc: enter "(args: $*; OPTIND=$OPTIND)"
5469 while getopts B oc; do
5472 echo bfunc: B option
5475 echo bfunc: odd option "($oc)"
5483 echo kfunc: enter "(args: $*; OPTIND=$OPTIND)"
5484 while getopts K oc; do
5487 echo kfunc: K option
5490 echo bfunc: odd option "($oc)"
5498 echo "line 1: OPTIND=$OPTIND"
5500 echo "line 2: ret=$?, optc=$optc, OPTIND=$OPTIND"
5502 echo "line 3: OPTIND=$OPTIND"
5504 echo "line 4: ret=$?, optc=$optc, OPTIND=$OPTIND"
5506 echo "line 5: OPTIND=$OPTIND"
5508 echo "line 6: ret=$?, optc=$optc, OPTIND=$OPTIND"
5513 echo "line 10: OPTIND=$OPTIND"
5515 echo "line 20: ret=$?, optc=$optc, OPTIND=$OPTIND"
5517 echo "line 30: OPTIND=$OPTIND"
5519 echo "line 40: ret=$?, optc=$optc, OPTIND=$OPTIND"
5521 echo "line 50: OPTIND=$OPTIND"
5523 echo "line 60: ret=$?, optc=$optc, OPTIND=$OPTIND"
5526 line 2: ret=0, optc=f, OPTIND=2
5527 bfunc: enter (args: -BBB blah; OPTIND=2)
5532 line 4: ret=0, optc=b, OPTIND=3
5533 kfunc: enter (args: -KKK blah; OPTIND=1)
5539 line 6: ret=0, optc=k, OPTIND=4
5542 line 20: ret=0, optc=f, OPTIND=2
5543 bfunc: enter (args: -BBB blah; OPTIND=2)
5548 line 40: ret=1, optc=?, OPTIND=2
5549 kfunc: enter (args: -KKK blah; OPTIND=1)
5555 line 60: ret=1, optc=?, OPTIND=2
5559 Check that ; is not required before the then in if (( ... )) then ...
5573 Check ${foo:%bar} is allowed (ksh88 allows it...)
5596 Check if typeset output is correct for
5597 uninitialised array elements.
5601 typeset -i | grep xxx | sed 's/^/ /'
5603 typeset | grep xxx | sed 's/^/ /'
5607 typeset -i | grep xxx | sed 's/^/ /'
5609 typeset | grep xxx | sed 's/^/ /'
5623 Check if trap exit is ok (exit not mistaken for signal name)
5632 Check if ${#array[*]} is calculated correctly.
5642 Check if default exit status is previous command
5648 ( (exit 103) ; exit)
5657 Check if EXIT trap is executed for sub shells.
5659 trap 'echo parent exit' EXIT
5661 (echo A; echo A last)
5663 (echo C; trap 'echo sub exit' EXIT; echo C last)
5678 Check if test -nt/-ot succeeds if second(first) file is missing.
5681 test a -nt b && echo nt OK || echo nt BAD
5682 test b -ot a && echo ot OK || echo ot BAD
5689 Check if typeset, export, and readonly work
5701 integer FNORD_E FNORD_F FNORD_G FNORD_H
5702 export FNORD_C FNORD_D FNORD_G FNORD_H
5703 readonly FNORD_B FNORD_D FNORD_F FNORD_H
5749 typeset -x -r FNORD_D
5751 typeset -i -r FNORD_F
5752 typeset -i -x FNORD_G
5753 typeset -i -x -r FNORD_H
5756 typeset -r FNORD_B=2
5757 typeset -x FNORD_C=3
5758 typeset -x -r FNORD_D=4
5759 typeset -i FNORD_E=5
5760 typeset -i -r FNORD_F=6
5761 typeset -i -x FNORD_G=7
5762 typeset -i -x -r FNORD_H=8
5780 Check that we can redefine functions calling time builtin
5792 check for a regression with sleep builtin and signal mask
5798 while read -p line; do :; done
5805 Check that quoting is sane
5813 while IFS= read -pr line; do
5814 if [[ $line = *space* ]]; then
5820 for line in "${lines[@]}"; do
5829 Ensure readonly is honoured for assignments and unset
5831 "$__progname" -c 'u=x; echo $? $u .' || echo aborted, $?
5833 "$__progname" -c 'readonly u; u=x; echo $? $u .' || echo aborted, $?
5835 "$__progname" -c 'u=x; readonly u; unset u; echo $? $u .' || echo aborted, $?
5842 expected-stderr-pattern:
5847 http://austingroupbugs.net/view.php?id=367 for export
5849 "$__progname" -c 'readonly foo; export foo=a; echo $?' || echo aborted, $?
5852 expected-stderr-pattern:
5857 Check that getopts works as intended, for readonly-2b to be valid
5859 "$__progname" -c 'set -- -a b; getopts a c; echo $? $c .; getopts a c; echo $? $c .' || echo aborted, $?
5866 http://austingroupbugs.net/view.php?id=367 for getopts
5868 "$__progname" -c 'readonly c; set -- -a b; getopts a c; echo $? $c .' || echo aborted, $?
5871 expected-stderr-pattern:
5876 http://austingroupbugs.net/view.php?id=367 for read
5878 echo x | "$__progname" -c 'read s; echo $? $s .' || echo aborted, $?
5879 echo y | "$__progname" -c 'readonly s; read s; echo $? $s .' || echo aborted, $?
5883 expected-stderr-pattern:
5888 Do not permit bypassing readonly for first array item
5890 set -A arr -- foo bar
5893 print -r -- "${arr[@]}"
5894 expected-exit: e != 0
5895 expected-stderr-pattern:
5900 Check that lone ampersand is a syntax error
5903 expected-exit: e != 0
5904 expected-stderr-pattern:
5907 name: xxx-quoted-newline-1
5909 Check that \<newline> works inside of ${}
5917 name: xxx-quoted-newline-2
5919 Check that \<newline> works at the start of a here document
5928 name: xxx-quoted-newline-3
5930 Check that \<newline> works at the end of a here document
5939 name: xxx-multi-assignment-cmd
5941 Check that assignments in a command affect subsequent assignments
5950 name: xxx-multi-assignment-posix-cmd
5952 Check that the behaviour for multiple assignments with a
5953 command name matches POSIX. See:
5954 http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925
5956 X=a Y=b; X=$Y Y=$X "$__progname" -c 'echo 1 $X $Y .'; echo 2 $X $Y .
5958 X=a Y=${X=b} Z=$X "$__progname" -c 'echo 3 $Z .'
5960 X=a Y=${X=b} Z=$X; echo 4 $Z .
5967 name: xxx-multi-assignment-posix-nocmd
5969 Check that the behaviour for multiple assignments with no
5970 command name matches POSIX (Debian #334182). See:
5971 http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925
5973 X=a Y=b; X=$Y Y=$X; echo 1 $X $Y .
5977 name: xxx-multi-assignment-posix-subassign
5979 Check that the behaviour for multiple assignments matches POSIX:
5980 - The assignment words shall be expanded in the current execution
5982 - The assignments happen in the temporary execution environment.
5985 Z=a Y=${X:=b} sh -c 'echo +$X+ +$Y+ +$Z+'
5987 # Now for the special case:
5989 X= Y=${X:=b} sh -c 'echo +$X+ +$Y+'
5997 name: xxx-exec-environment-1
5999 Check to see if exec sets it's environment correctly
6001 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
6002 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
6003 done >env; chmod +x env; PATH=.:$PATH
6005 expected-stdout-pattern:
6008 name: xxx-exec-environment-2
6010 Check to make sure exec doesn't change environment if a program
6013 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
6014 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
6015 done >env; chmod +x env; PATH=.:$PATH
6017 FOO=bar exec; env >bar2
6020 name: exec-function-environment-1
6022 Check assignments in function calls and whether they affect
6023 the current execution environment (ksh93, SUSv4)
6025 f() { a=2; }; g() { b=3; echo y$c-; }; a=1 f; b=2; c=1 g
6031 name: xxx-what-do-you-call-this-1
6037 name: xxx-prefix-strip-1
6044 name: xxx-prefix-strip-2
6052 name: xxx-variable-syntax-1
6055 expected-stderr-pattern:
6059 name: xxx-variable-syntax-2
6063 expected-stderr-pattern:
6067 name: xxx-variable-syntax-3
6071 expected-stderr-pattern:
6075 name: xxx-substitution-eval-order
6077 Check order of evaluation of expressions
6080 set -A A abc def GHI j G k
6081 echo ${A[x=(i+=1)]#${A[y=(i+=2)]}}
6087 name: xxx-set-option-1
6089 Check option parsing in set
6091 set -vsA foo -- A 1 3 2
6100 Check that exec exits for built-ins
6108 expected-stderr-pattern: /.*/
6112 Check the return value of while loops
6113 XXX need to do same for for/select/until loops
6116 while [ $i != xxx ] ; do
6118 if [ $i = xxx ] ; then
6126 while [ $i != xxx ] ; do
6128 if [ $i = xxx ] ; then
6136 while [ $i != xxx ] ; do
6148 Check that blank lines don't clear $?
6161 expected-stderr-pattern: /.*/
6165 Check that $? is preserved in subshells, includes, traps.
6174 echo 'echo include: $?' > foo
6178 trap 'echo trap: $?' ERR
6188 name: xxx-clean-chars-1
6190 Check MAGIC character is stuffed correctly
6196 name: xxx-param-subst-qmark-1
6198 Check suppresion of error message with null string. According to
6199 POSIX, it shouldn't print the error as 'word' isn't ommitted.
6200 ksh88/93, Solaris /bin/sh and /usr/xpg4/bin/sh all print the error,
6201 that's why the condition is reversed.
6209 #expected-stderr-pattern: !/not set/
6211 expected-stderr-pattern: /parameter null or not set/
6214 # fails due to weirdness of execv stuff
6215 category: !os:uwin-nt
6217 Check c flag is set.
6218 arguments: !-c!echo "[$-]"!
6219 expected-stdout-pattern: /^\[.*c.*\]$/
6221 name: tilde-expand-1
6223 Check tilde expansion after equal signs
6224 env-setup: !HOME=/sweet!
6226 echo ${A=a=}~ b=~ c=d~ ~
6229 echo ${A=a=}~ b=~ c=d~ ~
6231 a=/sweet b=/sweet c=d~ /sweet
6234 name: tilde-expand-2
6236 Check tilde expansion works
6237 env-setup: !HOME=/sweet!
6241 plus=$(print -r -- ~+)
6242 minus=$(print -r -- ~-)
6243 nix=$(print -r -- ~)
6244 [[ $plus = / ]]; echo one $? .
6245 [[ $minus = "$wd" ]]; echo two $? .
6246 [[ $nix = /sweet ]]; echo nix $? .
6254 Check some "exit on error" conditions
6256 print '#!'"$__progname"'\nexec "$1"' >env
6257 print '#!'"$__progname"'\nexit 1' >false
6261 env false && echo something
6271 Check some "exit on error" edge conditions (POSIXly)
6273 print '#!'"$__progname"'\nexec "$1"' >env
6274 print '#!'"$__progname"'\nexit 1' >false
6275 print '#!'"$__progname"'\nexit 0' >true
6280 env false && echo something
6292 pdksh regression which AT&T ksh does right
6293 TFM says: [set] -e | errexit
6294 Exit (after executing the ERR trap) ...
6296 trap 'echo EXIT' EXIT
6299 cd /XXXXX 2>/dev/null
6305 expected-exit: e != 0
6309 "set -e" test suite (POSIX)
6323 "set -e" test suite (POSIX)
6329 [ "$1" = "$E" ] && { shift ; continue 2 ; }
6346 "set -e" test suite (BSD make)
6350 print 'all:\n\t@echo eins\n\t@exit 42\n' >zd/a/Makefile
6351 print 'all:\n\t@echo zwei\n' >zd/b/Makefile
6354 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"
6360 Stop in WD/zd/a (line 2 of Makefile).
6364 "set -e" regression (LP#1104543)
6368 [ -x $PWD/nonexistant ] && $PWD/nonexistant
6379 "set -e" regression (Debian #700526)
6382 _db_cmd() { return $1; }
6383 db_input() { _db_cmd 30; }
6384 db_go() { _db_cmd 0; }
6391 SUSv4 says that the shell should exit with 126/127 in some situations
6395 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6396 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6398 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6399 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6401 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6402 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
6413 Check eval vs substitution exit codes (ksh93 alike)
6425 eval "eval $(false)"
6428 eval 'eval '"$(false)"
6432 eval $(echo :; false)
6450 Check that "exit" with no arguments behaves SUSv4 conformant.
6452 trap 'echo hi; exit' EXIT
6460 Check that ERR and EXIT traps are run just like ksh93 does.
6461 GNU bash does not run ERtrap in ±e eval-undef but runs it
6462 twice (bug?) in +e eval-false, so does ksh93 (bug?), which
6463 also has a bug to continue execution (echoing "and out" and
6464 returning 0) in +e eval-undef.
6465 file-setup: file 644 "x"
6467 trap 'echo EXtrap' EXIT
6468 trap 'echo ERtrap' ERR
6473 file-setup: file 644 "xt"
6475 trap 'echo EXtrap' EXIT
6476 trap 'echo ERtrap' ERR
6481 file-setup: file 644 "xf"
6483 trap 'echo EXtrap' EXIT
6484 trap 'echo ERtrap' ERR
6486 echo 'and run false'
6489 file-setup: file 644 "xu"
6491 trap 'echo EXtrap' EXIT
6492 trap 'echo ERtrap' ERR
6494 echo 'and run ${v?}'
6504 -e 's/parameter not set/parameter null or not set/' \
6505 -e 's/[[]6]//' -e 's/: eval: line 1//' -e 's/: line 6//' \
6506 -e "s
\ 1^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]
\ 1PROG
\ 1"
6511 echo = eval-true $(<rc) .
6513 echo = eval-false $(<rc) .
6514 runtest x $xe '${v?}'
6515 echo = eval-undef $(<rc) .
6517 echo = noeval-true $(<rc) .
6519 echo = noeval-false $(<rc) .
6521 echo = noeval-undef $(<rc) .
6525 echo = eval-true $(<rc) .
6527 echo = eval-false $(<rc) .
6528 runtest x $xe '${v?}'
6529 echo = eval-undef $(<rc) .
6531 echo = noeval-true $(<rc) .
6533 echo = noeval-false $(<rc) .
6535 echo = noeval-undef $(<rc) .
6547 x: v: parameter null or not set
6560 xu: v: parameter null or not set
6574 x: v: parameter null or not set
6588 xu: v: parameter null or not set
6592 name: exit-trap-interactive
6594 Check that interactive shell doesn't exit via EXIT trap on syntax error
6599 echo 'After error 1'
6600 trap 'echo Exit trap' EXIT
6602 echo 'After error 2'
6603 trap 'echo Exit trap' EXIT
6610 expected-stderr-pattern:
6611 /syntax error: 'newline' unexpected/
6615 Check that test also can handle string1 < string2 etc.
6617 test 2005/10/08 '<' 2005/08/21 && echo ja || echo nein
6618 test 2005/08/21 \< 2005/10/08 && echo ja || echo nein
6619 test 2005/10/08 '>' 2005/08/21 && echo ja || echo nein
6620 test 2005/08/21 \> 2005/10/08 && echo ja || echo nein
6626 expected-stderr-pattern: !/unexpected op/
6628 name: test-precedence-1
6630 Check a weird precedence case (and POSIX echo)
6640 Test the test -o operator
6645 [[ -o $1 ]]; echo $?
6648 test -o $1 -o -o !$1; echo $?
6649 [ -o $1 -o -o !$1 ]; echo $?
6650 [[ -o $1 || -o !$1 ]]; echo $?
6651 test -o ?$1; echo $?
6653 echo 0y $(if_test utf8-mode) =
6654 echo 0n $(if_test utf8-hack) =
6655 echo 1= $(runtest utf8-hack) =
6656 echo 2= $(runtest !utf8-hack) =
6657 echo 3= $(runtest ?utf8-hack) =
6659 echo 1+ $(runtest utf8-mode) =
6660 echo 2+ $(runtest !utf8-mode) =
6661 echo 3+ $(runtest ?utf8-mode) =
6663 echo 1- $(runtest utf8-mode) =
6664 echo 2- $(runtest !utf8-mode) =
6665 echo 3- $(runtest ?utf8-mode) =
6666 echo = short flags =
6667 echo 0y $(if_test -U) =
6668 echo 0y $(if_test +U) =
6669 echo 0n $(if_test -_) =
6670 echo 0n $(if_test -U-) =
6671 echo 1= $(runtest -_) =
6672 echo 2= $(runtest !-_) =
6673 echo 3= $(runtest ?-_) =
6675 echo 1+ $(runtest -U) =
6676 echo 2+ $(runtest !-U) =
6677 echo 3+ $(runtest ?-U) =
6678 echo 1+ $(runtest +U) =
6679 echo 2+ $(runtest !+U) =
6680 echo 3+ $(runtest ?+U) =
6682 echo 1- $(runtest -U) =
6683 echo 2- $(runtest !-U) =
6684 echo 3- $(runtest ?-U) =
6685 echo 1- $(runtest +U) =
6686 echo 2- $(runtest !+U) =
6687 echo 3- $(runtest ?+U) =
6723 Check that ~/.mkshrc works correctly.
6724 Part 1: verify user environment is not read (internal)
6732 Check that ~/.mkshrc works correctly.
6733 Part 2: verify mkshrc is not read (non-interactive shells)
6734 file-setup: file 644 ".mkshrc"
6736 env-setup: !HOME=.!ENV=!
6744 Check that ~/.mkshrc works correctly.
6745 Part 2: verify mkshrc can be read (interactive shells)
6746 file-setup: file 644 ".mkshrc"
6750 env-setup: !HOME=.!ENV=!PS1=!
6755 expected-stderr-pattern:
6760 Check that ~/.mkshrc works correctly.
6761 Part 3: verify mkshrc can be turned off
6762 file-setup: file 644 ".mkshrc"
6764 env-setup: !HOME=.!ENV=nonexistant!
6772 Check that sh mode turns braceexpand off
6773 and that that works correctly
6777 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
6778 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
6786 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
6787 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
6790 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
6791 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
6807 Check that posix or sh mode is *not* automatically turned on
6810 ln -s "$__progname" ksh || cp "$__progname" ksh
6811 ln -s "$__progname" sh || cp "$__progname" sh
6812 ln -s "$__progname" ./-ksh || cp "$__progname" ./-ksh
6813 ln -s "$__progname" ./-sh || cp "$__progname" ./-sh
6814 for shell in {,-}{,k}sh; do
6815 print -- $shell $(./$shell +l -c \
6816 '[[ $(set +o) == *"-o "@(sh|posix)@(| *) ]] && echo sh || echo nosh')
6826 Check that posix or sh mode *is* automatically turned on
6829 ln -s "$__progname" ksh || cp "$__progname" ksh
6830 ln -s "$__progname" sh || cp "$__progname" sh
6831 ln -s "$__progname" ./-ksh || cp "$__progname" ./-ksh
6832 ln -s "$__progname" ./-sh || cp "$__progname" ./-sh
6833 for shell in {,-}{,k}sh; do
6834 print -- $shell $(./$shell +l -c \
6835 '[[ $(set +o) == *"-o "@(sh|posix)@(| *) ]] && echo sh || echo nosh')
6845 pdksh bug: last command of a pipeline is executed in a
6846 subshell - make sure it still is, scripts depend on it
6847 file-setup: file 644 "abcx"
6848 file-setup: file 644 "abcy"
6851 echo a | while read d; do
6871 check that co-processes work with TCOMs, TPIPEs and TPARENs
6874 "$__progname" -c 'i=100; echo hi |& while read -p line; do echo "$((i++)) $line"; done'
6875 "$__progname" -c 'i=200; echo hi | cat |& while read -p line; do echo "$((i++)) $line"; done'
6876 "$__progname" -c 'i=300; (echo hi | cat) |& while read -p line; do echo "$((i++)) $line"; done'
6884 Check that PIPESTATUS does what it's supposed to
6886 echo 1 $PIPESTATUS .
6887 echo 2 ${PIPESTATUS[0]} .
6888 echo 3 ${PIPESTATUS[1]} .
6889 (echo x; exit 12) | (cat; exit 23) | (cat; exit 42)
6890 echo 5 $? , $PIPESTATUS , ${PIPESTATUS[0]} , ${PIPESTATUS[1]} , ${PIPESTATUS[2]} , ${PIPESTATUS[3]} .
6891 echo 6 ${PIPESTATUS[0]} .
6892 set | fgrep PIPESTATUS
6893 echo 8 $(set | fgrep PIPESTATUS) .
6899 5 42 , 12 , 12 , 23 , 42 , .
6902 8 PIPESTATUS[0]=0 PIPESTATUS[1]=0 .
6906 Check that "set -o pipefail" does what it's supposed to
6908 echo 1 "$("$__progname" -c '(exit 12) | (exit 23) | (exit 42); echo $?')" .
6909 echo 2 "$("$__progname" -c '! (exit 12) | (exit 23) | (exit 42); echo $?')" .
6910 echo 3 "$("$__progname" -o pipefail -c '(exit 12) | (exit 23) | (exit 42); echo $?')" .
6911 echo 4 "$("$__progname" -o pipefail -c '! (exit 12) | (exit 23) | (exit 42); echo $?')" .
6912 echo 5 "$("$__progname" -c '(exit 23) | (exit 42) | :; echo $?')" .
6913 echo 6 "$("$__progname" -c '! (exit 23) | (exit 42) | :; echo $?')" .
6914 echo 7 "$("$__progname" -o pipefail -c '(exit 23) | (exit 42) | :; echo $?')" .
6915 echo 8 "$("$__progname" -o pipefail -c '! (exit 23) | (exit 42) | :; echo $?')" .
6916 echo 9 "$("$__progname" -o pipefail -c 'x=$( (exit 23) | (exit 42) | :); echo $?')" .
6928 name: persist-history-1
6930 Check if persistent history saving works
6931 category: !no-histfile
6934 env-setup: !ENV=./Env!HISTFILE=hist.file!
6935 file-setup: file 644 "Env"
6939 expected-stdout-pattern:
6941 expected-stderr-pattern:
6946 Check that global does what typeset is supposed to do
6950 global -Uui16 arrfoo[*]
6952 echo before ${arrfoo[0]} .
6954 echo after ${arrfoo[0]} .
6957 echo inside before ${arrbar[0]} .
6959 echo inside changed ${arrbar[0]} .
6960 global -Uui16 arrbar[*]
6961 echo inside typeset ${arrbar[0]} .
6963 echo inside changed ${arrbar[0]} .
6965 echo before ${arrbar[0]} .
6967 echo after ${arrbar[0]} .
6974 inside typeset 16#61 .
6975 inside changed 16#30 .
6978 name: typeset-padding-1
6980 Check if left/right justification works as per TFM
6982 typeset -L10 ln=0hall0
6983 typeset -R10 rn=0hall0
6984 typeset -ZL10 lz=0hall0
6985 typeset -ZR10 rz=0hall0
6986 typeset -Z10 rx=" hallo "
6987 echo "<$ln> <$rn> <$lz> <$rz> <$rx>"
6989 <0hall0 > < 0hall0> <hall0 > <00000hall0> <0000 hallo>
6991 name: typeset-padding-2
6993 Check if base-!10 integers are padded right
6995 typeset -Uui16 -L9 ln=16#1
6996 typeset -Uui16 -R9 rn=16#1
6997 typeset -Uui16 -Z9 zn=16#1
7001 echo "<$ln> <$rn> <$zn> <$ls> <$rs> <$zs>"
7003 <16#1 > < 16#1> <16#000001> <16#1 > < 16#1> <0000016#1>
7007 Check that the UTF-8 Byte Order Mark is ignored as the first
7008 multibyte character of the shell input (with -c, from standard
7009 input, as file, or as eval argument), but nowhere else
7010 # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
7011 category: !os:darwin
7014 print '#!/bin/sh\necho ohne' >foo/fnord
7015 print '#!/bin/sh\necho mit' >foo/fnord
7016 print 'fnord\nfnord\nfnord\nfnord' >foo/bar
7017 print eval \''fnord\nfnord\nfnord\nfnord'\' >foo/zoo
7018 set -A anzahl -- foo/*
7019 echo got ${#anzahl[*]} files
7021 export PATH=$(pwd)/foo:$PATH
7022 "$__progname" -c 'fnord'
7024 "$__progname" -c 'fnord; fnord; fnord; fnord'
7026 "$__progname" foo/bar
7028 "$__progname" <foo/bar
7030 "$__progname" foo/zoo
7032 "$__progname" -c 'echo : $(fnord)'
7062 Check that we can execute BOM-shebangs (failures not fatal)
7063 XXX if the OS can already execute them, we lose
7064 note: cygwin execve(2) doesn't return to us with ENOEXEC, we lose
7065 note: Ultrix perl5 t4 returns 65280 (exit-code 255) and no text
7067 category: !os:cygwin,!os:msys,!os:ultrix,!os:uwin-nt,!smksh
7068 env-setup: !FOO=BAR!
7070 print '#!'"$__progname"'\nprint "1 a=$ENV{FOO}";' >t1
7071 print '#!'"$__progname"'\nprint "2 a=$ENV{FOO}";' >t2
7072 print '#!'"$__perlname"'\nprint "3 a=$ENV{FOO}\n";' >t3
7073 print '#!'"$__perlname"'\nprint "4 a=$ENV{FOO}\n";' >t4
7080 1 a=/nonexistant{FOO}
7081 2 a=/nonexistant{FOO}
7084 expected-stderr-pattern:
7085 /(Unrecognized character .... ignored at \..t4 line 1)*/
7089 Check that the utf8-mode flag is not set at non-interactive startup
7091 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8!
7093 if [[ $- = *U* ]]; then
7103 Check that the utf8-mode flag is not set at non-interactive startup
7105 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.utf8!
7107 if [[ $- = *U* ]]; then
7117 Check that the utf8-mode flag is set at interactive startup.
7118 -DMKSH_ASSUME_UTF8=0 => expected failure, please ignore
7119 -DMKSH_ASSUME_UTF8=1 => not expected, please investigate
7120 -UMKSH_ASSUME_UTF8 => not expected, but if your OS is old,
7121 try passing HAVE_SETLOCALE_CTYPE=0 to Build.sh
7123 category: !os:hpux,!os:msys
7126 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8!
7128 if [[ $- = *U* ]]; then
7135 expected-stderr-pattern:
7140 Check that the utf8-mode flag is set at interactive startup
7141 Expected failure if -DMKSH_ASSUME_UTF8=0
7145 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.utf8!
7147 if [[ $- = *U* ]]; then
7154 expected-stderr-pattern:
7159 Ensure ±U on the command line is honoured
7160 (these two tests may pass falsely depending on CPPFLAGS)
7163 code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi'
7164 let i++; "$__progname" -U -c "$code"
7165 let i++; "$__progname" +U -c "$code"
7174 Ensure ±U on the command line is honoured, interactive shells
7178 code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi'
7179 let i++; "$__progname" -U -ic "$code"
7180 let i++; "$__progname" +U -ic "$code"
7189 Check if built-in shell aliases are okay
7190 category: !android,!arge
7195 autoload='typeset -fu'
7196 functions='typeset -f'
7199 integer='typeset -i'
7202 nameref='typeset -n'
7205 source='PATH=$PATH:. command .'
7209 name: aliases-1-hartz4
7211 Check if built-in shell aliases are okay
7212 category: android,arge
7217 autoload='typeset -fu'
7218 functions='typeset -f'
7221 integer='typeset -i'
7224 nameref='typeset -n'
7227 source='PATH=$PATH:. command .'
7232 Check if “set -o sh” disables built-in aliases (except a few)
7239 integer='typeset -i'
7244 Check if running as sh disables built-in aliases (except a few)
7248 ./sh -c 'alias; typeset -f'
7251 integer='typeset -i'
7256 Check if “set -o sh” does not influence built-in aliases
7257 category: !android,!arge
7263 autoload='typeset -fu'
7264 functions='typeset -f'
7267 integer='typeset -i'
7270 nameref='typeset -n'
7273 source='PATH=$PATH:. command .'
7279 Check if running as sh does not influence built-in aliases
7280 category: !android,!arge
7283 ./sh -c 'alias; typeset -f'
7286 autoload='typeset -fu'
7287 functions='typeset -f'
7290 integer='typeset -i'
7293 nameref='typeset -n'
7296 source='PATH=$PATH:. command .'
7300 name: aliases-2b-hartz4
7302 Check if “set -o sh” does not influence built-in aliases
7303 category: android,arge
7309 autoload='typeset -fu'
7310 functions='typeset -f'
7313 integer='typeset -i'
7316 nameref='typeset -n'
7319 source='PATH=$PATH:. command .'
7322 name: aliases-3b-hartz4
7324 Check if running as sh does not influence built-in aliases
7325 category: android,arge
7328 ./sh -c 'alias; typeset -f'
7331 autoload='typeset -fu'
7332 functions='typeset -f'
7335 integer='typeset -i'
7338 nameref='typeset -n'
7341 source='PATH=$PATH:. command .'
7344 name: aliases-cmdline
7346 Check that aliases work from the command line (Debian #517009)
7347 Note that due to the nature of the lexing process, defining
7348 aliases in COMSUBs then immediately using them, and things
7349 like 'alias foo=bar && foo', still fail.
7351 "$__progname" -c $'alias a="echo OK"\na'
7355 name: aliases-funcdef-1
7357 Check if POSIX functions take precedences over aliases
7359 alias foo='echo makro'
7367 name: aliases-funcdef-2
7369 Check if POSIX functions take precedences over aliases
7371 alias foo='echo makro'
7379 name: aliases-funcdef-3
7381 Check if aliases take precedences over Korn functions
7383 alias foo='echo makro'
7391 name: aliases-funcdef-4
7393 Functions should only take over if actually being defined
7404 Check if Korn Shell arrays work as expected
7407 set -A foo -- a \$v "$v" '$v' b
7408 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
7414 Check if bash-style arrays work as expected
7417 foo=(a \$v "$v" '$v' b)
7418 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
7424 Check if bash-style arrays work as expected, with newlines
7426 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "$x|"; done' >pfp
7428 test -n "$ZSH_VERSION" && setopt KSH_ARRAYS
7434 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
7439 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
7444 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
7446 7|a|bc|d|$v|e f|$v|g|
7447 7|a|bc|d|$v|e f|$v|g|
7448 6|abc\|d|$v|e f|$v|g||
7452 Check if array bounds are uint32_t
7459 echo ${foo[4294967295]} g ${foo[*]}
7466 Check if Korn Shell arrays with specified indices work as expected
7469 set -A foo -- [1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b
7470 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|"
7471 # we don't want this at all:
7473 set -A arr "[5]=meh"
7474 echo "<${arr[0]}><${arr[5]}>"
7476 5|[1]=$v|[2]=c d|[4]=$v|[0]=a|[5]=b||
7481 Check if bash-style arrays with specified indices work as expected
7482 (taken out temporarily to fix arrays-4; see also arrays-9a comment)
7486 foo=([1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b)
7487 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|"
7488 x=([128]=foo bar baz)
7491 # Check that we do not break this by globbing
7496 echo "<${arr[0]}><${arr[5]}>"
7505 Check if we can get the array keys (indices) for indexed arrays,
7511 echo -n "$((i++))<$x>"
7522 echo a $(of ${foo[*]}) = $(of ${bar[*]}) a
7523 echo b $(of "${foo[*]}") = $(of "${bar[*]}") b
7524 echo c $(of ${foo[@]}) = $(of ${bar[@]}) c
7525 echo d $(of "${foo[@]}") = $(of "${bar[@]}") d
7526 echo e $(of ${!foo[*]}) = $(of ${!bar[*]}) e
7527 echo f $(of "${!foo[*]}") = $(of "${!bar[*]}") f
7528 echo g $(of ${!foo[@]}) = $(of ${!bar[@]}) g
7529 echo h $(of "${!foo[@]}") = $(of "${!bar[@]}") h
7537 a 0<zwei>1<eins>2<drei> = a
7538 b 0<zwei eins drei> = 0<> b
7539 c 0<zwei>1<eins>2<drei> = c
7540 d 0<zwei>1<eins>2<drei> = d
7548 Check if we can get the array keys (indices) for indexed arrays,
7549 Korn shell style, in some corner cases
7552 echo !arz[0]: ${!arz[0]}
7553 echo !arz[1]: ${!arz[1]}
7556 echo !arz[0]: ${!arz[0]}
7557 echo !arz[1]: ${!arz[1]}
7560 echo !arz[0]: ${!arz[0]}
7561 echo !arz[1]: ${!arz[1]}
7575 Check some behavioural rules for arrays.
7613 typeset -Z3 aa ab ac ad ae af ag
7658 Check that we can concatenate arrays
7660 unset foo; foo=(bar); foo+=(baz); echo 1 ${!foo[*]} : ${foo[*]} .
7661 unset foo; foo=(foo bar); foo+=(baz); echo 2 ${!foo[*]} : ${foo[*]} .
7662 # unset foo; foo=([2]=foo [0]=bar); foo+=(baz [5]=quux); echo 3 ${!foo[*]} : ${foo[*]} .
7665 2 0 1 2 : foo bar baz .
7666 # 3 0 2 3 5 : bar foo baz quux .
7670 Check that we can concatenate parameters too
7672 unset foo; foo=bar; foo+=baz; echo 1 $foo .
7673 unset foo; typeset -i16 foo=10; foo+=20; echo 2 $foo .
7678 name: arrassign-basic
7680 Check basic whitespace conserving properties of wdarrassign
7688 c+=("$(echo "c d")")
7690 echo ".a:${a[0]}.${a[1]}.${a[2]}.${a[3]}:"
7691 echo ".b:${b[0]}.${b[1]}.${b[2]}.${b[3]}:"
7692 echo ".c:${c[0]}.${c[1]}.${c[2]}.${c[3]}:"
7693 echo ".d:${d[0]}.${d[1]}.${d[2]}.${d[3]}:"
7700 name: arrassign-fnc-none
7702 Check locality of array access inside a function
7706 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7709 if [[ -n $BASH_VERSION ]]; then
7715 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7719 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7721 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7723 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7724 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7726 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7728 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7741 name: arrassign-fnc-local
7743 Check locality of array access inside a function
7744 with the bash/mksh/ksh93 local/typeset keyword
7745 (note: ksh93 has no local; typeset works only in FKSH)
7750 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7753 if [[ -n $BASH_VERSION ]]; then
7760 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7764 if [[ -n $BASH_VERSION ]]; then
7770 echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
7775 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7777 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7779 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7780 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7782 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7784 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7785 echo ".f0r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
7787 echo ".f1r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
7789 echo ".f2r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
7807 name: arrassign-fnc-global
7809 Check locality of array access inside a function
7810 with the mksh-specific global keyword
7815 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7821 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7827 echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
7832 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7834 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7836 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7837 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7839 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7841 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7842 echo ".f0r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
7844 echo ".f1r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
7846 echo ".f2r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
7864 name: strassign-fnc-none
7866 Check locality of string access inside a function
7901 name: strassign-fnc-local
7903 Check locality of string access inside a function
7904 with the bash/mksh/ksh93 local/typeset keyword
7905 (note: ksh93 has no local; typeset works only in FKSH)
7959 name: strassign-fnc-global
7961 Check locality of string access inside a function
7962 with the mksh-specific global keyword
8016 name: varexpand-substr-1
8018 Check if bash-style substring expansion works
8019 when using positive numerics
8022 typeset -i y=123456789
8023 typeset -i 16 z=123456789 # 16#75bcd15
8024 echo a t${x:2:2} ${y:2:3} ${z:2:3} a
8025 echo b ${x::3} ${y::3} ${z::3} b
8026 echo c ${x:2:} ${y:2:} ${z:2:} c
8027 echo d ${x:2} ${y:2} ${z:2} d
8028 echo e ${x:2:6} ${y:2:6} ${z:2:7} e
8029 echo f ${x:2:7} ${y:2:7} ${z:2:8} f
8030 echo g ${x:2:8} ${y:2:8} ${z:2:9} g
8035 d cdefghi 3456789 #75bcd15 d
8036 e cdefgh 345678 #75bcd1 e
8037 f cdefghi 3456789 #75bcd15 f
8038 g cdefghi 3456789 #75bcd15 g
8040 name: varexpand-substr-2
8042 Check if bash-style substring expansion works
8043 when using negative numerics or expressions
8046 typeset -i y=123456789
8047 typeset -i 16 z=123456789 # 16#75bcd15
8049 echo a ${x:$n:3} ${y:$n:3} ${z:$n:3} a
8050 echo b ${x:(n):3} ${y:(n):3} ${z:(n):3} b
8051 echo c ${x:(-2):1} ${y:(-2):1} ${z:(-2):1} c
8052 echo d t${x: n:2} ${y: n:3} ${z: n:3} d
8059 name: varexpand-substr-3
8061 Check that some things that work in bash fail.
8062 This is by design. And that some things fail in both.
8064 export x=abcdefghi n=2
8065 "$__progname" -c 'echo v${x:(n)}x'
8066 "$__progname" -c 'echo w${x: n}x'
8067 "$__progname" -c 'echo x${x:n}x'
8068 "$__progname" -c 'echo y${x:}x'
8069 "$__progname" -c 'echo z${x}x'
8070 "$__progname" -c 'x=abcdef;y=123;echo ${x:${y:2:1}:2}' >/dev/null 2>&1; echo $?
8076 expected-stderr-pattern:
8077 /x:n.*bad substitution.*\n.*bad substitution/
8079 name: varexpand-substr-4
8081 Check corner cases for substring expansion
8085 echo a ${x:(y == 1 ? 2 : 3):4} a
8089 name: varexpand-substr-5A
8091 Check that substring expansions work on characters
8095 echo a ${x::1} ${x: -1} a
8096 echo b ${x::3} ${x: -3} b
8097 echo c ${x:1:2} ${x: -3:2} c
8105 name: varexpand-substr-5W
8107 Check that substring expansions work on characters
8111 echo a ${x::1} ${x: -1} a
8112 echo b ${x::2} ${x: -2} b
8113 echo c ${x:1:1} ${x: -2:1} c
8121 name: varexpand-substr-6
8123 Check that string substitution works correctly
8128 echo a ${baz: foo: bar}
8129 echo b ${baz: foo: $bar}
8130 echo c ${baz: $foo: bar}
8131 echo d ${baz: $foo: $bar}
8138 name: varexpand-special-hash
8140 Check special ${var@x} expansion for x=hash
8145 print ${foo@#} ${bar@#} ${baz@#} .
8147 9B15FBFB CFBDD32B 00000000 .
8149 name: varexpand-special-quote
8151 Check special ${var@Q} expansion for quoted strings
8158 print -r -- "<i=$i j=$j k=$k>"
8159 s="u=${i@Q} v=${j@Q} w=${k@Q}"
8160 print -r -- "s=\"$s\""
8166 s="u=x v='a b' w=$'c\nd\240e\u20ACf'"
8169 typeset w=$'c\nd\240e\u20ACf'
8171 name: varexpand-null-1
8173 Ensure empty strings expand emptily
8176 print z ${a#?} ${b%?} w
8177 print v ${a=} ${b/c/d} u
8183 name: varexpand-null-2
8185 Ensure empty strings, when quoted, are expanded as empty strings
8187 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "<$x> "; done' >pfs
8189 ./pfs 1 "${a}" 2 "${a#?}" + "${b%?}" 3 "${a=}" + "${b/c/d}"
8192 <1> <> <2> <> <+> <> <3> <> <+> <> .
8194 name: varexpand-null-3
8196 Ensure concatenating behaviour matches other shells
8197 although the line 2<> is probably wrong? XNULLSUB case.
8199 x=; printf "1<%s>\n" "$x$@"
8200 set A; printf "2<%s>\n" "${@:+}"
8205 name: print-funny-chars
8207 Check print builtin's capability to output designated characters
8209 print '<\0144\0344\xDB\u00DB\u20AC\uDB\x40>'
8215 Check print builtin's \c escape
8217 print '\ca'; print b
8223 Check that CR+LF is not collapsed into LF as some MSYS shells wrongly do
8225 echo '#!'"$__progname" >foo
8227 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'
8232 ./foo | while IFS= read -r line; do
8233 print -r -- "{$line}"
8236 [220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT
\r
8237 220->> Bitte keine Werbung einwerfen! <<
\r\r
8238 220 Who do you wanna pretend to be today?
\r]
8239 {220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT
\r}
8240 {220->> Bitte keine Werbung einwerfen! <<
\r\r}
8241 {220 Who do you wanna pretend to be today?
\r}
8243 name: print-nul-chars
8245 Check handling of NUL characters for print and COMSUB
8248 print $(($(print '<\0>' | wc -c))) $(($(print "$x" | wc -c))) \
8250 expected-stdout-pattern:
8255 Check backslash expansion by the print builtin
8257 print '\ \!\"\#\$\%\&'\\\''\(\)\*\+\,\-\.\/\0\1\2\3\4\5\6\7\8' \
8258 '\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T' \
8259 '\U\V\W\X\Y\Z\[\\\]\^\_\`\a\b \d\e\f\g\h\i\j\k\l\m\n\o\p' \
8260 '\q\r\s\t\u\v\w\x\y\z\{\|\}\~' '\u20acd' '\U20acd' '\x123' \
8261 '\0x' '\0123' '\01234' | {
8262 # integer-base-one-3As
8263 typeset -Uui16 -Z11 pos=0
8264 typeset -Uui16 -Z5 hv=2147483647
8268 while IFS= read -r line; do
8270 while [[ -n $line ]]; do
8272 if (( (pos & 15) == 0 )); then
8273 (( pos )) && print "$dasc|"
8274 print -n "${pos#16#} "
8277 print -n "${hv#16#} "
8278 if (( (hv < 32) || (hv > 126) )); then
8281 dasc=$dasc${line::1}
8283 (( (pos++ & 15) == 7 )) && print -n -- '- '
8287 while (( pos & 15 )); do
8289 (( (pos++ & 15) == 7 )) && print -n -- '- '
8291 (( hv == 2147483647 )) || print "$dasc|"
8294 00000000 5C 20 5C 21 5C 22 5C 23 - 5C 24 5C 25 5C 26 5C 27 |\ \!\"\#\$\%\&\'|
8295 00000010 5C 28 5C 29 5C 2A 5C 2B - 5C 2C 5C 2D 5C 2E 5C 2F |\(\)\*\+\,\-\.\/|
8296 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|
8297 00000030 20 5C 39 5C 3A 5C 3B 5C - 3C 5C 3D 5C 3E 5C 3F 5C | \9\:\;\<\=\>\?\|
8298 00000040 40 5C 41 5C 42 5C 43 5C - 44 1B 5C 46 5C 47 5C 48 |@\A\B\C\D.\F\G\H|
8299 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|
8300 00000060 5C 51 5C 52 5C 53 5C 54 - 20 5C 56 5C 57 5C 58 5C |\Q\R\S\T \V\W\X\|
8301 00000070 59 5C 5A 5C 5B 5C 5C 5D - 5C 5E 5C 5F 5C 60 07 08 |Y\Z\[\]\^\_\`..|
8302 00000080 20 20 5C 64 1B 0C 5C 67 - 5C 68 5C 69 5C 6A 5C 6B | \d..\g\h\i\j\k|
8303 00000090 5C 6C 5C 6D 0A 5C 6F 5C - 70 20 5C 71 0D 5C 73 09 |\l\m.\o\p \q.\s.|
8304 000000A0 0B 5C 77 5C 79 5C 7A 5C - 7B 5C 7C 5C 7D 5C 7E 20 |.\w\y\z\{\|\}\~ |
8305 000000B0 E2 82 AC 64 20 EF BF BD - 20 12 33 20 78 20 53 20 |...d ... .3 x S |
8306 000000C0 53 34 0A - |S4.|
8308 name: dollar-doublequoted-strings
8310 Check that a $ preceding "…" is ignored
8312 echo $"Localise me!"
8317 I do not take a $V for a V!
8322 I do not take a $V for a V!
8324 name: dollar-quoted-strings
8326 Check backslash expansion by $'…' strings
8328 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
8330 ./pfn $'\ \!\"\#\$\%\&\'\(\)\*\+\,\-\.\/ \1\2\3\4\5\6' \
8331 $'a\0b' $'a\01b' $'\7\8\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I' \
8332 $'\J\K\L\M\N\O\P\Q\R\S\T\U1\V\W\X\Y\Z\[\\\]\^\_\`\a\b\d\e' \
8333 $'\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u1\v\w\x1\y\z\{\|\}\~ $x' \
8334 $'\u20acd' $'\U20acd' $'\x123' $'fn\x0rd' $'\0234' $'\234' \
8335 $'\2345' $'\ca' $'\c!' $'\c?' $'\c€' $'a\
8337 # integer-base-one-3As
8338 typeset -Uui16 -Z11 pos=0
8339 typeset -Uui16 -Z5 hv=2147483647
8343 while IFS= read -r line; do
8345 while [[ -n $line ]]; do
8347 if (( (pos & 15) == 0 )); then
8348 (( pos )) && print "$dasc|"
8349 print -n "${pos#16#} "
8352 print -n "${hv#16#} "
8353 if (( (hv < 32) || (hv > 126) )); then
8356 dasc=$dasc${line::1}
8358 (( (pos++ & 15) == 7 )) && print -n -- '- '
8362 while (( pos & 15 )); do
8364 (( (pos++ & 15) == 7 )) && print -n -- '- '
8366 (( hv == 2147483647 )) || print "$dasc|"
8369 00000000 20 21 22 23 24 25 26 27 - 28 29 2A 2B 2C 2D 2E 2F | !"#$%&'()*+,-./|
8370 00000010 20 01 02 03 04 05 06 0A - 61 0A 61 01 62 0A 07 38 | .......a.a.b..8|
8371 00000020 39 3A 3B 3C 3D 3E 3F 40 - 41 42 43 44 1B 46 47 48 |9:;<=>?@ABCD.FGH|
8372 00000030 49 0A 4A 4B 4C 4D 4E 4F - 50 51 52 53 54 01 56 57 |I.JKLMNOPQRST.VW|
8373 00000040 58 59 5A 5B 5C 5D 5E 5F - 60 07 08 64 1B 0A 0C 67 |XYZ[\]^_`..d...g|
8374 00000050 68 69 6A 6B 6C 6D 0A 6F - 70 71 0D 73 09 01 0B 77 |hijklm.opq.s...w|
8375 00000060 01 79 7A 7B 7C 7D 7E 20 - 24 78 0A E2 82 AC 64 0A |.yz{|}~ $x....d.|
8376 00000070 EF BF BD 0A C4 A3 0A 66 - 6E 0A 13 34 0A 9C 0A 9C |.......fn..4....|
8377 00000080 35 0A 01 0A 01 0A 7F 0A - 02 82 AC 0A 61 0A 62 0A |5...........a.b.|
8379 name: dollar-quotes-in-heredocs-strings
8381 They are, however, not parsed in here documents, here strings
8382 (outside of string delimiters) or regular strings, but in
8383 parameter substitutions.
8386 dollar = strchr(s, '$'); /* ' */
8392 cat <<<"dollar = strchr(s, '$'); /* ' */"
8393 cat <<<'dollar = strchr(s, '\''$'\''); /* '\'' */'
8394 x="dollar = strchr(s, '$'); /* ' */"
8397 unset nl; print -r -- "x${nl:=$'\n'}y"
8403 # probably never reached for here strings?
8405 cat <<<"4 foo\\\"bar"
8407 # old scripts use this (e.g. ncurses)
8409 # make sure this works, outside of quotes
8412 dollar = strchr(s, '$'); /* ' */
8415 dollar = strchr(s, '$'); /* ' */
8416 dollar = strchr(s, '$'); /* ' */
8417 dollar = strchr(s, '$'); /* ' */
8429 name: dot-needs-argument
8431 check Debian #415167 solution: '.' without arguments should fail
8434 "$__progname" -c source
8435 expected-exit: e != 0
8436 expected-stderr-pattern:
8437 /\.: missing argument.*\n.*\.: missing argument/
8439 name: alias-function-no-conflict
8441 make aliases not conflict with functions
8442 note: for ksh-like functions, the order of preference is
8443 different; bash outputs baz instead of bar in line 2 below
8445 alias foo='echo bar'
8449 alias korn='echo bar'
8456 foo 2>/dev/null || echo rab
8462 name: bash-function-parens
8464 ensure the keyword function is ignored when preceding
8465 POSIX style function declarations (bashism)
8468 echo '#!'"$__progname"
8470 echo ' echo "bar='\''$0'\'\"
8474 mk 'function foo' >f-korn
8476 mk 'function foo ()' >f-bash
8477 mk 'function stop ()' stop >f-stop
8478 print '#!'"$__progname"'\nprint -r -- "${0%/f-argh}"' >f-argh
8481 x="korn: $(./f-korn)"; echo "${x/@("$u")/.}"
8482 x="dash: $(./f-dash)"; echo "${x/@("$u")/.}"
8483 x="bash: $(./f-bash)"; echo "${x/@("$u")/.}"
8484 x="stop: $(./f-stop)"; echo "${x/@("$u")/.}"
8487 dash: bar='./f-dash'
8488 bash: bar='./f-bash'
8489 stop: bar='./f-stop'
8491 name: integer-base-one-1
8493 check if the use of fake integer base 1 works
8496 typeset -Uui16 i0=1#ï i1=1#â
\82¬
8498 typeset -i1 o1a=0x263A
8499 typeset -Uui1 o0b=0x7E
8500 typeset -Uui1 o1b=0xFDD0
8501 integer px=0xCAFE 'p0=1# ' p1=1#… pl=1#f
8502 echo "in <$i0> <$i1>"
8503 echo "out <${o0a#1#}|${o0b#1#}> <${o1a#1#}|${o1b#1#}>"
8505 echo "pass <$px> <$p0> <$p1> <$pl> <${i0#1#}|${i1#1#}>"
8506 typeset -Uui16 tv1=1#~ tv2=1#
\7f tv3=1#
\80 tv4=1#
\81 tv5=1#À tv6=1#Á tv7=1#Â tv8=1#Â
\80
8507 echo "specX <${tv1#16#}> <${tv2#16#}> <${tv3#16#}> <${tv4#16#}> <${tv5#16#}> <${tv6#16#}> <${tv7#16#}> <${tv8#16#}>"
8508 typeset -i1 tv1 tv2 tv3 tv4 tv5 tv6 tv7 tv8
8509 echo "specW <${tv1#1#}> <${tv2#1#}> <${tv3#1#}> <${tv4#1#}> <${tv5#1#}> <${tv6#1#}> <${tv7#1#}> <${tv8#1#}>"
8510 typeset -i1 xs1=0xEF7F xs2=0xEF80 xs3=0xFDD0
8511 echo "specU <${xs1#1#}> <${xs2#1#}> <${xs3#1#}>"
8513 in <16#EFEF> <16#20AC>
8515 pass <16#cafe> <1# > <1#â
\80¦> <1#f> <ï|â
\82¬>
8516 specX <7E> <7F> <EF80> <EF81> <EFC0> <EFC1> <A0> <80>
8517 specW <~> <
\7f> <
\80> <
\81> <À> <Á> <Â > <Â
\80>
8518 specU <> <
\80> <ï·
\90>
8520 name: integer-base-one-2a
8522 check if the use of fake integer base 1 stops at correct characters
8527 expected-stderr-pattern:
8528 /1#foo: unexpected 'oo'/
8529 expected-exit: e != 0
8531 name: integer-base-one-2b
8533 check if the use of fake integer base 1 stops at correct characters
8538 expected-stderr-pattern:
8539 /1#À
\80: unexpected '
\80'/
8540 expected-exit: e != 0
8542 name: integer-base-one-2c1
8544 check if the use of fake integer base 1 stops at correct characters
8552 name: integer-base-one-2c2
8554 check if the use of fake integer base 1 stops at correct characters
8559 expected-stderr-pattern:
8560 /1#â
\80¦: unexpected '
\80'/
8561 expected-exit: e != 0
8563 name: integer-base-one-2d1
8565 check if the use of fake integer base 1 handles octets okay
8569 echo /$x/ # invalid utf-8
8573 name: integer-base-one-2d2
8575 check if the use of fake integer base 1 handles octets
8579 echo /$x/ # invalid 2-byte
8583 name: integer-base-one-2d3
8585 check if the use of fake integer base 1 handles octets
8589 echo /$x/ # invalid 2-byte
8593 name: integer-base-one-2d4
8595 check if the use of fake integer base 1 stops at invalid input
8598 typeset -i16 x=1#ï¿À
8599 echo /$x/ # invalid 3-byte
8600 expected-stderr-pattern:
8601 /1#ï¿À: unexpected '¿'/
8602 expected-exit: e != 0
8604 name: integer-base-one-2d5
8606 check if the use of fake integer base 1 stops at invalid input
8609 typeset -i16 x=1#À
\80
8610 echo /$x/ # non-minimalistic
8611 expected-stderr-pattern:
8612 /1#À
\80: unexpected '
\80'/
8613 expected-exit: e != 0
8615 name: integer-base-one-2d6
8617 check if the use of fake integer base 1 stops at invalid input
8620 typeset -i16 x=1#à
\80\80
8621 echo /$x/ # non-minimalistic
8622 expected-stderr-pattern:
8623 /1#à
\80\80: unexpected '
\80'/
8624 expected-exit: e != 0
8626 name: integer-base-one-3As
8628 some sample code for hexdumping
8629 not NUL safe; input lines must be NL terminated
8632 print 'Hello, World!\\\nこんにちは!'
8633 typeset -Uui16 i=0x100
8634 # change that to 0xFF once we can handle embedded
8635 # NUL characters in strings / here documents
8636 while (( i++ < 0x1FF )); do
8637 print -n "\x${i#16#1}"
8641 # integer-base-one-3As
8642 typeset -Uui16 -Z11 pos=0
8643 typeset -Uui16 -Z5 hv=2147483647
8647 while IFS= read -r line; do
8649 while [[ -n $line ]]; do
8651 if (( (pos & 15) == 0 )); then
8652 (( pos )) && print "$dasc|"
8653 print -n "${pos#16#} "
8656 print -n "${hv#16#} "
8657 if (( (hv < 32) || (hv > 126) )); then
8660 dasc=$dasc${line::1}
8662 (( (pos++ & 15) == 7 )) && print -n -- '- '
8666 while (( pos & 15 )); do
8668 (( (pos++ & 15) == 7 )) && print -n -- '- '
8670 (( hv == 2147483647 )) || print "$dasc|"
8673 00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..|
8674 00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................|
8675 00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................|
8676 00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................|
8677 00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.|
8678 00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>|
8679 00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN|
8680 00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^|
8681 00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn|
8682 00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~|
8683 000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................|
8684 000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................|
8685 000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................|
8686 000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................|
8687 000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................|
8688 000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................|
8689 00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................|
8690 00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................|
8691 00000120 FF 7A 0A - |.z.|
8693 name: integer-base-one-3Ws
8695 some sample code for hexdumping Unicode
8696 not NUL safe; input lines must be NL terminated
8700 print 'Hello, World!\\\nこんにちは!'
8701 typeset -Uui16 i=0x100
8702 # change that to 0xFF once we can handle embedded
8703 # NUL characters in strings / here documents
8704 while (( i++ < 0x1FF )); do
8705 print -n "\u${i#16#1}"
8708 print \\xff # invalid utf-8
8709 print \\xc2 # invalid 2-byte
8710 print \\xef\\xbf\\xc0 # invalid 3-byte
8711 print \\xc0\\x80 # non-minimalistic
8712 print \\xe0\\x80\\x80 # non-minimalistic
8713 print '�' # end of range
8714 print '\0z' # embedded NUL
8716 # integer-base-one-3Ws
8717 typeset -Uui16 -Z11 pos=0
8718 typeset -Uui16 -Z7 hv
8723 while IFS= read -r line; do
8726 while (( lpos < ${#line} )); do
8727 wc=1#${line:(lpos++):1}
8728 if (( (wc < 32) || \
8729 ((wc > 126) && (wc < 160)) )); then
8731 elif (( (wc & 0xFF80) == 0xEF80 )); then
8736 if (( (pos & 7) == 7 )); then
8739 elif (( (pos & 7) == 0 )); then
8740 (( pos )) && print "$dasc|"
8741 print -n "${pos#16#} "
8745 print -n "${hv#16#} "
8746 (( (pos++ & 7) == 3 )) && \
8751 while (( pos & 7 )); do
8753 (( (pos++ & 7) == 3 )) && print -n -- '- '
8755 (( hv == 2147483647 )) || print "$dasc|"
8758 00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W|
8759 00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.こ|
8760 00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |んにちは!...|
8761 00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........|
8762 00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........|
8763 00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........|
8764 00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"|
8765 00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*|
8766 00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012|
8767 00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:|
8768 00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB|
8769 00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ|
8770 00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR|
8771 00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ|
8772 00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab|
8773 00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij|
8774 00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr|
8775 00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz|
8776 00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....|
8777 00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........|
8778 000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........|
8779 000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........|
8780 000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |..... ¡¢|
8781 000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA |£¤¥¦§¨©ª|
8782 000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 |«¬®¯°±²|
8783 000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA |³´µ¶·¸¹º|
8784 000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 |»¼½¾¿ÀÁÂ|
8785 000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA |ÃÄÅÆÇÈÉÊ|
8786 000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 |ËÌÍÎÏÐÑÒ|
8787 000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA |ÓÔÕÖ×ØÙÚ|
8788 000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 |ÛÜÝÞßàáâ|
8789 000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA |ãäåæçèéê|
8790 00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 |ëìíîïðñò|
8791 00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA |óôõö÷øùú|
8792 00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |ûüýþÿ.�.|
8793 00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |�.���.��|
8794 00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |.���.���|
8795 00000128 EFBE EFEF EFBF EFBF - 000A 007A 000A |����.z.|
8797 name: integer-base-one-3Ar
8799 some sample code for hexdumping; NUL and binary safe
8802 print 'Hello, World!\\\nこんにちは!'
8803 typeset -Uui16 i=0x100
8804 # change that to 0xFF once we can handle embedded
8805 # NUL characters in strings / here documents
8806 while (( i++ < 0x1FF )); do
8807 print -n "\x${i#16#1}"
8811 # integer-base-one-3Ar
8812 typeset -Uui16 -Z11 pos=0
8813 typeset -Uui16 -Z5 hv=2147483647
8815 if read -arN -1 line; then
8818 while (( i < ${#line[*]} )); do
8820 if (( (pos & 15) == 0 )); then
8821 (( pos )) && print "$dasc|"
8822 print -n "${pos#16#} "
8825 print -n "${hv#16#} "
8826 if (( (hv < 32) || (hv > 126) )); then
8829 dasc=$dasc${line[i-1]#1#}
8831 (( (pos++ & 15) == 7 )) && print -n -- '- '
8834 while (( pos & 15 )); do
8836 (( (pos++ & 15) == 7 )) && print -n -- '- '
8838 (( hv == 2147483647 )) || print "$dasc|"
8841 00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..|
8842 00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................|
8843 00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................|
8844 00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................|
8845 00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.|
8846 00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>|
8847 00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN|
8848 00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^|
8849 00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn|
8850 00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~|
8851 000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................|
8852 000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................|
8853 000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................|
8854 000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................|
8855 000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................|
8856 000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................|
8857 00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................|
8858 00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................|
8859 00000120 FF 00 7A 0A - |..z.|
8861 name: integer-base-one-3Wr
8863 some sample code for hexdumping Unicode; NUL and binary safe
8867 print 'Hello, World!\\\nこんにちは!'
8868 typeset -Uui16 i=0x100
8869 # change that to 0xFF once we can handle embedded
8870 # NUL characters in strings / here documents
8871 while (( i++ < 0x1FF )); do
8872 print -n "\u${i#16#1}"
8875 print \\xff # invalid utf-8
8876 print \\xc2 # invalid 2-byte
8877 print \\xef\\xbf\\xc0 # invalid 3-byte
8878 print \\xc0\\x80 # non-minimalistic
8879 print \\xe0\\x80\\x80 # non-minimalistic
8880 print '�' # end of range
8881 print '\0z' # embedded NUL
8883 # integer-base-one-3Wr
8884 typeset -Uui16 -Z11 pos=0
8885 typeset -Uui16 -Z7 hv=2147483647
8887 if read -arN -1 line; then
8890 while (( i < ${#line[*]} )); do
8892 if (( (hv < 32) || \
8893 ((hv > 126) && (hv < 160)) )); then
8895 elif (( (hv & 0xFF80) == 0xEF80 )); then
8900 if (( (pos & 7) == 7 )); then
8903 elif (( (pos & 7) == 0 )); then
8904 (( pos )) && print "$dasc|"
8905 print -n "${pos#16#} "
8908 print -n "${hv#16#} "
8909 (( (pos++ & 7) == 3 )) && \
8914 while (( pos & 7 )); do
8916 (( (pos++ & 7) == 3 )) && print -n -- '- '
8918 (( hv == 2147483647 )) || print "$dasc|"
8921 00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W|
8922 00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.こ|
8923 00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |んにちは!...|
8924 00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........|
8925 00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........|
8926 00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........|
8927 00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"|
8928 00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*|
8929 00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012|
8930 00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:|
8931 00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB|
8932 00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ|
8933 00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR|
8934 00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ|
8935 00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab|
8936 00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij|
8937 00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr|
8938 00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz|
8939 00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....|
8940 00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........|
8941 000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........|
8942 000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........|
8943 000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |..... ¡¢|
8944 000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA |£¤¥¦§¨©ª|
8945 000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 |«¬®¯°±²|
8946 000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA |³´µ¶·¸¹º|
8947 000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 |»¼½¾¿ÀÁÂ|
8948 000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA |ÃÄÅÆÇÈÉÊ|
8949 000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 |ËÌÍÎÏÐÑÒ|
8950 000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA |ÓÔÕÖ×ØÙÚ|
8951 000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 |ÛÜÝÞßàáâ|
8952 000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA |ãäåæçèéê|
8953 00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 |ëìíîïðñò|
8954 00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA |óôõö÷øùú|
8955 00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |ûüýþÿ.�.|
8956 00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |�.���.��|
8957 00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |.���.���|
8958 00000128 EFBE EFEF EFBF EFBF - 000A 0000 007A 000A |����..z.|
8960 name: integer-base-one-4
8962 Check if ksh93-style base-one integers work
8967 (echo 2f $(('aa'))) 2>&1 | sed "s/^[^']*'/2p '/"
8975 2p 'aa': multi-character character constant
8981 name: integer-base-one-5A
8983 Check to see that we’re NUL and Unicode safe
8986 print 'a\0b\xfdz' >x
8992 16#61 16#0 16#62 16#FD 16#7A .
8994 name: integer-base-one-5W
8996 Check to see that we’re NUL and Unicode safe
9005 16#61 16#0 16#62 16#20AC 16#63 .
9009 Check if we can use a specific syntax idiom for ulimit
9010 category: !os:syllable
9012 if ! x=$(ulimit -d) || [[ $x = unknown ]]; then
9013 #echo expected to fail on this OS
9016 ulimit -dS $x && echo okay
9023 Check some of the most basic invariants of I/O redirection
9028 print -u2 e$((i++)).
9053 Check if GNU bash-like I/O redirection works
9054 Part 1: this is also supported by GNU bash
9055 category: shell:legacy-no
9074 Check if GNU bash-like I/O redirection works
9075 Part 2: this is *not* supported by GNU bash
9076 category: shell:legacy-no
9095 Check if GNU bash-like I/O redirection works
9096 Part 2: this is *not* supported by GNU bash
9097 category: shell:legacy-no
9116 Check if GNU bash-like I/O redirection works
9117 Part 2: this is supported by GNU bash 4 only
9118 category: shell:legacy-no
9140 Check if GNU bash-like I/O redirection fails correctly
9141 Part 1: this is also supported by GNU bash
9142 category: shell:legacy-no
9158 expected-stderr-pattern: /.*: can't (create|overwrite) .*/
9162 Check if GNU bash-like I/O redirection fails correctly
9163 Part 2: this is *not* supported by GNU bash
9164 category: shell:legacy-no
9185 Check if GNU bash-like I/O redirection works
9186 Part 4: this is also supported by GNU bash,
9187 but failed in some mksh versions
9188 category: shell:legacy-no
9197 [[ -e bar ]] && threeout "$bf" &>foo
9210 name: bashiop-5-normal
9212 Check if GNU bash-like I/O redirection is only supported
9213 in !POSIX !sh mode as it breaks existing scripts' syntax
9214 category: shell:legacy-no
9216 :>x; echo 1 "$("$__progname" -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9217 :>x; echo 2 "$("$__progname" -o posix -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9218 :>x; echo 3 "$("$__progname" -o sh -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9224 name: bashiop-5-legacy
9226 Check if GNU bash-like I/O redirection is not parsed
9227 in lksh as it breaks existing scripts' syntax
9228 category: shell:legacy-yes
9230 :>x; echo 1 "$("$__progname" -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9231 :>x; echo 2 "$("$__progname" -o posix -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9232 :>x; echo 3 "$("$__progname" -o sh -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
9240 Check for support of more than 9 file descriptors
9243 read -u10 foo 10<<< bar
9250 Check for support of more than 9 file descriptors
9266 for n in ${a#*=}; do echo 1hu ${n} .; done
9267 for n in "${a#*=}"; do echo 1hq ${n} .; done
9268 for n in ${a##*=}; do echo 2hu ${n} .; done
9269 for n in "${a##*=}"; do echo 2hq ${n} .; done
9270 for n in ${a%=*}; do echo 1pu ${n} .; done
9271 for n in "${a%=*}"; do echo 1pq ${n} .; done
9272 for n in ${a%%=*}; do echo 2pu ${n} .; done
9273 for n in "${a%%=*}"; do echo 2pq ${n} .; done
9280 name: oksh-and-list-error-1
9282 Test exit status of rightmost element in 2 element && list in -e mode
9285 echo "should not print"
9287 expected-exit: e != 0
9289 name: oksh-and-list-error-2
9291 Test exit status of rightmost element in 3 element && list in -e mode
9293 true && true && false
9294 echo "should not print"
9296 expected-exit: e != 0
9298 name: oksh-or-list-error-1
9300 Test exit status of || list in -e mode
9303 echo "should not print"
9305 expected-exit: e != 0
9307 name: oksh-longline-crash
9309 This used to cause a core dump
9312 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"
9313 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"
9314 for deplib in $deplibs; do
9317 new_libs="$deplib $new_libs"
9320 case " $specialdeplibs " in
9322 new_libs="$deplib $new_libs";;
9328 name: oksh-seterror-1
9330 The -e flag should be ignored when executing a compound list
9331 followed by an if statement.
9333 if true; then false && false; fi
9336 expected-exit: e == 0
9338 name: oksh-seterror-2
9340 The -e flag should be ignored when executing a compound list
9341 followed by an if statement.
9343 if true; then if true; then false && false; fi; fi
9346 expected-exit: e == 0
9348 name: oksh-seterror-3
9350 The -e flag should be ignored when executing a compound list
9351 followed by an elif statement.
9353 if true; then :; elif true; then false && false; fi
9355 expected-exit: e == 0
9357 name: oksh-seterror-4
9359 The -e flag should be ignored when executing a pipeline
9368 expected-exit: e == 0
9370 name: oksh-seterror-5
9372 The -e flag should be ignored when executing a pipeline
9378 expected-exit: e == 0
9380 name: oksh-seterror-6
9382 When trapping ERR and EXIT, both traps should run in -e mode
9383 when an error occurs.
9385 trap 'echo EXIT' EXIT
9392 expected-exit: e != 0
9397 name: oksh-seterror-7
9399 The -e flag within a command substitution should be honored
9401 echo $( set -e; false; echo foo )
9406 name: oksh-input-comsub
9408 A command substitution using input redirection should exit with
9409 failure if the input file does not exist.
9411 var=$(< non-existent)
9412 expected-exit: e != 0
9413 expected-stderr-pattern: /non-existent/
9415 name: oksh-empty-for-list
9417 A for list which expands to zero items should not execute the body.
9419 set foo bar baz ; for out in ; do echo $out ; done
9421 name: oksh-varfunction-mod1
9423 (Inspired by PR 2450 on OpenBSD.) Calling
9425 where f is a ksh style function, should not set FOO in the current
9426 env. If f is a Bourne style function, FOO should be set. Furthermore,
9427 the function should receive a correct value of FOO. However, differing
9428 from oksh, setting FOO in the function itself must change the value in
9429 setting FOO in the function itself should not change the value in
9432 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
9433 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
9434 done >env; chmod +x env; PATH=.:$PATH
9436 if [ x$FOO != xbar ]; then
9441 if [ "x$x" != "xFOO=bar" ]; then
9449 if [ x$FOO != xbar ]; then
9454 if [ "x$x" != "xFOO=bar" ]; then
9462 if [ $? != 0 ]; then
9465 if [ x$FOO != x ]; then
9469 if [ $? != 0 ]; then
9472 if [ x$FOO != xfoo ]; then
9477 if [ $? != 0 ]; then
9480 if [ x$FOO != xbarbar ]; then
9484 if [ $? != 0 ]; then
9487 if [ x$FOO != xfoo ]; then
9493 Verify that file descriptors > 2 are private for Korn shells
9494 AT&T ksh93 does this still, which means we must keep it as well
9495 category: shell:legacy-no
9496 file-setup: file 644 "test.sh"
9500 "$__progname" test.sh
9501 expected-exit: e != 0
9502 expected-stderr-pattern:
9503 /bad file descriptor/
9507 Verify that file descriptors > 2 are not private for POSIX shells
9508 See Debian Bug #154540, Closes: #499139
9509 file-setup: file 644 "test.sh"
9512 test -n "$POSH_VERSION" || set -o sh
9514 "$__progname" test.sh
9520 Verify that file descriptors > 2 are not private for LEGACY KSH
9521 category: shell:legacy-yes
9522 file-setup: file 644 "test.sh"
9526 "$__progname" test.sh
9532 COMSUB are now parsed recursively, so this works
9533 see also regression-6: matching parenthesēs bug
9534 Fails on: pdksh bash2 bash3 zsh
9535 Passes on: bash4 ksh93 mksh(20110313+)
9537 echo 1 $(case 1 in (1) echo yes;; (2) echo no;; esac) .
9538 echo 2 $(case 1 in 1) echo yes;; 2) echo no;; esac) .
9539 TEST=1234; echo 3 ${TEST: $(case 1 in (1) echo 1;; (*) echo 2;; esac)} .
9540 TEST=5678; echo 4 ${TEST: $(case 1 in 1) echo 1;; *) echo 2;; esac)} .
9541 a=($(case 1 in (1) echo 1;; (*) echo 2;; esac)); echo 5 ${a[0]} .
9542 a=($(case 1 in 1) echo 1;; *) echo 2;; esac)); echo 6 ${a[0]} .
9553 COMSUB are now parsed recursively, so this works
9554 Fails on: pdksh bash2 bash3 bash4 zsh
9555 Passes on: ksh93 mksh(20110313+)
9557 echo 1 $(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10)) .
9558 echo 2 $(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20)) .
9559 (( a = $(case 1 in (1) echo 1;; (*) echo 2;; esac) )); echo 3 $a .
9560 (( a = $(case 1 in 1) echo 1;; *) echo 2;; esac) )); echo 4 $a .
9561 a=($(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10))); echo 5 ${a[0]} .
9562 a=($(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20))); echo 6 ${a[0]} .
9573 RedHat BZ#496791 – another case of missing recursion
9574 in parsing COMSUB expressions
9575 Fails on: pdksh bash2 bash3¹ bash4¹ zsh
9576 Passes on: ksh93 mksh(20110305+)
9577 ① bash[34] seem to choke on comment ending with backslash-newline
9579 # a comment with " ' \
9582 # a comment with " ' \
9590 Extended test for COMSUB explaining why a recursive parser
9591 is a must (a non-recursive parser cannot pass all three of
9592 these test cases, especially the ‘#’ is difficult)
9594 print '#!'"$__progname"'\necho 1234' >id; chmod +x id; PATH=.:$PATH
9595 echo $(typeset -i10 x=16#20; echo $x)
9596 echo $(typeset -Uui16 x=16#$(id -u)
9599 typeset -Uui16 a=36#foo; c=2
9600 typeset -Uui16 b=36 #foo; d=2
9609 Check the tree dump functions for !MKSH_SMALL functionality
9612 x() { case $1 in u) echo x ;;& *) echo $1 ;; esac; }
9628 Check COMSUB works with aliases (does not expand them twice)
9630 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
9641 ./pfn "$(echo foo )"
9644 name: comsub-torture
9646 Check the tree dump functions work correctly
9648 if [[ -z $__progname ]]; then echo >&2 call me with __progname; exit 1; fi
9649 while IFS= read -r line; do
9650 if [[ $line = '#1' ]]; then
9653 elif [[ $line = EOFN* ]]; then
9654 fbody=$fbody$'\n'$line
9656 elif [[ $line != '#'* ]]; then
9657 fbody=$fbody$'\n\t'$line
9660 if (( lastf )); then
9661 x="inline_${nextf}() {"$fbody$'\n}\n'
9663 print -r -- "${x}typeset -f inline_$nextf" | "$__progname"
9664 x="function comsub_$nextf { x=\$("$fbody$'\n); }\n'
9666 print -r -- "${x}typeset -f comsub_$nextf" | "$__progname"
9667 x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n'
9669 print -r -- "${x}typeset -f reread_$nextf" | "$__progname"
9677 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
9679 (echo $foo | tr -dc 0-9; echo)
9681 cmd && echo ja || echo nein
9683 select file in *; do echo "<$file>" ; break ; done
9685 time for i in {1,2,3} ; do echo $i ; done
9687 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
9688 #TIF_TBANG_TDBRACKET_TELIF
9689 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
9691 i=1; while (( i < 10 )); do echo $i; let ++i; done
9693 i=10; until (( !--i )) ; do echo $i; done
9696 #TFUNCT_TBRACE_TASYNC
9697 function korn { echo eins; echo zwei ; }
9698 bourne () { logger * & }
9701 #IOWRITE_IOCLOB_IOHERE_noIOSKIP
9705 #IOWRITE_noIOCLOB_IOHERE_IOSKIP
9710 sh 1<>/dev/console 0<&1 2>&1
9711 #COMSUB_EXPRSUB_FUNSUB_VALSUB
9712 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
9713 #QCHAR_OQUOTE_CQUOTE
9714 echo fo\ob\"a\`r\'b\$az
9715 echo "fo\ob\"a\`r\'b\$az"
9716 echo 'fo\ob\"a\`r'\''b\$az'
9717 #OSUBST_CSUBST_OPAT_SPAT_CPAT
9718 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
9721 note there must be no space between EOFN and )
9725 note the space between EOFN and ) is actually part of the here document marker
9728 x=$(sysctl -n kern.version | sed 1q)
9729 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
9730 ed -s /etc/motd 2>&1 <<-EOF
9737 EOF)" = @(?) ]] && rm -f /etc/motd
9738 if [[ ! -s /etc/motd ]]; then
9739 install -c -o root -g wheel -m 664 /dev/null /etc/motd
9740 print -- "$x\n" >/etc/motd
9750 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
9753 vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4"
9755 function comsub_TCOM { x=$(
9756 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
9758 function comsub_TCOM {
9759 x=$(vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" )
9761 function reread_TCOM { x=$((
9762 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
9764 function reread_TCOM {
9765 x=$(( vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" ) | tr u x )
9767 inline_TPAREN_TPIPE_TLIST() {
9768 (echo $foo | tr -dc 0-9; echo)
9770 inline_TPAREN_TPIPE_TLIST() {
9771 ( echo $foo | tr -dc 0-9
9774 function comsub_TPAREN_TPIPE_TLIST { x=$(
9775 (echo $foo | tr -dc 0-9; echo)
9777 function comsub_TPAREN_TPIPE_TLIST {
9778 x=$(( echo $foo | tr -dc 0-9 ; echo ) )
9780 function reread_TPAREN_TPIPE_TLIST { x=$((
9781 (echo $foo | tr -dc 0-9; echo)
9783 function reread_TPAREN_TPIPE_TLIST {
9784 x=$(( ( echo $foo | tr -dc 0-9 ; echo ) ) | tr u x )
9787 cmd && echo ja || echo nein
9790 cmd && echo ja || echo nein
9792 function comsub_TAND_TOR { x=$(
9793 cmd && echo ja || echo nein
9795 function comsub_TAND_TOR {
9796 x=$(cmd && echo ja || echo nein )
9798 function reread_TAND_TOR { x=$((
9799 cmd && echo ja || echo nein
9801 function reread_TAND_TOR {
9802 x=$(( cmd && echo ja || echo nein ) | tr u x )
9805 select file in *; do echo "<$file>" ; break ; done
9814 function comsub_TSELECT { x=$(
9815 select file in *; do echo "<$file>" ; break ; done
9817 function comsub_TSELECT {
9818 x=$(select file in * ; do echo "<$file>" ; break ; done )
9820 function reread_TSELECT { x=$((
9821 select file in *; do echo "<$file>" ; break ; done
9823 function reread_TSELECT {
9824 x=$(( select file in * ; do echo "<$file>" ; break ; done ) | tr u x )
9826 inline_TFOR_TTIME() {
9827 time for i in {1,2,3} ; do echo $i ; done
9829 inline_TFOR_TTIME() {
9830 time for i in {1,2,3}
9835 function comsub_TFOR_TTIME { x=$(
9836 time for i in {1,2,3} ; do echo $i ; done
9838 function comsub_TFOR_TTIME {
9839 x=$(time for i in {1,2,3} ; do echo $i ; done )
9841 function reread_TFOR_TTIME { x=$((
9842 time for i in {1,2,3} ; do echo $i ; done
9844 function reread_TFOR_TTIME {
9845 x=$(( time for i in {1,2,3} ; do echo $i ; done ) | tr u x )
9848 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
9859 echo kann net bis drei zählen
9863 function comsub_TCASE { x=$(
9864 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
9866 function comsub_TCASE {
9867 x=$(case $foo in (1) echo eins ;& (2) echo zwei ;| (*) echo kann net bis drei zählen ;; esac )
9869 function reread_TCASE { x=$((
9870 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
9872 function reread_TCASE {
9873 x=$(( case $foo in (1) echo eins ;& (2) echo zwei ;| (*) echo kann net bis drei zählen ;; esac ) | tr u x )
9875 inline_TIF_TBANG_TDBRACKET_TELIF() {
9876 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
9878 inline_TIF_TBANG_TDBRACKET_TELIF() {
9889 function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$(
9890 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
9892 function comsub_TIF_TBANG_TDBRACKET_TELIF {
9893 x=$(if ! [[ 1 = 1 ]] ; then echo eins ; elif [[ 1 = 2 ]] ; then echo zwei ; else echo drei ; fi )
9895 function reread_TIF_TBANG_TDBRACKET_TELIF { x=$((
9896 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
9898 function reread_TIF_TBANG_TDBRACKET_TELIF {
9899 x=$(( if ! [[ 1 = 1 ]] ; then echo eins ; elif [[ 1 = 2 ]] ; then echo zwei ; else echo drei ; fi ) | tr u x )
9902 i=1; while (( i < 10 )); do echo $i; let ++i; done
9906 while let] " i < 10 "
9912 function comsub_TWHILE { x=$(
9913 i=1; while (( i < 10 )); do echo $i; let ++i; done
9915 function comsub_TWHILE {
9916 x=$(i=1 ; while let] " i < 10 " ; do echo $i ; let ++i ; done )
9918 function reread_TWHILE { x=$((
9919 i=1; while (( i < 10 )); do echo $i; let ++i; done
9921 function reread_TWHILE {
9922 x=$(( i=1 ; while let] " i < 10 " ; do echo $i ; let ++i ; done ) | tr u x )
9925 i=10; until (( !--i )) ; do echo $i; done
9934 function comsub_TUNTIL { x=$(
9935 i=10; until (( !--i )) ; do echo $i; done
9937 function comsub_TUNTIL {
9938 x=$(i=10 ; until let] " !--i " ; do echo $i ; done )
9940 function reread_TUNTIL { x=$((
9941 i=10; until (( !--i )) ; do echo $i; done
9943 function reread_TUNTIL {
9944 x=$(( i=10 ; until let] " !--i " ; do echo $i ; done ) | tr u x )
9953 function comsub_TCOPROC { x=$(
9956 function comsub_TCOPROC {
9959 function reread_TCOPROC { x=$((
9962 function reread_TCOPROC {
9963 x=$(( cat * |& ls ) | tr u x )
9965 inline_TFUNCT_TBRACE_TASYNC() {
9966 function korn { echo eins; echo zwei ; }
9967 bourne () { logger * & }
9969 inline_TFUNCT_TBRACE_TASYNC() {
9978 function comsub_TFUNCT_TBRACE_TASYNC { x=$(
9979 function korn { echo eins; echo zwei ; }
9980 bourne () { logger * & }
9982 function comsub_TFUNCT_TBRACE_TASYNC {
9983 x=$(function korn { echo eins ; echo zwei ; } ; bourne() { logger * & } )
9985 function reread_TFUNCT_TBRACE_TASYNC { x=$((
9986 function korn { echo eins; echo zwei ; }
9987 bourne () { logger * & }
9989 function reread_TFUNCT_TBRACE_TASYNC {
9990 x=$(( function korn { echo eins ; echo zwei ; } ; bourne() { logger * & } ) | tr u x )
9992 inline_IOREAD_IOCAT() {
9995 inline_IOREAD_IOCAT() {
9998 function comsub_IOREAD_IOCAT { x=$(
10001 function comsub_IOREAD_IOCAT {
10002 x=$(tr x u <foo >>bar )
10004 function reread_IOREAD_IOCAT { x=$((
10007 function reread_IOREAD_IOCAT {
10008 x=$(( tr x u <foo >>bar ) | tr u x )
10010 inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
10015 inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
10021 function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$(
10026 function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
10027 x=$(cat >|bar <<"EOFN"
10032 function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$((
10037 function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
10038 x=$(( cat >|bar <<"EOFN"
10043 inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
10048 inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
10054 function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$(
10059 function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
10060 x=$(cat >bar <<-EOFI
10065 function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$((
10070 function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
10071 x=$(( cat >bar <<-EOFI
10076 inline_IORDWR_IODUP() {
10077 sh 1<>/dev/console 0<&1 2>&1
10079 inline_IORDWR_IODUP() {
10080 sh 1<>/dev/console <&1 2>&1
10082 function comsub_IORDWR_IODUP { x=$(
10083 sh 1<>/dev/console 0<&1 2>&1
10085 function comsub_IORDWR_IODUP {
10086 x=$(sh 1<>/dev/console <&1 2>&1 )
10088 function reread_IORDWR_IODUP { x=$((
10089 sh 1<>/dev/console 0<&1 2>&1
10091 function reread_IORDWR_IODUP {
10092 x=$(( sh 1<>/dev/console <&1 2>&1 ) | tr u x )
10094 inline_COMSUB_EXPRSUB_FUNSUB_VALSUB() {
10095 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
10097 inline_COMSUB_EXPRSUB_FUNSUB_VALSUB() {
10098 echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;}
10100 function comsub_COMSUB_EXPRSUB_FUNSUB_VALSUB { x=$(
10101 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
10103 function comsub_COMSUB_EXPRSUB_FUNSUB_VALSUB {
10104 x=$(echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;} )
10106 function reread_COMSUB_EXPRSUB_FUNSUB_VALSUB { x=$((
10107 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
10109 function reread_COMSUB_EXPRSUB_FUNSUB_VALSUB {
10110 x=$(( echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;} ) | tr u x )
10112 inline_QCHAR_OQUOTE_CQUOTE() {
10113 echo fo\ob\"a\`r\'b\$az
10114 echo "fo\ob\"a\`r\'b\$az"
10115 echo 'fo\ob\"a\`r'\''b\$az'
10117 inline_QCHAR_OQUOTE_CQUOTE() {
10118 echo fo\ob\"a\`r\'b\$az
10119 echo "fo\ob\"a\`r\'b\$az"
10120 echo "fo\\ob\\\"a\\\`r"\'"b\\\$az"
10122 function comsub_QCHAR_OQUOTE_CQUOTE { x=$(
10123 echo fo\ob\"a\`r\'b\$az
10124 echo "fo\ob\"a\`r\'b\$az"
10125 echo 'fo\ob\"a\`r'\''b\$az'
10127 function comsub_QCHAR_OQUOTE_CQUOTE {
10128 x=$(echo fo\ob\"a\`r\'b\$az ; echo "fo\ob\"a\`r\'b\$az" ; echo "fo\\ob\\\"a\\\`r"\'"b\\\$az" )
10130 function reread_QCHAR_OQUOTE_CQUOTE { x=$((
10131 echo fo\ob\"a\`r\'b\$az
10132 echo "fo\ob\"a\`r\'b\$az"
10133 echo 'fo\ob\"a\`r'\''b\$az'
10135 function reread_QCHAR_OQUOTE_CQUOTE {
10136 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 )
10138 inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() {
10139 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
10141 inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() {
10142 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
10144 function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$(
10145 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
10147 function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT {
10148 x=$([[ ${foo#bl\(u\)b} = @(bar|baz) ]] )
10150 function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$((
10151 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
10153 function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT {
10154 x=$(( [[ ${foo#bl\(u\)b} = @(bar|baz) ]] ) | tr u x )
10156 inline_heredoc_closed() {
10158 note there must be no space between EOFN and )
10161 inline_heredoc_closed() {
10163 note there must be no space between EOFN and )
10168 function comsub_heredoc_closed { x=$(
10170 note there must be no space between EOFN and )
10173 function comsub_heredoc_closed {
10175 note there must be no space between EOFN and )
10179 function reread_heredoc_closed { x=$((
10181 note there must be no space between EOFN and )
10184 function reread_heredoc_closed {
10185 x=$(( x=$(cat <<EOFN
10186 note there must be no space between EOFN and )
10188 ) ; echo $x ) | tr u x )
10190 inline_heredoc_space() {
10192 note the space between EOFN and ) is actually part of the here document marker
10195 inline_heredoc_space() {
10197 note the space between EOFN and ) is actually part of the here document marker
10202 function comsub_heredoc_space { x=$(
10204 note the space between EOFN and ) is actually part of the here document marker
10207 function comsub_heredoc_space {
10208 x=$(x=$(cat <<EOFN\
10209 note the space between EOFN and ) is actually part of the here document marker
10213 function reread_heredoc_space { x=$((
10215 note the space between EOFN and ) is actually part of the here document marker
10218 function reread_heredoc_space {
10219 x=$(( x=$(cat <<EOFN\
10220 note the space between EOFN and ) is actually part of the here document marker
10222 ) ; echo $x ) | tr u x )
10224 inline_patch_motd() {
10225 x=$(sysctl -n kern.version | sed 1q)
10226 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
10227 ed -s /etc/motd 2>&1 <<-EOF
10234 EOF)" = @(?) ]] && rm -f /etc/motd
10235 if [[ ! -s /etc/motd ]]; then
10236 install -c -o root -g wheel -m 664 /dev/null /etc/motd
10237 print -- "$x\n" >/etc/motd
10240 inline_patch_motd() {
10241 x=$(sysctl -n kern.version | sed 1q )
10242 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
10250 )" = @(?) ]] && rm -f /etc/motd
10251 if [[ ! -s /etc/motd ]]
10253 install -c -o root -g wheel -m 664 /dev/null /etc/motd
10254 print -- "$x\n" >/etc/motd
10257 function comsub_patch_motd { x=$(
10258 x=$(sysctl -n kern.version | sed 1q)
10259 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
10260 ed -s /etc/motd 2>&1 <<-EOF
10267 EOF)" = @(?) ]] && rm -f /etc/motd
10268 if [[ ! -s /etc/motd ]]; then
10269 install -c -o root -g wheel -m 664 /dev/null /etc/motd
10270 print -- "$x\n" >/etc/motd
10273 function comsub_patch_motd {
10274 x=$(x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
10282 )" = @(?) ]] && 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 )
10284 function reread_patch_motd { x=$((
10285 x=$(sysctl -n kern.version | sed 1q)
10286 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
10287 ed -s /etc/motd 2>&1 <<-EOF
10294 EOF)" = @(?) ]] && rm -f /etc/motd
10295 if [[ ! -s /etc/motd ]]; then
10296 install -c -o root -g wheel -m 664 /dev/null /etc/motd
10297 print -- "$x\n" >/etc/motd
10300 function reread_patch_motd {
10301 x=$(( x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
10309 )" = @(?) ]] && 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 )
10311 inline_wdarrassign() {
10316 inline_wdarrassign() {
10324 function comsub_wdarrassign { x=$(
10329 function comsub_wdarrassign {
10330 x=$(case x in (x) a+=b ; set -A c+ -- d e ;; esac )
10332 function reread_wdarrassign { x=$((
10337 function reread_wdarrassign {
10338 x=$(( case x in (x) a+=b ; set -A c+ -- d e ;; esac ) | tr u x )
10341 name: comsub-torture-io
10343 Check the tree dump functions work correctly with I/O redirection
10345 if [[ -z $__progname ]]; then echo >&2 call me with __progname; exit 1; fi
10346 while IFS= read -r line; do
10347 if [[ $line = '#1' ]]; then
10350 elif [[ $line = EOFN* ]]; then
10351 fbody=$fbody$'\n'$line
10353 elif [[ $line != '#'* ]]; then
10354 fbody=$fbody$'\n\t'$line
10357 if (( lastf )); then
10358 x="inline_${nextf}() {"$fbody$'\n}\n'
10360 print -r -- "${x}typeset -f inline_$nextf" | "$__progname"
10361 x="function comsub_$nextf { x=\$("$fbody$'\n); }\n'
10363 print -r -- "${x}typeset -f comsub_$nextf" | "$__progname"
10364 x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n'
10366 print -r -- "${x}typeset -f reread_$nextf" | "$__progname"
10374 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
10375 #TPAREN_TPIPE_TLIST
10376 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
10378 cmd >&3 && >&3 echo ja || echo >&3 nein
10380 select file in *; do echo "<$file>" ; break >&3 ; done >&3
10382 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
10384 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
10385 #TIF_TBANG_TDBRACKET_TELIF
10386 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
10388 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
10390 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
10392 cat * >&3 |& >&3 ls
10393 #TFUNCT_TBRACE_TASYNC
10394 function korn { echo eins; echo >&3 zwei ; }
10395 bourne () { logger * >&3 & }
10397 echo $(true >&3) $((1+ 2))
10402 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
10405 vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" >&3
10407 function comsub_TCOM { x=$(
10408 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
10410 function comsub_TCOM {
10411 x=$(vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" >&3 )
10413 function reread_TCOM { x=$((
10414 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
10416 function reread_TCOM {
10417 x=$(( vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" >&3 ) | tr u x )
10419 inline_TPAREN_TPIPE_TLIST() {
10420 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
10422 inline_TPAREN_TPIPE_TLIST() {
10423 ( echo $foo | tr -dc 0-9 >&3
10426 function comsub_TPAREN_TPIPE_TLIST { x=$(
10427 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
10429 function comsub_TPAREN_TPIPE_TLIST {
10430 x=$(( echo $foo | tr -dc 0-9 >&3 ; echo >&3 ) >&3 )
10432 function reread_TPAREN_TPIPE_TLIST { x=$((
10433 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
10435 function reread_TPAREN_TPIPE_TLIST {
10436 x=$(( ( echo $foo | tr -dc 0-9 >&3 ; echo >&3 ) >&3 ) | tr u x )
10438 inline_TAND_TOR() {
10439 cmd >&3 && >&3 echo ja || echo >&3 nein
10441 inline_TAND_TOR() {
10442 cmd >&3 && echo ja >&3 || echo nein >&3
10444 function comsub_TAND_TOR { x=$(
10445 cmd >&3 && >&3 echo ja || echo >&3 nein
10447 function comsub_TAND_TOR {
10448 x=$(cmd >&3 && echo ja >&3 || echo nein >&3 )
10450 function reread_TAND_TOR { x=$((
10451 cmd >&3 && >&3 echo ja || echo >&3 nein
10453 function reread_TAND_TOR {
10454 x=$(( cmd >&3 && echo ja >&3 || echo nein >&3 ) | tr u x )
10457 select file in *; do echo "<$file>" ; break >&3 ; done >&3
10466 function comsub_TSELECT { x=$(
10467 select file in *; do echo "<$file>" ; break >&3 ; done >&3
10469 function comsub_TSELECT {
10470 x=$(select file in * ; do echo "<$file>" ; break >&3 ; done >&3 )
10472 function reread_TSELECT { x=$((
10473 select file in *; do echo "<$file>" ; break >&3 ; done >&3
10475 function reread_TSELECT {
10476 x=$(( select file in * ; do echo "<$file>" ; break >&3 ; done >&3 ) | tr u x )
10478 inline_TFOR_TTIME() {
10479 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
10481 inline_TFOR_TTIME() {
10487 function comsub_TFOR_TTIME { x=$(
10488 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
10490 function comsub_TFOR_TTIME {
10491 x=$(for i in {1,2,3} ; do time echo $i >&3 ; done >&3 )
10493 function reread_TFOR_TTIME { x=$((
10494 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
10496 function reread_TFOR_TTIME {
10497 x=$(( for i in {1,2,3} ; do time echo $i >&3 ; done >&3 ) | tr u x )
10500 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
10511 echo kann net bis drei zählen >&3
10515 function comsub_TCASE { x=$(
10516 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
10518 function comsub_TCASE {
10519 x=$(case $foo in (1) echo eins >&3 ;& (2) echo zwei >&3 ;| (*) echo kann net bis drei zählen >&3 ;; esac >&3 )
10521 function reread_TCASE { x=$((
10522 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
10524 function reread_TCASE {
10525 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 )
10527 inline_TIF_TBANG_TDBRACKET_TELIF() {
10528 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
10530 inline_TIF_TBANG_TDBRACKET_TELIF() {
10531 if ! [[ 1 = 1 ]] >&3
10534 elif [[ 1 = 2 ]] >&3
10541 function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$(
10542 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
10544 function comsub_TIF_TBANG_TDBRACKET_TELIF {
10545 x=$(if ! [[ 1 = 1 ]] >&3 ; then echo eins ; elif [[ 1 = 2 ]] >&3 ; then echo zwei ; else echo drei ; fi >&3 )
10547 function reread_TIF_TBANG_TDBRACKET_TELIF { x=$((
10548 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
10550 function reread_TIF_TBANG_TDBRACKET_TELIF {
10551 x=$(( if ! [[ 1 = 1 ]] >&3 ; then echo eins ; elif [[ 1 = 2 ]] >&3 ; then echo zwei ; else echo drei ; fi >&3 ) | tr u x )
10554 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
10558 while let] " i < 10 " >&3
10564 function comsub_TWHILE { x=$(
10565 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
10567 function comsub_TWHILE {
10568 x=$(i=1 ; while let] " i < 10 " >&3 ; do echo $i ; let ++i ; done >&3 )
10570 function reread_TWHILE { x=$((
10571 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
10573 function reread_TWHILE {
10574 x=$(( i=1 ; while let] " i < 10 " >&3 ; do echo $i ; let ++i ; done >&3 ) | tr u x )
10577 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
10581 until let] " !--i " >&3
10586 function comsub_TUNTIL { x=$(
10587 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
10589 function comsub_TUNTIL {
10590 x=$(i=10 ; until let] " !--i " >&3 ; do echo $i ; done >&3 )
10592 function reread_TUNTIL { x=$((
10593 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
10595 function reread_TUNTIL {
10596 x=$(( i=10 ; until let] " !--i " >&3 ; do echo $i ; done >&3 ) | tr u x )
10599 cat * >&3 |& >&3 ls
10605 function comsub_TCOPROC { x=$(
10606 cat * >&3 |& >&3 ls
10608 function comsub_TCOPROC {
10609 x=$(cat * >&3 |& ls >&3 )
10611 function reread_TCOPROC { x=$((
10612 cat * >&3 |& >&3 ls
10614 function reread_TCOPROC {
10615 x=$(( cat * >&3 |& ls >&3 ) | tr u x )
10617 inline_TFUNCT_TBRACE_TASYNC() {
10618 function korn { echo eins; echo >&3 zwei ; }
10619 bourne () { logger * >&3 & }
10621 inline_TFUNCT_TBRACE_TASYNC() {
10630 function comsub_TFUNCT_TBRACE_TASYNC { x=$(
10631 function korn { echo eins; echo >&3 zwei ; }
10632 bourne () { logger * >&3 & }
10634 function comsub_TFUNCT_TBRACE_TASYNC {
10635 x=$(function korn { echo eins ; echo zwei >&3 ; } ; bourne() { logger * >&3 & } )
10637 function reread_TFUNCT_TBRACE_TASYNC { x=$((
10638 function korn { echo eins; echo >&3 zwei ; }
10639 bourne () { logger * >&3 & }
10641 function reread_TFUNCT_TBRACE_TASYNC {
10642 x=$(( function korn { echo eins ; echo zwei >&3 ; } ; bourne() { logger * >&3 & } ) | tr u x )
10644 inline_COMSUB_EXPRSUB() {
10645 echo $(true >&3) $((1+ 2))
10647 inline_COMSUB_EXPRSUB() {
10648 echo $(true >&3 ) $((1+ 2))
10650 function comsub_COMSUB_EXPRSUB { x=$(
10651 echo $(true >&3) $((1+ 2))
10653 function comsub_COMSUB_EXPRSUB {
10654 x=$(echo $(true >&3 ) $((1+ 2)) )
10656 function reread_COMSUB_EXPRSUB { x=$((
10657 echo $(true >&3) $((1+ 2))
10659 function reread_COMSUB_EXPRSUB {
10660 x=$(( echo $(true >&3 ) $((1+ 2)) ) | tr u x )
10665 Check that non-subenvironment command substitution works
10685 You can now reliably use local and return in funsubs
10688 x=q; e=1; x=${ echo a; e=2; echo x$e;}; echo 1:y$x,$e,$?.
10689 x=q; e=1; x=${ echo a; typeset e=2; echo x$e;}; echo 2:y$x,$e,$?.
10690 x=q; e=1; x=${ echo a; typeset e=2; return 3; echo x$e;}; echo 3:y$x,$e,$?.
10698 Check that "value substitutions" work as advertised
10704 echo "before: x<$x> y<$y> z<$z> R<$REPLY>"
10707 echo "begin: x<$x> y<$y> z<$z> R<$REPLY>"
10712 echo "end: x<$x> y<$y> z<$z> R<$REPLY>"
10714 echo "after: x<$x> y<$y> z<$z> R<$REPLY>"
10715 # ensure trailing newlines are kept
10716 t=${|REPLY=$'foo\n\n';}
10718 echo -n this used to segfault
10719 echo ${|true;}$(true).
10721 before: x<1> y<2> z<3> R<4>
10722 begin: x<1> y<> z<3> R<>
10723 end: x<5> y<6> z<7> R<8>
10724 after: x<8> y<2> z<7> R<4>
10725 typeset t=$'foo\n\n'
10726 this used to segfault.
10730 Check that the short form [ $x ] works
10734 rv=$?; echo $((++i)) $rv
10736 rv=$?; echo $((++i)) $rv
10738 rv=$?; echo $((++i)) $rv
10740 rv=$?; echo $((++i)) $rv
10743 rv=$?; echo $((++i)) $rv
10745 rv=$?; echo $((++i)) $rv
10747 rv=$?; echo $((++i)) $rv
10749 rv=$?; echo $((++i)) $rv
10752 rv=$?; echo $((++i)) $rv
10754 rv=$?; echo $((++i)) $rv
10756 rv=$?; echo $((++i)) $rv
10758 rv=$?; echo $((++i)) $rv
10775 Check that the short form [[ $x ]] works (ksh93 extension)
10779 rv=$?; echo $((++i)) $rv
10781 rv=$?; echo $((++i)) $rv
10783 rv=$?; echo $((++i)) $rv
10785 rv=$?; echo $((++i)) $rv
10788 rv=$?; echo $((++i)) $rv
10790 rv=$?; echo $((++i)) $rv
10792 rv=$?; echo $((++i)) $rv
10794 rv=$?; echo $((++i)) $rv
10797 rv=$?; echo $((++i)) $rv
10799 rv=$?; echo $((++i)) $rv
10801 rv=$?; echo $((++i)) $rv
10803 rv=$?; echo $((++i)) $rv
10818 name: event-subst-3
10820 Check that '!' substitution in noninteractive mode is ignored
10821 file-setup: file 755 "falsetto"
10825 file-setup: file 755 "!false"
10829 export PATH=.:$PATH
10837 ! false; then echo foo; else echo bar; fi
10846 name: event-subst-0
10848 Check that '!' substitution in interactive mode is ignored
10851 file-setup: file 755 "falsetto"
10855 file-setup: file 755 "!false"
10859 export PATH=.:$PATH
10867 ! false; then echo foo; else echo bar; fi
10875 expected-stderr-pattern:
10880 Check that "set -u" matches (future) SUSv4 requirement
10886 if [[ -n $v ]]; then
10921 (mypid=$$; try mypid)
10923 ) 2>&1 | sed -e 's/^[^]]*]//' -e 's/^[^:]*: *//'
10927 y: parameter not set
10931 y: parameter not set
10935 2: parameter not set
10937 1: parameter not set
10945 !: parameter not set
10956 Testsuite for nameref (bound variables)
10971 set|grep ^ir2|sed 's/^/s1: /'
10972 typeset|grep ' ir2'|sed -e 's/^/s2: /' -e 's/nameref/typeset -n/'
10973 set -A blub -- e1 e2 e3
10974 typeset -n ind=blub
10975 typeset -n ir2=blub[2]
10976 echo !ind[1]: ${!ind[1]}
10978 echo ind[1]: ${ind[1]}
10998 Testsuite for nameref (bound variables)
10999 Functions, argument given directly, after local
11002 typeset bar=lokal baz=auch
11034 Advanced testsuite for bound variables (ksh93 fails this)
11036 typeset -n foo=bar[i]
11037 set -A bar -- b c a
11038 for i in 0 1 2 3; do
11049 Ensure we don't run in an infinite loop
11053 typeset -n foo=fnord fnord=foo
11063 expected-stderr-pattern:
11064 /fnord: expression recurses on parameter/
11066 name: better-parens-1a
11068 Check support for ((…)) and $((…)) vs (…) and $(…)
11070 if ( (echo fubar)|tr u x); then
11079 name: better-parens-1b
11081 Check support for ((…)) and $((…)) vs (…) and $(…)
11083 echo $( (echo fubar)|tr u x) $?
11087 name: better-parens-1c
11089 Check support for ((…)) and $((…)) vs (…) and $(…)
11091 x=$( (echo fubar)|tr u x); echo $x $?
11095 name: better-parens-2a
11097 Check support for ((…)) and $((…)) vs (…) and $(…)
11099 if ((echo fubar)|tr u x); then
11108 name: better-parens-2b
11110 Check support for ((…)) and $((…)) vs (…) and $(…)
11112 echo $((echo fubar)|tr u x) $?
11116 name: better-parens-2c
11118 Check support for ((…)) and $((…)) vs (…) and $(…)
11120 x=$((echo fubar)|tr u x); echo $x $?
11124 name: better-parens-3a
11126 Check support for ((…)) and $((…)) vs (…) and $(…)
11128 if ( (echo fubar)|(tr u x)); then
11137 name: better-parens-3b
11139 Check support for ((…)) and $((…)) vs (…) and $(…)
11141 echo $( (echo fubar)|(tr u x)) $?
11145 name: better-parens-3c
11147 Check support for ((…)) and $((…)) vs (…) and $(…)
11149 x=$( (echo fubar)|(tr u x)); echo $x $?
11153 name: better-parens-4a
11155 Check support for ((…)) and $((…)) vs (…) and $(…)
11157 if ((echo fubar)|(tr u x)); then
11166 name: better-parens-4b
11168 Check support for ((…)) and $((…)) vs (…) and $(…)
11170 echo $((echo fubar)|(tr u x)) $?
11174 name: better-parens-4c
11176 Check support for ((…)) and $((…)) vs (…) and $(…)
11178 x=$((echo fubar)|(tr u x)); echo $x $?
11184 Test what the echo builtin does (mksh)
11186 echo -n 'foo\x40bar'
11193 Test what the echo builtin does (POSIX)
11194 Note: this follows Debian Policy 10.4 which mandates
11195 that -n shall be treated as an option, not XSI which
11196 mandates it shall be treated as string but escapes
11199 test -n "$POSH_VERSION" || set -o posix
11200 echo -n 'foo\x40bar'
11205 name: echo-test-3-mnbsd
11207 Test what the echo builtin does, and test a compatibility flag.
11210 "$__progname" -c 'echo -n 1=\\x40$1; echo -e \\x2E' -- foo bar
11211 "$__progname" -o posix -c 'echo -n 2=\\x40$1; echo -e \\x2E' -- foo bar
11212 "$__progname" -o sh -c 'echo -n 3=\\x40$1; echo -e \\x2E' -- foo bar
11218 name: echo-test-3-normal
11220 Test what the echo builtin does, and test a compatibility flag.
11221 category: !mnbsdash
11223 "$__progname" -c 'echo -n 1=\\x40$1; echo -e \\x2E' -- foo bar
11224 "$__progname" -o posix -c 'echo -n 2=\\x40$1; echo -e \\x2E' -- foo bar
11225 "$__progname" -o sh -c 'echo -n 3=\\x40$1; echo -e \\x2E' -- foo bar
11231 name: utilities-getopts-1
11233 getopts sets OPTIND correctly for unparsed option
11236 while getopts :a optc; do
11237 echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
11241 OPTARG=, OPTIND=2, optc=a.
11242 OPTARG=, OPTIND=3, optc=a.
11243 OPTARG=x, OPTIND=4, optc=?.
11246 name: utilities-getopts-2
11251 while getopts a: optc; do
11252 echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
11256 OPTARG=Mary, OPTIND=3, optc=a.
11257 OPTARG=, OPTIND=4, optc=?.
11259 expected-stderr-pattern: /.*-x.*option/
11263 Check the new wcswidth feature
11267 print octets: ${#s} .
11268 print 8-bit width: ${%s} .
11270 print characters: ${#s} .
11271 print columns: ${%s} .
11274 print octets: ${#s} .
11275 print 8-bit width: ${%s} .
11277 print characters: ${#s} .
11278 print columns: ${%s} .
11291 Check some corner cases
11307 Check some corner cases
11310 expected-stderr-pattern:
11316 Check some corner cases
11319 expected-stderr-pattern:
11325 Check some corner cases
11328 expected-stderr-pattern:
11334 Check some corner cases
11343 Check proper return values for realpath
11344 category: os:mirbsd
11357 x=$(realpath "$wd/$1" 2>&1); y=$?
11358 print $((++i)) "?$1" =${x##*$wd/} !$y
11384 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
11389 3 ?dir/file =dir/file !0
11390 4 ?dir/nix =dir/nix !0
11392 6 ?file/ =file/: Not a directory !20
11393 7 ?file/file =file/file: Not a directory !20
11394 8 ?file/nix =file/nix: Not a directory !20
11397 11 ?nix/file =nix/file: No such file or directory !2
11398 12 ?nix/nix =nix/nix: No such file or directory !2
11401 15 ?lndir/file =dir/file !0
11402 16 ?lndir/nix =dir/nix !0
11403 17 ?lnfile =file !0
11404 18 ?lnfile/ =lnfile/: Not a directory !20
11405 19 ?lnfile/file =lnfile/file: Not a directory !20
11406 20 ?lnfile/nix =lnfile/nix: Not a directory !20
11409 23 ?lnnix/file =lnnix/file: No such file or directory !2
11410 24 ?lnnix/nix =lnnix/nix: No such file or directory !2
11411 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
11415 Ensure that exactly two leading slashes are not collapsed
11416 POSIX guarantees this exception, e.g. for UNC paths on Cygwin
11417 category: os:mirbsd
11427 realpath /usr///bin
11436 realpath //usr/include/../bin
11453 Crashed during March 2011, fixed on vernal equinōx ☺
11454 category: os:mirbsd,os:openbsd
11456 export MALLOC_OPTIONS=FGJPRSX
11457 "$__progname" -c 'x=$(tr z r <<<baz); echo $x'
11463 Check test - bug#465250
11465 test \( ! -e \) ; echo $?
11471 Check test - bug#465250
11473 test \( -e \) ; echo $?
11479 Check test - bug#465250
11481 test ! -e ; echo $?
11487 Check test - bug#465250
11495 Check that zsh case variants work
11529 Check that case end tokens are not mixed up (Debian #220272)
11532 for value in 'x' '}' 'esac'; do
11533 print -n "$((++i))($value)bourne "
11538 print -n "$((++i))($value)korn "
11552 name: command-shift
11554 Check that 'command shift' works
11557 echo "before 0='$0' 1='$1' 2='$2'"
11559 echo "after 0='$0' 1='$1' 2='$2'"
11562 echo "before 0='$0' 1='$1' 2='$2'"
11564 echo "after 0='$0' 1='$1' 2='$2'"
11566 echo = without command
11568 echo = with command
11573 before 0='snc' 1='一' 2='二'
11574 after 0='snc' 1='二' 2=''
11576 before 0='swc' 1='一' 2='二'
11577 after 0='swc' 1='二' 2=''
11582 Check that the compiler did not optimise-break them
11583 (lex.c has got a similar one in SHEREDELIM)
11588 while (( ++i < 256 )); do
11591 s+=$'\xC2\xA0\xE2\x82\xAC\xEF\xBF\xBD\xEF\xBF\xBE\xEF\xBF\xBF\xF0\x90\x80\x80.'
11594 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.'
11596 name: stateptr-underflow
11598 This check overflows an Xrestpos stored in a short in R40
11601 function Lb64decode {
11602 [[ -o utf8-mode ]]; local u=$?
11605 [[ -n $s ]] || { s=$(cat;print x); s=${s%x}; }
11606 local -i i=0 n=${#s} p=0 v x
11609 while (( i < n )); do
11613 ([A-Z]) (( v = 1#$c - 65 )) ;;
11614 ([a-z]) (( v = 1#$c - 71 )) ;;
11615 ([0-9]) (( v = 1#$c + 4 )) ;;
11620 (( x = (x << 6) | v ))
11623 (1) (( o = (x >> 4) & 255 )) ;;
11624 (2) (( o = (x >> 2) & 255 )) ;;
11625 (3) (( o = x & 255 ))
11637 while (( ++i < 12120 )); do
11640 Lb64decode $s >/dev/null
11644 Check that "set -x" doesn't redirect too quickly
11646 print '#!'"$__progname" >bash
11648 echo 'GNU bash, version 2.05b.0(1)-release (i386-ecce-mirbsd10)
11649 Copyright (C) 2002 Free Software Foundation, Inc.'
11652 "$__progname" -xc 'foo=$(./bash --version 2>&1 | head -1); echo "=$foo="'
11654 =GNU bash, version 2.05b.0(1)-release (i386-ecce-mirbsd10)=
11655 expected-stderr-pattern: