1 # $MirOS: src/bin/mksh/check.t,v 1.629 2013/08/14 20:26:15 tg Exp $
2 # $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
3 # $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
4 # $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
5 # $OpenBSD: regress.t,v 1.15 2013/07/01 17:25:27 jca Exp $
6 # $OpenBSD: obsd-regress.t,v 1.5 2013/07/01 17:25:27 jca Exp $
8 # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010,
10 # Thorsten Glaser <tg@mirbsd.org>
12 # Provided that these terms and disclaimer and all copyright notices
13 # are retained or reproduced in an accompanying document, permission
14 # is granted to deal in this work without restriction, including un‐
15 # limited rights to use, publicly perform, distribute, sell, modify,
16 # merge, give away, or sublicence.
18 # This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
19 # the utmost extent permitted by applicable law, neither express nor
20 # implied; without malicious intent or gross negligence. In no event
21 # may a licensor, author or contributor be held liable for indirect,
22 # direct, other damage, loss, or other issues arising in any way out
23 # of dealing in the work, even if advised of the possibility of such
24 # damage or existence of a defect, except proven that it results out
25 # of said person’s immediate fault when using the work as intended.
27 # You may also want to test IFS with the script at
28 # http://www.research.att.com/~gsf/public/ifs.sh
31 # http://www.freebsd.org/cgi/cvsweb.cgi/src/tools/regression/bin/test/regress.sh?rev=HEAD
34 @(#)MIRBSD KSH R48 2013/08/14
36 Check version of shell.
40 category: shell:legacy-no
43 @(#)LEGACY KSH R48 2013/08/14
45 Check version of legacy shell.
48 name: KSH_VERSION-legacy
49 category: shell:legacy-yes
53 Regression test self-testing
61 Regression test self-testing
70 Regression test self-testing
71 env-setup: !ENV=fnord!
79 Just output the environment variables set (always fails)
86 Check some things in the LEGACY KSH
87 category: shell:legacy-yes
91 [[ "$(set +o) -o" = *"-o emacs -o"* ]] && echo 1=emacs
92 [[ "$(set +o) -o" = *"-o vi -o"* ]] && echo 1=vi
95 [[ "$(set +o) -o" = *"-o emacs -o"* ]] && echo 2=emacs
96 [[ "$(set +o) -o" = *"-o vi -o"* ]] && echo 2=vi
101 name: selftest-direct-builtin-call
103 Check that direct builtin calls work
105 ln -s "$__progname" cat || cp "$__progname" cat
106 ln -s "$__progname" echo || cp "$__progname" echo
107 ./echo -c 'echo foo' | ./cat -u
113 Check that recursion is detected/avoided in aliases.
118 expected-stderr-pattern:
119 /fooBar.*not found.*/
123 Check that recursion is detected/avoided in aliases.
130 expected-stderr-pattern:
131 /fooBar.*not found.*\n.*barFoo.*not found/
135 Check that recursion is detected/avoided in aliases.
149 Check that alias expansion isn't done on keywords (in keyword
154 while false; do echo hi ; done
161 Check that alias expansion done after alias with trailing space.
164 alias foo='bar stuff '
165 alias bar='Bar1 Bar2 '
174 Check that alias expansion done after alias with trailing space.
186 Check that alias expansion done after alias with trailing space
191 X Y in 'Y') echo is y ;; Z) echo is z ; esac
197 Check that newlines in an alias don't cause the command to be lost.
217 Check that recursion is detected/avoided in aliases.
218 This check fails for slow machines or Cygwin, raise
219 the time-limit clause (e.g. to 7) if this occurs.
222 print '#!'"$__progname"'\necho tf' >lq
240 Check that recursion is detected/avoided in aliases.
241 Regression, introduced during an old bugfix.
243 alias foo='print hello '
244 alias bar='foo world'
251 Check that only one side of ternary operator is evaluated
256 echo $((1 ? 20 : (x+=2)))
258 echo $((0 ? (y+=2) : 30))
268 Check that assignments not done on non-evaluated side of ternary
274 echo $((1 ? 20 : (x+=2)))
276 echo $((0 ? (y+=2) : 30))
286 Check that assignments not done on non-evaluated side of ternary
287 operator and this construct is parsed correctly (Debian #445651)
297 Check that preun/postun not done on non-evaluated side of ternary
300 (( m = n = 0, 1 ? n++ : m++ ? 2 : 3 ))
302 m=0; echo $(( 0 ? ++m : 2 )); echo $m
303 m=0; echo $(( 0 ? m++ : 2 )); echo $m
311 name: arith-ternary-prec-1
313 Check precedence of ternary operator vs assignment
317 expected-exit: e != 0
318 expected-stderr-pattern:
319 /.*:.*1 \? 20 : x\+=2.*lvalue.*\n$/
321 name: arith-ternary-prec-2
323 Check precedence of ternary operator vs assignment
326 echo $((0 ? x+=2 : 20))
330 name: arith-div-assoc-1
332 Check associativity of division operator
338 name: arith-div-byzero
340 Check division by zero errors out
346 expected-stderr-pattern:
349 name: arith-div-intmin-by-minusone
351 Check division overflow wraps around silently
354 echo signed:$((-2147483648 / -1))r$((-2147483648 % -1)).
355 echo unsigned:$((# -2147483648 / -1))r$((# -2147483648 % -1)).
357 signed:-2147483648r0.
358 unsigned:0r2147483648.
360 name: arith-div-intmin-by-minusone-64
362 Check division overflow wraps around silently
365 echo signed:$((-9223372036854775808 / -1))r$((-9223372036854775808 % -1)).
366 echo unsigned:$((# -9223372036854775808 / -1))r$((# -9223372036854775808 % -1)).
368 signed:-9223372036854775808r0.
369 unsigned:0r9223372036854775808.
371 name: arith-assop-assoc-1
373 Check associativity of assignment-operator operator
375 typeset -i i=1 j=2 k=3
376 echo $((i += j += k))
382 name: arith-mandatory
384 Passing of this test is *mandatory* for a valid mksh executable!
385 category: shell:legacy-no
390 print -r -- $((x++)):$sari=$uari. #0
392 print -r -- $((x++)):$sari=$uari. #1
393 sari=2147483647 uari=2147483647
394 print -r -- $((x++)):$sari=$uari. #2
396 print -r -- $((x++)):$sari=$uari. #3
398 let 'sari *= 2' 'uari *= 2'
400 print -r -- $((x++)):$sari=$uari. #4
402 print -r -- $((x++)):$sari=$uari. #5
403 sari=-2147483648 uari=-2147483648
404 print -r -- $((x++)):$sari=$uari. #6
406 print -r -- $((x++)):$sari=$uari. #7
408 ((# uari = -5 >> 1 ))
409 print -r -- $((x++)):$sari=$uari. #8
412 print -r -- $((x++)):$sari=$uari. #9
416 2:2147483647=2147483647.
417 3:-2147483648=2147483648.
420 6:-2147483648=2147483648.
421 7:2147483647=2147483647.
425 name: arith-unsigned-1
427 Check if unsigned arithmetics work
431 echo x1 $((-1)) $((#-1))
435 vs=4123456789; vu=4123456789
437 (( vs %= 2147483647 ))
438 (( vu %= 2147483647 ))
440 vs=4123456789; vu=4123456789
441 (( # vs %= 2147483647 ))
442 (( # vu %= 2147483647 ))
444 # make sure the calculation does not change unsigned flag
445 vs=4123456789; vu=4123456789
448 echo x6 $((# vs % 2147483647)) $((# vu % 2147483647))
453 echo x7 ${va[#4123456789%2147483647]}
456 x2 -171510507 4123456789
457 x3 -171510507 4123456789
458 x4 1975973142 1975973142
459 x5 -171510507 4123456789
460 x6 1975973142 1975973142
463 name: arith-limit32-1
465 Check if arithmetics are 32 bit
469 echo x1 $((-1)) $((#-1))
473 vs=2147483647; vu=2147483647
477 vs=4294967295; vu=4294967295
485 x2 2147483647 2147483647
486 x3 -2147483648 2147483648
491 name: arith-limit64-1
493 Check if arithmetics are 64 bit
497 echo x1 $((-1)) $((#-1))
501 vs=9223372036854775807; vu=9223372036854775807
505 vs=18446744073709551615; vu=18446744073709551615
512 x1 -1 18446744073709551615
513 x2 9223372036854775807 9223372036854775807
514 x3 -9223372036854775808 9223372036854775808
515 x4 -1 18446744073709551615
521 Check that \newline is not collapsed after #
531 Check that \newline is not collapsed inside single quotes
543 Check that \newline is not collapsed inside single quotes
555 Check interaction of aliases, single quotes and here-documents
556 with backslash-newline
557 (don't know what POSIX has to say about this)
579 Check what happens with backslash at end of input
580 (the old Bourne shell trashes them; so do we)
589 # Places \newline should be collapsed
593 Check that \newline is collapsed before, in the middle of, and
605 Check that \newline is collapsed in $ sequences
629 Check that \newline is collapsed in $(..) and `...` sequences
654 Check that \newline is collapsed in $((..)) sequences
665 echo $((1+2+3+4+5+6)\
676 Check that \newline is collapsed in double quoted strings
691 Check that \newline is collapsed in here document delimiters
692 (ksh93 fails second part of this)
714 Check that \newline is collapsed in double-quoted here-document
733 Check that \newline is collapsed in various 2+ character tokens
778 Check that \ at the end of an alias is collapsed when followed
780 (don't know what POSIX has to say about this)
790 Check that \newline in a keyword is collapsed
800 # Places \newline should be collapsed (ksh extensions)
804 Check that \newline is collapsed in extended globbing
821 Check that \newline is collapsed in ((...)) expressions
836 See if break breaks out of loops
838 for i in a b c; do echo $i; break; echo bad-$i; done
840 for i in a b c; do echo $i; break 1; echo bad-$i; done
866 See if break breaks out of nested loops
883 What if break used outside of any loops
884 (ksh88,ksh93 don't print error messages here)
887 expected-stderr-pattern:
892 What if break N used when only N-1 loops
893 (ksh88,ksh93 don't print error messages here)
895 for i in a b c; do echo $i; break 2; echo bad-$i; done
900 expected-stderr-pattern:
905 Error if break argument isn't a number
907 for i in a b c; do echo $i; break abc; echo more-$i; done
911 expected-exit: e != 0
912 expected-stderr-pattern:
917 See if continue continues loops
919 for i in a b c; do echo $i; continue; echo bad-$i ; done
921 for i in a b c; do echo $i; continue 1; echo bad-$i; done
957 See if continue breaks out of nested loops
976 What if continue used outside of any loops
977 (ksh88,ksh93 don't print error messages here)
980 expected-stderr-pattern:
985 What if continue N used when only N-1 loops
986 (ksh88,ksh93 don't print error messages here)
988 for i in a b c; do echo $i; continue 2; echo bad-$i; done
995 expected-stderr-pattern:
1000 Error if continue argument isn't a number
1002 for i in a b c; do echo $i; continue abc; echo more-$i; done
1006 expected-exit: e != 0
1007 expected-stderr-pattern:
1012 Test someone's CD history package (uses arrays)
1014 # go to known place before doing anything
1028 if [ "$CDHISTFILE" -a -r "$CDHISTFILE" ] # if directory history exists
1032 while read -r t # read directory history file
1038 if [ "${CDHIST[0]}" != "$PWD" -a "$PWD" != "" ]
1040 _cdins # insert $PWD into cd history
1043 cdlen=${#CDHIST[*]} # number of elements in history
1047 if [ "$OLDPWD" = "" ] && ((cdlen>1))
1049 'print' ${CDHIST[1]}
1057 -l) # print directory list
1060 while (((i=i-1)>=0))
1063 'print' "$num ${CDHIST[i]}"
1067 -[0-9]|-[0-9][0-9]) # cd to dir in list
1068 if (((i=${1#-})<cdlen))
1070 'print' ${CDHIST[i]}
1078 -*) # cd to matched dir in list
1083 case ${CDHIST[i]} in
1085 'print' ${CDHIST[i]}
1105 _cdins # insert $PWD into cd history
1107 if [ "$CDHISTFILE" ]
1109 cdlen=${#CDHIST[*]} # number of elements in history
1114 'print' -r ${CDHIST[i]} # update directory history
1120 function _cdins # insert $PWD into cd history
1121 { # meant to be called only by _cd
1125 while ((i<${#CDHIST[*]})) # see if dir is already in list
1127 if [ "${CDHIST[$i]}" = "$PWD" ]
1134 if ((i>22)) # limit max size of list
1139 while (((i=i-1)>=0)) # bump old dirs in list
1141 CDHIST[i+1]=${CDHIST[i]}
1144 CDHIST[0]=$PWD # insert new directory in list
1172 Check package for cd -Pe
1174 # the mv command fails on Cygwin
1175 # Hurd aborts the testsuite (permission denied)
1176 # QNX does not find subdir to cd into
1177 category: !os:cygwin,!os:gnu,!os:msys,!os:nto,!nosymlink
1178 file-setup: file 644 "x"
1179 mkdir noread noread/target noread/target/subdir
1186 echo 1=$?,${PWD#$bwd/}
1187 epwd=$($TSHELL -c pwd 2>/dev/null)
1188 # This unexpectedly succeeds on GNU/Linux and MidnightBSD
1191 mv ../../noread ../../renamed
1193 echo 2=$?,${PWD#$bwd/}
1196 rm -rf noread link renamed
1198 export TSHELL="$__progname"
1205 2=0,noread/target/subdir
1209 2=1,noread/target/subdir
1213 Check that prompt not printed when processing ENV
1214 env-setup: !ENV=./foo!
1215 file-setup: file 644 "foo"
1230 Check that weird ${foo+bar} constructs are parsed correctly
1232 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
1233 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "<$x> "; done' >pfs
1235 (echo 1 ${IFS+'}'z}) 2>/dev/null || echo failed in 1
1236 (echo 2 "${IFS+'}'z}") 2>/dev/null || echo failed in 2
1237 (echo 3 "foo ${IFS+'bar} baz") 2>/dev/null || echo failed in 3
1238 (echo -n '4 '; ./pfn "foo ${IFS+"b c"} baz") 2>/dev/null || echo failed in 4
1239 (echo -n '5 '; ./pfn "foo ${IFS+b c} baz") 2>/dev/null || echo failed in 5
1240 (echo 6 ${IFS+"}"z}) 2>/dev/null || echo failed in 6
1241 (echo 7 "${IFS+"}"z}") 2>/dev/null || echo failed in 7
1242 (echo 8 "${IFS+\"}\"z}") 2>/dev/null || echo failed in 8
1243 (echo 9 "${IFS+\"\}\"z}") 2>/dev/null || echo failed in 9
1244 (echo 10 foo ${IFS+'bar} baz'}) 2>/dev/null || echo failed in 10
1245 (echo 11 "$(echo "${IFS+'}'z}")") 2>/dev/null || echo failed in 11
1246 (echo 12 "$(echo ${IFS+'}'z})") 2>/dev/null || echo failed in 12
1247 (echo 13 ${IFS+\}z}) 2>/dev/null || echo failed in 13
1248 (echo 14 "${IFS+\}z}") 2>/dev/null || echo failed in 14
1249 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
1250 l=t; (echo 16 ${IFS+h`echo -n i ${IFS+$l}h`ere}) 2>/dev/null || echo failed in 16
1251 l=t; (echo 17 ${IFS+h$(echo -n i ${IFS+$l}h)ere}) 2>/dev/null || echo failed in 17
1252 l=t; (echo 18 "${IFS+h`echo -n i ${IFS+$l}h`ere}") 2>/dev/null || echo failed in 18
1253 l=t; (echo 19 "${IFS+h$(echo -n i ${IFS+$l}h)ere}") 2>/dev/null || echo failed in 19
1254 l=t; (echo 20 ${IFS+h`echo -n i "${IFS+$l}"h`ere}) 2>/dev/null || echo failed in 20
1255 l=t; (echo 21 ${IFS+h$(echo -n i "${IFS+$l}"h)ere}) 2>/dev/null || echo failed in 21
1256 l=t; (echo 22 "${IFS+h`echo -n i "${IFS+$l}"h`ere}") 2>/dev/null || echo failed in 22
1257 l=t; (echo 23 "${IFS+h$(echo -n i "${IFS+$l}"h)ere}") 2>/dev/null || echo failed in 23
1258 key=value; (echo -n '24 '; ./pfn "${IFS+'$key'}") 2>/dev/null || echo failed in 24
1259 key=value; (echo -n '25 '; ./pfn "${IFS+"'$key'"}") 2>/dev/null || echo failed in 25 # ksh93: “'$key'”
1260 key=value; (echo -n '26 '; ./pfn ${IFS+'$key'}) 2>/dev/null || echo failed in 26
1261 key=value; (echo -n '27 '; ./pfn ${IFS+"'$key'"}) 2>/dev/null || echo failed in 27
1262 (echo -n '28 '; ./pfn "${IFS+"'"x ~ x'}'x"'}"x}" #') 2>/dev/null || echo failed in 28
1263 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
1264 (echo -n '30 '; ./pfs ${IFS+foo 'b\
1265 ar' baz}; echo .) 2>/dev/null || (echo failed in 30; echo failed in 31)
1266 (echo -n '32 '; ./pfs ${IFS+foo "b\
1267 ar" baz}; echo .) 2>/dev/null || echo failed in 32
1268 (echo -n '33 '; ./pfs "${IFS+foo 'b\
1269 ar' baz}"; echo .) 2>/dev/null || echo failed in 33
1270 (echo -n '34 '; ./pfs "${IFS+foo "b\
1271 ar" baz}"; echo .) 2>/dev/null || echo failed in 34
1272 (echo -n '35 '; ./pfs ${v=a\ b} x ${v=c\ d}; echo .) 2>/dev/null || echo failed in 35
1273 (echo -n '36 '; ./pfs "${v=a\ b}" x "${v=c\ d}"; echo .) 2>/dev/null || echo failed in 36
1274 (echo -n '37 '; ./pfs ${v-a\ b} x ${v-c\ d}; echo .) 2>/dev/null || echo failed in 37
1275 (echo 38 ${IFS+x'a'y} / "${IFS+x'a'y}" .) 2>/dev/null || echo failed in 38
1276 foo="x'a'y"; (echo 39 ${foo%*'a'*} / "${foo%*'a'*}" .) 2>/dev/null || echo failed in 39
1277 foo="a b c"; (echo -n '40 '; ./pfs "${foo#a}"; echo .) 2>/dev/null || echo failed in 40
1293 15 <foo abx{ {{{}b c d{} bar> <}> <baz> .
1307 29 <foo> <abx{ {{> <{}b> <c> <d{}> <bar> <}> <baz> .
1310 32 <foo> <bar> <baz> .
1311 33 <foo 'bar' baz> .
1313 35 <a> <b> <x> <a> <b> .
1314 36 <a\ b> <x> <a\ b> .
1315 37 <a b> <x> <c d> .
1320 name: expand-unglob-dblq
1322 Check that regular "${foo+bar}" constructs are parsed correctly
1327 test x"$v" = x"-" && unset v
1328 (echo "$1 plus norm foo ${v+'bar'} baz")
1329 (echo "$1 dash norm foo ${v-'bar'} baz")
1330 (echo "$1 eqal norm foo ${v='bar'} baz")
1331 (echo "$1 qstn norm foo ${v?'bar'} baz") 2>/dev/null || \
1332 echo "$1 qstn norm -> error"
1333 (echo "$1 PLUS norm foo ${v:+'bar'} baz")
1334 (echo "$1 DASH norm foo ${v:-'bar'} baz")
1335 (echo "$1 EQAL norm foo ${v:='bar'} baz")
1336 (echo "$1 QSTN norm foo ${v:?'bar'} baz") 2>/dev/null || \
1337 echo "$1 QSTN norm -> error"
1341 test x"$v" = x"-" && unset v
1342 (echo "$1 plus parn foo ${v+(bar)} baz")
1343 (echo "$1 dash parn foo ${v-(bar)} baz")
1344 (echo "$1 eqal parn foo ${v=(bar)} baz")
1345 (echo "$1 qstn parn foo ${v?(bar)} baz") 2>/dev/null || \
1346 echo "$1 qstn parn -> error"
1347 (echo "$1 PLUS parn foo ${v:+(bar)} baz")
1348 (echo "$1 DASH parn foo ${v:-(bar)} baz")
1349 (echo "$1 EQAL parn foo ${v:=(bar)} baz")
1350 (echo "$1 QSTN parn foo ${v:?(bar)} baz") 2>/dev/null || \
1351 echo "$1 QSTN parn -> error"
1355 test x"$v" = x"-" && unset v
1356 (echo "$1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz")
1357 (echo "$1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz")
1358 (echo "$1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz")
1359 (echo "$1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz") 2>/dev/null || \
1360 echo "$1 qstn brac -> error"
1361 (echo "$1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz")
1362 (echo "$1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz")
1363 (echo "$1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz")
1364 (echo "$1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz") 2>/dev/null || \
1365 echo "$1 QSTN brac -> error"
1378 1 dash norm foo 'bar' baz
1379 1 eqal norm foo 'bar' baz
1380 1 qstn norm -> error
1382 1 DASH norm foo 'bar' baz
1383 1 EQAL norm foo 'bar' baz
1384 1 QSTN norm -> error
1385 2 plus norm foo 'bar' baz
1390 2 DASH norm foo 'bar' baz
1391 2 EQAL norm foo 'bar' baz
1392 2 QSTN norm -> error
1393 3 plus norm foo 'bar' baz
1394 3 dash norm foo x baz
1395 3 eqal norm foo x baz
1396 3 qstn norm foo x baz
1397 3 PLUS norm foo 'bar' baz
1398 3 DASH norm foo x baz
1399 3 EQAL norm foo x baz
1400 3 QSTN norm foo x baz
1402 4 dash parn foo (bar) baz
1403 4 eqal parn foo (bar) baz
1404 4 qstn parn -> error
1406 4 DASH parn foo (bar) baz
1407 4 EQAL parn foo (bar) baz
1408 4 QSTN parn -> error
1409 5 plus parn foo (bar) baz
1414 5 DASH parn foo (bar) baz
1415 5 EQAL parn foo (bar) baz
1416 5 QSTN parn -> error
1417 6 plus parn foo (bar) baz
1418 6 dash parn foo x baz
1419 6 eqal parn foo x baz
1420 6 qstn parn foo x baz
1421 6 PLUS parn foo (bar) baz
1422 6 DASH parn foo x baz
1423 6 EQAL parn foo x baz
1424 6 QSTN parn foo x baz
1425 7 plus brac foo c } baz
1426 7 dash brac foo ax{{{}b c d{} baz
1427 7 eqal brac foo ax{{{}b c ax{{{}b} baz
1428 7 qstn brac -> error
1429 7 PLUS brac foo c } baz
1430 7 DASH brac foo ax{{{}b c d{} baz
1431 7 EQAL brac foo ax{{{}b c ax{{{}b} baz
1432 7 QSTN brac -> error
1433 8 plus brac foo ax{{{}b c d{} baz
1434 8 dash brac foo c } baz
1435 8 eqal brac foo c } baz
1436 8 qstn brac foo c } baz
1437 8 PLUS brac foo c } baz
1438 8 DASH brac foo ax{{{}b c d{} baz
1439 8 EQAL brac foo ax{{{}b c ax{{{}b} baz
1440 8 QSTN brac -> error
1441 9 plus brac foo ax{{{}b c d{} baz
1442 9 dash brac foo x c x} baz
1443 9 eqal brac foo x c x} baz
1444 9 qstn brac foo x c x} baz
1445 9 PLUS brac foo ax{{{}b c d{} baz
1446 9 DASH brac foo x c x} baz
1447 9 EQAL brac foo x c x} baz
1448 9 QSTN brac foo x c x} baz
1450 name: expand-unglob-unq
1452 Check that regular ${foo+bar} constructs are parsed correctly
1457 test x"$v" = x"-" && unset v
1458 (echo $1 plus norm foo ${v+'bar'} baz)
1459 (echo $1 dash norm foo ${v-'bar'} baz)
1460 (echo $1 eqal norm foo ${v='bar'} baz)
1461 (echo $1 qstn norm foo ${v?'bar'} baz) 2>/dev/null || \
1462 echo "$1 qstn norm -> error"
1463 (echo $1 PLUS norm foo ${v:+'bar'} baz)
1464 (echo $1 DASH norm foo ${v:-'bar'} baz)
1465 (echo $1 EQAL norm foo ${v:='bar'} baz)
1466 (echo $1 QSTN norm foo ${v:?'bar'} baz) 2>/dev/null || \
1467 echo "$1 QSTN norm -> error"
1471 test x"$v" = x"-" && unset v
1472 (echo $1 plus parn foo ${v+\(bar')'} baz)
1473 (echo $1 dash parn foo ${v-\(bar')'} baz)
1474 (echo $1 eqal parn foo ${v=\(bar')'} baz)
1475 (echo $1 qstn parn foo ${v?\(bar')'} baz) 2>/dev/null || \
1476 echo "$1 qstn parn -> error"
1477 (echo $1 PLUS parn foo ${v:+\(bar')'} baz)
1478 (echo $1 DASH parn foo ${v:-\(bar')'} baz)
1479 (echo $1 EQAL parn foo ${v:=\(bar')'} baz)
1480 (echo $1 QSTN parn foo ${v:?\(bar')'} baz) 2>/dev/null || \
1481 echo "$1 QSTN parn -> error"
1485 test x"$v" = x"-" && unset v
1486 (echo $1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz)
1487 (echo $1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz)
1488 (echo $1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz)
1489 (echo $1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz) 2>/dev/null || \
1490 echo "$1 qstn brac -> error"
1491 (echo $1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz)
1492 (echo $1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz)
1493 (echo $1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz)
1494 (echo $1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz) 2>/dev/null || \
1495 echo "$1 QSTN brac -> error"
1508 1 dash norm foo bar baz
1509 1 eqal norm foo bar baz
1510 1 qstn norm -> error
1512 1 DASH norm foo bar baz
1513 1 EQAL norm foo bar baz
1514 1 QSTN norm -> error
1515 2 plus norm foo bar baz
1520 2 DASH norm foo bar baz
1521 2 EQAL norm foo bar baz
1522 2 QSTN norm -> error
1523 3 plus norm foo bar baz
1524 3 dash norm foo x baz
1525 3 eqal norm foo x baz
1526 3 qstn norm foo x baz
1527 3 PLUS norm foo bar baz
1528 3 DASH norm foo x baz
1529 3 EQAL norm foo x baz
1530 3 QSTN norm foo x baz
1532 4 dash parn foo (bar) baz
1533 4 eqal parn foo (bar) baz
1534 4 qstn parn -> error
1536 4 DASH parn foo (bar) baz
1537 4 EQAL parn foo (bar) baz
1538 4 QSTN parn -> error
1539 5 plus parn foo (bar) baz
1544 5 DASH parn foo (bar) baz
1545 5 EQAL parn foo (bar) baz
1546 5 QSTN parn -> error
1547 6 plus parn foo (bar) baz
1548 6 dash parn foo x baz
1549 6 eqal parn foo x baz
1550 6 qstn parn foo x baz
1551 6 PLUS parn foo (bar) baz
1552 6 DASH parn foo x baz
1553 6 EQAL parn foo x baz
1554 6 QSTN parn foo x baz
1555 7 plus brac foo c } baz
1556 7 dash brac foo ax{{{}b c d{} baz
1557 7 eqal brac foo ax{{{}b c ax{{{}b} baz
1558 7 qstn brac -> error
1559 7 PLUS brac foo c } baz
1560 7 DASH brac foo ax{{{}b c d{} baz
1561 7 EQAL brac foo ax{{{}b c ax{{{}b} baz
1562 7 QSTN brac -> error
1563 8 plus brac foo ax{{{}b c d{} baz
1564 8 dash brac foo c } baz
1565 8 eqal brac foo c } baz
1566 8 qstn brac foo c } baz
1567 8 PLUS brac foo c } baz
1568 8 DASH brac foo ax{{{}b c d{} baz
1569 8 EQAL brac foo ax{{{}b c ax{{{}b} baz
1570 8 QSTN brac -> error
1571 9 plus brac foo ax{{{}b c d{} baz
1572 9 dash brac foo x c x} baz
1573 9 eqal brac foo x c x} baz
1574 9 qstn brac foo x c x} baz
1575 9 PLUS brac foo ax{{{}b c d{} baz
1576 9 DASH brac foo x c x} baz
1577 9 EQAL brac foo x c x} baz
1578 9 QSTN brac foo x c x} baz
1580 name: expand-threecolons-dblq
1582 Check for a particular thing that used to segfault
1585 echo "${TEST:1:2:3}"
1586 echo $? but still living
1587 expected-stderr-pattern:
1591 name: expand-threecolons-unq
1593 Check for a particular thing that used to not error out
1597 echo $? but still living
1598 expected-stderr-pattern:
1602 name: expand-weird-1
1604 Check corner case of trim expansion vs. $# vs. ${#var}
1606 set 1 2 3 4 5 6 7 8 9 10 11
1607 echo ${#} # value of $#
1608 echo ${##} # length of $#
1609 echo ${##1} # $# trimmed 1
1610 set 1 2 3 4 5 6 7 8 9 10 11 12
1618 name: expand-weird-2
1620 Check corner case of ${var?} vs. ${#var}
1630 name: expand-weird-3
1632 Check that trimming works with positional parameters (Debian #48453)
1645 Check that globbing isn't done when glob has syntax error
1646 file-setup: file 644 "abcx"
1647 file-setup: file 644 "abcz"
1648 file-setup: file 644 "bbc"
1658 Check that globbing isn't done when glob has syntax error
1659 (AT&T ksh fails this test)
1660 file-setup: file 644 "abcx"
1661 file-setup: file 644 "abcz"
1662 file-setup: file 644 "bbc"
1668 name: eglob-infinite-plus
1670 Check that shell doesn't go into infinite loop expanding +(...)
1672 file-setup: file 644 "abc"
1687 Check that eglobbing isn't done on substitution results
1688 file-setup: file 644 "abc"
1695 name: eglob-nomatch-1
1697 Check that the pattern doesn't match
1699 echo 1: no-file+(a|b)stuff
1700 echo 2: no-file+(a*(c)|b)stuff
1701 echo 3: no-file+((((c)))|b)stuff
1703 1: no-file+(a|b)stuff
1704 2: no-file+(a*(c)|b)stuff
1705 3: no-file+((((c)))|b)stuff
1709 Check that the pattern matches correctly
1710 file-setup: file 644 "abd"
1711 file-setup: file 644 "acd"
1712 file-setup: file 644 "abac"
1716 echo 3: *(a(b|c)) # (...|...) can be used within X(..)
1717 echo 4: a[b*(foo|bar)]d # patterns not special inside [...]
1726 Simple negation tests
1728 case foo in !(foo|bar)) echo yes;; *) echo no;; esac
1729 case bar in !(foo|bar)) echo yes;; *) echo no;; esac
1738 case foo in *(a|b[)) echo yes;; *) echo no;; esac
1739 case foo in *(a|b[)|f*) echo yes;; *) echo no;; esac
1740 case '*(a|b[)' in *(a|b[)) echo yes;; *) echo no;; esac
1748 Eglobbing in trim expressions...
1749 (AT&T ksh fails this - docs say # matches shortest string, ## matches
1765 Check eglobbing works in trims...
1768 echo 1: ${x#*(a|b)cd}
1769 echo 2: "${x#*(a|b)cd}"
1770 echo 3: ${x#"*(a|b)cd"}
1780 Check eglobbing works in trims, for Korn Shell
1781 Ensure eglobbing does not work for reduced-feature /bin/sh
1787 echo "<${x%bar|baz},${y%bar|baz},${z%\?}>"
1788 echo "<${x%ba(r|z)},${y%ba(r|z)}>"
1790 echo "<${x%bar|baz},${y%bar|baz},${z%\?}>"
1796 <foobar,foobaz,fooba>
1799 name: eglob-substrpl-1
1801 Check eglobbing works in substs... and they work at all
1803 [[ -n $BASH_VERSION ]] && shopt -s extglob
1804 x=1222321_ab/cde_b/c_1221
1813 echo 8: ${x//+(2)/4}
1814 echo 9: ${x/b/c/e/f}
1815 echo 10: ${x/b\/c/e/f}
1816 echo 11: ${x/b\/c/e\/f}
1817 echo 12: ${x/b\/c/e\\/f}
1818 echo 13: ${x/b\\/c/e\\/f}
1819 echo 14: ${x//b/c/e/f}
1820 echo 15: ${x//b\/c/e/f}
1821 echo 16: ${x//b\/c/e\/f}
1822 echo 17: ${x//b\/c/e\\/f}
1823 echo 18: ${x//b\\/c/e\\/f}
1824 echo 19: ${x/b\/*\/c/x}
1830 echo 25: ${x//\%1/9}
1831 echo 26: ${x//\\%1/9}
1833 echo 28: ${x//\\a/9}
1836 1: 122321_ab/cde_b/c_1221
1837 2: 131_ab/cde_b/c_11
1838 3: 1321_ab/cde_b/c_1221
1839 4: 131_ab/cde_b/c_11
1840 5: 1422321_ab/cde_b/c_1221
1841 6: 1444341_ab/cde_b/c_1441
1842 7: 14321_ab/cde_b/c_1221
1843 8: 14341_ab/cde_b/c_141
1844 9: 1222321_ac/e/f/cde_b/c_1221
1845 10: 1222321_ae/fde_b/c_1221
1846 11: 1222321_ae/fde_b/c_1221
1847 12: 1222321_ae\/fde_b/c_1221
1848 13: 1222321_ab/cde_b/c_1221
1849 14: 1222321_ac/e/f/cde_c/e/f/c_1221
1850 15: 1222321_ae/fde_e/f_1221
1851 16: 1222321_ae/fde_e/f_1221
1852 17: 1222321_ae\/fde_e\/f_1221
1853 18: 1222321_ab/cde_b/c_1221
1855 20: 1222321_ab.cde_b/c_1221
1856 21: 1222321_ab.cde_b.c_1221
1857 22: 1222321_ab/cde_b/c_1221
1858 23: 9222321_ab/cde_b/c_1221
1859 24: 1222321_ab/cde_b/c_1229
1860 25: 1222321_ab/cde_b/c_1229
1861 26: 1222321_ab/cde_b/c_1221
1862 27: 1222321_9b/cde_b/c_1221
1863 28: 1222321_9b/cde_b/c_1221
1864 29: 1xyz22321_ab/cde_b/c_1221
1866 name: eglob-substrpl-2
1868 Check anchored substring replacement works, corner cases
1885 name: eglob-substrpl-3a
1887 Check substring replacement works with variables and slashes, too
1891 echo "${wd/#$pfx/~}"
1892 echo "${wd/#\$pfx/~}"
1893 echo "${wd/#"$pfx"/~}"
1894 echo "${wd/#'$pfx'/~}"
1895 echo "${wd/#"\$pfx"/~}"
1896 echo "${wd/#'\$pfx'/~}"
1905 name: eglob-substrpl-3b
1907 More of this, bash fails it (bash4 passes)
1911 echo "${wd/#$(echo /home/user)/~}"
1912 echo "${wd/#"$(echo /home/user)"/~}"
1913 echo "${wd/#'$(echo /home/user)'/~}"
1919 name: eglob-substrpl-3c
1921 Even more weird cases
1925 echo 1: ${wd/#$pfx/~}
1926 echo 2: ${wd/#\$pfx/~}
1927 echo 3: ${wd/#"$pfx"/~}
1928 echo 4: ${wd/#'$pfx'/~}
1929 echo 5: ${wd/#"\$pfx"/~}
1930 echo 6: ${wd/#'\$pfx'/~}
1931 ts='a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)'
1934 [[ -n $BASH_VERSION ]] && shopt -s extglob
1935 echo 7: ${ts/a\/b/$tr}
1936 echo 8: ${ts/a\/b/\$tr}
1937 echo 9: ${ts/$tp/$tr}
1938 echo 10: ${ts/\$tp/$tr}
1939 echo 11: ${ts/\\$tp/$tr}
1940 echo 12: ${ts/$tp/c/d}
1941 echo 13: ${ts/$tp/c\/d}
1942 echo 14: ${ts/$tp/c\\/d}
1943 echo 15: ${ts/+(a\/b)/$tr}
1944 echo 16: ${ts/+(a\/b)/\$tr}
1945 echo 17: ${ts/+($tp)/$tr}
1946 echo 18: ${ts/+($tp)/c/d}
1947 echo 19: ${ts/+($tp)/c\/d}
1948 echo 25: ${ts//a\/b/$tr}
1949 echo 26: ${ts//a\/b/\$tr}
1950 echo 27: ${ts//$tp/$tr}
1951 echo 28: ${ts//$tp/c/d}
1952 echo 29: ${ts//$tp/c\/d}
1953 echo 30: ${ts//+(a\/b)/$tr}
1954 echo 31: ${ts//+(a\/b)/\$tr}
1955 echo 32: ${ts//+($tp)/$tr}
1956 echo 33: ${ts//+($tp)/c/d}
1957 echo 34: ${ts//+($tp)/c\/d}
1959 echo 40: ${ts/$tp/$tr}
1960 echo 41: ${ts//$tp/$tr}
1968 7: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1969 8: $tra/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1970 9: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1971 10: a/ba/bc/d$tp_a/b$tp_*(a/b)_*($tp)
1972 11: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1973 12: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1974 13: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1975 14: c\/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1976 15: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
1977 16: $tr$tp$tp_a/b$tp_*(a/b)_*($tp)
1978 17: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
1979 18: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
1980 19: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
1981 25: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1982 26: $tr$tr$tp$tp_$tr$tp_*($tr)_*($tp)
1983 27: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1984 28: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1985 29: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1986 30: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1987 31: $tr$tp$tp_$tr$tp_*($tr)_*($tp)
1988 32: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1989 33: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1990 34: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1991 40: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1992 41: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1993 # This is what GNU bash does:
1994 # 40: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
1995 # 41: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1999 UTF-8 mode differences for eglobbing
2004 print 2: ${s/b???d/x} .
2007 print 4: ${s/b??d/x} .
2009 print 5: ${x%?} ${x%%?} .
2011 print 6: ${x#?} ${x##?} .
2013 print 7: ${x%?} ${x%%?} .
2015 print 8: ${x%?} ${x%%?} .
2017 print 9: ${x%?} ${x%%?} .
2031 Check that globbing isn't done when glob has syntax error
2032 file-setup: dir 755 "[x"
2033 file-setup: file 644 "[x/foo"
2045 Check that symbolic links aren't stat()'d
2046 # breaks on FreeMiNT (cannot unlink dangling symlinks)
2047 # breaks on MSYS (does not support symlinks)
2048 # breaks on Dell UNIX 4.0 R2.2 (SVR4) where unlink also fails
2049 category: !os:mint,!os:msys,!os:svr4.0,!nosymlink
2050 file-setup: dir 755 "dir"
2051 file-setup: symlink 644 "dir/abc"
2063 file-setup: file 644 ".bc"
2064 file-setup: file 644 "abc"
2065 file-setup: file 644 "bbc"
2066 file-setup: file 644 "cbc"
2067 file-setup: file 644 "-bc"
2084 (AT&T ksh fails this; POSIX says invalid)
2085 file-setup: file 644 "abc"
2093 Check that globbing matches the right things...
2094 # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
2095 # breaks on Cygwin 1.7 (files are now UTF-16 or something)
2096 # breaks on QNX 6.4.1 (says RT)
2097 category: !os:cygwin,!os:darwin,!os:msys,!os:nto
2099 file-setup: file 644 "aÂc"
2107 Results unspecified according to POSIX
2108 file-setup: file 644 ".bc"
2116 Results unspecified according to POSIX
2117 (AT&T ksh treats this like [a-cc-e]*)
2118 file-setup: file 644 "abc"
2119 file-setup: file 644 "bbc"
2120 file-setup: file 644 "cbc"
2121 file-setup: file 644 "dbc"
2122 file-setup: file 644 "ebc"
2123 file-setup: file 644 "-bc"
2131 Check ordering/content of redundent here documents.
2143 Check quoted here-doc is protected.
2162 Check that newline isn't needed after heredoc-delimiter marker.
2174 Check that an error occurs if the heredoc-delimiter is missing.
2179 expected-exit: e > 0
2180 expected-stderr-pattern: /.*/
2184 Check that backslash quotes a $, ` and \ and kills a \newline
2191 th\`echo not-run\`ere
2192 th\\`echo is-run`ere
2209 Check that \newline in initial here-delim word doesn't imply
2224 Check that double quoted $ expressions in here delimiters are
2225 not expanded and match the delimiter.
2226 POSIX says only quote removal is applied to the delimiter.
2243 Check that double quoted escaped $ expressions in here
2244 delimiters are not expanded and match the delimiter.
2245 POSIX says only quote removal is applied to the delimiter
2246 (\ counts as a quote).
2267 Check that here strings work.
2271 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo
2272 "$__progname" -c "tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo"
2273 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$bar"
2274 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<'$bar'
2275 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$bar
2276 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<-foo
2277 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$(echo "foo bar")"
2290 Check that a corner case of here strings works like bash
2295 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
2302 Check that a corner case of here strings works like ksh93, zsh
2307 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
2314 Check another corner case of here strings
2316 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<< bar
2322 Check here string related regression with multiple iops
2324 echo $(tr r z <<<'bar' 2>/dev/null)
2330 Check direct here document assignment
2344 fnd=$(typeset -f foo)
2352 # rather nonsensical, but…
2355 vf=<<<$'=f $x \x40='
2357 print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} ve={$ve} vf={$vf} |"
2376 Check here documents with no or empty delimiter
2393 fnd=$(typeset -f foo)
2401 print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} |"
2420 name: heredoc-comsub-1
2422 Tests for here documents in COMSUB, taken from Austin ML
2429 = here is the text =
2431 name: heredoc-comsub-2
2433 Tests for here documents in COMSUB, taken from Austin ML
2435 unbalanced=$(cat <<EOF
2436 this paren ) is a problem
2438 echo = $unbalanced =
2440 = this paren ) is a problem =
2442 name: heredoc-comsub-3
2444 Tests for here documents in COMSUB, taken from Austin ML
2446 balanced=$(cat <<EOF
2447 these parens ( ) are not a problem
2451 = these parens ( ) are not a problem =
2453 name: heredoc-comsub-4
2455 Tests for here documents in COMSUB, taken from Austin ML
2457 balanced=$(cat <<EOF
2458 these parens \( ) are a problem
2462 = these parens \( ) are a problem =
2464 name: heredoc-subshell-1
2466 Tests for here documents in subshells, taken from Austin ML
2476 name: heredoc-subshell-2
2478 Tests for here documents in subshells, taken from Austin ML
2489 name: heredoc-subshell-3
2491 Tests for here documents in subshells, taken from Austin ML
2501 name: heredoc-weird-1
2503 Tests for here documents, taken from Austin ML
2504 Documents current state in mksh, *NOT* necessarily correct!
2517 name: heredoc-weird-2
2519 Tests for here documents, taken from Austin ML
2529 name: heredoc-weird-4
2531 Tests for here documents, taken from Austin ML
2532 Documents current state in mksh, *NOT* necessarily correct!
2543 name: heredoc-weird-5
2545 Tests for here documents, taken from Austin ML
2546 Documents current state in mksh, *NOT* necessarily correct!
2558 name: heredoc-tmpfile-1
2560 Check that heredoc temp files aren't removed too soon or too late.
2561 Heredoc in simple command.
2582 name: heredoc-tmpfile-2
2584 Check that heredoc temp files aren't removed too soon or too late.
2585 Heredoc in function, multiple calls to function.
2604 name: heredoc-tmpfile-3
2606 Check that heredoc temp files aren't removed too soon or too late.
2607 Heredoc in function in loop, multiple calls to function.
2634 name: heredoc-tmpfile-4
2636 Check that heredoc temp files aren't removed too soon or too late.
2637 Backgrounded simple command with here doc
2651 name: heredoc-tmpfile-5
2653 Check that heredoc temp files aren't removed too soon or too late.
2654 Backgrounded subshell command with here doc
2659 sleep 1 # so parent exits
2675 name: heredoc-tmpfile-6
2677 Check that heredoc temp files aren't removed too soon or too late.
2678 Heredoc in pipeline.
2682 cat <<- EOF | sed "s/hi/HI/"
2692 name: heredoc-tmpfile-7
2694 Check that heredoc temp files aren't removed too soon or too late.
2695 Heredoc in backgrounded pipeline.
2699 cat <<- EOF | sed 's/hi/HI/' &
2709 name: heredoc-tmpfile-8
2711 Check that heredoc temp files aren't removed too soon or too
2712 late. Heredoc in function, backgrounded call to function.
2713 This check can fail on slow machines (<100 MHz), or Cygwin,
2718 # Background eval so main shell doesn't do parsing
2726 # sleep so eval can die
2740 name: heredoc-quoting-unsubst
2742 Check for correct handling of quoted characters in
2743 here documents without substitution (marker is quoted).
2747 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
2750 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
2752 name: heredoc-quoting-subst
2754 Check for correct handling of quoted characters in
2755 here documents with substitution (marker is not quoted).
2759 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
2762 x " \" \ \ $ $ baz `echo baz` bar $foo x
2764 name: single-quotes-in-braces
2766 Check that single quotes inside unquoted {} are treated as quotes
2769 echo ${foo:+'blah $foo'}
2773 name: single-quotes-in-quoted-braces
2775 Check that single quotes inside quoted {} are treated as
2779 echo "${foo:+'blah $foo'}"
2783 name: single-quotes-in-braces-nested
2785 Check that single quotes inside unquoted {} are treated as quotes,
2786 even if that's inside a double-quoted command expansion
2789 echo "$( echo ${foo:+'blah $foo'})"
2793 name: single-quotes-in-brace-pattern
2795 Check that single quotes inside {} pattern are treated as quotes
2798 echo ${foo%'2'*} "${foo%'2'*}" ${foo%2'*'} "${foo%2'*'}"
2802 name: single-quotes-in-heredoc-braces
2804 Check that single quotes inside {} in heredoc are treated
2814 name: single-quotes-in-nested-braces
2816 Check that single quotes inside nested unquoted {} are
2820 echo ${foo:+${foo:+'blah $foo'}}
2824 name: single-quotes-in-nested-quoted-braces
2826 Check that single quotes inside nested quoted {} are treated
2830 echo "${foo:+${foo:+'blah $foo'}}"
2834 name: single-quotes-in-nested-braces-nested
2836 Check that single quotes inside nested unquoted {} are treated
2837 as quotes, even if that's inside a double-quoted command expansion
2840 echo "$( echo ${foo:+${foo:+'blah $foo'}})"
2844 name: single-quotes-in-nested-brace-pattern
2846 Check that single quotes inside nested {} pattern are treated as quotes
2849 echo ${foo:+${foo%'2'*}} "${foo:+${foo%'2'*}}" ${foo:+${foo%2'*'}} "${foo:+${foo%2'*'}}"
2853 name: single-quotes-in-heredoc-nested-braces
2855 Check that single quotes inside nested {} in heredoc are treated
2860 ${foo:+${foo:+'blah $foo'}}
2867 See if we can test history at all
2870 env-setup: !ENV=./Env!HISTFILE=hist.file!
2871 file-setup: file 644 "Env"
2879 expected-stderr-pattern:
2884 Verify duplicates and spaces are not entered
2887 env-setup: !ENV=./Env!HISTFILE=hist.file!
2888 file-setup: file 644 "Env"
2900 expected-stderr-pattern:
2903 name: history-unlink
2905 Check if broken HISTFILEs do not cause trouble
2908 env-setup: !ENV=./Env!HISTFILE=foo/hist.file!
2909 file-setup: file 644 "Env"
2911 file-setup: dir 755 "foo"
2912 file-setup: file 644 "foo/hist.file"
2915 perl-setup: chmod(0555, "foo");
2923 expected-stderr-pattern:
2924 /(.*can't unlink HISTFILE.*\n)?X*$/
2926 name: history-e-minus-1
2928 Check if more recent command is executed
2931 env-setup: !ENV=./Env!HISTFILE=hist.file!
2932 file-setup: file 644 "Env"
2942 expected-stderr-pattern:
2943 /^X*echo there\nX*$/
2945 name: history-e-minus-2
2947 Check that repeated command is printed before command
2951 env-setup: !ENV=./Env!HISTFILE=hist.file!
2952 file-setup: file 644 "Env"
2959 expected-stdout-pattern:
2960 /X*hi\nX*there\nX*echo there\nthere\nX*/
2961 expected-stderr-pattern:
2964 name: history-e-minus-3
2966 fc -e - fails when there is no history
2967 (ksh93 has a bug that causes this to fail)
2968 (ksh88 loops on this)
2971 env-setup: !ENV=./Env!HISTFILE=hist.file!
2972 file-setup: file 644 "Env"
2979 expected-stderr-pattern:
2980 /^X*.*:.*history.*\nX*$/
2982 name: history-e-minus-4
2984 Check if "fc -e -" command output goes to stdout.
2987 env-setup: !ENV=./Env!HISTFILE=hist.file!
2988 file-setup: file 644 "Env"
2992 fc -e - | (read x; echo "A $x")
2998 expected-stderr-pattern:
3001 name: history-e-minus-5
3003 fc is replaced in history by new command.
3006 env-setup: !ENV=./Env!HISTFILE=hist.file!
3007 file-setup: file 644 "Env"
3023 expected-stderr-pattern:
3024 /^X*echo ghi jkl\nX*$/
3026 name: history-list-1
3028 List lists correct range
3029 (ksh88 fails 'cause it lists the fc command)
3032 env-setup: !ENV=./Env!HISTFILE=hist.file!
3033 file-setup: file 644 "Env"
3046 expected-stderr-pattern:
3049 name: history-list-2
3051 Lists oldest history if given pre-historic number
3052 (ksh93 has a bug that causes this to fail)
3053 (ksh88 fails 'cause it lists the fc command)
3056 env-setup: !ENV=./Env!HISTFILE=hist.file!
3057 file-setup: file 644 "Env"
3071 expected-stderr-pattern:
3074 name: history-list-3
3076 Can give number 'options' to fc
3079 env-setup: !ENV=./Env!HISTFILE=hist.file!
3080 file-setup: file 644 "Env"
3095 expected-stderr-pattern:
3098 name: history-list-4
3100 -1 refers to previous command
3103 env-setup: !ENV=./Env!HISTFILE=hist.file!
3104 file-setup: file 644 "Env"
3118 expected-stderr-pattern:
3121 name: history-list-5
3123 List command stays in history
3126 env-setup: !ENV=./Env!HISTFILE=hist.file!
3127 file-setup: file 644 "Env"
3144 expected-stderr-pattern:
3147 name: history-list-6
3149 HISTSIZE limits about of history kept.
3150 (ksh88 fails 'cause it lists the fc command)
3153 env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3!
3154 file-setup: file 644 "Env"
3171 expected-stderr-pattern:
3174 name: history-list-7
3176 fc allows too old/new errors in range specification
3179 env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3!
3180 file-setup: file 644 "Env"
3198 expected-stderr-pattern:
3201 name: history-list-r-1
3203 test -r flag in history
3206 env-setup: !ENV=./Env!HISTFILE=hist.file!
3207 file-setup: file 644 "Env"
3225 expected-stderr-pattern:
3228 name: history-list-r-2
3230 If first is newer than last, -r is implied.
3233 env-setup: !ENV=./Env!HISTFILE=hist.file!
3234 file-setup: file 644 "Env"
3252 expected-stderr-pattern:
3255 name: history-list-r-3
3257 If first is newer than last, -r is cancelled.
3260 env-setup: !ENV=./Env!HISTFILE=hist.file!
3261 file-setup: file 644 "Env"
3279 expected-stderr-pattern:
3282 name: history-subst-1
3287 env-setup: !ENV=./Env!HISTFILE=hist.file!
3288 file-setup: file 644 "Env"
3293 fc -e - abc=AB 'echo a'
3298 expected-stderr-pattern:
3299 /^X*echo AB def\nX*$/
3301 name: history-subst-2
3303 Does subst find previous command?
3306 env-setup: !ENV=./Env!HISTFILE=hist.file!
3307 file-setup: file 644 "Env"
3312 fc -e - jkl=XYZQRT 'echo g'
3317 expected-stderr-pattern:
3318 /^X*echo ghi XYZQRT\nX*$/
3320 name: history-subst-3
3322 Does subst find previous command when no arguments given
3325 env-setup: !ENV=./Env!HISTFILE=hist.file!
3326 file-setup: file 644 "Env"
3336 expected-stderr-pattern:
3337 /^X*echo ghi XYZQRT\nX*$/
3339 name: history-subst-4
3341 Global substitutions work
3342 (ksh88 and ksh93 do not have -g option)
3345 env-setup: !ENV=./Env!HISTFILE=hist.file!
3346 file-setup: file 644 "Env"
3349 echo abc def asjj sadjhasdjh asdjhasd
3352 abc def asjj sadjhasdjh asdjhasd
3353 FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd
3354 expected-stderr-pattern:
3355 /^X*echo FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd\nX*$/
3357 name: history-subst-5
3359 Make sure searches don't find current (fc) command
3360 (ksh88/ksh93 don't have the ? prefix thing so they fail this test)
3363 env-setup: !ENV=./Env!HISTFILE=hist.file!
3364 file-setup: file 644 "Env"
3369 fc -e - abc=AB \?abc
3374 expected-stderr-pattern:
3375 /^X*echo AB def\nX*$/
3377 name: history-ed-1-old
3379 Basic (ed) editing works (assumes you have generic ed editor
3380 that prints no prompts). This is for oldish ed(1) which write
3381 the character count to stdout.
3386 env-setup: !ENV=./Env!HISTFILE=hist.file!
3387 file-setup: file 644 "Env"
3400 expected-stderr-pattern:
3401 /^X*echo FOOBAR def\nX*$/
3403 name: history-ed-2-old
3405 Correct command is edited when number given
3410 env-setup: !ENV=./Env!HISTFILE=hist.file!
3411 file-setup: file 644 "Env"
3419 s/is here/is changed/
3430 expected-stderr-pattern:
3431 /^X*echo line 2 is changed\nX*$/
3433 name: history-ed-3-old
3435 Newly created multi line commands show up as single command
3437 (NOTE: adjusted for COMPLEX HISTORY compile time option)
3438 (ksh88 fails 'cause it lists the fc command)
3443 env-setup: !ENV=./Env!HISTFILE=hist.file!
3444 file-setup: file 644 "Env"
3465 expected-stderr-pattern:
3466 /^X*echo FOOBAR def\necho a new line\nX*$/
3470 Basic (ed) editing works (assumes you have generic ed editor
3471 that prints no prompts). This is for newish ed(1) and stderr.
3472 category: !no-stderr-ed
3476 env-setup: !ENV=./Env!HISTFILE=hist.file!
3477 file-setup: file 644 "Env"
3488 expected-stderr-pattern:
3489 /^X*13\n16\necho FOOBAR def\nX*$/
3493 Correct command is edited when number given
3494 category: !no-stderr-ed
3498 env-setup: !ENV=./Env!HISTFILE=hist.file!
3499 file-setup: file 644 "Env"
3507 s/is here/is changed/
3516 expected-stderr-pattern:
3517 /^X*20\n23\necho line 2 is changed\nX*$/
3521 Newly created multi line commands show up as single command
3523 category: !no-stderr-ed
3527 env-setup: !ENV=./Env!HISTFILE=hist.file!
3528 file-setup: file 644 "Env"
3547 expected-stderr-pattern:
3548 /^X*13\n32\necho FOOBAR def\necho a new line\nX*$/
3552 Simple test, default IFS
3554 showargs() { for i; do echo -n " <$i>"; done; echo; }
3570 showargs() { for i; do echo -n " <$i>"; done; echo; }
3587 showargs() { for i; do echo -n " <$i>"; done; echo; }
3600 name: IFS-space-colon-1
3602 Simple test, IFS=<white-space>:
3604 showargs() { for i; do echo -n " <$i>"; done; echo; }
3619 name: IFS-space-colon-2
3621 Simple test, IFS=<white-space>:
3622 AT&T ksh fails this, POSIX says the test is correct.
3624 showargs() { for i; do echo -n " <$i>"; done; echo; }
3631 name: IFS-space-colon-4
3633 Simple test, IFS=<white-space>:
3635 showargs() { for i; do echo -n " <$i>"; done; echo; }
3642 name: IFS-space-colon-5
3644 Simple test, IFS=<white-space>:
3645 Don't know what POSIX thinks of this. AT&T ksh does not do this.
3647 showargs() { for i; do echo -n " <$i>"; done; echo; }
3656 Simple test, IFS=<white-space>:
3658 showargs() { for i; do echo -n " <$i>"; done; echo; }
3661 echo -n '1:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3662 echo -n '2:'; for i in :b:: ; do echo -n " [$i]" ; done ; echo
3666 echo -n '5:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3669 echo -n '7:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3671 echo -n '9:'; for i in ${FOO-`echo -n h:i`th:ere} ; do echo -n " [$i]" ; done ; echo
3672 showargs 10 ${FOO-`echo -n h:i`th:ere}
3673 showargs 11 "${FOO-`echo -n h:i`th:ere}"
3675 echo -n '12:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3687 <10> <h> <ith> <ere>
3692 name: integer-base-err-1
3694 Can't have 0 base (causes shell to exit)
3695 expected-exit: e != 0
3701 expected-stderr-pattern:
3704 name: integer-base-err-2
3706 Can't have multiple bases in a 'constant' (causes shell to exit)
3707 (ksh88 fails this test)
3708 expected-exit: e != 0
3714 expected-stderr-pattern:
3715 /^.*:.*2#110#11.*\n$/
3717 name: integer-base-err-3
3719 Syntax errors in expressions and effects on bases
3720 (interactive so errors don't cause exits)
3721 (ksh88 fails this test - shell exits, even with -i)
3725 PS1= # minimise prompt hassles
3732 expected-stderr-pattern:
3733 /^([#\$] )?.*:.*2+.*\n.*:.*2+.*\n$/
3738 name: integer-base-err-4
3740 Are invalid digits (according to base) errors?
3741 (ksh93 fails this test)
3742 expected-exit: e != 0
3746 expected-stderr-pattern:
3747 /^([#\$] )?.*:.*3#4.*\n$/
3749 name: integer-base-1
3751 Missing number after base is treated as 0.
3760 name: integer-base-2
3762 Check 'stickyness' of base in various situations
3813 name: integer-base-3
3815 More base parsing (hmm doesn't test much..)
3835 name: integer-base-4
3837 Check that things not declared as integers are not made integers,
3838 also, check if base is not reset by -i with no arguments.
3839 (ksh93 fails - prints 10#20 - go figure)
3843 typeset -i | grep '^xx='
3850 name: integer-base-5
3866 for l in 1 2+3 4; do echo $l; done
3878 name: integer-base-6
3880 Even more base stuff
3881 (ksh93 fails this test - prints 0)
3889 name: integer-base-7
3891 Check that non-integer parameters don't get bases assigned
3893 echo $(( zz = 8#100 ))
3899 name: integer-base-check-flat
3901 Check behaviour does not match POSuX (except if set -o posix),
3902 because a not type-safe scripting language has *no* business
3903 interpreting the string "010" as octal numer eight (dangerous).
3905 echo 1 "$("$__progname" -c 'echo :$((10))/$((010)),$((0x10)):')" .
3906 echo 2 "$("$__progname" -o posix -c 'echo :$((10))/$((010)),$((0x10)):')" .
3907 echo 3 "$("$__progname" -o sh -c 'echo :$((10))/$((010)),$((0x10)):')" .
3913 name: integer-base-check-numeric-from
3915 Check behaviour for base one to 36, and that 37 errors out
3919 while (( ++i <= 36 )); do
3920 eval 'echo '$i':$(('$i'#10)).'
3922 echo 37:$($__progname -c 'echo $((37#10))').$?:
3961 expected-stderr-pattern:
3962 /.*bad number '37#10'/
3964 name: integer-base-check-numeric-to
3966 Check behaviour for base one to 36, and that 37 errors out
3969 while (( ++i <= 37 )); do
3970 typeset -Uui$i x=0x40
3971 eval "typeset -i10 y=$x"
4012 expected-stderr-pattern:
4013 /.*bad integer base: 37/
4015 name: integer-arithmetic-span
4017 Check wraparound and size that is defined in mksh
4020 echo s:$((2147483647+1)).$(((2147483647*2)+1)).$(((2147483647*2)+2)).
4021 echo u:$((#2147483647+1)).$((#(2147483647*2)+1)).$((#(2147483647*2)+2)).
4024 u:2147483648.4294967295.0.
4026 name: integer-arithmetic-span-64
4028 Check wraparound and size that is defined in mksh
4031 echo s:$((9223372036854775807+1)).$(((9223372036854775807*2)+1)).$(((9223372036854775807*2)+2)).
4032 echo u:$((#9223372036854775807+1)).$((#(9223372036854775807*2)+1)).$((#(9223372036854775807*2)+2)).
4034 s:-9223372036854775808.-1.0.
4035 u:9223372036854775808.18446744073709551615.0.
4037 name: integer-size-FAIL-to-detect
4039 Notify the user that their ints are not 32 or 64 bit
4046 See if $LINENO is updated and can be modified.
4059 See if $LINENO is set for .'d files.
4060 file-setup: file 644 "dotfile"
4078 See if $LINENO is set for commands in a function.
4097 See if unsetting LINENO makes it non-magic.
4098 file-setup: file 644 "dotfile"
4121 name: lineno-unset-use
4123 See if unsetting LINENO makes it non-magic even
4125 file-setup: file 644 "dotfile"
4151 Check if LINENO is tracked in traps
4157 trap 'fail $LINENO' INT ERR
4165 Ensure unknown traps are not a syntax error
4168 trap "echo trap 1 executed" UNKNOWNSIGNAL || echo "foo"
4170 trap "echo trap 2 executed" UNKNOWNSIGNAL EXIT 999999 FNORD
4172 ) 2>&1 | sed "s
\ 1^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]
\ 1PROG
\ 1"
4174 PROG: trap: bad signal 'UNKNOWNSIGNAL'
4177 PROG: trap: bad signal 'UNKNOWNSIGNAL'
4178 PROG: trap: bad signal '999999'
4179 PROG: trap: bad signal 'FNORD'
4185 Simple test, default IFS
4190 echo 1: "x[$x] y[$y] z[$z]"
4191 echo 1a: ${z-z not set}
4201 If no var specified, REPLY is used
4209 name: read-regress-1
4211 Check a regression of read
4212 file-setup: file 644 "foo"
4217 while read a b c; do
4221 echo "<$a|$b|$c><$d>"
4227 Check read with delimiters
4230 print -n 'foo bar\tbaz\nblah \0blub\tblech\nmyok meck \0'
4232 emit | while IFS= read -d "" foo; do print -r -- "<$foo>"; done
4233 emit | while read -d "" foo; do print -r -- "<$foo>"; done
4234 emit | while read -d "eh?" foo; do print -r -- "<$foo>"; done
4251 Check read with number of bytes specified, and -A
4253 print 'foo\nbar' >x1
4255 print 'foo\\ bar baz' >x3
4257 x1b=u; read -N-1 x1b <x1
4258 x2a=u; read x2a <x2; r2a=$?
4259 x2b=u; read -N2 x2c <x2; r2b=$?
4260 x2c=u; read -n2 x2c <x2; r2c=$?
4261 x3a=u; read -A x3a <x3
4262 print -r "x1a=<$x1a>"
4263 print -r "x1b=<$x1b>"
4264 print -r "x2a=$r2a<$x2a>"
4265 print -r "x2b=$r2b<$x2b>"
4266 print -r "x2c=$r2c<$x2c>"
4267 print -r "x3a=<${x3a[0]}|${x3a[1]}|${x3a[2]}>"
4279 Lex array code had problems with this.
4290 When PATH is set before running a command, the new path is
4291 not used in doing the path search
4292 $ echo echo hi > /tmp/q ; chmod a+rx /tmp/q
4296 in comexec() the two lines
4298 (void) typeset(*vp++, xxx, 0);
4299 need to be moved out of the switch to before findcom() is
4300 called - I don't know what this will break.
4302 : ${PWD:-`pwd 2> /dev/null`}
4303 : ${PWD:?"PWD not set - can't do test"}
4305 cat > Y/xxxscript << EOF
4307 # Need to restore path so echo can be found (some shells don't have
4313 chmod a+rx Y/xxxscript
4314 export OLDPATH="$PATH"
4315 PATH=$PWD/Y xxxscript
4322 Parsing of $(..) expressions is non-optimal. It is
4323 impossible to have any parentheses inside the expression.
4325 $ ksh -c 'echo $(echo \( )'
4327 $ ksh -c 'echo $(echo "(" )'
4330 The solution is to hack the parsing clode in lex.c, the
4331 question is how to hack it: should any parentheses be
4332 escaped by a backslash, or should recursive parsing be done
4333 (so quotes could also be used to hide hem). The former is
4334 easier, the later better...
4344 Continue in a for loop does not work right:
4346 if [ $i = b ] ; then
4355 if [ $i = b ] ; then
4356 if [ $first = no ] ; then
4357 echo 'continue in for loop broken'
4358 break # hope break isn't broken too :-)
4373 should print 0 according to POSIX (dash, bash, ksh93, posh)
4374 but not 0 according to the getopt(1) manual page, ksh88, and
4375 Bourne sh (such as /bin/sh on Solaris).
4376 We honour POSIX except when -o sh is set.
4377 category: shell:legacy-no
4380 [[ -o posix ]]; FPOSIX=$((1-$?))
4381 [[ -o sh ]]; FSH=$((1-$?))
4382 echo -n "FPOSIX=$FPOSIX FSH=$FSH "
4406 name: regression-10-legacy
4411 should print 0 according to POSIX (dash, bash, ksh93, posh)
4412 but not 0 according to the getopt(1) manual page, ksh88, and
4413 Bourne sh (such as /bin/sh on Solaris).
4414 category: shell:legacy-yes
4417 [[ -o posix ]]; FPOSIX=$((1-$?))
4418 [[ -o sh ]]; FSH=$((1-$?))
4419 echo -n "FPOSIX=$FPOSIX FSH=$FSH "
4448 should echo blah but on some machines echos /foo/bar/blah.
4457 Both of the following echos produce the same output under sh/ksh.att:
4460 echo "`echo \"$x\"`"
4462 pdksh produces different output for the former (foo instead of foo\tbar)
4465 echo "`echo \"$x\"`"
4473 The following command hangs forever:
4474 $ (: ; cat /etc/termcap) | sleep 2
4475 This is because the shell forks a shell to run the (..) command
4476 and this shell has the pipe open. When the sleep dies, the cat
4477 doesn't get a SIGPIPE 'cause a process (ie, the second shell)
4478 still has the pipe open.
4480 NOTE: this test provokes a bizarre bug in ksh93 (shell starts reading
4481 commands from /etc/termcap..)
4484 echo A line of text that will be duplicated quite a number of times.> t1
4485 cat t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 > t2
4486 cat t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 > t1
4487 cat t1 t1 t1 t1 > t2
4488 (: ; cat t2 2>/dev/null) | sleep 1
4493 $ (foobar) 2> /dev/null
4494 generates no output under /bin/sh, but pdksh produces the error
4497 $ foobar 2> /dev/null
4498 generates an error under /bin/sh and pdksh, but AT&T ksh88 produces
4499 no error (redirected to /dev/null).
4501 (you/should/not/see/this/error/1) 2> /dev/null
4502 you/should/not/see/this/error/2 2> /dev/null
4509 generates a blank line under pdksh and sets the exit status to 0.
4510 AT&T ksh88 generates no output and sets the exit status to 1. Also,
4513 generates no output under AT&T ksh88 (pdksh generates a blank line
4516 whence does/not/exist > /dev/null
4518 echo 2: $(whence does/not/exist | wc -l)
4519 echo 3: $(whence does/not/exist cat | wc -l)
4527 ${var%%expr} seems to be broken in many places. On the mips
4529 $ read line < /etc/passwd
4537 change the value of line. On sun4s & pas, the echo ${line%%:*} doesn't
4538 work. Haven't checked elsewhere...
4545 root:asdjhasdasjhs:0:1:Root:/:/bin/sh
4548 root:asdjhasdasjhs:0:1:Root:/:/bin/sh
4554 should set the exit status to non-zero (sh and AT&T ksh88 do).
4555 XXX doting a non existent file is a fatal error for a script
4558 expected-exit: e != 0
4559 expected-stderr-pattern: /.?/
4563 Both of the following echos should produce the same thing, but don't:
4577 backslash does not work as expected in case labels:
4596 Quoting backquotes inside backquotes doesn't work:
4597 $ echo `echo hi \`echo there\` folks`
4598 asks for more info. sh and AT&T ksh88 both echo
4601 echo `echo hi \`echo there\` folks`
4607 )) is not treated `correctly':
4608 $ (echo hi ; (echo there ; echo folks))
4611 instead of (as sh and ksh.att)
4612 $ (echo hi ; (echo there ; echo folks))
4618 ( : ; ( : ; echo hi))
4624 Check reading stdin in a while loop. The read should only read
4625 a single line, not a whole stdio buffer; the cat should get
4628 (echo a; echo b) | while read x ; do
4637 Check reading stdin in a while loop. The read should read both
4638 lines, not just the first.
4641 while [ "$a" != xxx ] ; do
4644 cat /dev/null | sed 's/x/y/'
4658 should cause a script to exit.
4662 expected-exit: e != 0
4663 expected-stderr-pattern: /does\/not\/exist/
4667 variable assignements not detected well
4670 expected-exit: e != 0
4671 expected-stderr-pattern: /a\.x=1/
4675 alias expansion different from AT&T ksh88
4677 alias a='for ' b='i in'
4678 a b hi ; do echo $i ; done
4684 strange characters allowed inside ${...}
4687 expected-exit: e != 0
4688 expected-stderr-pattern: /.?/
4692 Does read handle partial lines correctly
4695 while [ "$a" != xxx ] ; do
4712 Does read set variables to null at eof?
4715 while [ "$a" != xxx ] ; do
4719 echo 1: ${x-x not set} ${y-y not set} ${z-z not set}
4720 echo 2: ${x:+x not null} ${y:+y not null} ${z:+z not null}
4730 Does umask print a leading 0 when umask is 3 digits?
4732 # on MiNT, the first umask call seems to fail
4734 # now, the test proper
4742 Tempory files used for here-docs in functions get trashed after
4743 the function is parsed (before it is executed)
4766 Command substitution breaks reading in while loop
4767 (test from <sjg@void.zen.oz.au>)
4769 (echo abcdef; echo; echo 123) |
4772 # the following line breaks it
4773 c=`echo $line | wc -c`
4783 Machines with broken times() (reported by <sjg@void.zen.oz.au>)
4784 time does not report correct real time
4787 expected-stderr-pattern: !/^\s*0\.0[\s\d]+real|^\s*real[\s]+0+\.0/
4791 set -e doesn't ignore exit codes for if/while/until/&&/||/!.
4794 if false; then echo hi ; fi
4797 while false; do echo hi; done
4804 Only posh and oksh(2013-07) say “hi” below; FreeBSD sh,
4805 GNU bash in POSIX mode, dash, ksh93, mksh don’t. All of
4806 them exit 0. The POSIX behaviour is needed by BSD make.
4809 echo `false; echo hi`
4817 This used to cause a core dump
4818 env-setup: !RANDOM=12!
4826 foo should be set to bar (should not be empty)
4836 Can't use command line assignments to assign readonly parameters.
4838 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
4839 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
4840 done >env; chmod +x env; PATH=.:$PATH
4843 foo=stuff env | grep '^foo'
4844 expected-exit: e != 0
4845 expected-stderr-pattern:
4850 Can subshells be prefixed by redirections (historical shells allow
4853 < /dev/null (sed 's/^/X/')
4857 Parameter assignments with [] recognised correctly
4875 Check that alias expansion works in command substitutions and
4888 Check that aliases are fully read.
4901 Check that (here doc) temp files are not left behind after an exec.
4904 TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
4906 sed 's/^/X /' << E_O_F
4913 echo=echo; [ -x /bin/echo ] && echo=/bin/echo
4914 exec $echo subtest-1 hi
4916 echo subtest-1 foo/*
4917 TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
4918 echo=echo; [ -x /bin/echo ] && echo=/bin/echo
4919 sed 's/^/X /' << E_O_F; exec $echo subtest-2 hi
4925 echo subtest-2 foo/*
4937 Check that unset params with attributes are reported by set, those
4938 sans attributes are not.
4954 Check that aliases do not use continuation prompt after trailing
4956 file-setup: file 644 "envf"
4959 env-setup: !ENV=./envf!
4963 alias foo='echo hi ; '
4975 Check that set allows both +o and -o options on same command line.
4978 set -o noglob +o allexport
4985 Check that globbing works in pipelined commands
4986 file-setup: file 644 "envf"
4988 file-setup: file 644 "abc"
4990 env-setup: !ENV=./envf!
4996 sed 's/^/X /' < ab* | sed 's/^/Y /'
5008 Check that getopts works in functions
5011 echo bfunc: enter "(args: $*; OPTIND=$OPTIND)"
5012 while getopts B oc; do
5015 echo bfunc: B option
5018 echo bfunc: odd option "($oc)"
5026 echo kfunc: enter "(args: $*; OPTIND=$OPTIND)"
5027 while getopts K oc; do
5030 echo kfunc: K option
5033 echo bfunc: odd option "($oc)"
5041 echo "line 1: OPTIND=$OPTIND"
5043 echo "line 2: ret=$?, optc=$optc, OPTIND=$OPTIND"
5045 echo "line 3: OPTIND=$OPTIND"
5047 echo "line 4: ret=$?, optc=$optc, OPTIND=$OPTIND"
5049 echo "line 5: OPTIND=$OPTIND"
5051 echo "line 6: ret=$?, optc=$optc, OPTIND=$OPTIND"
5056 echo "line 10: OPTIND=$OPTIND"
5058 echo "line 20: ret=$?, optc=$optc, OPTIND=$OPTIND"
5060 echo "line 30: OPTIND=$OPTIND"
5062 echo "line 40: ret=$?, optc=$optc, OPTIND=$OPTIND"
5064 echo "line 50: OPTIND=$OPTIND"
5066 echo "line 60: ret=$?, optc=$optc, OPTIND=$OPTIND"
5069 line 2: ret=0, optc=f, OPTIND=2
5070 bfunc: enter (args: -BBB blah; OPTIND=2)
5075 line 4: ret=0, optc=b, OPTIND=3
5076 kfunc: enter (args: -KKK blah; OPTIND=1)
5082 line 6: ret=0, optc=k, OPTIND=4
5085 line 20: ret=0, optc=f, OPTIND=2
5086 bfunc: enter (args: -BBB blah; OPTIND=2)
5091 line 40: ret=1, optc=?, OPTIND=2
5092 kfunc: enter (args: -KKK blah; OPTIND=1)
5098 line 60: ret=1, optc=?, OPTIND=2
5102 Check that ; is not required before the then in if (( ... )) then ...
5116 Check ${foo:%bar} is allowed (ksh88 allows it...)
5139 Check if typeset output is correct for
5140 uninitialised array elements.
5144 typeset -i | grep xxx | sed 's/^/ /'
5146 typeset | grep xxx | sed 's/^/ /'
5150 typeset -i | grep xxx | sed 's/^/ /'
5152 typeset | grep xxx | sed 's/^/ /'
5166 Check if trap exit is ok (exit not mistaken for signal name)
5175 Check if ${#array[*]} is calculated correctly.
5185 Check if default exit status is previous command
5191 ( (exit 103) ; exit)
5200 Check if EXIT trap is executed for sub shells.
5202 trap 'echo parent exit' EXIT
5204 (echo A; echo A last)
5206 (echo C; trap 'echo sub exit' EXIT; echo C last)
5221 Check if test -nt/-ot succeeds if second(first) file is missing.
5224 test a -nt b && echo nt OK || echo nt BAD
5225 test b -ot a && echo ot OK || echo ot BAD
5232 Check if typeset, export, and readonly work
5244 integer FNORD_E FNORD_F FNORD_G FNORD_H
5245 export FNORD_C FNORD_D FNORD_G FNORD_H
5246 readonly FNORD_B FNORD_D FNORD_F FNORD_H
5292 typeset -x -r FNORD_D
5294 typeset -i -r FNORD_F
5295 typeset -i -x FNORD_G
5296 typeset -i -x -r FNORD_H
5299 typeset -r FNORD_B=2
5300 typeset -x FNORD_C=3
5301 typeset -x -r FNORD_D=4
5302 typeset -i FNORD_E=5
5303 typeset -i -r FNORD_F=6
5304 typeset -i -x FNORD_G=7
5305 typeset -i -x -r FNORD_H=8
5323 Check that we can redefine functions calling time builtin
5335 check for a regression with sleep builtin and signal mask
5341 while read -p line; do :; done
5348 Check that quoting is sane
5356 while IFS= read -pr line; do
5357 if [[ $line = *space* ]]; then
5363 for line in "${lines[@]}"; do
5372 Ensure readonly is honoured for assignments and unset
5374 "$__progname" -c 'u=x; echo $? $u .' || echo aborted, $?
5376 "$__progname" -c 'readonly u; u=x; echo $? $u .' || echo aborted, $?
5378 "$__progname" -c 'u=x; readonly u; unset u; echo $? $u .' || echo aborted, $?
5385 expected-stderr-pattern:
5390 http://austingroupbugs.net/view.php?id=367 for export
5392 "$__progname" -c 'readonly foo; export foo=a; echo $?' || echo aborted, $?
5395 expected-stderr-pattern:
5400 Check that getopts works as intended, for readonly-2b to be valid
5402 "$__progname" -c 'set -- -a b; getopts a c; echo $? $c .; getopts a c; echo $? $c .' || echo aborted, $?
5409 http://austingroupbugs.net/view.php?id=367 for getopts
5411 "$__progname" -c 'readonly c; set -- -a b; getopts a c; echo $? $c .' || echo aborted, $?
5414 expected-stderr-pattern:
5419 http://austingroupbugs.net/view.php?id=367 for read
5421 echo x | "$__progname" -c 'read s; echo $? $s .' || echo aborted, $?
5422 echo y | "$__progname" -c 'readonly s; read s; echo $? $s .' || echo aborted, $?
5426 expected-stderr-pattern:
5431 Check that lone ampersand is a syntax error
5434 expected-exit: e != 0
5435 expected-stderr-pattern:
5438 name: xxx-quoted-newline-1
5440 Check that \<newline> works inside of ${}
5448 name: xxx-quoted-newline-2
5450 Check that \<newline> works at the start of a here document
5459 name: xxx-quoted-newline-3
5461 Check that \<newline> works at the end of a here document
5470 name: xxx-multi-assignment-cmd
5472 Check that assignments in a command affect subsequent assignments
5481 name: xxx-multi-assignment-posix-cmd
5483 Check that the behaviour for multiple assignments with a
5484 command name matches POSIX. See:
5485 http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925
5487 X=a Y=b; X=$Y Y=$X "$__progname" -c 'echo 1 $X $Y .'; echo 2 $X $Y .
5489 X=a Y=${X=b} Z=$X "$__progname" -c 'echo 3 $Z .'
5491 X=a Y=${X=b} Z=$X; echo 4 $Z .
5498 name: xxx-multi-assignment-posix-nocmd
5500 Check that the behaviour for multiple assignments with no
5501 command name matches POSIX (Debian #334182). See:
5502 http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925
5504 X=a Y=b; X=$Y Y=$X; echo 1 $X $Y .
5508 name: xxx-multi-assignment-posix-subassign
5510 Check that the behaviour for multiple assignments matches POSIX:
5511 - The assignment words shall be expanded in the current execution
5513 - The assignments happen in the temporary execution environment.
5516 Z=a Y=${X:=b} sh -c 'echo +$X+ +$Y+ +$Z+'
5518 # Now for the special case:
5520 X= Y=${X:=b} sh -c 'echo +$X+ +$Y+'
5528 name: xxx-exec-environment-1
5530 Check to see if exec sets it's environment correctly
5532 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
5533 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
5534 done >env; chmod +x env; PATH=.:$PATH
5536 expected-stdout-pattern:
5539 name: xxx-exec-environment-2
5541 Check to make sure exec doesn't change environment if a program
5544 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
5545 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
5546 done >env; chmod +x env; PATH=.:$PATH
5548 FOO=bar exec; env >bar2
5551 name: exec-function-environment-1
5553 Check assignments in function calls and whether they affect
5554 the current execution environment (ksh93, SUSv4)
5556 f() { a=2; }; g() { b=3; echo y$c-; }; a=1 f; b=2; c=1 g
5562 name: xxx-what-do-you-call-this-1
5568 name: xxx-prefix-strip-1
5575 name: xxx-prefix-strip-2
5583 name: xxx-variable-syntax-1
5586 expected-stderr-pattern:
5590 name: xxx-variable-syntax-2
5594 expected-stderr-pattern:
5598 name: xxx-variable-syntax-3
5602 expected-stderr-pattern:
5606 name: xxx-substitution-eval-order
5608 Check order of evaluation of expressions
5611 set -A A abc def GHI j G k
5612 echo ${A[x=(i+=1)]#${A[y=(i+=2)]}}
5618 name: xxx-set-option-1
5620 Check option parsing in set
5622 set -vsA foo -- A 1 3 2
5631 Check that exec exits for built-ins
5639 expected-stderr-pattern: /.*/
5643 Check the return value of while loops
5644 XXX need to do same for for/select/until loops
5647 while [ $i != xxx ] ; do
5649 if [ $i = xxx ] ; then
5657 while [ $i != xxx ] ; do
5659 if [ $i = xxx ] ; then
5667 while [ $i != xxx ] ; do
5679 Check that blank lines don't clear $?
5692 expected-stderr-pattern: /.*/
5696 Check that $? is preserved in subshells, includes, traps.
5705 echo 'echo include: $?' > foo
5709 trap 'echo trap: $?' ERR
5719 name: xxx-clean-chars-1
5721 Check MAGIC character is stuffed correctly
5727 name: xxx-param-subst-qmark-1
5729 Check suppresion of error message with null string. According to
5730 POSIX, it shouldn't print the error as 'word' isn't ommitted.
5731 ksh88/93, Solaris /bin/sh and /usr/xpg4/bin/sh all print the error,
5732 that's why the condition is reversed.
5740 #expected-stderr-pattern: !/not set/
5742 expected-stderr-pattern: /parameter null or not set/
5745 # fails due to weirdness of execv stuff
5746 category: !os:uwin-nt
5748 Check c flag is set.
5749 arguments: !-c!echo "[$-]"!
5750 expected-stdout-pattern: /^\[.*c.*\]$/
5752 name: tilde-expand-1
5754 Check tilde expansion after equal signs
5755 env-setup: !HOME=/sweet!
5757 echo ${A=a=}~ b=~ c=d~ ~
5760 echo ${A=a=}~ b=~ c=d~ ~
5762 a=/sweet b=/sweet c=d~ /sweet
5765 name: tilde-expand-2
5767 Check tilde expansion works
5768 env-setup: !HOME=/sweet!
5772 plus=$(print -r -- ~+)
5773 minus=$(print -r -- ~-)
5774 nix=$(print -r -- ~)
5775 [[ $plus = / ]]; echo one $? .
5776 [[ $minus = "$wd" ]]; echo two $? .
5777 [[ $nix = /sweet ]]; echo nix $? .
5785 Check some "exit on error" conditions
5787 print '#!'"$__progname"'\nexec "$1"' >env
5788 print '#!'"$__progname"'\nexit 1' >false
5792 env false && echo something
5802 Check some "exit on error" edge conditions (POSIXly)
5804 print '#!'"$__progname"'\nexec "$1"' >env
5805 print '#!'"$__progname"'\nexit 1' >false
5806 print '#!'"$__progname"'\nexit 0' >true
5811 env false && echo something
5823 pdksh regression which AT&T ksh does right
5824 TFM says: [set] -e | errexit
5825 Exit (after executing the ERR trap) ...
5827 trap 'echo EXIT' EXIT
5830 cd /XXXXX 2>/dev/null
5836 expected-exit: e != 0
5840 "set -e" test suite (POSIX)
5854 "set -e" test suite (POSIX)
5860 [ "$1" = "$E" ] && { shift ; continue 2 ; }
5877 "set -e" test suite (BSD make)
5881 print 'all:\n\t@echo eins\n\t@exit 42\n' >zd/a/Makefile
5882 print 'all:\n\t@echo zwei\n' >zd/b/Makefile
5885 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"
5891 Stop in WD/zd/a (line 2 of Makefile).
5895 "set -e" regression (LP#1104543)
5899 [ -x $PWD/nonexistant ] && $PWD/nonexistant
5910 "set -e" regression (Debian #700526)
5913 _db_cmd() { return $1; }
5914 db_input() { _db_cmd 30; }
5915 db_go() { _db_cmd 0; }
5922 SUSv4 says that the shell should exit with 126/127 in some situations
5926 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
5927 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
5929 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
5930 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
5932 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
5933 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
5944 Check eval vs substitution exit codes (ksh93 alike)
5956 eval "eval $(false)"
5959 eval 'eval '"$(false)"
5963 eval $(echo :; false)
5981 Check that "exit" with no arguments behaves SUSv4 conformant.
5983 trap 'echo hi; exit' EXIT
5991 Check that ERR and EXIT traps are run just like ksh93 does.
5992 GNU bash does not run ERtrap in ±e eval-undef but runs it
5993 twice (bug?) in +e eval-false, so does ksh93 (bug?), which
5994 also has a bug to continue execution (echoing "and out" and
5995 returning 0) in +e eval-undef.
5996 file-setup: file 644 "x"
5998 trap 'echo EXtrap' EXIT
5999 trap 'echo ERtrap' ERR
6004 file-setup: file 644 "xt"
6006 trap 'echo EXtrap' EXIT
6007 trap 'echo ERtrap' ERR
6012 file-setup: file 644 "xf"
6014 trap 'echo EXtrap' EXIT
6015 trap 'echo ERtrap' ERR
6017 echo 'and run false'
6020 file-setup: file 644 "xu"
6022 trap 'echo EXtrap' EXIT
6023 trap 'echo ERtrap' ERR
6025 echo 'and run ${v?}'
6035 -e 's/parameter not set/parameter null or not set/' \
6036 -e 's/[[]6]//' -e 's/: eval: line 1//' -e 's/: line 6//' \
6037 -e "s
\ 1^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]
\ 1PROG
\ 1"
6042 echo = eval-true $(<rc) .
6044 echo = eval-false $(<rc) .
6045 runtest x $xe '${v?}'
6046 echo = eval-undef $(<rc) .
6048 echo = noeval-true $(<rc) .
6050 echo = noeval-false $(<rc) .
6052 echo = noeval-undef $(<rc) .
6056 echo = eval-true $(<rc) .
6058 echo = eval-false $(<rc) .
6059 runtest x $xe '${v?}'
6060 echo = eval-undef $(<rc) .
6062 echo = noeval-true $(<rc) .
6064 echo = noeval-false $(<rc) .
6066 echo = noeval-undef $(<rc) .
6078 x: v: parameter null or not set
6091 xu: v: parameter null or not set
6105 x: v: parameter null or not set
6119 xu: v: parameter null or not set
6123 name: exit-trap-interactive
6125 Check that interactive shell doesn't exit via EXIT trap on syntax error
6130 echo 'After error 1'
6131 trap 'echo Exit trap' EXIT
6133 echo 'After error 2'
6134 trap 'echo Exit trap' EXIT
6141 expected-stderr-pattern:
6142 /syntax error: 'newline' unexpected/
6146 Check that test also can handle string1 < string2 etc.
6148 test 2005/10/08 '<' 2005/08/21 && echo ja || echo nein
6149 test 2005/08/21 \< 2005/10/08 && echo ja || echo nein
6150 test 2005/10/08 '>' 2005/08/21 && echo ja || echo nein
6151 test 2005/08/21 \> 2005/10/08 && echo ja || echo nein
6157 expected-stderr-pattern: !/unexpected op/
6159 name: test-precedence-1
6161 Check a weird precedence case (and POSIX echo)
6171 Test the test -o operator
6176 [[ -o $1 ]]; echo $?
6179 test -o $1 -o -o !$1; echo $?
6180 [ -o $1 -o -o !$1 ]; echo $?
6181 [[ -o $1 || -o !$1 ]]; echo $?
6182 test -o ?$1; echo $?
6184 echo 0y $(if_test utf8-mode) =
6185 echo 0n $(if_test utf8-hack) =
6186 echo 1= $(runtest utf8-hack) =
6187 echo 2= $(runtest !utf8-hack) =
6188 echo 3= $(runtest ?utf8-hack) =
6190 echo 1+ $(runtest utf8-mode) =
6191 echo 2+ $(runtest !utf8-mode) =
6192 echo 3+ $(runtest ?utf8-mode) =
6194 echo 1- $(runtest utf8-mode) =
6195 echo 2- $(runtest !utf8-mode) =
6196 echo 3- $(runtest ?utf8-mode) =
6197 echo = short flags =
6198 echo 0y $(if_test -U) =
6199 echo 0y $(if_test +U) =
6200 echo 0n $(if_test -_) =
6201 echo 0n $(if_test -U-) =
6202 echo 1= $(runtest -_) =
6203 echo 2= $(runtest !-_) =
6204 echo 3= $(runtest ?-_) =
6206 echo 1+ $(runtest -U) =
6207 echo 2+ $(runtest !-U) =
6208 echo 3+ $(runtest ?-U) =
6209 echo 1+ $(runtest +U) =
6210 echo 2+ $(runtest !+U) =
6211 echo 3+ $(runtest ?+U) =
6213 echo 1- $(runtest -U) =
6214 echo 2- $(runtest !-U) =
6215 echo 3- $(runtest ?-U) =
6216 echo 1- $(runtest +U) =
6217 echo 2- $(runtest !+U) =
6218 echo 3- $(runtest ?+U) =
6254 Check that ~/.mkshrc works correctly.
6255 Part 1: verify user environment is not read (internal)
6263 Check that ~/.mkshrc works correctly.
6264 Part 2: verify mkshrc is not read (non-interactive shells)
6265 file-setup: file 644 ".mkshrc"
6267 env-setup: !HOME=.!ENV=!
6275 Check that ~/.mkshrc works correctly.
6276 Part 2: verify mkshrc can be read (interactive shells)
6277 file-setup: file 644 ".mkshrc"
6281 env-setup: !HOME=.!ENV=!PS1=!
6286 expected-stderr-pattern:
6291 Check that ~/.mkshrc works correctly.
6292 Part 3: verify mkshrc can be turned off
6293 file-setup: file 644 ".mkshrc"
6295 env-setup: !HOME=.!ENV=nonexistant!
6303 Check that sh mode turns braceexpand off
6304 and that that works correctly
6308 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
6309 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
6317 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
6318 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
6321 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
6322 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
6338 Check that posix or sh mode is *not* automatically turned on
6341 ln -s "$__progname" ksh || cp "$__progname" ksh
6342 ln -s "$__progname" sh || cp "$__progname" sh
6343 ln -s "$__progname" ./-ksh || cp "$__progname" ./-ksh
6344 ln -s "$__progname" ./-sh || cp "$__progname" ./-sh
6345 for shell in {,-}{,k}sh; do
6346 print -- $shell $(./$shell +l -c \
6347 '[[ $(set +o) == *"-o "@(sh|posix)@(| *) ]] && echo sh || echo nosh')
6357 Check that posix or sh mode *is* automatically turned on
6360 ln -s "$__progname" ksh || cp "$__progname" ksh
6361 ln -s "$__progname" sh || cp "$__progname" sh
6362 ln -s "$__progname" ./-ksh || cp "$__progname" ./-ksh
6363 ln -s "$__progname" ./-sh || cp "$__progname" ./-sh
6364 for shell in {,-}{,k}sh; do
6365 print -- $shell $(./$shell +l -c \
6366 '[[ $(set +o) == *"-o "@(sh|posix)@(| *) ]] && echo sh || echo nosh')
6376 pdksh bug: last command of a pipeline is executed in a
6377 subshell - make sure it still is, scripts depend on it
6378 file-setup: file 644 "abcx"
6379 file-setup: file 644 "abcy"
6382 echo a | while read d; do
6402 check that co-processes work with TCOMs, TPIPEs and TPARENs
6405 "$__progname" -c 'i=100; echo hi |& while read -p line; do echo "$((i++)) $line"; done'
6406 "$__progname" -c 'i=200; echo hi | cat |& while read -p line; do echo "$((i++)) $line"; done'
6407 "$__progname" -c 'i=300; (echo hi | cat) |& while read -p line; do echo "$((i++)) $line"; done'
6415 Check that PIPESTATUS does what it's supposed to
6417 echo 1 $PIPESTATUS .
6418 echo 2 ${PIPESTATUS[0]} .
6419 echo 3 ${PIPESTATUS[1]} .
6420 (echo x; exit 12) | (cat; exit 23) | (cat; exit 42)
6421 echo 5 $? , $PIPESTATUS , ${PIPESTATUS[0]} , ${PIPESTATUS[1]} , ${PIPESTATUS[2]} , ${PIPESTATUS[3]} .
6422 echo 6 ${PIPESTATUS[0]} .
6423 set | fgrep PIPESTATUS
6424 echo 8 $(set | fgrep PIPESTATUS) .
6430 5 42 , 12 , 12 , 23 , 42 , .
6433 8 PIPESTATUS[0]=0 PIPESTATUS[1]=0 .
6437 Check that "set -o pipefail" does what it's supposed to
6439 echo 1 "$("$__progname" -c '(exit 12) | (exit 23) | (exit 42); echo $?')" .
6440 echo 2 "$("$__progname" -c '! (exit 12) | (exit 23) | (exit 42); echo $?')" .
6441 echo 3 "$("$__progname" -o pipefail -c '(exit 12) | (exit 23) | (exit 42); echo $?')" .
6442 echo 4 "$("$__progname" -o pipefail -c '! (exit 12) | (exit 23) | (exit 42); echo $?')" .
6443 echo 5 "$("$__progname" -c '(exit 23) | (exit 42) | :; echo $?')" .
6444 echo 6 "$("$__progname" -c '! (exit 23) | (exit 42) | :; echo $?')" .
6445 echo 7 "$("$__progname" -o pipefail -c '(exit 23) | (exit 42) | :; echo $?')" .
6446 echo 8 "$("$__progname" -o pipefail -c '! (exit 23) | (exit 42) | :; echo $?')" .
6457 name: persist-history-1
6459 Check if persistent history saving works
6460 category: !no-histfile
6463 env-setup: !ENV=./Env!HISTFILE=hist.file!
6464 file-setup: file 644 "Env"
6468 expected-stdout-pattern:
6470 expected-stderr-pattern:
6475 Check that global does what typeset is supposed to do
6479 global -Uui16 arrfoo[*]
6481 echo before ${arrfoo[0]} .
6483 echo after ${arrfoo[0]} .
6486 echo inside before ${arrbar[0]} .
6488 echo inside changed ${arrbar[0]} .
6489 global -Uui16 arrbar[*]
6490 echo inside typeset ${arrbar[0]} .
6492 echo inside changed ${arrbar[0]} .
6494 echo before ${arrbar[0]} .
6496 echo after ${arrbar[0]} .
6503 inside typeset 16#61 .
6504 inside changed 16#30 .
6507 name: typeset-padding-1
6509 Check if left/right justification works as per TFM
6511 typeset -L10 ln=0hall0
6512 typeset -R10 rn=0hall0
6513 typeset -ZL10 lz=0hall0
6514 typeset -ZR10 rz=0hall0
6515 typeset -Z10 rx=" hallo "
6516 echo "<$ln> <$rn> <$lz> <$rz> <$rx>"
6518 <0hall0 > < 0hall0> <hall0 > <00000hall0> <0000 hallo>
6520 name: typeset-padding-2
6522 Check if base-!10 integers are padded right
6524 typeset -Uui16 -L9 ln=16#1
6525 typeset -Uui16 -R9 rn=16#1
6526 typeset -Uui16 -Z9 zn=16#1
6530 echo "<$ln> <$rn> <$zn> <$ls> <$rs> <$zs>"
6532 <16#1 > < 16#1> <16#000001> <16#1 > < 16#1> <0000016#1>
6536 Check that the UTF-8 Byte Order Mark is ignored as the first
6537 multibyte character of the shell input (with -c, from standard
6538 input, as file, or as eval argument), but nowhere else
6539 # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
6540 category: !os:darwin
6543 print '#!/bin/sh\necho ohne' >foo/fnord
6544 print '#!/bin/sh\necho mit' >foo/fnord
6545 print 'fnord\nfnord\nfnord\nfnord' >foo/bar
6546 print eval \''fnord\nfnord\nfnord\nfnord'\' >foo/zoo
6547 set -A anzahl -- foo/*
6548 echo got ${#anzahl[*]} files
6550 export PATH=$(pwd)/foo:$PATH
6551 "$__progname" -c 'fnord'
6553 "$__progname" -c 'fnord; fnord; fnord; fnord'
6555 "$__progname" foo/bar
6557 "$__progname" <foo/bar
6559 "$__progname" foo/zoo
6561 "$__progname" -c 'echo : $(fnord)'
6591 Check that we can execute BOM-shebangs (failures not fatal)
6592 XXX if the OS can already execute them, we lose
6593 note: cygwin execve(2) doesn't return to us with ENOEXEC, we lose
6594 note: Ultrix perl5 t4 returns 65280 (exit-code 255) and no text
6596 category: !os:cygwin,!os:msys,!os:ultrix,!os:uwin-nt,!smksh
6597 env-setup: !FOO=BAR!
6599 print '#!'"$__progname"'\nprint "1 a=$ENV{FOO}";' >t1
6600 print '#!'"$__progname"'\nprint "2 a=$ENV{FOO}";' >t2
6601 print '#!'"$__perlname"'\nprint "3 a=$ENV{FOO}\n";' >t3
6602 print '#!'"$__perlname"'\nprint "4 a=$ENV{FOO}\n";' >t4
6609 1 a=/nonexistant{FOO}
6610 2 a=/nonexistant{FOO}
6613 expected-stderr-pattern:
6614 /(Unrecognized character .... ignored at \..t4 line 1)*/
6618 Check that the utf8-mode flag is not set at non-interactive startup
6620 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8!
6622 if [[ $- = *U* ]]; then
6632 Check that the utf8-mode flag is not set at non-interactive startup
6634 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.utf8!
6636 if [[ $- = *U* ]]; then
6646 Check that the utf8-mode flag is set at interactive startup.
6647 -DMKSH_ASSUME_UTF8=0 => expected failure, please ignore
6648 -DMKSH_ASSUME_UTF8=1 => not expected, please investigate
6649 -UMKSH_ASSUME_UTF8 => not expected, but if your OS is old,
6650 try passing HAVE_SETLOCALE_CTYPE=0 to Build.sh
6652 category: !os:hpux,!os:msys
6655 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8!
6657 if [[ $- = *U* ]]; then
6664 expected-stderr-pattern:
6669 Check that the utf8-mode flag is set at interactive startup
6670 Expected failure if -DMKSH_ASSUME_UTF8=0
6674 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.utf8!
6676 if [[ $- = *U* ]]; then
6683 expected-stderr-pattern:
6688 Ensure ±U on the command line is honoured
6689 (these two tests may pass falsely depending on CPPFLAGS)
6692 code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi'
6693 let i++; "$__progname" -U -c "$code"
6694 let i++; "$__progname" +U -c "$code"
6703 Ensure ±U on the command line is honoured, interactive shells
6707 code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi'
6708 let i++; "$__progname" -U -ic "$code"
6709 let i++; "$__progname" +U -ic "$code"
6718 Check if built-in shell aliases are okay
6719 category: !android,!arge
6724 autoload='typeset -fu'
6725 functions='typeset -f'
6728 integer='typeset -i'
6731 nameref='typeset -n'
6734 source='PATH=$PATH:. command .'
6736 suspend='kill -STOP $$'
6739 name: aliases-1-hartz4
6741 Check if built-in shell aliases are okay
6742 category: android,arge
6747 autoload='typeset -fu'
6748 functions='typeset -f'
6751 integer='typeset -i'
6754 nameref='typeset -n'
6757 source='PATH=$PATH:. command .'
6762 Check if “set -o sh” disables built-in aliases (except a few)
6769 integer='typeset -i'
6774 Check if running as sh disables built-in aliases (except a few)
6778 ./sh -c 'alias; typeset -f'
6781 integer='typeset -i'
6786 Check if “set -o sh” does not influence built-in aliases
6787 category: !android,!arge
6793 autoload='typeset -fu'
6794 functions='typeset -f'
6797 integer='typeset -i'
6800 nameref='typeset -n'
6803 source='PATH=$PATH:. command .'
6805 suspend='kill -STOP $$'
6810 Check if running as sh does not influence built-in aliases
6811 category: !android,!arge
6814 ./sh -c 'alias; typeset -f'
6817 autoload='typeset -fu'
6818 functions='typeset -f'
6821 integer='typeset -i'
6824 nameref='typeset -n'
6827 source='PATH=$PATH:. command .'
6829 suspend='kill -STOP $$'
6832 name: aliases-2b-hartz4
6834 Check if “set -o sh” does not influence built-in aliases
6835 category: android,arge
6841 autoload='typeset -fu'
6842 functions='typeset -f'
6845 integer='typeset -i'
6848 nameref='typeset -n'
6851 source='PATH=$PATH:. command .'
6854 name: aliases-3b-hartz4
6856 Check if running as sh does not influence built-in aliases
6857 category: android,arge
6860 ./sh -c 'alias; typeset -f'
6863 autoload='typeset -fu'
6864 functions='typeset -f'
6867 integer='typeset -i'
6870 nameref='typeset -n'
6873 source='PATH=$PATH:. command .'
6876 name: aliases-cmdline
6878 Check that aliases work from the command line (Debian #517009)
6879 Note that due to the nature of the lexing process, defining
6880 aliases in COMSUBs then immediately using them, and things
6881 like 'alias foo=bar && foo', still fail.
6883 "$__progname" -c $'alias a="echo OK"\na'
6887 name: aliases-funcdef-1
6889 Check if POSIX functions take precedences over aliases
6891 alias foo='echo makro'
6899 name: aliases-funcdef-2
6901 Check if POSIX functions take precedences over aliases
6903 alias foo='echo makro'
6911 name: aliases-funcdef-3
6913 Check if aliases take precedences over Korn functions
6915 alias foo='echo makro'
6923 name: aliases-funcdef-4
6925 Functions should only take over if actually being defined
6936 Check if Korn Shell arrays work as expected
6939 set -A foo -- a \$v "$v" '$v' b
6940 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
6946 Check if bash-style arrays work as expected
6949 foo=(a \$v "$v" '$v' b)
6950 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
6956 Check if bash-style arrays work as expected, with newlines
6958 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "$x|"; done' >pfp
6960 test -n "$ZSH_VERSION" && setopt KSH_ARRAYS
6966 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
6971 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
6976 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
6978 7|a|bc|d|$v|e f|$v|g|
6979 7|a|bc|d|$v|e f|$v|g|
6980 6|abc\|d|$v|e f|$v|g||
6984 Check if array bounds are uint32_t
6991 echo ${foo[4294967295]} g ${foo[*]}
6998 Check if Korn Shell arrays with specified indices work as expected
7001 set -A foo -- [1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b
7002 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|"
7008 Check if bash-style arrays with specified indices work as expected
7011 foo=([1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b)
7012 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|"
7013 x=([128]=foo bar baz)
7023 Check if we can get the array keys (indices) for indexed arrays,
7029 echo -n "$((i++))<$x>"
7040 echo a $(of ${foo[*]}) = $(of ${bar[*]}) a
7041 echo b $(of "${foo[*]}") = $(of "${bar[*]}") b
7042 echo c $(of ${foo[@]}) = $(of ${bar[@]}) c
7043 echo d $(of "${foo[@]}") = $(of "${bar[@]}") d
7044 echo e $(of ${!foo[*]}) = $(of ${!bar[*]}) e
7045 echo f $(of "${!foo[*]}") = $(of "${!bar[*]}") f
7046 echo g $(of ${!foo[@]}) = $(of ${!bar[@]}) g
7047 echo h $(of "${!foo[@]}") = $(of "${!bar[@]}") h
7055 a 0<zwei>1<eins>2<drei> = a
7056 b 0<zwei eins drei> = 0<> b
7057 c 0<zwei>1<eins>2<drei> = c
7058 d 0<zwei>1<eins>2<drei> = d
7066 Check if we can get the array keys (indices) for indexed arrays,
7067 Korn shell style, in some corner cases
7070 echo !arz[0]: ${!arz[0]}
7071 echo !arz[1]: ${!arz[1]}
7074 echo !arz[0]: ${!arz[0]}
7075 echo !arz[1]: ${!arz[1]}
7078 echo !arz[0]: ${!arz[0]}
7079 echo !arz[1]: ${!arz[1]}
7093 Check some behavioural rules for arrays.
7131 typeset -Z3 aa ab ac ad ae af ag
7176 Check that we can concatenate arrays
7178 unset foo; foo=(bar); foo+=(baz); echo 1 ${!foo[*]} : ${foo[*]} .
7179 unset foo; foo=(foo bar); foo+=(baz); echo 2 ${!foo[*]} : ${foo[*]} .
7180 unset foo; foo=([2]=foo [0]=bar); foo+=(baz [5]=quux); echo 3 ${!foo[*]} : ${foo[*]} .
7183 2 0 1 2 : foo bar baz .
7184 3 0 2 3 5 : bar foo baz quux .
7188 Check that we can concatenate parameters too
7190 unset foo; foo=bar; foo+=baz; echo 1 $foo .
7191 unset foo; typeset -i16 foo=10; foo+=20; echo 2 $foo .
7196 name: arrassign-basic
7198 Check basic whitespace conserving properties of wdarrassign
7206 c+=("$(echo "c d")")
7208 echo ".a:${a[0]}.${a[1]}.${a[2]}.${a[3]}:"
7209 echo ".b:${b[0]}.${b[1]}.${b[2]}.${b[3]}:"
7210 echo ".c:${c[0]}.${c[1]}.${c[2]}.${c[3]}:"
7211 echo ".d:${d[0]}.${d[1]}.${d[2]}.${d[3]}:"
7218 name: arrassign-fnc-none
7220 Check locality of array access inside a function
7224 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7227 if [[ -n $BASH_VERSION ]]; then
7233 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7237 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7239 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7241 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7242 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7244 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7246 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7259 name: arrassign-fnc-local
7261 Check locality of array access inside a function
7262 with the bash/mksh/ksh93 local/typeset keyword
7263 (note: ksh93 has no local; typeset works only in FKSH)
7268 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7271 if [[ -n $BASH_VERSION ]]; then
7278 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7282 if [[ -n $BASH_VERSION ]]; then
7288 echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
7293 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7295 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7297 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7298 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7300 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7302 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7303 echo ".f0r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
7305 echo ".f1r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
7307 echo ".f2r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
7325 name: arrassign-fnc-global
7327 Check locality of array access inside a function
7328 with the mksh-specific global keyword
7333 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7339 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7345 echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
7350 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7352 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7354 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:"
7355 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7357 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7359 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:"
7360 echo ".f0r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
7362 echo ".f1r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
7364 echo ".f2r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:"
7382 name: strassign-fnc-none
7384 Check locality of string access inside a function
7419 name: strassign-fnc-local
7421 Check locality of string access inside a function
7422 with the bash/mksh/ksh93 local/typeset keyword
7423 (note: ksh93 has no local; typeset works only in FKSH)
7477 name: strassign-fnc-global
7479 Check locality of string access inside a function
7480 with the mksh-specific global keyword
7534 name: varexpand-substr-1
7536 Check if bash-style substring expansion works
7537 when using positive numerics
7540 typeset -i y=123456789
7541 typeset -i 16 z=123456789 # 16#75bcd15
7542 echo a t${x:2:2} ${y:2:3} ${z:2:3} a
7543 echo b ${x::3} ${y::3} ${z::3} b
7544 echo c ${x:2:} ${y:2:} ${z:2:} c
7545 echo d ${x:2} ${y:2} ${z:2} d
7546 echo e ${x:2:6} ${y:2:6} ${z:2:7} e
7547 echo f ${x:2:7} ${y:2:7} ${z:2:8} f
7548 echo g ${x:2:8} ${y:2:8} ${z:2:9} g
7553 d cdefghi 3456789 #75bcd15 d
7554 e cdefgh 345678 #75bcd1 e
7555 f cdefghi 3456789 #75bcd15 f
7556 g cdefghi 3456789 #75bcd15 g
7558 name: varexpand-substr-2
7560 Check if bash-style substring expansion works
7561 when using negative numerics or expressions
7564 typeset -i y=123456789
7565 typeset -i 16 z=123456789 # 16#75bcd15
7567 echo a ${x:$n:3} ${y:$n:3} ${z:$n:3} a
7568 echo b ${x:(n):3} ${y:(n):3} ${z:(n):3} b
7569 echo c ${x:(-2):1} ${y:(-2):1} ${z:(-2):1} c
7570 echo d t${x: n:2} ${y: n:3} ${z: n:3} d
7577 name: varexpand-substr-3
7579 Check that some things that work in bash fail.
7580 This is by design. And that some things fail in both.
7582 export x=abcdefghi n=2
7583 "$__progname" -c 'echo v${x:(n)}x'
7584 "$__progname" -c 'echo w${x: n}x'
7585 "$__progname" -c 'echo x${x:n}x'
7586 "$__progname" -c 'echo y${x:}x'
7587 "$__progname" -c 'echo z${x}x'
7588 "$__progname" -c 'x=abcdef;y=123;echo ${x:${y:2:1}:2}' >/dev/null 2>&1; echo $?
7594 expected-stderr-pattern:
7595 /x:n.*bad substitution.*\n.*bad substitution/
7597 name: varexpand-substr-4
7599 Check corner cases for substring expansion
7603 echo a ${x:(y == 1 ? 2 : 3):4} a
7607 name: varexpand-substr-5A
7609 Check that substring expansions work on characters
7613 echo a ${x::1} ${x: -1} a
7614 echo b ${x::3} ${x: -3} b
7615 echo c ${x:1:2} ${x: -3:2} c
7623 name: varexpand-substr-5W
7625 Check that substring expansions work on characters
7629 echo a ${x::1} ${x: -1} a
7630 echo b ${x::2} ${x: -2} b
7631 echo c ${x:1:1} ${x: -2:1} c
7639 name: varexpand-substr-6
7641 Check that string substitution works correctly
7646 echo a ${baz: foo: bar}
7647 echo b ${baz: foo: $bar}
7648 echo c ${baz: $foo: bar}
7649 echo d ${baz: $foo: $bar}
7656 name: varexpand-special-hash
7658 Check special ${var@x} expansion for x=hash
7664 print ${foo@#} ${bar@#} ${baz@#} .
7665 print ${foo@#123} ${bar@#456} ${baz@#789} .
7666 print ${foo@#bla} ${bar@#bar} ${baz@#OPTIND} .
7668 D50219A0 20E5DB5B 00000000 .
7669 554A1C76 004A212E CB209562 .
7670 6B21CF91 20E5DB5B 124EA49D .
7672 name: varexpand-special-quote
7674 Check special ${var@Q} expansion for quoted strings
7681 print -r -- "<i=$i j=$j k=$k>"
7682 s="u=${i@Q} v=${j@Q} w=${k@Q}"
7683 print -r -- "s=\"$s\""
7689 s="u=x v='a b' w=$'c\nd\240e\u20ACf'"
7692 typeset w=$'c\nd\240e\u20ACf'
7694 name: varexpand-null-1
7696 Ensure empty strings expand emptily
7699 print z ${a#?} ${b%?} w
7700 print v ${a=} ${b/c/d} u
7706 name: varexpand-null-2
7708 Ensure empty strings, when quoted, are expanded as empty strings
7710 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "<$x> "; done' >pfs
7712 ./pfs 1 "${a}" 2 "${a#?}" + "${b%?}" 3 "${a=}" + "${b/c/d}"
7715 <1> <> <2> <> <+> <> <3> <> <+> <> .
7717 name: print-funny-chars
7719 Check print builtin's capability to output designated characters
7721 print '<\0144\0344\xDB\u00DB\u20AC\uDB\x40>'
7727 Check print builtin's \c escape
7729 print '\ca'; print b
7735 Check that CR+LF is not collapsed into LF as some MSYS shells wrongly do
7737 echo '#!'"$__progname" >foo
7739 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'
7744 ./foo | while IFS= read -r line; do
7745 print -r -- "{$line}"
7748 [220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT
\r
7749 220->> Bitte keine Werbung einwerfen! <<
\r\r
7750 220 Who do you wanna pretend to be today?
\r]
7751 {220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT
\r}
7752 {220->> Bitte keine Werbung einwerfen! <<
\r\r}
7753 {220 Who do you wanna pretend to be today?
\r}
7755 name: print-nul-chars
7757 Check handling of NUL characters for print and COMSUB
7760 print $(($(print '<\0>' | wc -c))) $(($(print "$x" | wc -c))) \
7762 expected-stdout-pattern:
7767 Check backslash expansion by the print builtin
7769 print '\ \!\"\#\$\%\&'\\\''\(\)\*\+\,\-\.\/\0\1\2\3\4\5\6\7\8' \
7770 '\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T' \
7771 '\U\V\W\X\Y\Z\[\\\]\^\_\`\a\b \d\e\f\g\h\i\j\k\l\m\n\o\p' \
7772 '\q\r\s\t\u\v\w\x\y\z\{\|\}\~' '\u20acd' '\U20acd' '\x123' \
7773 '\0x' '\0123' '\01234' | {
7774 # integer-base-one-3As
7775 typeset -Uui16 -Z11 pos=0
7776 typeset -Uui16 -Z5 hv=2147483647
7780 while IFS= read -r line; do
7782 while [[ -n $line ]]; do
7784 if (( (pos & 15) == 0 )); then
7785 (( pos )) && print "$dasc|"
7786 print -n "${pos#16#} "
7789 print -n "${hv#16#} "
7790 if (( (hv < 32) || (hv > 126) )); then
7793 dasc=$dasc${line::1}
7795 (( (pos++ & 15) == 7 )) && print -n -- '- '
7799 while (( pos & 15 )); do
7801 (( (pos++ & 15) == 7 )) && print -n -- '- '
7803 (( hv == 2147483647 )) || print "$dasc|"
7806 00000000 5C 20 5C 21 5C 22 5C 23 - 5C 24 5C 25 5C 26 5C 27 |\ \!\"\#\$\%\&\'|
7807 00000010 5C 28 5C 29 5C 2A 5C 2B - 5C 2C 5C 2D 5C 2E 5C 2F |\(\)\*\+\,\-\.\/|
7808 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|
7809 00000030 20 5C 39 5C 3A 5C 3B 5C - 3C 5C 3D 5C 3E 5C 3F 5C | \9\:\;\<\=\>\?\|
7810 00000040 40 5C 41 5C 42 5C 43 5C - 44 1B 5C 46 5C 47 5C 48 |@\A\B\C\D.\F\G\H|
7811 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|
7812 00000060 5C 51 5C 52 5C 53 5C 54 - 20 5C 56 5C 57 5C 58 5C |\Q\R\S\T \V\W\X\|
7813 00000070 59 5C 5A 5C 5B 5C 5C 5D - 5C 5E 5C 5F 5C 60 07 08 |Y\Z\[\]\^\_\`..|
7814 00000080 20 20 5C 64 1B 0C 5C 67 - 5C 68 5C 69 5C 6A 5C 6B | \d..\g\h\i\j\k|
7815 00000090 5C 6C 5C 6D 0A 5C 6F 5C - 70 20 5C 71 0D 5C 73 09 |\l\m.\o\p \q.\s.|
7816 000000A0 0B 5C 77 5C 79 5C 7A 5C - 7B 5C 7C 5C 7D 5C 7E 20 |.\w\y\z\{\|\}\~ |
7817 000000B0 E2 82 AC 64 20 EF BF BD - 20 12 33 20 78 20 53 20 |...d ... .3 x S |
7818 000000C0 53 34 0A - |S4.|
7820 name: dollar-doublequoted-strings
7822 Check that a $ preceding "…" is ignored
7824 echo $"Localise me!"
7829 I do not take a $V for a V!
7834 I do not take a $V for a V!
7836 name: dollar-quoted-strings
7838 Check backslash expansion by $'…' strings
7840 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
7842 ./pfn $'\ \!\"\#\$\%\&\'\(\)\*\+\,\-\.\/ \1\2\3\4\5\6' \
7843 $'a\0b' $'a\01b' $'\7\8\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I' \
7844 $'\J\K\L\M\N\O\P\Q\R\S\T\U1\V\W\X\Y\Z\[\\\]\^\_\`\a\b\d\e' \
7845 $'\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u1\v\w\x1\y\z\{\|\}\~ $x' \
7846 $'\u20acd' $'\U20acd' $'\x123' $'fn\x0rd' $'\0234' $'\234' \
7847 $'\2345' $'\ca' $'\c!' $'\c?' $'\c€' $'a\
7849 # integer-base-one-3As
7850 typeset -Uui16 -Z11 pos=0
7851 typeset -Uui16 -Z5 hv=2147483647
7855 while IFS= read -r line; do
7857 while [[ -n $line ]]; do
7859 if (( (pos & 15) == 0 )); then
7860 (( pos )) && print "$dasc|"
7861 print -n "${pos#16#} "
7864 print -n "${hv#16#} "
7865 if (( (hv < 32) || (hv > 126) )); then
7868 dasc=$dasc${line::1}
7870 (( (pos++ & 15) == 7 )) && print -n -- '- '
7874 while (( pos & 15 )); do
7876 (( (pos++ & 15) == 7 )) && print -n -- '- '
7878 (( hv == 2147483647 )) || print "$dasc|"
7881 00000000 20 21 22 23 24 25 26 27 - 28 29 2A 2B 2C 2D 2E 2F | !"#$%&'()*+,-./|
7882 00000010 20 01 02 03 04 05 06 0A - 61 0A 61 01 62 0A 07 38 | .......a.a.b..8|
7883 00000020 39 3A 3B 3C 3D 3E 3F 40 - 41 42 43 44 1B 46 47 48 |9:;<=>?@ABCD.FGH|
7884 00000030 49 0A 4A 4B 4C 4D 4E 4F - 50 51 52 53 54 01 56 57 |I.JKLMNOPQRST.VW|
7885 00000040 58 59 5A 5B 5C 5D 5E 5F - 60 07 08 64 1B 0A 0C 67 |XYZ[\]^_`..d...g|
7886 00000050 68 69 6A 6B 6C 6D 0A 6F - 70 71 0D 73 09 01 0B 77 |hijklm.opq.s...w|
7887 00000060 01 79 7A 7B 7C 7D 7E 20 - 24 78 0A E2 82 AC 64 0A |.yz{|}~ $x....d.|
7888 00000070 EF BF BD 0A C4 A3 0A 66 - 6E 0A 13 34 0A 9C 0A 9C |.......fn..4....|
7889 00000080 35 0A 01 0A 01 0A 7F 0A - 02 82 AC 0A 61 0A 62 0A |5...........a.b.|
7891 name: dollar-quotes-in-heredocs-strings
7893 They are, however, not parsed in here documents, here strings
7894 (outside of string delimiters) or regular strings, but in
7895 parameter substitutions.
7898 dollar = strchr(s, '$'); /* ' */
7904 cat <<<"dollar = strchr(s, '$'); /* ' */"
7905 cat <<<'dollar = strchr(s, '\''$'\''); /* '\'' */'
7906 x="dollar = strchr(s, '$'); /* ' */"
7909 unset nl; print -r -- "x${nl:=$'\n'}y"
7915 # probably never reached for here strings?
7917 cat <<<"4 foo\\\"bar"
7919 # old scripts use this (e.g. ncurses)
7921 # make sure this works, outside of quotes
7924 dollar = strchr(s, '$'); /* ' */
7927 dollar = strchr(s, '$'); /* ' */
7928 dollar = strchr(s, '$'); /* ' */
7929 dollar = strchr(s, '$'); /* ' */
7941 name: dot-needs-argument
7943 check Debian #415167 solution: '.' without arguments should fail
7946 "$__progname" -c source
7947 expected-exit: e != 0
7948 expected-stderr-pattern:
7949 /\.: missing argument.*\n.*\.: missing argument/
7951 name: alias-function-no-conflict
7953 make aliases not conflict with functions
7954 note: for ksh-like functions, the order of preference is
7955 different; bash outputs baz instead of bar in line 2 below
7957 alias foo='echo bar'
7961 alias korn='echo bar'
7968 foo 2>/dev/null || echo rab
7974 name: bash-function-parens
7976 ensure the keyword function is ignored when preceding
7977 POSIX style function declarations (bashism)
7980 echo '#!'"$__progname"
7982 echo ' echo "bar='\''$0'\'\"
7986 mk 'function foo' >f-korn
7988 mk 'function foo ()' >f-bash
7989 mk 'function stop ()' stop >f-stop
7990 print '#!'"$__progname"'\nprint -r -- "${0%/f-argh}"' >f-argh
7993 x="korn: $(./f-korn)"; echo "${x/@("$u")/.}"
7994 x="dash: $(./f-dash)"; echo "${x/@("$u")/.}"
7995 x="bash: $(./f-bash)"; echo "${x/@("$u")/.}"
7996 x="stop: $(./f-stop)"; echo "${x/@("$u")/.}"
7999 dash: bar='./f-dash'
8000 bash: bar='./f-bash'
8001 stop: bar='./f-stop'
8003 name: integer-base-one-1
8005 check if the use of fake integer base 1 works
8008 typeset -Uui16 i0=1#ï i1=1#â
\82¬
8010 typeset -i1 o1a=0x263A
8011 typeset -Uui1 o0b=0x7E
8012 typeset -Uui1 o1b=0xFDD0
8013 integer px=0xCAFE 'p0=1# ' p1=1#… pl=1#f
8014 echo "in <$i0> <$i1>"
8015 echo "out <${o0a#1#}|${o0b#1#}> <${o1a#1#}|${o1b#1#}>"
8017 echo "pass <$px> <$p0> <$p1> <$pl> <${i0#1#}|${i1#1#}>"
8018 typeset -Uui16 tv1=1#~ tv2=1#
\7f tv3=1#
\80 tv4=1#
\81 tv5=1#À tv6=1#Á tv7=1#Â tv8=1#Â
\80
8019 echo "specX <${tv1#16#}> <${tv2#16#}> <${tv3#16#}> <${tv4#16#}> <${tv5#16#}> <${tv6#16#}> <${tv7#16#}> <${tv8#16#}>"
8020 typeset -i1 tv1 tv2 tv3 tv4 tv5 tv6 tv7 tv8
8021 echo "specW <${tv1#1#}> <${tv2#1#}> <${tv3#1#}> <${tv4#1#}> <${tv5#1#}> <${tv6#1#}> <${tv7#1#}> <${tv8#1#}>"
8022 typeset -i1 xs1=0xEF7F xs2=0xEF80 xs3=0xFDD0
8023 echo "specU <${xs1#1#}> <${xs2#1#}> <${xs3#1#}>"
8025 in <16#EFEF> <16#20AC>
8027 pass <16#cafe> <1# > <1#â
\80¦> <1#f> <ï|â
\82¬>
8028 specX <7E> <7F> <EF80> <EF81> <EFC0> <EFC1> <A0> <80>
8029 specW <~> <
\7f> <
\80> <
\81> <À> <Á> <Â > <Â
\80>
8030 specU <> <
\80> <ï·
\90>
8032 name: integer-base-one-2a
8034 check if the use of fake integer base 1 stops at correct characters
8039 expected-stderr-pattern:
8040 /1#foo: unexpected 'oo'/
8041 expected-exit: e != 0
8043 name: integer-base-one-2b
8045 check if the use of fake integer base 1 stops at correct characters
8050 expected-stderr-pattern:
8051 /1#À
\80: unexpected '
\80'/
8052 expected-exit: e != 0
8054 name: integer-base-one-2c1
8056 check if the use of fake integer base 1 stops at correct characters
8064 name: integer-base-one-2c2
8066 check if the use of fake integer base 1 stops at correct characters
8071 expected-stderr-pattern:
8072 /1#â
\80¦: unexpected '
\80'/
8073 expected-exit: e != 0
8075 name: integer-base-one-2d1
8077 check if the use of fake integer base 1 handles octets okay
8081 echo /$x/ # invalid utf-8
8085 name: integer-base-one-2d2
8087 check if the use of fake integer base 1 handles octets
8091 echo /$x/ # invalid 2-byte
8095 name: integer-base-one-2d3
8097 check if the use of fake integer base 1 handles octets
8101 echo /$x/ # invalid 2-byte
8105 name: integer-base-one-2d4
8107 check if the use of fake integer base 1 stops at invalid input
8110 typeset -i16 x=1#ï¿À
8111 echo /$x/ # invalid 3-byte
8112 expected-stderr-pattern:
8113 /1#ï¿À: unexpected '¿'/
8114 expected-exit: e != 0
8116 name: integer-base-one-2d5
8118 check if the use of fake integer base 1 stops at invalid input
8121 typeset -i16 x=1#À
\80
8122 echo /$x/ # non-minimalistic
8123 expected-stderr-pattern:
8124 /1#À
\80: unexpected '
\80'/
8125 expected-exit: e != 0
8127 name: integer-base-one-2d6
8129 check if the use of fake integer base 1 stops at invalid input
8132 typeset -i16 x=1#à
\80\80
8133 echo /$x/ # non-minimalistic
8134 expected-stderr-pattern:
8135 /1#à
\80\80: unexpected '
\80'/
8136 expected-exit: e != 0
8138 name: integer-base-one-3As
8140 some sample code for hexdumping
8141 not NUL safe; input lines must be NL terminated
8144 print 'Hello, World!\\\nこんにちは!'
8145 typeset -Uui16 i=0x100
8146 # change that to 0xFF once we can handle embedded
8147 # NUL characters in strings / here documents
8148 while (( i++ < 0x1FF )); do
8149 print -n "\x${i#16#1}"
8153 # integer-base-one-3As
8154 typeset -Uui16 -Z11 pos=0
8155 typeset -Uui16 -Z5 hv=2147483647
8159 while IFS= read -r line; do
8161 while [[ -n $line ]]; do
8163 if (( (pos & 15) == 0 )); then
8164 (( pos )) && print "$dasc|"
8165 print -n "${pos#16#} "
8168 print -n "${hv#16#} "
8169 if (( (hv < 32) || (hv > 126) )); then
8172 dasc=$dasc${line::1}
8174 (( (pos++ & 15) == 7 )) && print -n -- '- '
8178 while (( pos & 15 )); do
8180 (( (pos++ & 15) == 7 )) && print -n -- '- '
8182 (( hv == 2147483647 )) || print "$dasc|"
8185 00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..|
8186 00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................|
8187 00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................|
8188 00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................|
8189 00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.|
8190 00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>|
8191 00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN|
8192 00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^|
8193 00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn|
8194 00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~|
8195 000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................|
8196 000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................|
8197 000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................|
8198 000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................|
8199 000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................|
8200 000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................|
8201 00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................|
8202 00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................|
8203 00000120 FF 7A 0A - |.z.|
8205 name: integer-base-one-3Ws
8207 some sample code for hexdumping Unicode
8208 not NUL safe; input lines must be NL terminated
8212 print 'Hello, World!\\\nこんにちは!'
8213 typeset -Uui16 i=0x100
8214 # change that to 0xFF once we can handle embedded
8215 # NUL characters in strings / here documents
8216 while (( i++ < 0x1FF )); do
8217 print -n "\u${i#16#1}"
8220 print \\xff # invalid utf-8
8221 print \\xc2 # invalid 2-byte
8222 print \\xef\\xbf\\xc0 # invalid 3-byte
8223 print \\xc0\\x80 # non-minimalistic
8224 print \\xe0\\x80\\x80 # non-minimalistic
8225 print '�' # end of range
8226 print '\0z' # embedded NUL
8228 # integer-base-one-3Ws
8229 typeset -Uui16 -Z11 pos=0
8230 typeset -Uui16 -Z7 hv
8235 while IFS= read -r line; do
8238 while (( lpos < ${#line} )); do
8239 wc=1#${line:(lpos++):1}
8240 if (( (wc < 32) || \
8241 ((wc > 126) && (wc < 160)) )); then
8243 elif (( (wc & 0xFF80) == 0xEF80 )); then
8248 if (( (pos & 7) == 7 )); then
8251 elif (( (pos & 7) == 0 )); then
8252 (( pos )) && print "$dasc|"
8253 print -n "${pos#16#} "
8257 print -n "${hv#16#} "
8258 (( (pos++ & 7) == 3 )) && \
8263 while (( pos & 7 )); do
8265 (( (pos++ & 7) == 3 )) && print -n -- '- '
8267 (( hv == 2147483647 )) || print "$dasc|"
8270 00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W|
8271 00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.こ|
8272 00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |んにちは!...|
8273 00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........|
8274 00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........|
8275 00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........|
8276 00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"|
8277 00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*|
8278 00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012|
8279 00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:|
8280 00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB|
8281 00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ|
8282 00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR|
8283 00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ|
8284 00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab|
8285 00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij|
8286 00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr|
8287 00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz|
8288 00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....|
8289 00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........|
8290 000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........|
8291 000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........|
8292 000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |..... ¡¢|
8293 000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA |£¤¥¦§¨©ª|
8294 000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 |«¬®¯°±²|
8295 000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA |³´µ¶·¸¹º|
8296 000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 |»¼½¾¿ÀÁÂ|
8297 000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA |ÃÄÅÆÇÈÉÊ|
8298 000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 |ËÌÍÎÏÐÑÒ|
8299 000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA |ÓÔÕÖ×ØÙÚ|
8300 000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 |ÛÜÝÞßàáâ|
8301 000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA |ãäåæçèéê|
8302 00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 |ëìíîïðñò|
8303 00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA |óôõö÷øùú|
8304 00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |ûüýþÿ.�.|
8305 00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |�.���.��|
8306 00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |.���.���|
8307 00000128 EFBE EFEF EFBF EFBF - 000A 007A 000A |����.z.|
8309 name: integer-base-one-3Ar
8311 some sample code for hexdumping; NUL and binary safe
8314 print 'Hello, World!\\\nこんにちは!'
8315 typeset -Uui16 i=0x100
8316 # change that to 0xFF once we can handle embedded
8317 # NUL characters in strings / here documents
8318 while (( i++ < 0x1FF )); do
8319 print -n "\x${i#16#1}"
8323 # integer-base-one-3Ar
8324 typeset -Uui16 -Z11 pos=0
8325 typeset -Uui16 -Z5 hv=2147483647
8327 if read -arN -1 line; then
8330 while (( i < ${#line[*]} )); do
8332 if (( (pos & 15) == 0 )); then
8333 (( pos )) && print "$dasc|"
8334 print -n "${pos#16#} "
8337 print -n "${hv#16#} "
8338 if (( (hv < 32) || (hv > 126) )); then
8341 dasc=$dasc${line[i-1]#1#}
8343 (( (pos++ & 15) == 7 )) && print -n -- '- '
8346 while (( pos & 15 )); do
8348 (( (pos++ & 15) == 7 )) && print -n -- '- '
8350 (( hv == 2147483647 )) || print "$dasc|"
8353 00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..|
8354 00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................|
8355 00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................|
8356 00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................|
8357 00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.|
8358 00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>|
8359 00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN|
8360 00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^|
8361 00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn|
8362 00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~|
8363 000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................|
8364 000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................|
8365 000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................|
8366 000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................|
8367 000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................|
8368 000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................|
8369 00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................|
8370 00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................|
8371 00000120 FF 00 7A 0A - |..z.|
8373 name: integer-base-one-3Wr
8375 some sample code for hexdumping Unicode; NUL and binary safe
8379 print 'Hello, World!\\\nこんにちは!'
8380 typeset -Uui16 i=0x100
8381 # change that to 0xFF once we can handle embedded
8382 # NUL characters in strings / here documents
8383 while (( i++ < 0x1FF )); do
8384 print -n "\u${i#16#1}"
8387 print \\xff # invalid utf-8
8388 print \\xc2 # invalid 2-byte
8389 print \\xef\\xbf\\xc0 # invalid 3-byte
8390 print \\xc0\\x80 # non-minimalistic
8391 print \\xe0\\x80\\x80 # non-minimalistic
8392 print '�' # end of range
8393 print '\0z' # embedded NUL
8395 # integer-base-one-3Wr
8396 typeset -Uui16 -Z11 pos=0
8397 typeset -Uui16 -Z7 hv=2147483647
8399 if read -arN -1 line; then
8402 while (( i < ${#line[*]} )); do
8404 if (( (hv < 32) || \
8405 ((hv > 126) && (hv < 160)) )); then
8407 elif (( (hv & 0xFF80) == 0xEF80 )); then
8412 if (( (pos & 7) == 7 )); then
8415 elif (( (pos & 7) == 0 )); then
8416 (( pos )) && print "$dasc|"
8417 print -n "${pos#16#} "
8420 print -n "${hv#16#} "
8421 (( (pos++ & 7) == 3 )) && \
8426 while (( pos & 7 )); do
8428 (( (pos++ & 7) == 3 )) && print -n -- '- '
8430 (( hv == 2147483647 )) || print "$dasc|"
8433 00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W|
8434 00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.こ|
8435 00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |んにちは!...|
8436 00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........|
8437 00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........|
8438 00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........|
8439 00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"|
8440 00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*|
8441 00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012|
8442 00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:|
8443 00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB|
8444 00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ|
8445 00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR|
8446 00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ|
8447 00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab|
8448 00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij|
8449 00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr|
8450 00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz|
8451 00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....|
8452 00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........|
8453 000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........|
8454 000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........|
8455 000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |..... ¡¢|
8456 000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA |£¤¥¦§¨©ª|
8457 000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 |«¬®¯°±²|
8458 000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA |³´µ¶·¸¹º|
8459 000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 |»¼½¾¿ÀÁÂ|
8460 000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA |ÃÄÅÆÇÈÉÊ|
8461 000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 |ËÌÍÎÏÐÑÒ|
8462 000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA |ÓÔÕÖ×ØÙÚ|
8463 000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 |ÛÜÝÞßàáâ|
8464 000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA |ãäåæçèéê|
8465 00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 |ëìíîïðñò|
8466 00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA |óôõö÷øùú|
8467 00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |ûüýþÿ.�.|
8468 00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |�.���.��|
8469 00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |.���.���|
8470 00000128 EFBE EFEF EFBF EFBF - 000A 0000 007A 000A |����..z.|
8472 name: integer-base-one-4
8474 Check if ksh93-style base-one integers work
8479 (echo 2f $(('aa'))) 2>&1 | sed "s/^[^']*'/2p '/"
8487 2p 'aa': multi-character character constant
8493 name: integer-base-one-5A
8495 Check to see that we’re NUL and Unicode safe
8498 print 'a\0b\xfdz' >x
8504 16#61 16#0 16#62 16#FD 16#7A .
8506 name: integer-base-one-5W
8508 Check to see that we’re NUL and Unicode safe
8517 16#61 16#0 16#62 16#20AC 16#63 .
8521 Check if we can use a specific syntax idiom for ulimit
8522 category: !os:syllable
8524 if ! x=$(ulimit -d) || [[ $x = unknown ]]; then
8525 #echo expected to fail on this OS
8528 ulimit -dS $x && echo okay
8535 Check some of the most basic invariants of I/O redirection
8540 print -u2 e$((i++)).
8565 Check if GNU bash-like I/O redirection works
8566 Part 1: this is also supported by GNU bash
8567 category: shell:legacy-no
8586 Check if GNU bash-like I/O redirection works
8587 Part 2: this is *not* supported by GNU bash
8588 category: shell:legacy-no
8607 Check if GNU bash-like I/O redirection works
8608 Part 2: this is *not* supported by GNU bash
8609 category: shell:legacy-no
8628 Check if GNU bash-like I/O redirection works
8629 Part 2: this is supported by GNU bash 4 only
8630 category: shell:legacy-no
8652 Check if GNU bash-like I/O redirection fails correctly
8653 Part 1: this is also supported by GNU bash
8654 category: shell:legacy-no
8670 expected-stderr-pattern: /.*: can't (create|overwrite) .*/
8674 Check if GNU bash-like I/O redirection fails correctly
8675 Part 2: this is *not* supported by GNU bash
8676 category: shell:legacy-no
8697 Check if GNU bash-like I/O redirection works
8698 Part 4: this is also supported by GNU bash,
8699 but failed in some mksh versions
8700 category: shell:legacy-no
8709 [[ -e bar ]] && threeout "$bf" &>foo
8722 name: bashiop-5-normal
8724 Check if GNU bash-like I/O redirection is only supported
8725 in !POSIX !sh mode as it breaks existing scripts' syntax
8726 category: shell:legacy-no
8728 :>x; echo 1 "$("$__progname" -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
8729 :>x; echo 2 "$("$__progname" -o posix -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
8730 :>x; echo 3 "$("$__progname" -o sh -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
8736 name: bashiop-5-legacy
8738 Check if GNU bash-like I/O redirection is not parsed
8739 in lksh as it breaks existing scripts' syntax
8740 category: shell:legacy-yes
8742 :>x; echo 1 "$("$__progname" -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
8743 :>x; echo 2 "$("$__progname" -o posix -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
8744 :>x; echo 3 "$("$__progname" -o sh -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" .
8752 Check for support of more than 9 file descriptors
8755 read -u10 foo 10<<< bar
8762 Check for support of more than 9 file descriptors
8775 $OpenBSD: eval.sh,v 1.1 2010/03/24 08:29:44 fgsch Exp $
8778 for n in ${a#*=}; do echo 1hu ${n} .; done
8779 for n in "${a#*=}"; do echo 1hq ${n} .; done
8780 for n in ${a##*=}; do echo 2hu ${n} .; done
8781 for n in "${a##*=}"; do echo 2hq ${n} .; done
8782 for n in ${a%=*}; do echo 1pu ${n} .; done
8783 for n in "${a%=*}"; do echo 1pq ${n} .; done
8784 for n in ${a%%=*}; do echo 2pu ${n} .; done
8785 for n in "${a%%=*}"; do echo 2pq ${n} .; done
8792 name: oksh-and-list-error-1
8794 Test exit status of rightmost element in 2 element && list in -e mode
8797 echo "should not print"
8799 expected-exit: e != 0
8801 name: oksh-and-list-error-2
8803 Test exit status of rightmost element in 3 element && list in -e mode
8805 true && true && false
8806 echo "should not print"
8808 expected-exit: e != 0
8810 name: oksh-or-list-error-1
8812 Test exit status of || list in -e mode
8815 echo "should not print"
8817 expected-exit: e != 0
8819 name: oksh-longline-crash
8821 This used to cause a core dump
8824 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"
8825 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"
8826 for deplib in $deplibs; do
8829 new_libs="$deplib $new_libs"
8832 case " $specialdeplibs " in
8834 new_libs="$deplib $new_libs";;
8840 name: oksh-seterror-1
8842 The -e flag should be ignored when executing a compound list
8843 followed by an if statement.
8845 if true; then false && false; fi
8848 expected-exit: e == 0
8850 name: oksh-seterror-2
8852 The -e flag should be ignored when executing a compound list
8853 followed by an if statement.
8855 if true; then if true; then false && false; fi; fi
8858 expected-exit: e == 0
8860 name: oksh-seterror-3
8862 The -e flag should be ignored when executing a compound list
8863 followed by an elif statement.
8865 if true; then :; elif true; then false && false; fi
8867 expected-exit: e == 0
8869 name: oksh-seterror-4
8871 The -e flag should be ignored when executing a pipeline
8880 expected-exit: e == 0
8882 name: oksh-seterror-5
8884 The -e flag should be ignored when executing a pipeline
8890 expected-exit: e == 0
8892 name: oksh-seterror-6
8894 When trapping ERR and EXIT, both traps should run in -e mode
8895 when an error occurs.
8897 trap 'echo EXIT' EXIT
8904 expected-exit: e != 0
8909 name: oksh-seterror-7
8911 The -e flag within a command substitution should be honored
8913 echo $( set -e; false; echo foo )
8918 name: oksh-input-comsub
8920 A command substitution using input redirection should exit with
8921 failure if the input file does not exist.
8923 var=$(< non-existent)
8924 expected-exit: e != 0
8925 expected-stderr-pattern: /non-existent/
8927 name: oksh-empty-for-list
8929 A for list which expands to zero items should not execute the body.
8931 set foo bar baz ; for out in ; do echo $out ; done
8933 name: oksh-varfunction-mod1
8935 $OpenBSD: varfunction.sh,v 1.1 2003/12/15 05:28:40 otto Exp $
8938 where f is a ksh style function, should not set FOO in the current
8939 env. If f is a Bourne style function, FOO should be set. Furthermore,
8940 the function should receive a correct value of FOO. However, differing
8941 from oksh, setting FOO in the function itself must change the value in
8942 setting FOO in the function itself should not change the value in
8944 Inspired by PR 2450.
8946 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \
8947 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \
8948 done >env; chmod +x env; PATH=.:$PATH
8950 if [ x$FOO != xbar ]; then
8955 if [ "x$x" != "xFOO=bar" ]; then
8963 if [ x$FOO != xbar ]; then
8968 if [ "x$x" != "xFOO=bar" ]; then
8976 if [ $? != 0 ]; then
8979 if [ x$FOO != x ]; then
8983 if [ $? != 0 ]; then
8986 if [ x$FOO != xfoo ]; then
8991 if [ $? != 0 ]; then
8994 if [ x$FOO != xbarbar ]; then
8998 if [ $? != 0 ]; then
9001 if [ x$FOO != xfoo ]; then
9007 Verify that file descriptors > 2 are private for Korn shells
9008 AT&T ksh93 does this still, which means we must keep it as well
9009 category: shell:legacy-no
9010 file-setup: file 644 "test.sh"
9014 "$__progname" test.sh
9015 expected-exit: e != 0
9016 expected-stderr-pattern:
9017 /bad file descriptor/
9021 Verify that file descriptors > 2 are not private for POSIX shells
9022 See Debian Bug #154540, Closes: #499139
9023 file-setup: file 644 "test.sh"
9026 test -n "$POSH_VERSION" || set -o sh
9028 "$__progname" test.sh
9034 Verify that file descriptors > 2 are not private for LEGACY KSH
9035 category: shell:legacy-yes
9036 file-setup: file 644 "test.sh"
9040 "$__progname" test.sh
9046 COMSUB are now parsed recursively, so this works
9047 see also regression-6: matching parenthesēs bug
9048 Fails on: pdksh bash2 bash3 zsh
9049 Passes on: bash4 ksh93 mksh(20110313+)
9051 echo 1 $(case 1 in (1) echo yes;; (2) echo no;; esac) .
9052 echo 2 $(case 1 in 1) echo yes;; 2) echo no;; esac) .
9053 TEST=1234; echo 3 ${TEST: $(case 1 in (1) echo 1;; (*) echo 2;; esac)} .
9054 TEST=5678; echo 4 ${TEST: $(case 1 in 1) echo 1;; *) echo 2;; esac)} .
9055 a=($(case 1 in (1) echo 1;; (*) echo 2;; esac)); echo 5 ${a[0]} .
9056 a=($(case 1 in 1) echo 1;; *) echo 2;; esac)); echo 6 ${a[0]} .
9067 COMSUB are now parsed recursively, so this works
9068 Fails on: pdksh bash2 bash3 bash4 zsh
9069 Passes on: ksh93 mksh(20110313+)
9071 echo 1 $(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10)) .
9072 echo 2 $(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20)) .
9073 (( a = $(case 1 in (1) echo 1;; (*) echo 2;; esac) )); echo 3 $a .
9074 (( a = $(case 1 in 1) echo 1;; *) echo 2;; esac) )); echo 4 $a .
9075 a=($(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10))); echo 5 ${a[0]} .
9076 a=($(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20))); echo 6 ${a[0]} .
9087 RedHat BZ#496791 – another case of missing recursion
9088 in parsing COMSUB expressions
9089 Fails on: pdksh bash2 bash3¹ bash4¹ zsh
9090 Passes on: ksh93 mksh(20110305+)
9091 ① bash[34] seem to choke on comment ending with backslash-newline
9093 # a comment with " ' \
9096 # a comment with " ' \
9104 Extended test for COMSUB explaining why a recursive parser
9105 is a must (a non-recursive parser cannot pass all three of
9106 these test cases, especially the ‘#’ is difficult)
9108 print '#!'"$__progname"'\necho 1234' >id; chmod +x id; PATH=.:$PATH
9109 echo $(typeset -i10 x=16#20; echo $x)
9110 echo $(typeset -Uui16 x=16#$(id -u)
9113 typeset -Uui16 a=36#foo; c=2
9114 typeset -Uui16 b=36 #foo; d=2
9123 Check the tree dump functions for !MKSH_SMALL functionality
9126 x() { case $1 in u) echo x ;;& *) echo $1 ;; esac; }
9142 Check COMSUB works with aliases (does not expand them twice)
9144 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn
9155 ./pfn "$(echo foo )"
9158 name: comsub-torture
9160 Check the tree dump functions work correctly
9162 if [[ -z $__progname ]]; then echo >&2 call me with __progname; exit 1; fi
9163 while IFS= read -r line; do
9164 if [[ $line = '#1' ]]; then
9167 elif [[ $line = EOFN* ]]; then
9168 fbody=$fbody$'\n'$line
9170 elif [[ $line != '#'* ]]; then
9171 fbody=$fbody$'\n\t'$line
9174 if (( lastf )); then
9175 x="inline_${nextf}() {"$fbody$'\n}\n'
9177 print -r -- "${x}typeset -f inline_$nextf" | "$__progname"
9178 x="function comsub_$nextf { x=\$("$fbody$'\n); }\n'
9180 print -r -- "${x}typeset -f comsub_$nextf" | "$__progname"
9181 x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n'
9183 print -r -- "${x}typeset -f reread_$nextf" | "$__progname"
9191 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
9193 (echo $foo | tr -dc 0-9; echo)
9195 cmd && echo ja || echo nein
9197 select file in *; do echo "<$file>" ; break ; done
9199 time for i in {1,2,3} ; do echo $i ; done
9201 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
9202 #TIF_TBANG_TDBRACKET_TELIF
9203 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
9205 i=1; while (( i < 10 )); do echo $i; let ++i; done
9207 i=10; until (( !--i )) ; do echo $i; done
9210 #TFUNCT_TBRACE_TASYNC
9211 function korn { echo eins; echo zwei ; }
9212 bourne () { logger * & }
9215 #IOWRITE_IOCLOB_IOHERE_noIOSKIP
9219 #IOWRITE_noIOCLOB_IOHERE_IOSKIP
9224 sh 1<>/dev/console 0<&1 2>&1
9225 #COMSUB_EXPRSUB_FUNSUB_VALSUB
9226 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
9227 #QCHAR_OQUOTE_CQUOTE
9228 echo fo\ob\"a\`r\'b\$az
9229 echo "fo\ob\"a\`r\'b\$az"
9230 echo 'fo\ob\"a\`r'\''b\$az'
9231 #OSUBST_CSUBST_OPAT_SPAT_CPAT
9232 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
9235 note there must be no space between EOFN and )
9239 note the space between EOFN and ) is actually part of the here document marker
9242 x=$(sysctl -n kern.version | sed 1q)
9243 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
9244 ed -s /etc/motd 2>&1 <<-EOF
9251 EOF)" = @(?) ]] && rm -f /etc/motd
9252 if [[ ! -s /etc/motd ]]; then
9253 install -c -o root -g wheel -m 664 /dev/null /etc/motd
9254 print -- "$x\n" >/etc/motd
9264 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
9267 vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4"
9269 function comsub_TCOM { x=$(
9270 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
9272 function comsub_TCOM {
9273 x=$(vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" )
9275 function reread_TCOM { x=$((
9276 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
9278 function reread_TCOM {
9279 x=$(( vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" ) | tr u x )
9281 inline_TPAREN_TPIPE_TLIST() {
9282 (echo $foo | tr -dc 0-9; echo)
9284 inline_TPAREN_TPIPE_TLIST() {
9285 ( echo $foo | tr -dc 0-9
9288 function comsub_TPAREN_TPIPE_TLIST { x=$(
9289 (echo $foo | tr -dc 0-9; echo)
9291 function comsub_TPAREN_TPIPE_TLIST {
9292 x=$(( echo $foo | tr -dc 0-9 ; echo ) )
9294 function reread_TPAREN_TPIPE_TLIST { x=$((
9295 (echo $foo | tr -dc 0-9; echo)
9297 function reread_TPAREN_TPIPE_TLIST {
9298 x=$(( ( echo $foo | tr -dc 0-9 ; echo ) ) | tr u x )
9301 cmd && echo ja || echo nein
9304 cmd && echo ja || echo nein
9306 function comsub_TAND_TOR { x=$(
9307 cmd && echo ja || echo nein
9309 function comsub_TAND_TOR {
9310 x=$(cmd && echo ja || echo nein )
9312 function reread_TAND_TOR { x=$((
9313 cmd && echo ja || echo nein
9315 function reread_TAND_TOR {
9316 x=$(( cmd && echo ja || echo nein ) | tr u x )
9319 select file in *; do echo "<$file>" ; break ; done
9328 function comsub_TSELECT { x=$(
9329 select file in *; do echo "<$file>" ; break ; done
9331 function comsub_TSELECT {
9332 x=$(select file in * ; do echo "<$file>" ; break ; done )
9334 function reread_TSELECT { x=$((
9335 select file in *; do echo "<$file>" ; break ; done
9337 function reread_TSELECT {
9338 x=$(( select file in * ; do echo "<$file>" ; break ; done ) | tr u x )
9340 inline_TFOR_TTIME() {
9341 time for i in {1,2,3} ; do echo $i ; done
9343 inline_TFOR_TTIME() {
9344 time for i in {1,2,3}
9349 function comsub_TFOR_TTIME { x=$(
9350 time for i in {1,2,3} ; do echo $i ; done
9352 function comsub_TFOR_TTIME {
9353 x=$(time for i in {1,2,3} ; do echo $i ; done )
9355 function reread_TFOR_TTIME { x=$((
9356 time for i in {1,2,3} ; do echo $i ; done
9358 function reread_TFOR_TTIME {
9359 x=$(( time for i in {1,2,3} ; do echo $i ; done ) | tr u x )
9362 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
9373 echo kann net bis drei zählen
9377 function comsub_TCASE { x=$(
9378 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
9380 function comsub_TCASE {
9381 x=$(case $foo in (1) echo eins ;& (2) echo zwei ;| (*) echo kann net bis drei zählen ;; esac )
9383 function reread_TCASE { x=$((
9384 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
9386 function reread_TCASE {
9387 x=$(( case $foo in (1) echo eins ;& (2) echo zwei ;| (*) echo kann net bis drei zählen ;; esac ) | tr u x )
9389 inline_TIF_TBANG_TDBRACKET_TELIF() {
9390 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
9392 inline_TIF_TBANG_TDBRACKET_TELIF() {
9403 function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$(
9404 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
9406 function comsub_TIF_TBANG_TDBRACKET_TELIF {
9407 x=$(if ! [[ 1 = 1 ]] ; then echo eins ; elif [[ 1 = 2 ]] ; then echo zwei ; else echo drei ; fi )
9409 function reread_TIF_TBANG_TDBRACKET_TELIF { x=$((
9410 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
9412 function reread_TIF_TBANG_TDBRACKET_TELIF {
9413 x=$(( if ! [[ 1 = 1 ]] ; then echo eins ; elif [[ 1 = 2 ]] ; then echo zwei ; else echo drei ; fi ) | tr u x )
9416 i=1; while (( i < 10 )); do echo $i; let ++i; done
9420 while let] " i < 10 "
9426 function comsub_TWHILE { x=$(
9427 i=1; while (( i < 10 )); do echo $i; let ++i; done
9429 function comsub_TWHILE {
9430 x=$(i=1 ; while let] " i < 10 " ; do echo $i ; let ++i ; done )
9432 function reread_TWHILE { x=$((
9433 i=1; while (( i < 10 )); do echo $i; let ++i; done
9435 function reread_TWHILE {
9436 x=$(( i=1 ; while let] " i < 10 " ; do echo $i ; let ++i ; done ) | tr u x )
9439 i=10; until (( !--i )) ; do echo $i; done
9448 function comsub_TUNTIL { x=$(
9449 i=10; until (( !--i )) ; do echo $i; done
9451 function comsub_TUNTIL {
9452 x=$(i=10 ; until let] " !--i " ; do echo $i ; done )
9454 function reread_TUNTIL { x=$((
9455 i=10; until (( !--i )) ; do echo $i; done
9457 function reread_TUNTIL {
9458 x=$(( i=10 ; until let] " !--i " ; do echo $i ; done ) | tr u x )
9467 function comsub_TCOPROC { x=$(
9470 function comsub_TCOPROC {
9473 function reread_TCOPROC { x=$((
9476 function reread_TCOPROC {
9477 x=$(( cat * |& ls ) | tr u x )
9479 inline_TFUNCT_TBRACE_TASYNC() {
9480 function korn { echo eins; echo zwei ; }
9481 bourne () { logger * & }
9483 inline_TFUNCT_TBRACE_TASYNC() {
9492 function comsub_TFUNCT_TBRACE_TASYNC { x=$(
9493 function korn { echo eins; echo zwei ; }
9494 bourne () { logger * & }
9496 function comsub_TFUNCT_TBRACE_TASYNC {
9497 x=$(function korn { echo eins ; echo zwei ; } ; bourne() { logger * & } )
9499 function reread_TFUNCT_TBRACE_TASYNC { x=$((
9500 function korn { echo eins; echo zwei ; }
9501 bourne () { logger * & }
9503 function reread_TFUNCT_TBRACE_TASYNC {
9504 x=$(( function korn { echo eins ; echo zwei ; } ; bourne() { logger * & } ) | tr u x )
9506 inline_IOREAD_IOCAT() {
9509 inline_IOREAD_IOCAT() {
9512 function comsub_IOREAD_IOCAT { x=$(
9515 function comsub_IOREAD_IOCAT {
9516 x=$(tr x u <foo >>bar )
9518 function reread_IOREAD_IOCAT { x=$((
9521 function reread_IOREAD_IOCAT {
9522 x=$(( tr x u <foo >>bar ) | tr u x )
9524 inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
9529 inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
9535 function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$(
9540 function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
9541 x=$(cat >|bar <<"EOFN"
9546 function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$((
9551 function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
9552 x=$(( cat >|bar <<"EOFN"
9557 inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
9562 inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
9568 function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$(
9573 function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
9574 x=$(cat >bar <<-EOFI
9579 function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$((
9584 function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
9585 x=$(( cat >bar <<-EOFI
9590 inline_IORDWR_IODUP() {
9591 sh 1<>/dev/console 0<&1 2>&1
9593 inline_IORDWR_IODUP() {
9594 sh 1<>/dev/console <&1 2>&1
9596 function comsub_IORDWR_IODUP { x=$(
9597 sh 1<>/dev/console 0<&1 2>&1
9599 function comsub_IORDWR_IODUP {
9600 x=$(sh 1<>/dev/console <&1 2>&1 )
9602 function reread_IORDWR_IODUP { x=$((
9603 sh 1<>/dev/console 0<&1 2>&1
9605 function reread_IORDWR_IODUP {
9606 x=$(( sh 1<>/dev/console <&1 2>&1 ) | tr u x )
9608 inline_COMSUB_EXPRSUB_FUNSUB_VALSUB() {
9609 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
9611 inline_COMSUB_EXPRSUB_FUNSUB_VALSUB() {
9612 echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;}
9614 function comsub_COMSUB_EXPRSUB_FUNSUB_VALSUB { x=$(
9615 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
9617 function comsub_COMSUB_EXPRSUB_FUNSUB_VALSUB {
9618 x=$(echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;} )
9620 function reread_COMSUB_EXPRSUB_FUNSUB_VALSUB { x=$((
9621 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;}
9623 function reread_COMSUB_EXPRSUB_FUNSUB_VALSUB {
9624 x=$(( echo $(true ) $((1+ 2)) ${ : ;} ${|REPLY=x ;} ) | tr u x )
9626 inline_QCHAR_OQUOTE_CQUOTE() {
9627 echo fo\ob\"a\`r\'b\$az
9628 echo "fo\ob\"a\`r\'b\$az"
9629 echo 'fo\ob\"a\`r'\''b\$az'
9631 inline_QCHAR_OQUOTE_CQUOTE() {
9632 echo fo\ob\"a\`r\'b\$az
9633 echo "fo\ob\"a\`r\'b\$az"
9634 echo "fo\\ob\\\"a\\\`r"\'"b\\\$az"
9636 function comsub_QCHAR_OQUOTE_CQUOTE { x=$(
9637 echo fo\ob\"a\`r\'b\$az
9638 echo "fo\ob\"a\`r\'b\$az"
9639 echo 'fo\ob\"a\`r'\''b\$az'
9641 function comsub_QCHAR_OQUOTE_CQUOTE {
9642 x=$(echo fo\ob\"a\`r\'b\$az ; echo "fo\ob\"a\`r\'b\$az" ; echo "fo\\ob\\\"a\\\`r"\'"b\\\$az" )
9644 function reread_QCHAR_OQUOTE_CQUOTE { x=$((
9645 echo fo\ob\"a\`r\'b\$az
9646 echo "fo\ob\"a\`r\'b\$az"
9647 echo 'fo\ob\"a\`r'\''b\$az'
9649 function reread_QCHAR_OQUOTE_CQUOTE {
9650 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 )
9652 inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() {
9653 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
9655 inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() {
9656 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
9658 function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$(
9659 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
9661 function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT {
9662 x=$([[ ${foo#bl\(u\)b} = @(bar|baz) ]] )
9664 function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$((
9665 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
9667 function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT {
9668 x=$(( [[ ${foo#bl\(u\)b} = @(bar|baz) ]] ) | tr u x )
9670 inline_heredoc_closed() {
9672 note there must be no space between EOFN and )
9675 inline_heredoc_closed() {
9677 note there must be no space between EOFN and )
9682 function comsub_heredoc_closed { x=$(
9684 note there must be no space between EOFN and )
9687 function comsub_heredoc_closed {
9689 note there must be no space between EOFN and )
9693 function reread_heredoc_closed { x=$((
9695 note there must be no space between EOFN and )
9698 function reread_heredoc_closed {
9699 x=$(( x=$(cat <<EOFN
9700 note there must be no space between EOFN and )
9702 ) ; echo $x ) | tr u x )
9704 inline_heredoc_space() {
9706 note the space between EOFN and ) is actually part of the here document marker
9709 inline_heredoc_space() {
9711 note the space between EOFN and ) is actually part of the here document marker
9716 function comsub_heredoc_space { x=$(
9718 note the space between EOFN and ) is actually part of the here document marker
9721 function comsub_heredoc_space {
9723 note the space between EOFN and ) is actually part of the here document marker
9727 function reread_heredoc_space { x=$((
9729 note the space between EOFN and ) is actually part of the here document marker
9732 function reread_heredoc_space {
9733 x=$(( x=$(cat <<EOFN\
9734 note the space between EOFN and ) is actually part of the here document marker
9736 ) ; echo $x ) | tr u x )
9738 inline_patch_motd() {
9739 x=$(sysctl -n kern.version | sed 1q)
9740 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
9741 ed -s /etc/motd 2>&1 <<-EOF
9748 EOF)" = @(?) ]] && rm -f /etc/motd
9749 if [[ ! -s /etc/motd ]]; then
9750 install -c -o root -g wheel -m 664 /dev/null /etc/motd
9751 print -- "$x\n" >/etc/motd
9754 inline_patch_motd() {
9755 x=$(sysctl -n kern.version | sed 1q )
9756 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
9764 )" = @(?) ]] && rm -f /etc/motd
9765 if [[ ! -s /etc/motd ]]
9767 install -c -o root -g wheel -m 664 /dev/null /etc/motd
9768 print -- "$x\n" >/etc/motd
9771 function comsub_patch_motd { x=$(
9772 x=$(sysctl -n kern.version | sed 1q)
9773 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
9774 ed -s /etc/motd 2>&1 <<-EOF
9781 EOF)" = @(?) ]] && rm -f /etc/motd
9782 if [[ ! -s /etc/motd ]]; then
9783 install -c -o root -g wheel -m 664 /dev/null /etc/motd
9784 print -- "$x\n" >/etc/motd
9787 function comsub_patch_motd {
9788 x=$(x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
9796 )" = @(?) ]] && 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 )
9798 function reread_patch_motd { x=$((
9799 x=$(sysctl -n kern.version | sed 1q)
9800 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
9801 ed -s /etc/motd 2>&1 <<-EOF
9808 EOF)" = @(?) ]] && rm -f /etc/motd
9809 if [[ ! -s /etc/motd ]]; then
9810 install -c -o root -g wheel -m 664 /dev/null /etc/motd
9811 print -- "$x\n" >/etc/motd
9814 function reread_patch_motd {
9815 x=$(( x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
9823 )" = @(?) ]] && 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 )
9825 inline_wdarrassign() {
9830 inline_wdarrassign() {
9838 function comsub_wdarrassign { x=$(
9843 function comsub_wdarrassign {
9844 x=$(case x in (x) a+=b ; set -A c+ -- d e ;; esac )
9846 function reread_wdarrassign { x=$((
9851 function reread_wdarrassign {
9852 x=$(( case x in (x) a+=b ; set -A c+ -- d e ;; esac ) | tr u x )
9855 name: comsub-torture-io
9857 Check the tree dump functions work correctly with I/O redirection
9859 if [[ -z $__progname ]]; then echo >&2 call me with __progname; exit 1; fi
9860 while IFS= read -r line; do
9861 if [[ $line = '#1' ]]; then
9864 elif [[ $line = EOFN* ]]; then
9865 fbody=$fbody$'\n'$line
9867 elif [[ $line != '#'* ]]; then
9868 fbody=$fbody$'\n\t'$line
9871 if (( lastf )); then
9872 x="inline_${nextf}() {"$fbody$'\n}\n'
9874 print -r -- "${x}typeset -f inline_$nextf" | "$__progname"
9875 x="function comsub_$nextf { x=\$("$fbody$'\n); }\n'
9877 print -r -- "${x}typeset -f comsub_$nextf" | "$__progname"
9878 x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n'
9880 print -r -- "${x}typeset -f reread_$nextf" | "$__progname"
9888 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
9890 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
9892 cmd >&3 && >&3 echo ja || echo >&3 nein
9894 select file in *; do echo "<$file>" ; break >&3 ; done >&3
9896 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
9898 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
9899 #TIF_TBANG_TDBRACKET_TELIF
9900 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
9902 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
9904 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
9907 #TFUNCT_TBRACE_TASYNC
9908 function korn { echo eins; echo >&3 zwei ; }
9909 bourne () { logger * >&3 & }
9911 echo $(true >&3) $((1+ 2))
9916 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
9919 vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" >&3
9921 function comsub_TCOM { x=$(
9922 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
9924 function comsub_TCOM {
9925 x=$(vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" >&3 )
9927 function reread_TCOM { x=$((
9928 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3
9930 function reread_TCOM {
9931 x=$(( vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" >&3 ) | tr u x )
9933 inline_TPAREN_TPIPE_TLIST() {
9934 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
9936 inline_TPAREN_TPIPE_TLIST() {
9937 ( echo $foo | tr -dc 0-9 >&3
9940 function comsub_TPAREN_TPIPE_TLIST { x=$(
9941 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
9943 function comsub_TPAREN_TPIPE_TLIST {
9944 x=$(( echo $foo | tr -dc 0-9 >&3 ; echo >&3 ) >&3 )
9946 function reread_TPAREN_TPIPE_TLIST { x=$((
9947 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3
9949 function reread_TPAREN_TPIPE_TLIST {
9950 x=$(( ( echo $foo | tr -dc 0-9 >&3 ; echo >&3 ) >&3 ) | tr u x )
9953 cmd >&3 && >&3 echo ja || echo >&3 nein
9956 cmd >&3 && echo ja >&3 || echo nein >&3
9958 function comsub_TAND_TOR { x=$(
9959 cmd >&3 && >&3 echo ja || echo >&3 nein
9961 function comsub_TAND_TOR {
9962 x=$(cmd >&3 && echo ja >&3 || echo nein >&3 )
9964 function reread_TAND_TOR { x=$((
9965 cmd >&3 && >&3 echo ja || echo >&3 nein
9967 function reread_TAND_TOR {
9968 x=$(( cmd >&3 && echo ja >&3 || echo nein >&3 ) | tr u x )
9971 select file in *; do echo "<$file>" ; break >&3 ; done >&3
9980 function comsub_TSELECT { x=$(
9981 select file in *; do echo "<$file>" ; break >&3 ; done >&3
9983 function comsub_TSELECT {
9984 x=$(select file in * ; do echo "<$file>" ; break >&3 ; done >&3 )
9986 function reread_TSELECT { x=$((
9987 select file in *; do echo "<$file>" ; break >&3 ; done >&3
9989 function reread_TSELECT {
9990 x=$(( select file in * ; do echo "<$file>" ; break >&3 ; done >&3 ) | tr u x )
9992 inline_TFOR_TTIME() {
9993 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
9995 inline_TFOR_TTIME() {
10001 function comsub_TFOR_TTIME { x=$(
10002 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
10004 function comsub_TFOR_TTIME {
10005 x=$(for i in {1,2,3} ; do time echo $i >&3 ; done >&3 )
10007 function reread_TFOR_TTIME { x=$((
10008 for i in {1,2,3} ; do time >&3 echo $i ; done >&3
10010 function reread_TFOR_TTIME {
10011 x=$(( for i in {1,2,3} ; do time echo $i >&3 ; done >&3 ) | tr u x )
10014 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
10025 echo kann net bis drei zählen >&3
10029 function comsub_TCASE { x=$(
10030 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
10032 function comsub_TCASE {
10033 x=$(case $foo in (1) echo eins >&3 ;& (2) echo zwei >&3 ;| (*) echo kann net bis drei zählen >&3 ;; esac >&3 )
10035 function reread_TCASE { x=$((
10036 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3
10038 function reread_TCASE {
10039 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 )
10041 inline_TIF_TBANG_TDBRACKET_TELIF() {
10042 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
10044 inline_TIF_TBANG_TDBRACKET_TELIF() {
10045 if ! [[ 1 = 1 ]] >&3
10048 elif [[ 1 = 2 ]] >&3
10055 function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$(
10056 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
10058 function comsub_TIF_TBANG_TDBRACKET_TELIF {
10059 x=$(if ! [[ 1 = 1 ]] >&3 ; then echo eins ; elif [[ 1 = 2 ]] >&3 ; then echo zwei ; else echo drei ; fi >&3 )
10061 function reread_TIF_TBANG_TDBRACKET_TELIF { x=$((
10062 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3
10064 function reread_TIF_TBANG_TDBRACKET_TELIF {
10065 x=$(( if ! [[ 1 = 1 ]] >&3 ; then echo eins ; elif [[ 1 = 2 ]] >&3 ; then echo zwei ; else echo drei ; fi >&3 ) | tr u x )
10068 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
10072 while let] " i < 10 " >&3
10078 function comsub_TWHILE { x=$(
10079 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
10081 function comsub_TWHILE {
10082 x=$(i=1 ; while let] " i < 10 " >&3 ; do echo $i ; let ++i ; done >&3 )
10084 function reread_TWHILE { x=$((
10085 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3
10087 function reread_TWHILE {
10088 x=$(( i=1 ; while let] " i < 10 " >&3 ; do echo $i ; let ++i ; done >&3 ) | tr u x )
10091 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
10095 until let] " !--i " >&3
10100 function comsub_TUNTIL { x=$(
10101 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
10103 function comsub_TUNTIL {
10104 x=$(i=10 ; until let] " !--i " >&3 ; do echo $i ; done >&3 )
10106 function reread_TUNTIL { x=$((
10107 i=10; until (( !--i )) >&3 ; do echo $i; done >&3
10109 function reread_TUNTIL {
10110 x=$(( i=10 ; until let] " !--i " >&3 ; do echo $i ; done >&3 ) | tr u x )
10113 cat * >&3 |& >&3 ls
10119 function comsub_TCOPROC { x=$(
10120 cat * >&3 |& >&3 ls
10122 function comsub_TCOPROC {
10123 x=$(cat * >&3 |& ls >&3 )
10125 function reread_TCOPROC { x=$((
10126 cat * >&3 |& >&3 ls
10128 function reread_TCOPROC {
10129 x=$(( cat * >&3 |& ls >&3 ) | tr u x )
10131 inline_TFUNCT_TBRACE_TASYNC() {
10132 function korn { echo eins; echo >&3 zwei ; }
10133 bourne () { logger * >&3 & }
10135 inline_TFUNCT_TBRACE_TASYNC() {
10144 function comsub_TFUNCT_TBRACE_TASYNC { x=$(
10145 function korn { echo eins; echo >&3 zwei ; }
10146 bourne () { logger * >&3 & }
10148 function comsub_TFUNCT_TBRACE_TASYNC {
10149 x=$(function korn { echo eins ; echo zwei >&3 ; } ; bourne() { logger * >&3 & } )
10151 function reread_TFUNCT_TBRACE_TASYNC { x=$((
10152 function korn { echo eins; echo >&3 zwei ; }
10153 bourne () { logger * >&3 & }
10155 function reread_TFUNCT_TBRACE_TASYNC {
10156 x=$(( function korn { echo eins ; echo zwei >&3 ; } ; bourne() { logger * >&3 & } ) | tr u x )
10158 inline_COMSUB_EXPRSUB() {
10159 echo $(true >&3) $((1+ 2))
10161 inline_COMSUB_EXPRSUB() {
10162 echo $(true >&3 ) $((1+ 2))
10164 function comsub_COMSUB_EXPRSUB { x=$(
10165 echo $(true >&3) $((1+ 2))
10167 function comsub_COMSUB_EXPRSUB {
10168 x=$(echo $(true >&3 ) $((1+ 2)) )
10170 function reread_COMSUB_EXPRSUB { x=$((
10171 echo $(true >&3) $((1+ 2))
10173 function reread_COMSUB_EXPRSUB {
10174 x=$(( echo $(true >&3 ) $((1+ 2)) ) | tr u x )
10179 Check that non-subenvironment command substitution works
10199 You can now reliably use local and return in funsubs
10202 x=q; e=1; x=${ echo a; e=2; echo x$e;}; echo 1:y$x,$e,$?.
10203 x=q; e=1; x=${ echo a; typeset e=2; echo x$e;}; echo 2:y$x,$e,$?.
10204 x=q; e=1; x=${ echo a; typeset e=2; return 3; echo x$e;}; echo 3:y$x,$e,$?.
10212 Check that "value substitutions" work as advertised
10218 echo "before: x<$x> y<$y> z<$z> R<$REPLY>"
10221 echo "begin: x<$x> y<$y> z<$z> R<$REPLY>"
10226 echo "end: x<$x> y<$y> z<$z> R<$REPLY>"
10228 echo "after: x<$x> y<$y> z<$z> R<$REPLY>"
10229 # ensure trailing newlines are kept
10230 t=${|REPLY=$'foo\n\n';}
10232 echo -n this used to segfault
10233 echo ${|true;}$(true).
10235 before: x<1> y<2> z<3> R<4>
10236 begin: x<1> y<> z<3> R<>
10237 end: x<5> y<6> z<7> R<8>
10238 after: x<8> y<2> z<7> R<4>
10239 typeset t=$'foo\n\n'
10240 this used to segfault.
10244 Check that the short form [ $x ] works
10248 rv=$?; echo $((++i)) $rv
10250 rv=$?; echo $((++i)) $rv
10252 rv=$?; echo $((++i)) $rv
10254 rv=$?; echo $((++i)) $rv
10257 rv=$?; echo $((++i)) $rv
10259 rv=$?; echo $((++i)) $rv
10261 rv=$?; echo $((++i)) $rv
10263 rv=$?; echo $((++i)) $rv
10266 rv=$?; echo $((++i)) $rv
10268 rv=$?; echo $((++i)) $rv
10270 rv=$?; echo $((++i)) $rv
10272 rv=$?; echo $((++i)) $rv
10289 Check that the short form [[ $x ]] works (ksh93 extension)
10293 rv=$?; echo $((++i)) $rv
10295 rv=$?; echo $((++i)) $rv
10297 rv=$?; echo $((++i)) $rv
10299 rv=$?; echo $((++i)) $rv
10302 rv=$?; echo $((++i)) $rv
10304 rv=$?; echo $((++i)) $rv
10306 rv=$?; echo $((++i)) $rv
10308 rv=$?; echo $((++i)) $rv
10311 rv=$?; echo $((++i)) $rv
10313 rv=$?; echo $((++i)) $rv
10315 rv=$?; echo $((++i)) $rv
10317 rv=$?; echo $((++i)) $rv
10332 name: event-subst-3
10334 Check that '!' substitution in noninteractive mode is ignored
10335 file-setup: file 755 "falsetto"
10339 file-setup: file 755 "!false"
10343 export PATH=.:$PATH
10351 ! false; then echo foo; else echo bar; fi
10360 name: event-subst-0
10362 Check that '!' substitution in interactive mode is ignored
10365 file-setup: file 755 "falsetto"
10369 file-setup: file 755 "!false"
10373 export PATH=.:$PATH
10381 ! false; then echo foo; else echo bar; fi
10389 expected-stderr-pattern:
10394 Check that "set -u" matches (future) SUSv4 requirement
10400 if [[ -n $v ]]; then
10435 (mypid=$$; try mypid)
10437 ) 2>&1 | sed -e 's/^[^]]*]//' -e 's/^[^:]*: *//'
10441 y: parameter not set
10445 y: parameter not set
10449 2: parameter not set
10451 1: parameter not set
10459 !: parameter not set
10470 Testsuite for nameref (bound variables)
10485 set|grep ^ir2|sed 's/^/s1: /'
10486 typeset|grep ' ir2'|sed -e 's/^/s2: /' -e 's/nameref/typeset -n/'
10487 set -A blub -- e1 e2 e3
10488 typeset -n ind=blub
10489 typeset -n ir2=blub[2]
10490 echo !ind[1]: ${!ind[1]}
10492 echo ind[1]: ${ind[1]}
10512 Testsuite for nameref (bound variables)
10513 Functions, argument given directly, after local
10516 typeset bar=lokal baz=auch
10548 Advanced testsuite for bound variables (ksh93 fails this)
10550 typeset -n foo=bar[i]
10551 set -A bar -- b c a
10552 for i in 0 1 2 3; do
10563 Ensure we don't run in an infinite loop
10567 typeset -n foo=fnord fnord=foo
10577 expected-stderr-pattern:
10578 /fnord: expression recurses on parameter/
10580 name: better-parens-1a
10582 Check support for ((…)) and $((…)) vs (…) and $(…)
10584 if ( (echo fubar)|tr u x); then
10593 name: better-parens-1b
10595 Check support for ((…)) and $((…)) vs (…) and $(…)
10597 echo $( (echo fubar)|tr u x) $?
10601 name: better-parens-1c
10603 Check support for ((…)) and $((…)) vs (…) and $(…)
10605 x=$( (echo fubar)|tr u x); echo $x $?
10609 name: better-parens-2a
10611 Check support for ((…)) and $((…)) vs (…) and $(…)
10613 if ((echo fubar)|tr u x); then
10622 name: better-parens-2b
10624 Check support for ((…)) and $((…)) vs (…) and $(…)
10626 echo $((echo fubar)|tr u x) $?
10630 name: better-parens-2c
10632 Check support for ((…)) and $((…)) vs (…) and $(…)
10634 x=$((echo fubar)|tr u x); echo $x $?
10638 name: better-parens-3a
10640 Check support for ((…)) and $((…)) vs (…) and $(…)
10642 if ( (echo fubar)|(tr u x)); then
10651 name: better-parens-3b
10653 Check support for ((…)) and $((…)) vs (…) and $(…)
10655 echo $( (echo fubar)|(tr u x)) $?
10659 name: better-parens-3c
10661 Check support for ((…)) and $((…)) vs (…) and $(…)
10663 x=$( (echo fubar)|(tr u x)); echo $x $?
10667 name: better-parens-4a
10669 Check support for ((…)) and $((…)) vs (…) and $(…)
10671 if ((echo fubar)|(tr u x)); then
10680 name: better-parens-4b
10682 Check support for ((…)) and $((…)) vs (…) and $(…)
10684 echo $((echo fubar)|(tr u x)) $?
10688 name: better-parens-4c
10690 Check support for ((…)) and $((…)) vs (…) and $(…)
10692 x=$((echo fubar)|(tr u x)); echo $x $?
10698 Test what the echo builtin does (mksh)
10700 echo -n 'foo\x40bar'
10707 Test what the echo builtin does (POSIX)
10708 Note: this follows Debian Policy 10.4 which mandates
10709 that -n shall be treated as an option, not XSI which
10710 mandates it shall be treated as string but escapes
10713 test -n "$POSH_VERSION" || set -o posix
10714 echo -n 'foo\x40bar'
10719 name: echo-test-3-mnbsd
10721 Test what the echo builtin does, and test a compatibility flag.
10724 "$__progname" -c 'echo -n 1=\\x40$1; echo -e \\x2E' -- foo bar
10725 "$__progname" -o posix -c 'echo -n 2=\\x40$1; echo -e \\x2E' -- foo bar
10726 "$__progname" -o sh -c 'echo -n 3=\\x40$1; echo -e \\x2E' -- foo bar
10732 name: echo-test-3-normal
10734 Test what the echo builtin does, and test a compatibility flag.
10735 category: !mnbsdash
10737 "$__progname" -c 'echo -n 1=\\x40$1; echo -e \\x2E' -- foo bar
10738 "$__progname" -o posix -c 'echo -n 2=\\x40$1; echo -e \\x2E' -- foo bar
10739 "$__progname" -o sh -c 'echo -n 3=\\x40$1; echo -e \\x2E' -- foo bar
10745 name: utilities-getopts-1
10747 getopts sets OPTIND correctly for unparsed option
10750 while getopts :a optc; do
10751 echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
10755 OPTARG=, OPTIND=2, optc=a.
10756 OPTARG=, OPTIND=3, optc=a.
10757 OPTARG=x, OPTIND=4, optc=?.
10760 name: utilities-getopts-2
10765 while getopts a: optc; do
10766 echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
10770 OPTARG=Mary, OPTIND=3, optc=a.
10771 OPTARG=, OPTIND=4, optc=?.
10773 expected-stderr-pattern: /.*-x.*option/
10777 Check the new wcswidth feature
10781 print octets: ${#s} .
10782 print 8-bit width: ${%s} .
10784 print characters: ${#s} .
10785 print columns: ${%s} .
10788 print octets: ${#s} .
10789 print 8-bit width: ${%s} .
10791 print characters: ${#s} .
10792 print columns: ${%s} .
10805 Check some corner cases
10821 Check some corner cases
10824 expected-stderr-pattern:
10830 Check some corner cases
10833 expected-stderr-pattern:
10839 Check some corner cases
10842 expected-stderr-pattern:
10848 Check some corner cases
10857 Check proper return values for realpath
10858 category: os:mirbsd
10871 x=$(realpath "$wd/$1" 2>&1); y=$?
10872 print $((++i)) "?$1" =${x##*$wd/} !$y
10898 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
10903 3 ?dir/file =dir/file !0
10904 4 ?dir/nix =dir/nix !0
10906 6 ?file/ =file/: Not a directory !20
10907 7 ?file/file =file/file: Not a directory !20
10908 8 ?file/nix =file/nix: Not a directory !20
10911 11 ?nix/file =nix/file: No such file or directory !2
10912 12 ?nix/nix =nix/nix: No such file or directory !2
10915 15 ?lndir/file =dir/file !0
10916 16 ?lndir/nix =dir/nix !0
10917 17 ?lnfile =file !0
10918 18 ?lnfile/ =lnfile/: Not a directory !20
10919 19 ?lnfile/file =lnfile/file: Not a directory !20
10920 20 ?lnfile/nix =lnfile/nix: Not a directory !20
10923 23 ?lnnix/file =lnnix/file: No such file or directory !2
10924 24 ?lnnix/nix =lnnix/nix: No such file or directory !2
10925 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
10929 Ensure that exactly two leading slashes are not collapsed
10930 POSIX guarantees this exception, e.g. for UNC paths on Cygwin
10931 category: os:mirbsd
10941 realpath /usr///bin
10950 realpath //usr/include/../bin
10967 Crashed during March 2011, fixed on vernal equinōx ☺
10968 category: os:mirbsd,os:openbsd
10970 export MALLOC_OPTIONS=FGJPRSX
10971 "$__progname" -c 'x=$(tr z r <<<baz); echo $x'
10977 Check test - bug#465250
10979 test \( ! -e \) ; echo $?
10985 Check test - bug#465250
10987 test \( -e \) ; echo $?
10993 Check test - bug#465250
10995 test ! -e ; echo $?
11001 Check test - bug#465250
11009 Check that zsh case variants work
11043 Check that case end tokens are not mixed up (Debian #220272)
11046 for value in 'x' '}' 'esac'; do
11047 print -n "$((++i))($value)bourne "
11052 print -n "$((++i))($value)korn "
11066 name: command-shift
11068 Check that 'command shift' works
11071 echo "before 0='$0' 1='$1' 2='$2'"
11073 echo "after 0='$0' 1='$1' 2='$2'"
11076 echo "before 0='$0' 1='$1' 2='$2'"
11078 echo "after 0='$0' 1='$1' 2='$2'"
11080 echo = without command
11082 echo = with command
11087 before 0='snc' 1='一' 2='二'
11088 after 0='snc' 1='二' 2=''
11090 before 0='swc' 1='一' 2='二'
11091 after 0='swc' 1='二' 2=''
11096 Check that the compiler did not optimise-break them
11097 (lex.c has got a similar one in SHEREDELIM)
11102 while (( ++i < 256 )); do
11105 s+=$'\xC2\xA0\xE2\x82\xAC\xEF\xBF\xBD\xEF\xBF\xBE\xEF\xBF\xBF\xF0\x90\x80\x80.'
11108 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.'
11110 name: stateptr-underflow
11112 This check overflows an Xrestpos stored in a short in R40
11115 function Lb64decode {
11116 [[ -o utf8-mode ]]; local u=$?
11119 [[ -n $s ]] || { s=$(cat;print x); s=${s%x}; }
11120 local -i i=0 n=${#s} p=0 v x
11123 while (( i < n )); do
11127 ([A-Z]) (( v = 1#$c - 65 )) ;;
11128 ([a-z]) (( v = 1#$c - 71 )) ;;
11129 ([0-9]) (( v = 1#$c + 4 )) ;;
11134 (( x = (x << 6) | v ))
11137 (1) (( o = (x >> 4) & 255 )) ;;
11138 (2) (( o = (x >> 2) & 255 )) ;;
11139 (3) (( o = x & 255 ))
11151 while (( ++i < 12120 )); do
11154 Lb64decode $s >/dev/null
11158 Check that "set -x" doesn't redirect too quickly
11160 print '#!'"$__progname" >bash
11162 echo 'GNU bash, version 2.05b.0(1)-release (i386-ecce-mirbsd10)
11163 Copyright (C) 2002 Free Software Foundation, Inc.'
11166 "$__progname" -xc 'foo=$(./bash --version 2>&1 | head -1); echo "=$foo="'
11168 =GNU bash, version 2.05b.0(1)-release (i386-ecce-mirbsd10)=
11169 expected-stderr-pattern: