1 # $MirOS: src/bin/mksh/check.t,v 1.483 2011/10/07 19:51:42 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 $
6 # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011
7 # Thorsten Glaser <tg@mirbsd.org>
9 # Provided that these terms and disclaimer and all copyright notices
10 # are retained or reproduced in an accompanying document, permission
11 # is granted to deal in this work without restriction, including un‐
12 # limited rights to use, publicly perform, distribute, sell, modify,
13 # merge, give away, or sublicence.
15 # This work is provided “AS IS” and WITHOUT WARRANTY of any kind, to
16 # the utmost extent permitted by applicable law, neither express nor
17 # implied; without malicious intent or gross negligence. In no event
18 # may a licensor, author or contributor be held liable for indirect,
19 # direct, other damage, loss, or other issues arising in any way out
20 # of dealing in the work, even if advised of the possibility of such
21 # damage or existence of a defect, except proven that it results out
22 # of said person’s immediate fault when using the work as intended.
24 # You may also want to test IFS with the script at
25 # http://www.research.att.com/~gsf/public/ifs.sh
28 @(#)MIRBSD KSH R40 2011/10/07
30 Check version of shell.
37 Regression test self-testing
45 Regression test self-testing
54 Regression test self-testing
55 env-setup: !ENV=fnord!
63 Just output the environment variables set (always fails)
68 name: selftest-direct-builtin-call
70 Check that direct builtin calls work
72 ln -s "$__progname" cat
73 ln -s "$__progname" echo
74 ./echo -c 'echo foo' | ./cat -u
80 Check that recursion is detected/avoided in aliases.
85 expected-stderr-pattern:
90 Check that recursion is detected/avoided in aliases.
97 expected-stderr-pattern:
98 /fooBar.*not found.*\n.*barFoo.*not found/
102 Check that recursion is detected/avoided in aliases.
116 Check that alias expansion isn't done on keywords (in keyword
121 while false; do echo hi ; done
128 Check that alias expansion done after alias with trailing space.
131 alias foo='bar stuff '
132 alias bar='Bar1 Bar2 '
141 Check that alias expansion done after alias with trailing space.
153 Check that alias expansion done after alias with trailing space
158 X Y in 'Y') echo is y ;; Z) echo is z ; esac
164 Check that newlines in an alias don't cause the command to be lost.
184 Check that recursion is detected/avoided in aliases.
185 This check fails for slow machines or Cygwin, raise
186 the time-limit clause (e.g. to 7) if this occurs.
200 Check that recursion is detected/avoided in aliases.
201 Regression, introduced during an old bugfix.
203 alias foo='print hello '
204 alias bar='foo world'
211 Check that only one side of ternary operator is evaluated
216 echo $((1 ? 20 : (x+=2)))
218 echo $((0 ? (y+=2) : 30))
228 Check that assignments not done on non-evaluated side of ternary
234 echo $((1 ? 20 : (x+=2)))
236 echo $((0 ? (y+=2) : 30))
246 Check that assignments not done on non-evaluated side of ternary
247 operator and this construct is parsed correctly (Debian #445651)
255 name: arith-ternary-prec-1
257 Check precedence of ternary operator vs assignment
261 expected-exit: e != 0
262 expected-stderr-pattern:
263 /.*:.*1 \? 20 : x\+=2.*lvalue.*\n$/
265 name: arith-ternary-prec-2
267 Check precedence of ternary operator vs assignment
270 echo $((0 ? x+=2 : 20))
274 name: arith-div-assoc-1
276 Check associativity of division operator
282 name: arith-assop-assoc-1
284 Check associativity of assignment-operator operator
286 typeset -i i=1 j=2 k=3
287 echo $((i += j += k))
293 name: arith-unsigned-1
295 Check if unsigned arithmetics work
298 echo x1 $((-1)) $((#-1))
302 vs=4123456789; vu=4123456789
304 (( vs %= 2147483647 ))
305 (( vu %= 2147483647 ))
307 vs=4123456789; vu=4123456789
308 (( # vs %= 2147483647 ))
309 (( # vu %= 2147483647 ))
311 # make sure the calculation does not change unsigned flag
312 vs=4123456789; vu=4123456789
315 echo x6 $((# vs % 2147483647)) $((# vu % 2147483647))
320 echo x7 ${va[#4123456789%2147483647]}
323 x2 -171510507 4123456789
324 x3 -171510507 4123456789
325 x4 1975973142 1975973142
326 x5 -171510507 4123456789
327 x6 1975973142 1975973142
330 name: arith-limit32-1
332 Check if arithmetics are 32 bit
335 echo x1 $((-1)) $((#-1))
339 vs=2147483647; vu=2147483647
343 vs=4294967295; vu=4294967295
351 x2 2147483647 2147483647
352 x3 -2147483648 2147483648
359 Check that \newline is not collapsed after #
369 Check that \newline is not collapsed inside single quotes
381 Check that \newline is not collapsed inside single quotes
393 Check interaction of aliases, single quotes and here-documents
394 with backslash-newline
395 (don't know what POSIX has to say about this)
417 Check what happens with backslash at end of input
418 (the old Bourne shell trashes them; so do we)
427 # Places \newline should be collapsed
431 Check that \newline is collapsed before, in the middle of, and
443 Check that \newline is collapsed in $ sequences
467 Check that \newline is collapsed in $(..) and `...` sequences
492 Check that \newline is collapsed in $((..)) sequences
503 echo $((1+2+3+4+5+6)\
514 Check that \newline is collapsed in double quoted strings
529 Check that \newline is collapsed in here document delimiters
530 (ksh93 fails second part of this)
552 Check that \newline is collapsed in double-quoted here-document
571 Check that \newline is collapsed in various 2+ character tokens
616 Check that \ at the end of an alias is collapsed when followed
618 (don't know what POSIX has to say about this)
628 Check that \newline in a keyword is collapsed
638 # Places \newline should be collapsed (ksh extensions)
642 Check that \newline is collapsed in extended globbing
659 Check that \newline is collapsed in ((...)) expressions
674 See if break breaks out of loops
676 for i in a b c; do echo $i; break; echo bad-$i; done
678 for i in a b c; do echo $i; break 1; echo bad-$i; done
704 See if break breaks out of nested loops
721 What if break used outside of any loops
722 (ksh88,ksh93 don't print error messages here)
725 expected-stderr-pattern:
730 What if break N used when only N-1 loops
731 (ksh88,ksh93 don't print error messages here)
733 for i in a b c; do echo $i; break 2; echo bad-$i; done
738 expected-stderr-pattern:
743 Error if break argument isn't a number
745 for i in a b c; do echo $i; break abc; echo more-$i; done
749 expected-exit: e != 0
750 expected-stderr-pattern:
755 See if continue continues loops
757 for i in a b c; do echo $i; continue; echo bad-$i ; done
759 for i in a b c; do echo $i; continue 1; echo bad-$i; done
795 See if continue breaks out of nested loops
814 What if continue used outside of any loops
815 (ksh88,ksh93 don't print error messages here)
818 expected-stderr-pattern:
823 What if continue N used when only N-1 loops
824 (ksh88,ksh93 don't print error messages here)
826 for i in a b c; do echo $i; continue 2; echo bad-$i; done
833 expected-stderr-pattern:
838 Error if continue argument isn't a number
840 for i in a b c; do echo $i; continue abc; echo more-$i; done
844 expected-exit: e != 0
845 expected-stderr-pattern:
850 Test someone's CD history package (uses arrays)
852 # go to known place before doing anything
866 if [ "$CDHISTFILE" -a -r "$CDHISTFILE" ] # if directory history exists
870 while read -r t # read directory history file
876 if [ "${CDHIST[0]}" != "$PWD" -a "$PWD" != "" ]
878 _cdins # insert $PWD into cd history
881 cdlen=${#CDHIST[*]} # number of elements in history
885 if [ "$OLDPWD" = "" ] && ((cdlen>1))
895 -l) # print directory list
901 'print' "$num ${CDHIST[i]}"
905 -[0-9]|-[0-9][0-9]) # cd to dir in list
906 if (((i=${1#-})<cdlen))
916 -*) # cd to matched dir in list
943 _cdins # insert $PWD into cd history
947 cdlen=${#CDHIST[*]} # number of elements in history
952 'print' -r ${CDHIST[i]} # update directory history
958 function _cdins # insert $PWD into cd history
959 { # meant to be called only by _cd
963 while ((i<${#CDHIST[*]})) # see if dir is already in list
965 if [ "${CDHIST[$i]}" = "$PWD" ]
972 if ((i>22)) # limit max size of list
977 while (((i=i-1)>=0)) # bump old dirs in list
979 CDHIST[i+1]=${CDHIST[i]}
982 CDHIST[0]=$PWD # insert new directory in list
1010 Check package for cd -Pe
1012 # the mv command fails on Cygwin
1013 category: !os:cygwin
1014 file-setup: file 644 "x"
1015 mkdir noread noread/target noread/target/subdir
1022 echo 1=$?,${PWD#$bwd/}
1023 epwd=$($TSHELL -c pwd 2>/dev/null)
1024 # This unexpectedly succeeds on GNU/Linux and MidnightBSD
1027 mv ../../noread ../../renamed
1029 echo 2=$?,${PWD#$bwd/}
1032 rm -rf noread link renamed
1034 export TSHELL="$__progname"
1041 2=0,noread/target/subdir
1045 2=1,noread/target/subdir
1049 Check that prompt not printed when processing ENV
1050 env-setup: !ENV=./foo!
1051 file-setup: file 644 "foo"
1066 Check that weird ${foo+bar} constructs are parsed correctly
1068 (echo 1 ${IFS+'}'z}) 2>&- || echo failed in 1
1069 (echo 2 "${IFS+'}'z}") 2>&- || echo failed in 2
1070 (echo 3 "foo ${IFS+'bar} baz") 2>&- || echo failed in 3
1071 (echo -n '4 '; printf '%s\n' "foo ${IFS+"b c"} baz") 2>&- || echo failed in 4
1072 (echo -n '5 '; printf '%s\n' "foo ${IFS+b c} baz") 2>&- || echo failed in 5
1073 (echo 6 ${IFS+"}"z}) 2>&- || echo failed in 6
1074 (echo 7 "${IFS+"}"z}") 2>&- || echo failed in 7
1075 (echo 8 "${IFS+\"}\"z}") 2>&- || echo failed in 8
1076 (echo 9 "${IFS+\"\}\"z}") 2>&- || echo failed in 9
1077 (echo 10 foo ${IFS+'bar} baz'}) 2>&- || echo failed in 10
1078 (echo 11 "$(echo "${IFS+'}'z}")") 2>&- || echo failed in 11
1079 (echo 12 "$(echo ${IFS+'}'z})") 2>&- || echo failed in 12
1080 (echo 13 ${IFS+\}z}) 2>&- || echo failed in 13
1081 (echo 14 "${IFS+\}z}") 2>&- || echo failed in 14
1082 u=x; (echo -n '15 '; printf '<%s> ' "foo ${IFS+a"b$u{ {"{{\}b} c ${IFS+d{}} bar" ${IFS-e{}} baz; echo .) 2>&- || echo failed in 15
1083 l=t; (echo 16 ${IFS+h`echo -n i ${IFS+$l}h`ere}) 2>&- || echo failed in 16
1084 l=t; (echo 17 ${IFS+h$(echo -n i ${IFS+$l}h)ere}) 2>&- || echo failed in 17
1085 l=t; (echo 18 "${IFS+h`echo -n i ${IFS+$l}h`ere}") 2>&- || echo failed in 18
1086 l=t; (echo 19 "${IFS+h$(echo -n i ${IFS+$l}h)ere}") 2>&- || echo failed in 19
1087 l=t; (echo 20 ${IFS+h`echo -n i "${IFS+$l}"h`ere}) 2>&- || echo failed in 20
1088 l=t; (echo 21 ${IFS+h$(echo -n i "${IFS+$l}"h)ere}) 2>&- || echo failed in 21
1089 l=t; (echo 22 "${IFS+h`echo -n i "${IFS+$l}"h`ere}") 2>&- || echo failed in 22
1090 l=t; (echo 23 "${IFS+h$(echo -n i "${IFS+$l}"h)ere}") 2>&- || echo failed in 23
1091 key=value; (echo -n '24 '; printf '%s\n' "${IFS+'$key'}") 2>&- || echo failed in 24
1092 key=value; (echo -n '25 '; printf '%s\n' "${IFS+"'$key'"}") 2>&- || echo failed in 25 # ksh93: “'$key'”
1093 key=value; (echo -n '26 '; printf '%s\n' ${IFS+'$key'}) 2>&- || echo failed in 26
1094 key=value; (echo -n '27 '; printf '%s\n' ${IFS+"'$key'"}) 2>&- || echo failed in 27
1095 (echo -n '28 '; printf '%s\n' "${IFS+"'"x ~ x'}'x"'}"x}" #') 2>&- || echo failed in 28
1096 u=x; (echo -n '29 '; printf '<%s> ' foo ${IFS+a"b$u{ {"{ {\}b} c ${IFS+d{}} bar ${IFS-e{}} baz; echo .) 2>&- || echo failed in 29
1097 (echo -n '30 '; printf '<%s> ' ${IFS+foo 'b\
1098 ar' baz}; echo .) 2>&- || (echo failed in 30; echo failed in 31)
1099 (echo -n '32 '; printf '<%s> ' ${IFS+foo "b\
1100 ar" baz}; echo .) 2>&- || echo failed in 32
1101 (echo -n '33 '; printf '<%s> ' "${IFS+foo 'b\
1102 ar' baz}"; echo .) 2>&- || echo failed in 33
1103 (echo -n '34 '; printf '<%s> ' "${IFS+foo "b\
1104 ar" baz}"; echo .) 2>&- || echo failed in 34
1105 (echo -n '35 '; printf '<%s> ' ${v=a\ b} x ${v=c\ d}; echo .) 2>&- || echo failed in 35
1106 (echo -n '36 '; printf '<%s> ' "${v=a\ b}" x "${v=c\ d}"; echo .) 2>&- || echo failed in 36
1107 (echo -n '37 '; printf '<%s> ' ${v-a\ b} x ${v-c\ d}; echo .) 2>&- || echo failed in 37
1108 (echo 38 ${IFS+x'a'y} / "${IFS+x'a'y}" .) 2>&- || echo failed in 38
1109 foo="x'a'y"; (echo 39 ${foo%*'a'*} / "${foo%*'a'*}" .) 2>&- || echo failed in 39
1110 foo="a b c"; (echo -n '40 '; printf '<%s> ' "${foo#a}"; echo .) 2>&- || echo failed in 40
1126 15 <foo abx{ {{{}b c d{} bar> <}> <baz> .
1140 29 <foo> <abx{ {{> <{}b> <c> <d{}> <bar> <}> <baz> .
1143 32 <foo> <bar> <baz> .
1144 33 <foo 'bar' baz> .
1146 35 <a> <b> <x> <a> <b> .
1147 36 <a\ b> <x> <a\ b> .
1148 37 <a b> <x> <c d> .
1153 name: expand-unglob-dblq
1155 Check that regular "${foo+bar}" constructs are parsed correctly
1160 test x"$v" = x"-" && unset v
1161 (echo "$1 plus norm foo ${v+'bar'} baz")
1162 (echo "$1 dash norm foo ${v-'bar'} baz")
1163 (echo "$1 eqal norm foo ${v='bar'} baz")
1164 (echo "$1 qstn norm foo ${v?'bar'} baz") 2>&- || \
1165 echo "$1 qstn norm -> error"
1166 (echo "$1 PLUS norm foo ${v:+'bar'} baz")
1167 (echo "$1 DASH norm foo ${v:-'bar'} baz")
1168 (echo "$1 EQAL norm foo ${v:='bar'} baz")
1169 (echo "$1 QSTN norm foo ${v:?'bar'} baz") 2>&- || \
1170 echo "$1 QSTN norm -> error"
1174 test x"$v" = x"-" && unset v
1175 (echo "$1 plus parn foo ${v+(bar)} baz")
1176 (echo "$1 dash parn foo ${v-(bar)} baz")
1177 (echo "$1 eqal parn foo ${v=(bar)} baz")
1178 (echo "$1 qstn parn foo ${v?(bar)} baz") 2>&- || \
1179 echo "$1 qstn parn -> error"
1180 (echo "$1 PLUS parn foo ${v:+(bar)} baz")
1181 (echo "$1 DASH parn foo ${v:-(bar)} baz")
1182 (echo "$1 EQAL parn foo ${v:=(bar)} baz")
1183 (echo "$1 QSTN parn foo ${v:?(bar)} baz") 2>&- || \
1184 echo "$1 QSTN parn -> error"
1188 test x"$v" = x"-" && unset v
1189 (echo "$1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz")
1190 (echo "$1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz")
1191 (echo "$1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz")
1192 (echo "$1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz") 2>&- || \
1193 echo "$1 qstn brac -> error"
1194 (echo "$1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz")
1195 (echo "$1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz")
1196 (echo "$1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz")
1197 (echo "$1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz") 2>&- || \
1198 echo "$1 QSTN brac -> error"
1211 1 dash norm foo 'bar' baz
1212 1 eqal norm foo 'bar' baz
1213 1 qstn norm -> error
1215 1 DASH norm foo 'bar' baz
1216 1 EQAL norm foo 'bar' baz
1217 1 QSTN norm -> error
1218 2 plus norm foo 'bar' baz
1223 2 DASH norm foo 'bar' baz
1224 2 EQAL norm foo 'bar' baz
1225 2 QSTN norm -> error
1226 3 plus norm foo 'bar' baz
1227 3 dash norm foo x baz
1228 3 eqal norm foo x baz
1229 3 qstn norm foo x baz
1230 3 PLUS norm foo 'bar' baz
1231 3 DASH norm foo x baz
1232 3 EQAL norm foo x baz
1233 3 QSTN norm foo x baz
1235 4 dash parn foo (bar) baz
1236 4 eqal parn foo (bar) baz
1237 4 qstn parn -> error
1239 4 DASH parn foo (bar) baz
1240 4 EQAL parn foo (bar) baz
1241 4 QSTN parn -> error
1242 5 plus parn foo (bar) baz
1247 5 DASH parn foo (bar) baz
1248 5 EQAL parn foo (bar) baz
1249 5 QSTN parn -> error
1250 6 plus parn foo (bar) baz
1251 6 dash parn foo x baz
1252 6 eqal parn foo x baz
1253 6 qstn parn foo x baz
1254 6 PLUS parn foo (bar) baz
1255 6 DASH parn foo x baz
1256 6 EQAL parn foo x baz
1257 6 QSTN parn foo x baz
1258 7 plus brac foo c } baz
1259 7 dash brac foo ax{{{}b c d{} baz
1260 7 eqal brac foo ax{{{}b c ax{{{}b} baz
1261 7 qstn brac -> error
1262 7 PLUS brac foo c } baz
1263 7 DASH brac foo ax{{{}b c d{} baz
1264 7 EQAL brac foo ax{{{}b c ax{{{}b} baz
1265 7 QSTN brac -> error
1266 8 plus brac foo ax{{{}b c d{} baz
1267 8 dash brac foo c } baz
1268 8 eqal brac foo c } baz
1269 8 qstn brac foo c } baz
1270 8 PLUS brac foo c } baz
1271 8 DASH brac foo ax{{{}b c d{} baz
1272 8 EQAL brac foo ax{{{}b c ax{{{}b} baz
1273 8 QSTN brac -> error
1274 9 plus brac foo ax{{{}b c d{} baz
1275 9 dash brac foo x c x} baz
1276 9 eqal brac foo x c x} baz
1277 9 qstn brac foo x c x} baz
1278 9 PLUS brac foo ax{{{}b c d{} baz
1279 9 DASH brac foo x c x} baz
1280 9 EQAL brac foo x c x} baz
1281 9 QSTN brac foo x c x} baz
1283 name: expand-unglob-unq
1285 Check that regular ${foo+bar} constructs are parsed correctly
1290 test x"$v" = x"-" && unset v
1291 (echo $1 plus norm foo ${v+'bar'} baz)
1292 (echo $1 dash norm foo ${v-'bar'} baz)
1293 (echo $1 eqal norm foo ${v='bar'} baz)
1294 (echo $1 qstn norm foo ${v?'bar'} baz) 2>&- || \
1295 echo "$1 qstn norm -> error"
1296 (echo $1 PLUS norm foo ${v:+'bar'} baz)
1297 (echo $1 DASH norm foo ${v:-'bar'} baz)
1298 (echo $1 EQAL norm foo ${v:='bar'} baz)
1299 (echo $1 QSTN norm foo ${v:?'bar'} baz) 2>&- || \
1300 echo "$1 QSTN norm -> error"
1304 test x"$v" = x"-" && unset v
1305 (echo $1 plus parn foo ${v+\(bar')'} baz)
1306 (echo $1 dash parn foo ${v-\(bar')'} baz)
1307 (echo $1 eqal parn foo ${v=\(bar')'} baz)
1308 (echo $1 qstn parn foo ${v?\(bar')'} baz) 2>&- || \
1309 echo "$1 qstn parn -> error"
1310 (echo $1 PLUS parn foo ${v:+\(bar')'} baz)
1311 (echo $1 DASH parn foo ${v:-\(bar')'} baz)
1312 (echo $1 EQAL parn foo ${v:=\(bar')'} baz)
1313 (echo $1 QSTN parn foo ${v:?\(bar')'} baz) 2>&- || \
1314 echo "$1 QSTN parn -> error"
1318 test x"$v" = x"-" && unset v
1319 (echo $1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz)
1320 (echo $1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz)
1321 (echo $1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz)
1322 (echo $1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz) 2>&- || \
1323 echo "$1 qstn brac -> error"
1324 (echo $1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz)
1325 (echo $1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz)
1326 (echo $1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz)
1327 (echo $1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz) 2>&- || \
1328 echo "$1 QSTN brac -> error"
1341 1 dash norm foo bar baz
1342 1 eqal norm foo bar baz
1343 1 qstn norm -> error
1345 1 DASH norm foo bar baz
1346 1 EQAL norm foo bar baz
1347 1 QSTN norm -> error
1348 2 plus norm foo bar baz
1353 2 DASH norm foo bar baz
1354 2 EQAL norm foo bar baz
1355 2 QSTN norm -> error
1356 3 plus norm foo bar baz
1357 3 dash norm foo x baz
1358 3 eqal norm foo x baz
1359 3 qstn norm foo x baz
1360 3 PLUS norm foo bar baz
1361 3 DASH norm foo x baz
1362 3 EQAL norm foo x baz
1363 3 QSTN norm foo x baz
1365 4 dash parn foo (bar) baz
1366 4 eqal parn foo (bar) baz
1367 4 qstn parn -> error
1369 4 DASH parn foo (bar) baz
1370 4 EQAL parn foo (bar) baz
1371 4 QSTN parn -> error
1372 5 plus parn foo (bar) baz
1377 5 DASH parn foo (bar) baz
1378 5 EQAL parn foo (bar) baz
1379 5 QSTN parn -> error
1380 6 plus parn foo (bar) baz
1381 6 dash parn foo x baz
1382 6 eqal parn foo x baz
1383 6 qstn parn foo x baz
1384 6 PLUS parn foo (bar) baz
1385 6 DASH parn foo x baz
1386 6 EQAL parn foo x baz
1387 6 QSTN parn foo x baz
1388 7 plus brac foo c } baz
1389 7 dash brac foo ax{{{}b c d{} baz
1390 7 eqal brac foo ax{{{}b c ax{{{}b} baz
1391 7 qstn brac -> error
1392 7 PLUS brac foo c } baz
1393 7 DASH brac foo ax{{{}b c d{} baz
1394 7 EQAL brac foo ax{{{}b c ax{{{}b} baz
1395 7 QSTN brac -> error
1396 8 plus brac foo ax{{{}b c d{} baz
1397 8 dash brac foo c } baz
1398 8 eqal brac foo c } baz
1399 8 qstn brac foo c } baz
1400 8 PLUS brac foo c } baz
1401 8 DASH brac foo ax{{{}b c d{} baz
1402 8 EQAL brac foo ax{{{}b c ax{{{}b} baz
1403 8 QSTN brac -> error
1404 9 plus brac foo ax{{{}b c d{} baz
1405 9 dash brac foo x c x} baz
1406 9 eqal brac foo x c x} baz
1407 9 qstn brac foo x c x} baz
1408 9 PLUS brac foo ax{{{}b c d{} baz
1409 9 DASH brac foo x c x} baz
1410 9 EQAL brac foo x c x} baz
1411 9 QSTN brac foo x c x} baz
1413 name: expand-threecolons-dblq
1415 Check for a particular thing that used to segfault
1418 echo "${TEST:1:2:3}"
1419 echo $? but still living
1420 expected-stderr-pattern:
1424 name: expand-threecolons-unq
1426 Check for a particular thing that used to not error out
1430 echo $? but still living
1431 expected-stderr-pattern:
1435 name: expand-weird-1
1437 Check corner case of trim expansion vs. $# vs. ${#var}
1439 set 1 2 3 4 5 6 7 8 9 10 11
1440 echo ${#} # value of $#
1441 echo ${##} # length of $#
1442 echo ${##1} # $# trimmed 1
1443 set 1 2 3 4 5 6 7 8 9 10 11 12
1451 name: expand-weird-2
1453 Check corner case of ${var?} vs. ${#var}
1465 Check that globbing isn't done when glob has syntax error
1466 file-setup: file 644 "abcx"
1467 file-setup: file 644 "abcz"
1468 file-setup: file 644 "bbc"
1478 Check that globbing isn't done when glob has syntax error
1479 (AT&T ksh fails this test)
1480 file-setup: file 644 "abcx"
1481 file-setup: file 644 "abcz"
1482 file-setup: file 644 "bbc"
1488 name: eglob-infinite-plus
1490 Check that shell doesn't go into infinite loop expanding +(...)
1492 file-setup: file 644 "abc"
1507 Check that eglobbing isn't done on substitution results
1508 file-setup: file 644 "abc"
1515 name: eglob-nomatch-1
1517 Check that the pattern doesn't match
1519 echo 1: no-file+(a|b)stuff
1520 echo 2: no-file+(a*(c)|b)stuff
1521 echo 3: no-file+((((c)))|b)stuff
1523 1: no-file+(a|b)stuff
1524 2: no-file+(a*(c)|b)stuff
1525 3: no-file+((((c)))|b)stuff
1529 Check that the pattern matches correctly
1530 file-setup: file 644 "abd"
1531 file-setup: file 644 "acd"
1532 file-setup: file 644 "abac"
1536 echo 3: *(a(b|c)) # (...|...) can be used within X(..)
1537 echo 4: a[b*(foo|bar)]d # patterns not special inside [...]
1546 Simple negation tests
1548 case foo in !(foo|bar)) echo yes;; *) echo no;; esac
1549 case bar in !(foo|bar)) echo yes;; *) echo no;; esac
1558 case foo in *(a|b[)) echo yes;; *) echo no;; esac
1559 case foo in *(a|b[)|f*) echo yes;; *) echo no;; esac
1560 case '*(a|b[)' in *(a|b[)) echo yes;; *) echo no;; esac
1568 Eglobbing in trim expressions...
1569 (AT&T ksh fails this - docs say # matches shortest string, ## matches
1585 Check eglobbing works in trims...
1588 echo 1: ${x#*(a|b)cd}
1589 echo 2: "${x#*(a|b)cd}"
1590 echo 3: ${x#"*(a|b)cd"}
1600 Check eglobbing works in trims, for Korn Shell
1601 Ensure eglobbing does not work for reduced-feature /bin/sh
1607 echo "<${x%bar|baz},${y%bar|baz},${z%\?}>"
1608 echo "<${x%ba(r|z)},${y%ba(r|z)}>"
1610 echo "<${x%bar|baz},${y%bar|baz},${z%\?}>"
1616 <foobar,foobaz,fooba>
1619 name: eglob-substrpl-1
1621 Check eglobbing works in substs... and they work at all
1623 [[ -n $BASH_VERSION ]] && shopt -s extglob
1624 x=1222321_ab/cde_b/c_1221
1633 echo 8: ${x//+(2)/4}
1634 echo 9: ${x/b/c/e/f}
1635 echo 10: ${x/b\/c/e/f}
1636 echo 11: ${x/b\/c/e\/f}
1637 echo 12: ${x/b\/c/e\\/f}
1638 echo 13: ${x/b\\/c/e\\/f}
1639 echo 14: ${x//b/c/e/f}
1640 echo 15: ${x//b\/c/e/f}
1641 echo 16: ${x//b\/c/e\/f}
1642 echo 17: ${x//b\/c/e\\/f}
1643 echo 18: ${x//b\\/c/e\\/f}
1644 echo 19: ${x/b\/*\/c/x}
1650 echo 25: ${x//\%1/9}
1651 echo 26: ${x//\\%1/9}
1653 echo 28: ${x//\\a/9}
1656 1: 122321_ab/cde_b/c_1221
1657 2: 131_ab/cde_b/c_11
1658 3: 1321_ab/cde_b/c_1221
1659 4: 131_ab/cde_b/c_11
1660 5: 1422321_ab/cde_b/c_1221
1661 6: 1444341_ab/cde_b/c_1441
1662 7: 14321_ab/cde_b/c_1221
1663 8: 14341_ab/cde_b/c_141
1664 9: 1222321_ac/e/f/cde_b/c_1221
1665 10: 1222321_ae/fde_b/c_1221
1666 11: 1222321_ae/fde_b/c_1221
1667 12: 1222321_ae\/fde_b/c_1221
1668 13: 1222321_ab/cde_b/c_1221
1669 14: 1222321_ac/e/f/cde_c/e/f/c_1221
1670 15: 1222321_ae/fde_e/f_1221
1671 16: 1222321_ae/fde_e/f_1221
1672 17: 1222321_ae\/fde_e\/f_1221
1673 18: 1222321_ab/cde_b/c_1221
1675 20: 1222321_ab.cde_b/c_1221
1676 21: 1222321_ab.cde_b.c_1221
1677 22: 1222321_ab/cde_b/c_1221
1678 23: 9222321_ab/cde_b/c_1221
1679 24: 1222321_ab/cde_b/c_1229
1680 25: 1222321_ab/cde_b/c_1229
1681 26: 1222321_ab/cde_b/c_1221
1682 27: 1222321_9b/cde_b/c_1221
1683 28: 1222321_9b/cde_b/c_1221
1684 29: 1xyz22321_ab/cde_b/c_1221
1686 name: eglob-substrpl-2
1688 Check anchored substring replacement works, corner cases
1705 name: eglob-substrpl-3a
1707 Check substring replacement works with variables and slashes, too
1711 echo "${wd/#$pfx/~}"
1712 echo "${wd/#\$pfx/~}"
1713 echo "${wd/#"$pfx"/~}"
1714 echo "${wd/#'$pfx'/~}"
1715 echo "${wd/#"\$pfx"/~}"
1716 echo "${wd/#'\$pfx'/~}"
1725 name: eglob-substrpl-3b
1727 More of this, bash fails it (bash4 passes)
1731 echo "${wd/#$(echo /home/user)/~}"
1732 echo "${wd/#"$(echo /home/user)"/~}"
1733 echo "${wd/#'$(echo /home/user)'/~}"
1739 name: eglob-substrpl-3c
1741 Even more weird cases
1745 echo 1: ${wd/#$pfx/~}
1746 echo 2: ${wd/#\$pfx/~}
1747 echo 3: ${wd/#"$pfx"/~}
1748 echo 4: ${wd/#'$pfx'/~}
1749 echo 5: ${wd/#"\$pfx"/~}
1750 echo 6: ${wd/#'\$pfx'/~}
1751 ts='a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)'
1754 [[ -n $BASH_VERSION ]] && shopt -s extglob
1755 echo 7: ${ts/a\/b/$tr}
1756 echo 8: ${ts/a\/b/\$tr}
1757 echo 9: ${ts/$tp/$tr}
1758 echo 10: ${ts/\$tp/$tr}
1759 echo 11: ${ts/\\$tp/$tr}
1760 echo 12: ${ts/$tp/c/d}
1761 echo 13: ${ts/$tp/c\/d}
1762 echo 14: ${ts/$tp/c\\/d}
1763 echo 15: ${ts/+(a\/b)/$tr}
1764 echo 16: ${ts/+(a\/b)/\$tr}
1765 echo 17: ${ts/+($tp)/$tr}
1766 echo 18: ${ts/+($tp)/c/d}
1767 echo 19: ${ts/+($tp)/c\/d}
1768 echo 25: ${ts//a\/b/$tr}
1769 echo 26: ${ts//a\/b/\$tr}
1770 echo 27: ${ts//$tp/$tr}
1771 echo 28: ${ts//$tp/c/d}
1772 echo 29: ${ts//$tp/c\/d}
1773 echo 30: ${ts//+(a\/b)/$tr}
1774 echo 31: ${ts//+(a\/b)/\$tr}
1775 echo 32: ${ts//+($tp)/$tr}
1776 echo 33: ${ts//+($tp)/c/d}
1777 echo 34: ${ts//+($tp)/c\/d}
1779 echo 40: ${ts/$tp/$tr}
1780 echo 41: ${ts//$tp/$tr}
1788 7: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1789 8: $tra/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1790 9: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1791 10: a/ba/bc/d$tp_a/b$tp_*(a/b)_*($tp)
1792 11: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1793 12: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1794 13: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1795 14: c\/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1796 15: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
1797 16: $tr$tp$tp_a/b$tp_*(a/b)_*($tp)
1798 17: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
1799 18: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
1800 19: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
1801 25: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1802 26: $tr$tr$tp$tp_$tr$tp_*($tr)_*($tp)
1803 27: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1804 28: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1805 29: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1806 30: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1807 31: $tr$tp$tp_$tr$tp_*($tr)_*($tp)
1808 32: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1809 33: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1810 34: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1811 40: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1812 41: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1813 # This is what GNU bash does:
1814 # 40: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
1815 # 41: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1819 UTF-8 mode differences for eglobbing
1824 print 2: ${s/b???d/x} .
1827 print 4: ${s/b??d/x} .
1829 print 5: ${x%?} ${x%%?} .
1831 print 6: ${x#?} ${x##?} .
1833 print 7: ${x%?} ${x%%?} .
1835 print 8: ${x%?} ${x%%?} .
1837 print 9: ${x%?} ${x%%?} .
1851 Check that globbing isn't done when glob has syntax error
1852 file-setup: dir 755 "[x"
1853 file-setup: file 644 "[x/foo"
1865 Check that symbolic links aren't stat()'d
1866 # breaks on FreeMiNT (cannot unlink dangling symlinks)
1868 file-setup: dir 755 "dir"
1869 file-setup: symlink 644 "dir/abc"
1881 file-setup: file 644 ".bc"
1882 file-setup: file 644 "abc"
1883 file-setup: file 644 "bbc"
1884 file-setup: file 644 "cbc"
1885 file-setup: file 644 "-bc"
1902 (AT&T ksh fails this; POSIX says invalid)
1903 file-setup: file 644 "abc"
1911 Check that globbing matches the right things...
1912 # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
1913 # breaks on Cygwin 1.7 (files are now UTF-16 or something)
1914 category: !os:cygwin,!os:darwin
1915 file-setup: file 644 "aÂc"
1923 Results unspecified according to POSIX
1924 file-setup: file 644 ".bc"
1932 Results unspecified according to POSIX
1933 (AT&T ksh treats this like [a-cc-e]*)
1934 file-setup: file 644 "abc"
1935 file-setup: file 644 "bbc"
1936 file-setup: file 644 "cbc"
1937 file-setup: file 644 "dbc"
1938 file-setup: file 644 "ebc"
1939 file-setup: file 644 "-bc"
1947 Check ordering/content of redundent here documents.
1959 Check quoted here-doc is protected.
1978 Check that newline isn't needed after heredoc-delimiter marker.
1990 Check that an error occurs if the heredoc-delimiter is missing.
1995 expected-exit: e > 0
1996 expected-stderr-pattern: /.*/
2000 Check that backslash quotes a $, ` and \ and kills a \newline
2007 th\`echo not-run\`ere
2008 th\\`echo is-run`ere
2025 Check that \newline in initial here-delim word doesn't imply
2040 Check that double quoted $ expressions in here delimiters are
2041 not expanded and match the delimiter.
2042 POSIX says only quote removal is applied to the delimiter.
2059 Check that double quoted escaped $ expressions in here
2060 delimiters are not expanded and match the delimiter.
2061 POSIX says only quote removal is applied to the delimiter
2062 (\ counts as a quote).
2083 Check that here strings work.
2087 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo
2088 "$__progname" -c "tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo"
2089 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$bar"
2090 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<'$bar'
2091 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$bar
2092 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<-foo
2104 Check that a corner case of here strings works like bash
2109 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
2116 Check that a corner case of here strings works like ksh93, zsh
2121 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
2128 Check another corner case of here strings
2130 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<< bar
2136 Check here string related regression with multiple iops
2138 echo $(tr r z <<<'bar' 2>&-)
2144 Check direct here document assignment
2160 # rather nonsensical, but…
2163 vf=<<<$'=f $x \x40='
2165 print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} ve={$ve} vf={$vf} |"
2183 Check here documents with no or empty delimiter
2202 print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} |"
2220 name: heredoc-comsub-1
2222 Tests for here documents in COMSUB, taken from Austin ML
2229 = here is the text =
2231 name: heredoc-comsub-2
2233 Tests for here documents in COMSUB, taken from Austin ML
2235 unbalanced=$(cat <<EOF
2236 this paren ) is a problem
2238 echo = $unbalanced =
2240 = this paren ) is a problem =
2242 name: heredoc-comsub-3
2244 Tests for here documents in COMSUB, taken from Austin ML
2246 balanced=$(cat <<EOF
2247 these parens ( ) are not a problem
2251 = these parens ( ) are not a problem =
2253 name: heredoc-comsub-4
2255 Tests for here documents in COMSUB, taken from Austin ML
2257 balanced=$(cat <<EOF
2258 these parens \( ) are a problem
2262 = these parens \( ) are a problem =
2264 name: heredoc-subshell-1
2266 Tests for here documents in subshells, taken from Austin ML
2276 name: heredoc-subshell-2
2278 Tests for here documents in subshells, taken from Austin ML
2289 name: heredoc-subshell-3
2291 Tests for here documents in subshells, taken from Austin ML
2301 name: heredoc-weird-1
2303 Tests for here documents, taken from Austin ML
2304 Documents current state in mksh, *NOT* necessarily correct!
2317 name: heredoc-weird-2
2319 Tests for here documents, taken from Austin ML
2329 name: heredoc-weird-4
2331 Tests for here documents, taken from Austin ML
2332 Documents current state in mksh, *NOT* necessarily correct!
2343 name: heredoc-weird-5
2345 Tests for here documents, taken from Austin ML
2346 Documents current state in mksh, *NOT* necessarily correct!
2358 name: heredoc-quoting-unsubst
2360 Check for correct handling of quoted characters in
2361 here documents without substitution (marker is quoted).
2365 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
2368 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
2370 name: heredoc-quoting-subst
2372 Check for correct handling of quoted characters in
2373 here documents with substitution (marker is not quoted).
2377 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
2380 x " \" \ \ $ $ baz `echo baz` bar $foo x
2382 name: heredoc-tmpfile-1
2384 Check that heredoc temp files aren't removed too soon or too late.
2385 Heredoc in simple command.
2406 name: heredoc-tmpfile-2
2408 Check that heredoc temp files aren't removed too soon or too late.
2409 Heredoc in function, multiple calls to function.
2428 name: heredoc-tmpfile-3
2430 Check that heredoc temp files aren't removed too soon or too late.
2431 Heredoc in function in loop, multiple calls to function.
2458 name: heredoc-tmpfile-4
2460 Check that heredoc temp files aren't removed too soon or too late.
2461 Backgrounded simple command with here doc
2475 name: heredoc-tmpfile-5
2477 Check that heredoc temp files aren't removed too soon or too late.
2478 Backgrounded subshell command with here doc
2483 sleep 1 # so parent exits
2499 name: heredoc-tmpfile-6
2501 Check that heredoc temp files aren't removed too soon or too late.
2502 Heredoc in pipeline.
2506 cat <<- EOF | sed "s/hi/HI/"
2516 name: heredoc-tmpfile-7
2518 Check that heredoc temp files aren't removed too soon or too late.
2519 Heredoc in backgrounded pipeline.
2523 cat <<- EOF | sed 's/hi/HI/' &
2533 name: heredoc-tmpfile-8
2535 Check that heredoc temp files aren't removed too soon or too
2536 late. Heredoc in function, backgrounded call to function.
2537 This check can fail on slow machines (<100 MHz), or Cygwin,
2542 # Background eval so main shell doesn't do parsing
2550 # sleep so eval can die
2566 See if we can test history at all
2569 env-setup: !ENV=./Env!HISTFILE=hist.file!
2570 file-setup: file 644 "Env"
2578 expected-stderr-pattern:
2583 Verify duplicates and spaces are not entered
2586 env-setup: !ENV=./Env!HISTFILE=hist.file!
2587 file-setup: file 644 "Env"
2599 expected-stderr-pattern:
2602 name: history-unlink
2604 Check if broken HISTFILEs do not cause trouble
2607 env-setup: !ENV=./Env!HISTFILE=foo/hist.file!
2608 file-setup: file 644 "Env"
2610 file-setup: dir 755 "foo"
2611 file-setup: file 644 "foo/hist.file"
2614 perl-setup: chmod(0555, "foo");
2622 expected-stderr-pattern:
2623 /(.*can't unlink HISTFILE.*\n)?X*$/
2625 name: history-e-minus-1
2627 Check if more recent command is executed
2630 env-setup: !ENV=./Env!HISTFILE=hist.file!
2631 file-setup: file 644 "Env"
2641 expected-stderr-pattern:
2642 /^X*echo there\nX*$/
2644 name: history-e-minus-2
2646 Check that repeated command is printed before command
2650 env-setup: !ENV=./Env!HISTFILE=hist.file!
2651 file-setup: file 644 "Env"
2658 expected-stdout-pattern:
2659 /X*hi\nX*there\nX*echo there\nthere\nX*/
2660 expected-stderr-pattern:
2663 name: history-e-minus-3
2665 fc -e - fails when there is no history
2666 (ksh93 has a bug that causes this to fail)
2667 (ksh88 loops on this)
2670 env-setup: !ENV=./Env!HISTFILE=hist.file!
2671 file-setup: file 644 "Env"
2678 expected-stderr-pattern:
2679 /^X*.*:.*history.*\nX*$/
2681 name: history-e-minus-4
2683 Check if "fc -e -" command output goes to stdout.
2686 env-setup: !ENV=./Env!HISTFILE=hist.file!
2687 file-setup: file 644 "Env"
2691 fc -e - | (read x; echo "A $x")
2697 expected-stderr-pattern:
2700 name: history-e-minus-5
2702 fc is replaced in history by new command.
2705 env-setup: !ENV=./Env!HISTFILE=hist.file!
2706 file-setup: file 644 "Env"
2722 expected-stderr-pattern:
2723 /^X*echo ghi jkl\nX*$/
2725 name: history-list-1
2727 List lists correct range
2728 (ksh88 fails 'cause it lists the fc command)
2731 env-setup: !ENV=./Env!HISTFILE=hist.file!
2732 file-setup: file 644 "Env"
2745 expected-stderr-pattern:
2748 name: history-list-2
2750 Lists oldest history if given pre-historic number
2751 (ksh93 has a bug that causes this to fail)
2752 (ksh88 fails 'cause it lists the fc command)
2755 env-setup: !ENV=./Env!HISTFILE=hist.file!
2756 file-setup: file 644 "Env"
2770 expected-stderr-pattern:
2773 name: history-list-3
2775 Can give number 'options' to fc
2778 env-setup: !ENV=./Env!HISTFILE=hist.file!
2779 file-setup: file 644 "Env"
2794 expected-stderr-pattern:
2797 name: history-list-4
2799 -1 refers to previous command
2802 env-setup: !ENV=./Env!HISTFILE=hist.file!
2803 file-setup: file 644 "Env"
2817 expected-stderr-pattern:
2820 name: history-list-5
2822 List command stays in history
2825 env-setup: !ENV=./Env!HISTFILE=hist.file!
2826 file-setup: file 644 "Env"
2843 expected-stderr-pattern:
2846 name: history-list-6
2848 HISTSIZE limits about of history kept.
2849 (ksh88 fails 'cause it lists the fc command)
2852 env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3!
2853 file-setup: file 644 "Env"
2870 expected-stderr-pattern:
2873 name: history-list-7
2875 fc allows too old/new errors in range specification
2878 env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3!
2879 file-setup: file 644 "Env"
2897 expected-stderr-pattern:
2900 name: history-list-r-1
2902 test -r flag in history
2905 env-setup: !ENV=./Env!HISTFILE=hist.file!
2906 file-setup: file 644 "Env"
2924 expected-stderr-pattern:
2927 name: history-list-r-2
2929 If first is newer than last, -r is implied.
2932 env-setup: !ENV=./Env!HISTFILE=hist.file!
2933 file-setup: file 644 "Env"
2951 expected-stderr-pattern:
2954 name: history-list-r-3
2956 If first is newer than last, -r is cancelled.
2959 env-setup: !ENV=./Env!HISTFILE=hist.file!
2960 file-setup: file 644 "Env"
2978 expected-stderr-pattern:
2981 name: history-subst-1
2986 env-setup: !ENV=./Env!HISTFILE=hist.file!
2987 file-setup: file 644 "Env"
2992 fc -e - abc=AB 'echo a'
2997 expected-stderr-pattern:
2998 /^X*echo AB def\nX*$/
3000 name: history-subst-2
3002 Does subst find previous command?
3005 env-setup: !ENV=./Env!HISTFILE=hist.file!
3006 file-setup: file 644 "Env"
3011 fc -e - jkl=XYZQRT 'echo g'
3016 expected-stderr-pattern:
3017 /^X*echo ghi XYZQRT\nX*$/
3019 name: history-subst-3
3021 Does subst find previous command when no arguments given
3024 env-setup: !ENV=./Env!HISTFILE=hist.file!
3025 file-setup: file 644 "Env"
3035 expected-stderr-pattern:
3036 /^X*echo ghi XYZQRT\nX*$/
3038 name: history-subst-4
3040 Global substitutions work
3041 (ksh88 and ksh93 do not have -g option)
3044 env-setup: !ENV=./Env!HISTFILE=hist.file!
3045 file-setup: file 644 "Env"
3048 echo abc def asjj sadjhasdjh asdjhasd
3051 abc def asjj sadjhasdjh asdjhasd
3052 FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd
3053 expected-stderr-pattern:
3054 /^X*echo FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd\nX*$/
3056 name: history-subst-5
3058 Make sure searches don't find current (fc) command
3059 (ksh88/ksh93 don't have the ? prefix thing so they fail this test)
3062 env-setup: !ENV=./Env!HISTFILE=hist.file!
3063 file-setup: file 644 "Env"
3068 fc -e - abc=AB \?abc
3073 expected-stderr-pattern:
3074 /^X*echo AB def\nX*$/
3076 name: history-ed-1-old
3078 Basic (ed) editing works (assumes you have generic ed editor
3079 that prints no prompts). This is for oldish ed(1) which write
3080 the character count to stdout.
3085 env-setup: !ENV=./Env!HISTFILE=hist.file!
3086 file-setup: file 644 "Env"
3099 expected-stderr-pattern:
3100 /^X*echo FOOBAR def\nX*$/
3102 name: history-ed-2-old
3104 Correct command is edited when number given
3109 env-setup: !ENV=./Env!HISTFILE=hist.file!
3110 file-setup: file 644 "Env"
3118 s/is here/is changed/
3129 expected-stderr-pattern:
3130 /^X*echo line 2 is changed\nX*$/
3132 name: history-ed-3-old
3134 Newly created multi line commands show up as single command
3136 (NOTE: adjusted for COMPLEX HISTORY compile time option)
3137 (ksh88 fails 'cause it lists the fc command)
3142 env-setup: !ENV=./Env!HISTFILE=hist.file!
3143 file-setup: file 644 "Env"
3164 expected-stderr-pattern:
3165 /^X*echo FOOBAR def\necho a new line\nX*$/
3169 Basic (ed) editing works (assumes you have generic ed editor
3170 that prints no prompts). This is for newish ed(1) and stderr.
3171 category: !no-stderr-ed
3175 env-setup: !ENV=./Env!HISTFILE=hist.file!
3176 file-setup: file 644 "Env"
3187 expected-stderr-pattern:
3188 /^X*13\n16\necho FOOBAR def\nX*$/
3192 Correct command is edited when number given
3193 category: !no-stderr-ed
3197 env-setup: !ENV=./Env!HISTFILE=hist.file!
3198 file-setup: file 644 "Env"
3206 s/is here/is changed/
3215 expected-stderr-pattern:
3216 /^X*20\n23\necho line 2 is changed\nX*$/
3220 Newly created multi line commands show up as single command
3222 category: !no-stderr-ed
3226 env-setup: !ENV=./Env!HISTFILE=hist.file!
3227 file-setup: file 644 "Env"
3246 expected-stderr-pattern:
3247 /^X*13\n32\necho FOOBAR def\necho a new line\nX*$/
3251 Simple test, default IFS
3253 showargs() { for i; do echo -n " <$i>"; done; echo; }
3269 showargs() { for i; do echo -n " <$i>"; done; echo; }
3286 showargs() { for i; do echo -n " <$i>"; done; echo; }
3299 name: IFS-space-colon-1
3301 Simple test, IFS=<white-space>:
3303 showargs() { for i; do echo -n " <$i>"; done; echo; }
3318 name: IFS-space-colon-2
3320 Simple test, IFS=<white-space>:
3321 AT&T ksh fails this, POSIX says the test is correct.
3323 showargs() { for i; do echo -n " <$i>"; done; echo; }
3330 name: IFS-space-colon-4
3332 Simple test, IFS=<white-space>:
3334 showargs() { for i; do echo -n " <$i>"; done; echo; }
3341 name: IFS-space-colon-5
3343 Simple test, IFS=<white-space>:
3344 Don't know what POSIX thinks of this. AT&T ksh does not do this.
3346 showargs() { for i; do echo -n " <$i>"; done; echo; }
3355 Simple test, IFS=<white-space>:
3357 showargs() { for i; do echo -n " <$i>"; done; echo; }
3360 echo -n '1:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3361 echo -n '2:'; for i in :b:: ; do echo -n " [$i]" ; done ; echo
3365 echo -n '5:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3368 echo -n '7:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3370 echo -n '9:'; for i in ${FOO-`echo -n h:i`th:ere} ; do echo -n " [$i]" ; done ; echo
3371 showargs 10 ${FOO-`echo -n h:i`th:ere}
3372 showargs 11 "${FOO-`echo -n h:i`th:ere}"
3374 echo -n '12:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3386 <10> <h> <ith> <ere>
3391 name: integer-base-err-1
3393 Can't have 0 base (causes shell to exit)
3394 expected-exit: e != 0
3400 expected-stderr-pattern:
3403 name: integer-base-err-2
3405 Can't have multiple bases in a 'constant' (causes shell to exit)
3406 (ksh88 fails this test)
3407 expected-exit: e != 0
3413 expected-stderr-pattern:
3414 /^.*:.*2#110#11.*\n$/
3416 name: integer-base-err-3
3418 Syntax errors in expressions and effects on bases
3419 (interactive so errors don't cause exits)
3420 (ksh88 fails this test - shell exits, even with -i)
3424 PS1= # minimise prompt hassles
3431 expected-stderr-pattern:
3432 /^([#\$] )?.*:.*2+.*\n.*:.*2+.*\n$/
3437 name: integer-base-err-4
3439 Are invalid digits (according to base) errors?
3440 (ksh93 fails this test)
3441 expected-exit: e != 0
3445 expected-stderr-pattern:
3446 /^([#\$] )?.*:.*3#4.*\n$/
3448 name: integer-base-1
3450 Missing number after base is treated as 0.
3459 name: integer-base-2
3461 Check 'stickyness' of base in various situations
3512 name: integer-base-3
3514 More base parsing (hmm doesn't test much..)
3534 name: integer-base-4
3536 Check that things not declared as integers are not made integers,
3537 also, check if base is not reset by -i with no arguments.
3538 (ksh93 fails - prints 10#20 - go figure)
3542 typeset -i | grep '^xx='
3549 name: integer-base-5
3565 for l in 1 2+3 4; do echo $l; done
3577 name: integer-base-6
3579 Even more base stuff
3580 (ksh93 fails this test - prints 0)
3588 name: integer-base-7
3590 Check that non-integer parameters don't get bases assigned
3592 echo $(( zz = 8#100 ))
3600 See if $LINENO is updated and can be modified.
3613 See if $LINENO is set for .'d files.
3614 file-setup: file 644 "dotfile"
3632 See if $LINENO is set for commands in a function.
3651 See if unsetting LINENO makes it non-magic.
3652 file-setup: file 644 "dotfile"
3675 name: lineno-unset-use
3677 See if unsetting LINENO makes it non-magic even
3679 file-setup: file 644 "dotfile"
3705 Check if LINENO is tracked in traps
3711 trap 'fail $LINENO' INT ERR
3719 Ensure unknown traps are not a syntax error
3722 trap "echo trap 1 executed" UNKNOWNSIGNAL || echo "foo"
3724 trap "echo trap 2 executed" UNKNOWNSIGNAL EXIT 999999 FNORD
3726 ) 2>&1 | sed "s
\ 1^${__progname}: <stdin>\[[0-9]*]
\ 1PROG
\ 1"
3728 PROG: trap: bad signal 'UNKNOWNSIGNAL'
3731 PROG: trap: bad signal 'UNKNOWNSIGNAL'
3732 PROG: trap: bad signal '999999'
3733 PROG: trap: bad signal 'FNORD'
3739 Simple test, default IFS
3744 echo 1: "x[$x] y[$y] z[$z]"
3745 echo 1a: ${z-z not set}
3755 If no var specified, REPLY is used
3763 name: read-regress-1
3765 Check a regression of read
3766 file-setup: file 644 "foo"
3771 while read a b c; do
3775 echo "<$a|$b|$c><$d>"
3781 Check read with delimiters
3784 printf 'foo bar\tbaz\nblah \0blub\tblech\nmyok meck \0'
3786 emit | while IFS= read -d "" foo; do print -r -- "<$foo>"; done
3787 emit | while read -d "" foo; do print -r -- "<$foo>"; done
3788 emit | while read -d "eh?" foo; do print -r -- "<$foo>"; done
3805 Check read with number of bytes specified, and -A
3807 print 'foo\nbar' >x1
3809 print 'foo\\ bar baz' >x3
3811 x1b=u; read -N-1 x1b <x1
3812 x2a=u; read x2a <x2; r2a=$?
3813 x2b=u; read -N2 x2c <x2; r2b=$?
3814 x2c=u; read -n2 x2c <x2; r2c=$?
3815 x3a=u; read -A x3a <x3
3816 print -r "x1a=<$x1a>"
3817 print -r "x1b=<$x1b>"
3818 print -r "x2a=$r2a<$x2a>"
3819 print -r "x2b=$r2b<$x2b>"
3820 print -r "x2c=$r2c<$x2c>"
3821 print -r "x3a=<${x3a[0]}|${x3a[1]}|${x3a[2]}>"
3833 Lex array code had problems with this.
3844 When PATH is set before running a command, the new path is
3845 not used in doing the path search
3846 $ echo echo hi > /tmp/q ; chmod a+rx /tmp/q
3850 in comexec() the two lines
3852 (void) typeset(*vp++, xxx, 0);
3853 need to be moved out of the switch to before findcom() is
3854 called - I don't know what this will break.
3856 : ${PWD:-`pwd 2> /dev/null`}
3857 : ${PWD:?"PWD not set - can't do test"}
3859 cat > Y/xxxscript << EOF
3861 # Need to restore path so echo can be found (some shells don't have
3867 chmod a+rx Y/xxxscript
3868 export OLDPATH="$PATH"
3869 PATH=$PWD/Y xxxscript
3876 Parsing of $(..) expressions is non-optimal. It is
3877 impossible to have any parentheses inside the expression.
3879 $ ksh -c 'echo $(echo \( )'
3881 $ ksh -c 'echo $(echo "(" )'
3884 The solution is to hack the parsing clode in lex.c, the
3885 question is how to hack it: should any parentheses be
3886 escaped by a backslash, or should recursive parsing be done
3887 (so quotes could also be used to hide hem). The former is
3888 easier, the later better...
3896 Continue in a for loop does not work right:
3898 if [ $i = b ] ; then
3907 if [ $i = b ] ; then
3908 if [ $first = no ] ; then
3909 echo 'continue in for loop broken'
3910 break # hope break isn't broken too :-)
3925 should print 0 according to POSIX (dash, bash, ksh93, posh)
3926 but not 0 according to the getopt(1) manual page, ksh88, and
3927 Bourne sh (such as /bin/sh on Solaris).
3928 In mksh R39b, we honour POSIX except when -o sh is set.
3931 [[ -o posix ]]; FPOSIX=$((1-$?))
3932 [[ -o sh ]]; FSH=$((1-$?))
3933 echo -n "FPOSIX=$FPOSIX FSH=$FSH "
3957 should echo blah but on some machines echos /foo/bar/blah.
3966 Both of the following echos produce the same output under sh/ksh.att:
3969 echo "`echo \"$x\"`"
3971 pdksh produces different output for the former (foo instead of foo\tbar)
3974 echo "`echo \"$x\"`"
3982 The following command hangs forever:
3983 $ (: ; cat /etc/termcap) | sleep 2
3984 This is because the shell forks a shell to run the (..) command
3985 and this shell has the pipe open. When the sleep dies, the cat
3986 doesn't get a SIGPIPE 'cause a process (ie, the second shell)
3987 still has the pipe open.
3989 NOTE: this test provokes a bizarre bug in ksh93 (shell starts reading
3990 commands from /etc/termcap..)
3993 echo A line of text that will be duplicated quite a number of times.> t1
3994 cat t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 > t2
3995 cat t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 > t1
3996 cat t1 t1 t1 t1 > t2
3997 (: ; cat t2 2>&-) | sleep 1
4002 $ (foobar) 2> /dev/null
4003 generates no output under /bin/sh, but pdksh produces the error
4006 $ foobar 2> /dev/null
4007 generates an error under /bin/sh and pdksh, but AT&T ksh88 produces
4008 no error (redirected to /dev/null).
4010 (you/should/not/see/this/error/1) 2> /dev/null
4011 you/should/not/see/this/error/2 2> /dev/null
4018 generates a blank line under pdksh and sets the exit status to 0.
4019 AT&T ksh88 generates no output and sets the exit status to 1. Also,
4022 generates no output under AT&T ksh88 (pdksh generates a blank line
4025 whence does/not/exist > /dev/null
4027 echo 2: $(whence does/not/exist | wc -l)
4028 echo 3: $(whence does/not/exist cat | wc -l)
4036 ${var%%expr} seems to be broken in many places. On the mips
4038 $ read line < /etc/passwd
4046 change the value of line. On sun4s & pas, the echo ${line%%:*} doesn't
4047 work. Haven't checked elsewhere...
4054 root:asdjhasdasjhs:0:1:Root:/:/bin/sh
4057 root:asdjhasdasjhs:0:1:Root:/:/bin/sh
4063 should set the exit status to non-zero (sh and AT&T ksh88 do).
4064 XXX doting a non existent file is a fatal error for a script
4067 expected-exit: e != 0
4068 expected-stderr-pattern: /.?/
4072 Both of the following echos should produce the same thing, but don't:
4086 backslash does not work as expected in case labels:
4105 Quoting backquotes inside backquotes doesn't work:
4106 $ echo `echo hi \`echo there\` folks`
4107 asks for more info. sh and AT&T ksh88 both echo
4110 echo `echo hi \`echo there\` folks`
4116 )) is not treated `correctly':
4117 $ (echo hi ; (echo there ; echo folks))
4120 instead of (as sh and ksh.att)
4121 $ (echo hi ; (echo there ; echo folks))
4127 ( : ; ( : ; echo hi))
4133 Check reading stdin in a while loop. The read should only read
4134 a single line, not a whole stdio buffer; the cat should get
4137 (echo a; echo b) | while read x ; do
4146 Check reading stdin in a while loop. The read should read both
4147 lines, not just the first.
4150 while [ "$a" != xxx ] ; do
4153 cat /dev/null | sed 's/x/y/'
4167 should cause a script to exit.
4171 expected-exit: e != 0
4172 expected-stderr-pattern: /does\/not\/exist/
4176 variable assignements not detected well
4179 expected-exit: e != 0
4180 expected-stderr-pattern: /a\.x=1/
4184 alias expansion different from AT&T ksh88
4186 alias a='for ' b='i in'
4187 a b hi ; do echo $i ; done
4193 strange characters allowed inside ${...}
4196 expected-exit: e != 0
4197 expected-stderr-pattern: /.?/
4201 Does read handle partial lines correctly
4204 while [ "$a" != xxx ] ; do
4221 Does read set variables to null at eof?
4224 while [ "$a" != xxx ] ; do
4228 echo 1: ${x-x not set} ${y-y not set} ${z-z not set}
4229 echo 2: ${x:+x not null} ${y:+y not null} ${z:+z not null}
4239 Does umask print a leading 0 when umask is 3 digits?
4241 # on MiNT, the first umask call seems to fail
4243 # now, the test proper
4251 Tempory files used for here-docs in functions get trashed after
4252 the function is parsed (before it is executed)
4275 Command substitution breaks reading in while loop
4276 (test from <sjg@void.zen.oz.au>)
4278 (echo abcdef; echo; echo 123) |
4281 # the following line breaks it
4282 c=`echo $line | wc -c`
4292 Machines with broken times() (reported by <sjg@void.zen.oz.au>)
4293 time does not report correct real time
4296 expected-stderr-pattern: !/^\s*0\.0[\s\d]+real|^\s*real[\s]+0+\.0/
4300 set -e doesn't ignore exit codes for if/while/until/&&/||/!.
4303 if false; then echo hi ; fi
4306 while false; do echo hi; done
4313 set -e: errors in command substitutions aren't ignored
4314 Not clear if they should be or not... bash passes here
4315 this may actually be required for make, so changed the
4316 test to make this an mksh feature, not a bug
4319 echo `false; echo hi`
4328 This used to cause a core dump
4329 env-setup: !RANDOM=12!
4337 foo should be set to bar (should not be empty)
4347 Can't use command line assignments to assign readonly parameters.
4351 foo=stuff env | grep '^foo'
4352 expected-exit: e != 0
4353 expected-stderr-pattern:
4358 Can subshells be prefixed by redirections (historical shells allow
4361 < /dev/null (sed 's/^/X/')
4365 Parameter assignments with [] recognised correctly
4383 Check that alias expansion works in command substitutions and
4396 Check that aliases are fully read.
4409 Check that (here doc) temp files are not left behind after an exec.
4412 TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
4414 sed 's/^/X /' << E_O_F
4421 echo=echo; [ -x /bin/echo ] && echo=/bin/echo
4422 exec $echo subtest-1 hi
4424 echo subtest-1 foo/*
4425 TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
4426 echo=echo; [ -x /bin/echo ] && echo=/bin/echo
4427 sed 's/^/X /' << E_O_F; exec $echo subtest-2 hi
4433 echo subtest-2 foo/*
4445 Check that unset params with attributes are reported by set, those
4446 sans attributes are not.
4462 Check that aliases do not use continuation prompt after trailing
4464 file-setup: file 644 "env"
4467 env-setup: !ENV=./env!
4471 alias foo='echo hi ; '
4483 Check that set allows both +o and -o options on same command line.
4486 set -o noglob +o allexport
4493 Check that globbing works in pipelined commands
4494 file-setup: file 644 "env"
4496 file-setup: file 644 "abc"
4498 env-setup: !ENV=./env!
4504 sed 's/^/X /' < ab* | sed 's/^/Y /'
4516 Check that getopts works in functions
4519 echo bfunc: enter "(args: $*; OPTIND=$OPTIND)"
4520 while getopts B oc; do
4523 echo bfunc: B option
4526 echo bfunc: odd option "($oc)"
4534 echo kfunc: enter "(args: $*; OPTIND=$OPTIND)"
4535 while getopts K oc; do
4538 echo kfunc: K option
4541 echo bfunc: odd option "($oc)"
4549 echo "line 1: OPTIND=$OPTIND"
4551 echo "line 2: ret=$?, optc=$optc, OPTIND=$OPTIND"
4553 echo "line 3: OPTIND=$OPTIND"
4555 echo "line 4: ret=$?, optc=$optc, OPTIND=$OPTIND"
4557 echo "line 5: OPTIND=$OPTIND"
4559 echo "line 6: ret=$?, optc=$optc, OPTIND=$OPTIND"
4564 echo "line 10: OPTIND=$OPTIND"
4566 echo "line 20: ret=$?, optc=$optc, OPTIND=$OPTIND"
4568 echo "line 30: OPTIND=$OPTIND"
4570 echo "line 40: ret=$?, optc=$optc, OPTIND=$OPTIND"
4572 echo "line 50: OPTIND=$OPTIND"
4574 echo "line 60: ret=$?, optc=$optc, OPTIND=$OPTIND"
4577 line 2: ret=0, optc=f, OPTIND=2
4578 bfunc: enter (args: -BBB blah; OPTIND=2)
4583 line 4: ret=0, optc=b, OPTIND=3
4584 kfunc: enter (args: -KKK blah; OPTIND=1)
4590 line 6: ret=0, optc=k, OPTIND=4
4593 line 20: ret=0, optc=f, OPTIND=2
4594 bfunc: enter (args: -BBB blah; OPTIND=2)
4599 line 40: ret=1, optc=?, OPTIND=2
4600 kfunc: enter (args: -KKK blah; OPTIND=1)
4606 line 60: ret=1, optc=?, OPTIND=2
4610 Check that ; is not required before the then in if (( ... )) then ...
4624 Check ${foo:%bar} is allowed (ksh88 allows it...)
4647 Check if typeset output is correct for
4648 uninitialised array elements.
4652 typeset -i | grep xxx | sed 's/^/ /'
4654 typeset | grep xxx | sed 's/^/ /'
4658 typeset -i | grep xxx | sed 's/^/ /'
4660 typeset | grep xxx | sed 's/^/ /'
4673 Check if trap exit is ok (exit not mistaken for signal name)
4682 Check if ${#array[*]} is calculated correctly.
4692 Check if default exit status is previous command
4698 ( (exit 103) ; exit)
4707 Check if EXIT trap is executed for sub shells.
4709 trap 'echo parent exit' EXIT
4711 (echo A; echo A last)
4713 (echo C; trap 'echo sub exit' EXIT; echo C last)
4728 Check if test -nt/-ot succeeds if second(first) file is missing.
4731 test a -nt b && echo nt OK || echo nt BAD
4732 test b -ot a && echo ot OK || echo ot BAD
4739 Check if typeset, export, and readonly work
4751 integer FNORD_E FNORD_F FNORD_G FNORD_H
4752 export FNORD_C FNORD_D FNORD_G FNORD_H
4753 readonly FNORD_B FNORD_D FNORD_F FNORD_H
4796 typeset -x -r FNORD_D
4798 typeset -i -r FNORD_F
4799 typeset -i -x FNORD_G
4800 typeset -i -x -r FNORD_H
4803 typeset -r FNORD_B=2
4804 typeset -x FNORD_C=3
4805 typeset -x -r FNORD_D=4
4806 typeset -i FNORD_E=5
4807 typeset -i -r FNORD_F=6
4808 typeset -i -x FNORD_G=7
4809 typeset -i -x -r FNORD_H=8
4823 Check that we can redefine functions calling time builtin
4835 check for a regression with sleep builtin and signal mask
4841 while read -p line; do :; done
4848 Ensure readonly is honoured for assignments and unset
4850 "$__progname" -c 'u=x; echo $? $u .' || echo aborted, $?
4852 "$__progname" -c 'readonly u; u=x; echo $? $u .' || echo aborted, $?
4854 "$__progname" -c 'u=x; readonly u; unset u; echo $? $u .' || echo aborted, $?
4861 expected-stderr-pattern:
4866 http://austingroupbugs.net/view.php?id=367 for export
4868 "$__progname" -c 'readonly foo; export foo=a; echo $?' || echo aborted, $?
4871 expected-stderr-pattern:
4876 Check that getopts works as intended, for readonly-2b to be valid
4878 "$__progname" -c 'set -- -a b; getopts a c; echo $? $c .; getopts a c; echo $? $c .' || echo aborted, $?
4885 http://austingroupbugs.net/view.php?id=367 for getopts
4887 "$__progname" -c 'readonly c; set -- -a b; getopts a c; echo $? $c .' || echo aborted, $?
4890 expected-stderr-pattern:
4895 http://austingroupbugs.net/view.php?id=367 for read
4897 echo x | "$__progname" -c 'read s; echo $? $s .' || echo aborted, $?
4898 echo y | "$__progname" -c 'readonly s; read s; echo $? $s .' || echo aborted, $?
4902 expected-stderr-pattern:
4907 Check that lone ampersand is a syntax error
4910 expected-exit: e != 0
4911 expected-stderr-pattern:
4914 name: xxx-quoted-newline-1
4916 Check that \<newline> works inside of ${}
4924 name: xxx-quoted-newline-2
4926 Check that \<newline> works at the start of a here document
4935 name: xxx-quoted-newline-3
4937 Check that \<newline> works at the end of a here document
4946 name: xxx-multi-assignment-cmd
4948 Check that assignments in a command affect subsequent assignments
4957 name: xxx-multi-assignment-posix-cmd
4959 Check that the behaviour for multiple assignments with a
4960 command name matches POSIX. See:
4961 http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925
4963 X=a Y=b; X=$Y Y=$X "$__progname" -c 'echo 1 $X $Y .'; echo 2 $X $Y .
4965 X=a Y=${X=b} Z=$X "$__progname" -c 'echo 3 $Z .'
4967 X=a Y=${X=b} Z=$X; echo 4 $Z .
4974 name: xxx-multi-assignment-posix-nocmd
4976 Check that the behaviour for multiple assignments with no
4977 command name matches POSIX (Debian #334182). See:
4978 http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925
4980 X=a Y=b; X=$Y Y=$X; echo 1 $X $Y .
4984 name: xxx-multi-assignment-posix-subassign
4986 Check that the behaviour for multiple assignments matches POSIX:
4987 - The assignment words shall be expanded in the current execution
4989 - The assignments happen in the temporary execution environment.
4992 Z=a Y=${X:=b} sh -c 'echo +$X+ +$Y+ +$Z+'
4994 # Now for the special case:
4996 X= Y=${X:=b} sh -c 'echo +$X+ +$Y+'
5004 name: xxx-exec-environment-1
5006 Check to see if exec sets it's environment correctly
5009 expected-stdout-pattern:
5012 name: xxx-exec-environment-2
5014 Check to make sure exec doesn't change environment if a program
5017 sortprog=$(whence -p sort) || sortprog=cat
5018 env | $sortprog | grep -v '^RANDOM=' >bar1
5019 FOO=bar exec; env | $sortprog | grep -v '^RANDOM=' >bar2
5022 name: exec-function-environment-1
5024 Check assignments in function calls and whether they affect
5025 the current execution environment (ksh93, SUSv4)
5027 f() { a=2; }; g() { b=3; echo y$c-; }; a=1 f; b=2; c=1 g
5033 name: xxx-what-do-you-call-this-1
5039 name: xxx-prefix-strip-1
5046 name: xxx-prefix-strip-2
5054 name: xxx-variable-syntax-1
5057 expected-stderr-pattern:
5061 name: xxx-variable-syntax-2
5065 expected-stderr-pattern:
5069 name: xxx-variable-syntax-3
5073 expected-stderr-pattern:
5077 name: xxx-substitution-eval-order
5079 Check order of evaluation of expressions
5082 set -A A abc def GHI j G k
5083 echo ${A[x=(i+=1)]#${A[y=(i+=2)]}}
5089 name: xxx-set-option-1
5091 Check option parsing in set
5093 set -vsA foo -- A 1 3 2
5102 Check that exec exits for built-ins
5110 expected-stderr-pattern: /.*/
5114 Check the return value of while loops
5115 XXX need to do same for for/select/until loops
5118 while [ $i != xxx ] ; do
5120 if [ $i = xxx ] ; then
5128 while [ $i != xxx ] ; do
5130 if [ $i = xxx ] ; then
5138 while [ $i != xxx ] ; do
5150 Check that blank lines don't clear $?
5163 expected-stderr-pattern: /.*/
5167 Check that $? is preserved in subshells, includes, traps.
5176 echo 'echo include: $?' > foo
5180 trap 'echo trap: $?' ERR
5190 name: xxx-clean-chars-1
5192 Check MAGIC character is stuffed correctly
5198 name: xxx-param-subst-qmark-1
5200 Check suppresion of error message with null string. According to
5201 POSIX, it shouldn't print the error as 'word' isn't ommitted.
5202 ksh88/93, Solaris /bin/sh and /usr/xpg4/bin/sh all print the error,
5203 that's why the condition is reversed.
5211 #expected-stderr-pattern: !/not set/
5213 expected-stderr-pattern: /parameter null or not set/
5216 # fails due to weirdness of execv stuff
5217 category: !os:uwin-nt
5219 Check c flag is set.
5220 arguments: !-c!echo "[$-]"!
5221 expected-stdout-pattern: /^\[.*c.*\]$/
5223 name: tilde-expand-1
5225 Check tilde expansion after equal signs
5226 env-setup: !HOME=/sweet!
5228 echo ${A=a=}~ b=~ c=d~ ~
5230 echo ${A=a=}~ b=~ c=d~ ~
5232 a=/sweet b=/sweet c=d~ /sweet
5237 Check some "exit on error" conditions
5240 env false && echo something
5250 Check some "exit on error" edge conditions (POSIXly)
5254 env false && echo something
5266 pdksh regression which AT&T ksh does right
5267 TFM says: [set] -e | errexit
5268 Exit (after executing the ERR trap) ...
5270 trap 'echo EXIT' EXIT
5273 cd /XXXXX 2>/dev/null
5279 expected-exit: e != 0
5283 "set -e" test suite (POSIX)
5297 "set -e" test suite (POSIX)
5303 [ "$1" = "$E" ] && { shift ; continue 2 ; }
5320 "set -e" test suite (BSD make)
5324 print 'all:\n\t@echo eins\n\t@exit 42\n' >zd/a/Makefile
5325 print 'all:\n\t@echo zwei\n' >zd/b/Makefile
5328 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"
5334 Stop in WD/zd/a (line 2 of Makefile).
5338 SUSv4 says that the shell should exit with 126/127 in some situations
5342 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
5343 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
5345 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
5346 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
5348 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
5349 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r .
5360 Check eval vs substitution exit codes (ksh93 alike)
5368 eval "eval $(false)"
5370 eval 'eval '"$(false)"
5373 eval $(echo :; false)
5385 Check that "exit" with no arguments behaves SUSv4 conformant.
5387 trap 'echo hi; exit' EXIT
5395 Check that test also can handle string1 < string2 etc.
5397 test 2005/10/08 '<' 2005/08/21 && echo ja || echo nein
5398 test 2005/08/21 \< 2005/10/08 && echo ja || echo nein
5399 test 2005/10/08 '>' 2005/08/21 && echo ja || echo nein
5400 test 2005/08/21 \> 2005/10/08 && echo ja || echo nein
5406 expected-stderr-pattern: !/unexpected op/
5408 name: test-precedence-1
5410 Check a weird precedence case (and POSIX echo)
5414 test -n "$POSH_VERSION" || set -o sh
5421 Test the test -o operator
5426 [[ -o $1 ]]; echo $?
5429 test -o $1 -o -o !$1; echo $?
5430 [ -o $1 -o -o !$1 ]; echo $?
5431 [[ -o $1 || -o !$1 ]]; echo $?
5432 test -o ?$1; echo $?
5434 echo 0y $(if_test utf8-mode) =
5435 echo 0n $(if_test utf8-hack) =
5436 echo 1= $(runtest utf8-hack) =
5437 echo 2= $(runtest !utf8-hack) =
5438 echo 3= $(runtest ?utf8-hack) =
5440 echo 1+ $(runtest utf8-mode) =
5441 echo 2+ $(runtest !utf8-mode) =
5442 echo 3+ $(runtest ?utf8-mode) =
5444 echo 1- $(runtest utf8-mode) =
5445 echo 2- $(runtest !utf8-mode) =
5446 echo 3- $(runtest ?utf8-mode) =
5447 echo = short flags =
5448 echo 0y $(if_test -U) =
5449 echo 0y $(if_test +U) =
5450 echo 0n $(if_test -_) =
5451 echo 0n $(if_test -U-) =
5452 echo 1= $(runtest -_) =
5453 echo 2= $(runtest !-_) =
5454 echo 3= $(runtest ?-_) =
5456 echo 1+ $(runtest -U) =
5457 echo 2+ $(runtest !-U) =
5458 echo 3+ $(runtest ?-U) =
5459 echo 1+ $(runtest +U) =
5460 echo 2+ $(runtest !+U) =
5461 echo 3+ $(runtest ?+U) =
5463 echo 1- $(runtest -U) =
5464 echo 2- $(runtest !-U) =
5465 echo 3- $(runtest ?-U) =
5466 echo 1- $(runtest +U) =
5467 echo 2- $(runtest !+U) =
5468 echo 3- $(runtest ?+U) =
5504 Check that ~/.mkshrc works correctly.
5505 Part 1: verify user environment is not read (internal)
5513 Check that ~/.mkshrc works correctly.
5514 Part 2: verify mkshrc is not read (non-interactive shells)
5515 file-setup: file 644 ".mkshrc"
5517 env-setup: !HOME=.!ENV=!
5525 Check that ~/.mkshrc works correctly.
5526 Part 2: verify mkshrc can be read (interactive shells)
5527 file-setup: file 644 ".mkshrc"
5531 env-setup: !HOME=.!ENV=!PS1=!
5536 expected-stderr-pattern:
5541 Check that ~/.mkshrc works correctly.
5542 Part 3: verify mkshrc can be turned off
5543 file-setup: file 644 ".mkshrc"
5545 env-setup: !HOME=.!ENV=nonexistant!
5553 Check that sh mode turns braceexpand off
5554 and that that works correctly
5558 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
5559 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
5567 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
5568 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
5571 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh
5572 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex
5588 Check that sh mode is *not* automatically turned on
5591 ln -s "$__progname" ksh
5592 ln -s "$__progname" sh
5593 ln -s "$__progname" ./-ksh
5594 ln -s "$__progname" ./-sh
5595 for shell in {,-}{,k}sh; do
5596 print -- $shell $(./$shell +l -c \
5597 '[[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh')
5607 Check that sh mode *is* automatically turned on
5610 ln -s "$__progname" ksh
5611 ln -s "$__progname" sh
5612 ln -s "$__progname" ./-ksh
5613 ln -s "$__progname" ./-sh
5614 for shell in {,-}{,k}sh; do
5615 print -- $shell $(./$shell +l -c \
5616 '[[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh')
5626 pdksh bug: last command of a pipeline is executed in a
5627 subshell - make sure it still is, scripts depend on it
5628 file-setup: file 644 "abcx"
5629 file-setup: file 644 "abcy"
5632 echo a | while read d; do
5652 check that co-processes work with TCOMs, TPIPEs and TPARENs
5655 "$__progname" -c 'i=100; echo hi |& while read -p line; do echo "$((i++)) $line"; done'
5656 "$__progname" -c 'i=200; echo hi | cat |& while read -p line; do echo "$((i++)) $line"; done'
5657 "$__progname" -c 'i=300; (echo hi | cat) |& while read -p line; do echo "$((i++)) $line"; done'
5665 Check that PIPESTATUS does what it's supposed to
5667 echo 1 $PIPESTATUS .
5668 echo 2 ${PIPESTATUS[0]} .
5669 echo 3 ${PIPESTATUS[1]} .
5670 (echo x; exit 12) | (cat; exit 23) | (cat; exit 42)
5671 echo 5 $? , $PIPESTATUS , ${PIPESTATUS[0]} , ${PIPESTATUS[1]} , ${PIPESTATUS[2]} , ${PIPESTATUS[3]} .
5672 echo 6 ${PIPESTATUS[0]} .
5673 set | fgrep PIPESTATUS
5674 echo 8 $(set | fgrep PIPESTATUS) .
5680 5 42 , 12 , 12 , 23 , 42 , .
5683 8 PIPESTATUS[0]=0 PIPESTATUS[1]=0 .
5685 name: persist-history-1
5687 Check if persistent history saving works
5688 category: !no-histfile
5691 env-setup: !ENV=./Env!HISTFILE=hist.file!
5692 file-setup: file 644 "Env"
5696 expected-stdout-pattern:
5698 expected-stderr-pattern:
5703 Check that global does what typeset is supposed to do
5707 global -Uui16 arrfoo[*]
5709 echo before ${arrfoo[0]} .
5711 echo after ${arrfoo[0]} .
5714 echo inside before ${arrbar[0]} .
5716 echo inside changed ${arrbar[0]} .
5717 global -Uui16 arrbar[*]
5718 echo inside typeset ${arrbar[0]} .
5720 echo inside changed ${arrbar[0]} .
5722 echo before ${arrbar[0]} .
5724 echo after ${arrbar[0]} .
5731 inside typeset 16#61 .
5732 inside changed 16#30 .
5735 name: typeset-padding-1
5737 Check if left/right justification works as per TFM
5739 typeset -L10 ln=0hall0
5740 typeset -R10 rn=0hall0
5741 typeset -ZL10 lz=0hall0
5742 typeset -ZR10 rz=0hall0
5743 typeset -Z10 rx=" hallo "
5744 echo "<$ln> <$rn> <$lz> <$rz> <$rx>"
5746 <0hall0 > < 0hall0> <hall0 > <00000hall0> <0000 hallo>
5748 name: typeset-padding-2
5750 Check if base-!10 integers are padded right
5752 typeset -Uui16 -L9 ln=16#1
5753 typeset -Uui16 -R9 rn=16#1
5754 typeset -Uui16 -Z9 zn=16#1
5758 echo "<$ln> <$rn> <$zn> <$ls> <$rs> <$zs>"
5760 <16#1 > < 16#1> <16#000001> <16#1 > < 16#1> <0000016#1>
5764 Check that the UTF-8 Byte Order Mark is ignored as the first
5765 multibyte character of the shell input (with -c, from standard
5766 input, as file, or as eval argument), but nowhere else
5767 # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
5768 category: !os:darwin
5771 print '#!/bin/sh\necho ohne' >foo/fnord
5772 print '#!/bin/sh\necho mit' >foo/fnord
5773 print 'fnord\nfnord\nfnord\nfnord' >foo/bar
5774 print eval \''fnord\nfnord\nfnord\nfnord'\' >foo/zoo
5775 set -A anzahl -- foo/*
5776 echo got ${#anzahl[*]} files
5778 export PATH=$(pwd)/foo:$PATH
5779 "$__progname" -c 'fnord'
5781 "$__progname" -c 'fnord; fnord; fnord; fnord'
5783 "$__progname" foo/bar
5785 "$__progname" <foo/bar
5787 "$__progname" foo/zoo
5789 "$__progname" -c 'echo : $(fnord)'
5819 Check that we can execute BOM-shebangs (failures not fatal)
5820 XXX if the OS can already execute them, we lose
5821 note: cygwin execve(2) doesn't return to us with ENOEXEC, we lose
5822 note: Ultrix perl5 t4 returns 65280 (exit-code 255) and no text
5824 category: !os:cygwin,!os:uwin-nt,!os:ultrix,!smksh
5825 env-setup: !FOO=BAR!
5827 print '#!'"$__progname"'\nprint "1 a=$ENV{FOO}";' >t1
5828 print '#!'"$__progname"'\nprint "2 a=$ENV{FOO}";' >t2
5829 print '#!'"$__perlname"'\nprint "3 a=$ENV{FOO}\n";' >t3
5830 print '#!'"$__perlname"'\nprint "4 a=$ENV{FOO}\n";' >t4
5837 1 a=/nonexistant{FOO}
5838 2 a=/nonexistant{FOO}
5841 expected-stderr-pattern:
5842 /(Unrecognized character .... ignored at \..t4 line 1)*/
5846 Reading the UTF-8 BOM should enable the utf8-mode flag
5847 (temporarily for COMSUBs)
5849 "$__progname" -c ':; if [[ $- = *U* ]]; then echo 1 on; else echo 1 off; fi'
5850 "$__progname" -c ':; if [[ $- = *U* ]]; then echo 2 on; else echo 2 off; fi'
5851 "$__progname" -c 'if [[ $- = *U* ]]; then echo 3 on; else echo 3 off; fi; x=$(:; if [[ $- = *U* ]]; then echo 4 on; else echo 4 off; fi); echo $x; if [[ $- = *U* ]]; then echo 5 on; else echo 5 off; fi'
5861 Check that the utf8-mode flag is not set at non-interactive startup
5863 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8!
5865 if [[ $- = *U* ]]; then
5875 Check that the utf8-mode flag is not set at non-interactive startup
5877 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.utf8!
5879 if [[ $- = *U* ]]; then
5889 Check that the utf8-mode flag is set at interactive startup.
5890 -DMKSH_ASSUME_UTF8=0 => expected failure, please ignore
5891 -DMKSH_ASSUME_UTF8=1 => not expected, please investigate
5892 -UMKSH_ASSUME_UTF8 => not expected, but if your OS is old,
5893 try passing HAVE_SETLOCALE_CTYPE=0 to Build.sh
5898 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8!
5900 if [[ $- = *U* ]]; then
5907 expected-stderr-pattern:
5912 Check that the utf8-mode flag is set at interactive startup
5913 Expected failure if -DMKSH_ASSUME_UTF8=0
5917 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.utf8!
5919 if [[ $- = *U* ]]; then
5926 expected-stderr-pattern:
5931 Ensure ±U on the command line is honoured
5932 (these two tests may pass falsely depending on CPPFLAGS)
5935 code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi'
5936 let i++; "$__progname" -U -c "$code"
5937 let i++; "$__progname" +U -c "$code"
5946 Ensure ±U on the command line is honoured, interactive shells
5950 code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi'
5951 let i++; "$__progname" -U -ic "$code"
5952 let i++; "$__progname" +U -ic "$code"
5961 Check if built-in shell aliases are okay
5962 category: !android,!arge
5967 autoload='typeset -fu'
5968 functions='typeset -f'
5971 integer='typeset -i'
5974 nameref='typeset -n'
5977 source='PATH=$PATH:. command .'
5979 suspend='kill -STOP $$'
5982 name: aliases-1-hartz4
5984 Check if built-in shell aliases are okay
5985 category: android,arge
5990 autoload='typeset -fu'
5991 functions='typeset -f'
5994 integer='typeset -i'
5997 nameref='typeset -n'
6000 source='PATH=$PATH:. command .'
6005 Check if “set -o sh” disables built-in aliases (except a few)
6012 integer='typeset -i'
6017 Check if running as sh disables built-in aliases (except a few)
6021 ./sh -c 'alias; typeset -f'
6024 integer='typeset -i'
6029 Check if “set -o sh” does not influence built-in aliases
6030 category: !android,!arge
6036 autoload='typeset -fu'
6037 functions='typeset -f'
6040 integer='typeset -i'
6043 nameref='typeset -n'
6046 source='PATH=$PATH:. command .'
6048 suspend='kill -STOP $$'
6053 Check if running as sh does not influence built-in aliases
6054 category: !android,!arge
6057 ./sh -c 'alias; typeset -f'
6060 autoload='typeset -fu'
6061 functions='typeset -f'
6064 integer='typeset -i'
6067 nameref='typeset -n'
6070 source='PATH=$PATH:. command .'
6072 suspend='kill -STOP $$'
6075 name: aliases-2b-hartz4
6077 Check if “set -o sh” does not influence built-in aliases
6078 category: android,arge
6084 autoload='typeset -fu'
6085 functions='typeset -f'
6088 integer='typeset -i'
6091 nameref='typeset -n'
6094 source='PATH=$PATH:. command .'
6097 name: aliases-3b-hartz4
6099 Check if running as sh does not influence built-in aliases
6100 category: android,arge
6103 ./sh -c 'alias; typeset -f'
6106 autoload='typeset -fu'
6107 functions='typeset -f'
6110 integer='typeset -i'
6113 nameref='typeset -n'
6116 source='PATH=$PATH:. command .'
6119 name: aliases-funcdef-1
6121 Check if POSIX functions take precedences over aliases
6123 alias foo='echo makro'
6131 name: aliases-funcdef-2
6133 Check if POSIX functions take precedences over aliases
6135 alias foo='echo makro'
6143 name: aliases-funcdef-3
6145 Check if aliases take precedences over Korn functions
6147 alias foo='echo makro'
6155 name: aliases-funcdef-4
6157 Functions should only take over if actually being defined
6168 Check if Korn Shell arrays work as expected
6171 set -A foo -- a \$v "$v" '$v' b
6172 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
6178 Check if bash-style arrays work as expected
6182 foo=(a \$v "$v" '$v' b)
6183 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
6189 Check if bash-style arrays work as expected, with newlines
6192 test -n "$ZSH_VERSION" && setopt KSH_ARRAYS
6198 printf '%s|' "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
6203 printf '%s|' "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
6208 printf '%s|' "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo
6210 7|a|bc|d|$v|e f|$v|g|
6211 7|a|bc|d|$v|e f|$v|g|
6212 6|abc\|d|$v|e f|$v|g||
6216 Check if array bounds are uint32_t
6223 echo ${foo[4294967295]} g ${foo[*]}
6230 Check if Korn Shell arrays with specified indices work as expected
6234 set -A foo -- [1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b
6235 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|"
6241 Check if bash-style arrays with specified indices work as expected
6245 foo=([1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b)
6246 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|"
6247 x=([128]=foo bar baz)
6257 Check if we can get the array keys (indices) for indexed arrays,
6263 echo -n "$((i++))<$x>"
6274 echo a $(of ${foo[*]}) = $(of ${bar[*]}) a
6275 echo b $(of "${foo[*]}") = $(of "${bar[*]}") b
6276 echo c $(of ${foo[@]}) = $(of ${bar[@]}) c
6277 echo d $(of "${foo[@]}") = $(of "${bar[@]}") d
6278 echo e $(of ${!foo[*]}) = $(of ${!bar[*]}) e
6279 echo f $(of "${!foo[*]}") = $(of "${!bar[*]}") f
6280 echo g $(of ${!foo[@]}) = $(of ${!bar[@]}) g
6281 echo h $(of "${!foo[@]}") = $(of "${!bar[@]}") h
6289 a 0<zwei>1<eins>2<drei> = a
6290 b 0<zwei eins drei> = 0<> b
6291 c 0<zwei>1<eins>2<drei> = c
6292 d 0<zwei>1<eins>2<drei> = d
6300 Check if we can get the array keys (indices) for indexed arrays,
6301 Korn shell style, in some corner cases
6304 echo !arz[0]: ${!arz[0]}
6305 echo !arz[1]: ${!arz[1]}
6308 echo !arz[0]: ${!arz[0]}
6309 echo !arz[1]: ${!arz[1]}
6312 echo !arz[0]: ${!arz[0]}
6313 echo !arz[1]: ${!arz[1]}
6327 Check some behavioural rules for arrays.
6365 typeset -Z3 aa ab ac ad ae af ag
6410 Check that we can concatenate arrays
6413 unset foo; foo=(bar); foo+=(baz); echo 1 ${!foo[*]} : ${foo[*]} .
6414 unset foo; foo=(foo bar); foo+=(baz); echo 2 ${!foo[*]} : ${foo[*]} .
6415 unset foo; foo=([2]=foo [0]=bar); foo+=(baz [5]=quux); echo 3 ${!foo[*]} : ${foo[*]} .
6418 2 0 1 2 : foo bar baz .
6419 3 0 2 3 5 : bar foo baz quux .
6423 Check that we can concatenate parameters too
6425 unset foo; foo=bar; foo+=baz; echo 1 $foo .
6426 unset foo; typeset -i16 foo=10; foo+=20; echo 2 $foo .
6431 name: varexpand-substr-1
6433 Check if bash-style substring expansion works
6434 when using positive numerics
6437 typeset -i y=123456789
6438 typeset -i 16 z=123456789 # 16#75bcd15
6439 echo a t${x:2:2} ${y:2:3} ${z:2:3} a
6440 echo b ${x::3} ${y::3} ${z::3} b
6441 echo c ${x:2:} ${y:2:} ${z:2:} c
6442 echo d ${x:2} ${y:2} ${z:2} d
6443 echo e ${x:2:6} ${y:2:6} ${z:2:7} e
6444 echo f ${x:2:7} ${y:2:7} ${z:2:8} f
6445 echo g ${x:2:8} ${y:2:8} ${z:2:9} g
6450 d cdefghi 3456789 #75bcd15 d
6451 e cdefgh 345678 #75bcd1 e
6452 f cdefghi 3456789 #75bcd15 f
6453 g cdefghi 3456789 #75bcd15 g
6455 name: varexpand-substr-2
6457 Check if bash-style substring expansion works
6458 when using negative numerics or expressions
6461 typeset -i y=123456789
6462 typeset -i 16 z=123456789 # 16#75bcd15
6464 echo a ${x:$n:3} ${y:$n:3} ${z:$n:3} a
6465 echo b ${x:(n):3} ${y:(n):3} ${z:(n):3} b
6466 echo c ${x:(-2):1} ${y:(-2):1} ${z:(-2):1} c
6467 echo d t${x: n:2} ${y: n:3} ${z: n:3} d
6474 name: varexpand-substr-3
6476 Check that some things that work in bash fail.
6477 This is by design. And that some things fail in both.
6479 export x=abcdefghi n=2
6480 "$__progname" -c 'echo v${x:(n)}x'
6481 "$__progname" -c 'echo w${x: n}x'
6482 "$__progname" -c 'echo x${x:n}x'
6483 "$__progname" -c 'echo y${x:}x'
6484 "$__progname" -c 'echo z${x}x'
6485 "$__progname" -c 'x=abcdef;y=123;echo ${x:${y:2:1}:2}' >/dev/null 2>&1; echo $?
6491 expected-stderr-pattern:
6492 /x:n.*bad substitution.*\n.*bad substitution/
6494 name: varexpand-substr-4
6496 Check corner cases for substring expansion
6500 echo a ${x:(y == 1 ? 2 : 3):4} a
6504 name: varexpand-substr-5A
6506 Check that substring expansions work on characters
6510 echo a ${x::1} ${x: -1} a
6511 echo b ${x::3} ${x: -3} b
6512 echo c ${x:1:2} ${x: -3:2} c
6520 name: varexpand-substr-5W
6522 Check that substring expansions work on characters
6526 echo a ${x::1} ${x: -1} a
6527 echo b ${x::2} ${x: -2} b
6528 echo c ${x:1:1} ${x: -2:1} c
6536 name: varexpand-substr-6
6538 Check that string substitution works correctly
6543 echo a ${baz: foo: bar}
6544 echo b ${baz: foo: $bar}
6545 echo c ${baz: $foo: bar}
6546 echo d ${baz: $foo: $bar}
6553 name: varexpand-special-hash
6555 Check special ${var@x} expansion for x=hash
6560 print ${foo@#} ${bar@#} ${baz@#} .
6562 D50219A0 20E5DB5B 00000001 .
6564 name: varexpand-null-1
6566 Ensure empty strings expand emptily
6569 print z ${a#?} ${b%?} w
6570 print v ${a=} ${b/c/d} u
6576 name: varexpand-null-2
6578 Ensure empty strings, when quoted, are expanded as empty strings
6580 printf '<%s> ' 1 "${a}" 2 "${a#?}" + "${b%?}" 3 "${a=}" + "${b/c/d}"
6583 <1> <> <2> <> <+> <> <3> <> <+> <> .
6585 name: print-funny-chars
6587 Check print builtin's capability to output designated characters
6589 print '<\0144\0344\xDB\u00DB\u20AC\uDB\x40>'
6595 Check print builtin's \c escape
6597 print '\ca'; print b
6601 name: print-nul-chars
6603 Check handling of NUL characters for print and read
6604 note: second line should output “4 3” but we cannot
6605 handle NUL characters in strings yet
6607 print $(($(print '<\0>' | wc -c)))
6609 print $(($(print "$x" | wc -c))) ${#x}
6616 Check backslash expansion by the print builtin
6618 print '\ \!\"\#\$\%\&'\\\''\(\)\*\+\,\-\.\/\0\1\2\3\4\5\6\7\8' \
6619 '\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T' \
6620 '\U\V\W\X\Y\Z\[\\\]\^\_\`\a\b \d\e\f\g\h\i\j\k\l\m\n\o\p' \
6621 '\q\r\s\t\u\v\w\x\y\z\{\|\}\~' '\u20acd' '\U20acd' '\x123' \
6622 '\0x' '\0123' '\01234' | {
6623 # integer-base-one-3As
6624 typeset -Uui16 -Z11 pos=0
6625 typeset -Uui16 -Z5 hv=2147483647
6629 while IFS= read -r line; do
6631 while [[ -n $line ]]; do
6633 if (( (pos & 15) == 0 )); then
6634 (( pos )) && print "$dasc|"
6635 print -n "${pos#16#} "
6638 print -n "${hv#16#} "
6639 if (( (hv < 32) || (hv > 126) )); then
6642 dasc=$dasc${line::1}
6644 (( (pos++ & 15) == 7 )) && print -n -- '- '
6648 while (( pos & 15 )); do
6650 (( (pos++ & 15) == 7 )) && print -n -- '- '
6652 (( hv == 2147483647 )) || print "$dasc|"
6655 00000000 5C 20 5C 21 5C 22 5C 23 - 5C 24 5C 25 5C 26 5C 27 |\ \!\"\#\$\%\&\'|
6656 00000010 5C 28 5C 29 5C 2A 5C 2B - 5C 2C 5C 2D 5C 2E 5C 2F |\(\)\*\+\,\-\.\/|
6657 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|
6658 00000030 20 5C 39 5C 3A 5C 3B 5C - 3C 5C 3D 5C 3E 5C 3F 5C | \9\:\;\<\=\>\?\|
6659 00000040 40 5C 41 5C 42 5C 43 5C - 44 1B 5C 46 5C 47 5C 48 |@\A\B\C\D.\F\G\H|
6660 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|
6661 00000060 5C 51 5C 52 5C 53 5C 54 - 20 5C 56 5C 57 5C 58 5C |\Q\R\S\T \V\W\X\|
6662 00000070 59 5C 5A 5C 5B 5C 5C 5D - 5C 5E 5C 5F 5C 60 07 08 |Y\Z\[\]\^\_\`..|
6663 00000080 20 20 5C 64 1B 0C 5C 67 - 5C 68 5C 69 5C 6A 5C 6B | \d..\g\h\i\j\k|
6664 00000090 5C 6C 5C 6D 0A 5C 6F 5C - 70 20 5C 71 0D 5C 73 09 |\l\m.\o\p \q.\s.|
6665 000000A0 0B 5C 77 5C 79 5C 7A 5C - 7B 5C 7C 5C 7D 5C 7E 20 |.\w\y\z\{\|\}\~ |
6666 000000B0 E2 82 AC 64 20 EF BF BD - 20 12 33 20 78 20 53 20 |...d ... .3 x S |
6667 000000C0 53 34 0A - |S4.|
6669 name: dollar-doublequoted-strings
6671 Check that a $ preceding "…" is ignored
6673 echo $"Localise me!"
6678 I do not take a $V for a V!
6683 I do not take a $V for a V!
6685 name: dollar-quoted-strings
6687 Check backslash expansion by $'…' strings
6689 printf '%s\n' $'\ \!\"\#\$\%\&\'\(\)\*\+\,\-\.\/ \1\2\3\4\5\6' \
6690 $'a\0b' $'a\01b' $'\7\8\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I' \
6691 $'\J\K\L\M\N\O\P\Q\R\S\T\U1\V\W\X\Y\Z\[\\\]\^\_\`\a\b\d\e' \
6692 $'\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u1\v\w\x1\y\z\{\|\}\~ $x' \
6693 $'\u20acd' $'\U20acd' $'\x123' $'fn\x0rd' $'\0234' $'\234' \
6694 $'\2345' $'\ca' $'\c!' $'\c?' $'\c€' $'a\
6696 # integer-base-one-3As
6697 typeset -Uui16 -Z11 pos=0
6698 typeset -Uui16 -Z5 hv=2147483647
6702 while IFS= read -r line; do
6704 while [[ -n $line ]]; do
6706 if (( (pos & 15) == 0 )); then
6707 (( pos )) && print "$dasc|"
6708 print -n "${pos#16#} "
6711 print -n "${hv#16#} "
6712 if (( (hv < 32) || (hv > 126) )); then
6715 dasc=$dasc${line::1}
6717 (( (pos++ & 15) == 7 )) && print -n -- '- '
6721 while (( pos & 15 )); do
6723 (( (pos++ & 15) == 7 )) && print -n -- '- '
6725 (( hv == 2147483647 )) || print "$dasc|"
6728 00000000 20 21 22 23 24 25 26 27 - 28 29 2A 2B 2C 2D 2E 2F | !"#$%&'()*+,-./|
6729 00000010 20 01 02 03 04 05 06 0A - 61 0A 61 01 62 0A 07 38 | .......a.a.b..8|
6730 00000020 39 3A 3B 3C 3D 3E 3F 40 - 41 42 43 44 1B 46 47 48 |9:;<=>?@ABCD.FGH|
6731 00000030 49 0A 4A 4B 4C 4D 4E 4F - 50 51 52 53 54 01 56 57 |I.JKLMNOPQRST.VW|
6732 00000040 58 59 5A 5B 5C 5D 5E 5F - 60 07 08 64 1B 0A 0C 67 |XYZ[\]^_`..d...g|
6733 00000050 68 69 6A 6B 6C 6D 0A 6F - 70 71 0D 73 09 01 0B 77 |hijklm.opq.s...w|
6734 00000060 01 79 7A 7B 7C 7D 7E 20 - 24 78 0A E2 82 AC 64 0A |.yz{|}~ $x....d.|
6735 00000070 EF BF BD 0A C4 A3 0A 66 - 6E 0A 13 34 0A 9C 0A 9C |.......fn..4....|
6736 00000080 35 0A 01 0A 01 0A 7F 0A - 02 82 AC 0A 61 0A 62 0A |5...........a.b.|
6738 name: dollar-quotes-in-heredocs
6740 They are, however, not parsed in here documents
6743 dollar = strchr(s, '$'); /* ' */
6749 dollar = strchr(s, '$'); /* ' */
6752 name: dollar-quotes-in-herestrings
6754 They are, not parsed in here strings either
6756 cat <<<"dollar = strchr(s, '$'); /* ' */"
6757 cat <<<'dollar = strchr(s, '\''$'\''); /* '\'' */'
6758 x="dollar = strchr(s, '$'); /* ' */"
6762 dollar = strchr(s, '$'); /* ' */
6763 dollar = strchr(s, '$'); /* ' */
6764 dollar = strchr(s, '$'); /* ' */
6767 name: dot-needs-argument
6769 check Debian #415167 solution: '.' without arguments should fail
6772 "$__progname" -c source
6773 expected-exit: e != 0
6774 expected-stderr-pattern:
6775 /\.: missing argument.*\n.*\.: missing argument/
6777 name: alias-function-no-conflict
6779 make aliases not conflict with functions
6780 note: for ksh-like functions, the order of preference is
6781 different; bash outputs baz instead of bar in line 2 below
6783 alias foo='echo bar'
6787 alias korn='echo bar'
6794 foo 2>&- || echo rab
6800 name: bash-function-parens
6802 ensure the keyword function is ignored when preceding
6803 POSIX style function declarations (bashism)
6806 echo '#!'"$__progname"
6808 echo ' echo "bar='\''$0'\'\"
6812 mk 'function foo' >f-korn
6814 mk 'function foo ()' >f-bash
6815 mk 'function stop ()' stop >f-stop
6817 echo "korn: $(./f-korn)"
6818 echo "dash: $(./f-dash)"
6819 echo "bash: $(./f-bash)"
6820 echo "stop: $(./f-stop)"
6823 dash: bar='./f-dash'
6824 bash: bar='./f-bash'
6825 stop: bar='./f-stop'
6827 name: integer-base-one-1
6829 check if the use of fake integer base 1 works
6832 typeset -Uui16 i0=1#ï i1=1#â
\82¬
6834 typeset -i1 o1a=0x263A
6835 typeset -Uui1 o0b=0x7E
6836 typeset -Uui1 o1b=0xFDD0
6837 integer px=0xCAFE 'p0=1# ' p1=1#… pl=1#f
6838 echo "in <$i0> <$i1>"
6839 echo "out <${o0a#1#}|${o0b#1#}> <${o1a#1#}|${o1b#1#}>"
6841 echo "pass <$px> <$p0> <$p1> <$pl> <${i0#1#}|${i1#1#}>"
6842 typeset -Uui16 tv1=1#~ tv2=1#
\7f tv3=1#
\80 tv4=1#
\81 tv5=1#À tv6=1#Á tv7=1#Â tv8=1#Â
\80
6843 echo "specX <${tv1#16#}> <${tv2#16#}> <${tv3#16#}> <${tv4#16#}> <${tv5#16#}> <${tv6#16#}> <${tv7#16#}> <${tv8#16#}>"
6844 typeset -i1 tv1 tv2 tv3 tv4 tv5 tv6 tv7 tv8
6845 echo "specW <${tv1#1#}> <${tv2#1#}> <${tv3#1#}> <${tv4#1#}> <${tv5#1#}> <${tv6#1#}> <${tv7#1#}> <${tv8#1#}>"
6846 typeset -i1 xs1=0xEF7F xs2=0xEF80 xs3=0xFDD0
6847 echo "specU <${xs1#1#}> <${xs2#1#}> <${xs3#1#}>"
6849 in <16#EFEF> <16#20AC>
6851 pass <16#cafe> <1# > <1#â
\80¦> <1#f> <ï|â
\82¬>
6852 specX <7E> <7F> <EF80> <EF81> <EFC0> <EFC1> <A0> <80>
6853 specW <~> <
\7f> <
\80> <
\81> <À> <Á> <Â > <Â
\80>
6854 specU <> <
\80> <ï·
\90>
6856 name: integer-base-one-2a
6858 check if the use of fake integer base 1 stops at correct characters
6863 expected-stderr-pattern:
6864 /1#foo: unexpected 'oo'/
6865 expected-exit: e != 0
6867 name: integer-base-one-2b
6869 check if the use of fake integer base 1 stops at correct characters
6874 expected-stderr-pattern:
6875 /1#À
\80: unexpected '
\80'/
6876 expected-exit: e != 0
6878 name: integer-base-one-2c1
6880 check if the use of fake integer base 1 stops at correct characters
6888 name: integer-base-one-2c2
6890 check if the use of fake integer base 1 stops at correct characters
6895 expected-stderr-pattern:
6896 /1#â
\80¦: unexpected '
\80'/
6897 expected-exit: e != 0
6899 name: integer-base-one-2d1
6901 check if the use of fake integer base 1 handles octets okay
6905 echo /$x/ # invalid utf-8
6909 name: integer-base-one-2d2
6911 check if the use of fake integer base 1 handles octets
6915 echo /$x/ # invalid 2-byte
6919 name: integer-base-one-2d3
6921 check if the use of fake integer base 1 handles octets
6925 echo /$x/ # invalid 2-byte
6929 name: integer-base-one-2d4
6931 check if the use of fake integer base 1 stops at invalid input
6934 typeset -i16 x=1#ï¿À
6935 echo /$x/ # invalid 3-byte
6936 expected-stderr-pattern:
6937 /1#ï¿À: unexpected '¿'/
6938 expected-exit: e != 0
6940 name: integer-base-one-2d5
6942 check if the use of fake integer base 1 stops at invalid input
6945 typeset -i16 x=1#À
\80
6946 echo /$x/ # non-minimalistic
6947 expected-stderr-pattern:
6948 /1#À
\80: unexpected '
\80'/
6949 expected-exit: e != 0
6951 name: integer-base-one-2d6
6953 check if the use of fake integer base 1 stops at invalid input
6956 typeset -i16 x=1#à
\80\80
6957 echo /$x/ # non-minimalistic
6958 expected-stderr-pattern:
6959 /1#à
\80\80: unexpected '
\80'/
6960 expected-exit: e != 0
6962 name: integer-base-one-3As
6964 some sample code for hexdumping
6965 not NUL safe; input lines must be NL terminated
6968 print 'Hello, World!\\\nこんにちは!'
6969 typeset -Uui16 i=0x100
6970 # change that to 0xFF once we can handle embedded
6971 # NUL characters in strings / here documents
6972 while (( i++ < 0x1FF )); do
6973 print -n "\x${i#16#1}"
6977 # integer-base-one-3As
6978 typeset -Uui16 -Z11 pos=0
6979 typeset -Uui16 -Z5 hv=2147483647
6983 while IFS= read -r line; do
6985 while [[ -n $line ]]; do
6987 if (( (pos & 15) == 0 )); then
6988 (( pos )) && print "$dasc|"
6989 print -n "${pos#16#} "
6992 print -n "${hv#16#} "
6993 if (( (hv < 32) || (hv > 126) )); then
6996 dasc=$dasc${line::1}
6998 (( (pos++ & 15) == 7 )) && print -n -- '- '
7002 while (( pos & 15 )); do
7004 (( (pos++ & 15) == 7 )) && print -n -- '- '
7006 (( hv == 2147483647 )) || print "$dasc|"
7009 00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..|
7010 00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................|
7011 00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................|
7012 00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................|
7013 00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.|
7014 00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>|
7015 00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN|
7016 00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^|
7017 00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn|
7018 00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~|
7019 000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................|
7020 000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................|
7021 000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................|
7022 000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................|
7023 000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................|
7024 000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................|
7025 00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................|
7026 00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................|
7027 00000120 FF 7A 0A - |.z.|
7029 name: integer-base-one-3Ws
7031 some sample code for hexdumping Unicode
7032 not NUL safe; input lines must be NL terminated
7036 print 'Hello, World!\\\nこんにちは!'
7037 typeset -Uui16 i=0x100
7038 # change that to 0xFF once we can handle embedded
7039 # NUL characters in strings / here documents
7040 while (( i++ < 0x1FF )); do
7041 print -n "\u${i#16#1}"
7044 print \\xff # invalid utf-8
7045 print \\xc2 # invalid 2-byte
7046 print \\xef\\xbf\\xc0 # invalid 3-byte
7047 print \\xc0\\x80 # non-minimalistic
7048 print \\xe0\\x80\\x80 # non-minimalistic
7049 print '�' # end of range
7050 print '\0z' # embedded NUL
7052 # integer-base-one-3Ws
7053 typeset -Uui16 -Z11 pos=0
7054 typeset -Uui16 -Z7 hv
7059 while IFS= read -r line; do
7062 while (( lpos < ${#line} )); do
7063 wc=1#${line:(lpos++):1}
7064 if (( (wc < 32) || \
7065 ((wc > 126) && (wc < 160)) )); then
7067 elif (( (wc & 0xFF80) == 0xEF80 )); then
7072 if (( (pos & 7) == 7 )); then
7075 elif (( (pos & 7) == 0 )); then
7076 (( pos )) && print "$dasc|"
7077 print -n "${pos#16#} "
7081 print -n "${hv#16#} "
7082 (( (pos++ & 7) == 3 )) && \
7087 while (( pos & 7 )); do
7089 (( (pos++ & 7) == 3 )) && print -n -- '- '
7091 (( hv == 2147483647 )) || print "$dasc|"
7094 00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W|
7095 00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.こ|
7096 00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |んにちは!...|
7097 00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........|
7098 00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........|
7099 00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........|
7100 00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"|
7101 00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*|
7102 00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012|
7103 00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:|
7104 00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB|
7105 00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ|
7106 00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR|
7107 00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ|
7108 00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab|
7109 00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij|
7110 00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr|
7111 00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz|
7112 00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....|
7113 00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........|
7114 000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........|
7115 000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........|
7116 000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |..... ¡¢|
7117 000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA |£¤¥¦§¨©ª|
7118 000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 |«¬®¯°±²|
7119 000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA |³´µ¶·¸¹º|
7120 000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 |»¼½¾¿ÀÁÂ|
7121 000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA |ÃÄÅÆÇÈÉÊ|
7122 000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 |ËÌÍÎÏÐÑÒ|
7123 000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA |ÓÔÕÖ×ØÙÚ|
7124 000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 |ÛÜÝÞßàáâ|
7125 000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA |ãäåæçèéê|
7126 00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 |ëìíîïðñò|
7127 00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA |óôõö÷øùú|
7128 00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |ûüýþÿ.�.|
7129 00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |�.���.��|
7130 00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |.���.���|
7131 00000128 EFBE EFEF EFBF EFBF - 000A 007A 000A |����.z.|
7133 name: integer-base-one-3Ar
7135 some sample code for hexdumping; NUL and binary safe
7138 print 'Hello, World!\\\nこんにちは!'
7139 typeset -Uui16 i=0x100
7140 # change that to 0xFF once we can handle embedded
7141 # NUL characters in strings / here documents
7142 while (( i++ < 0x1FF )); do
7143 print -n "\x${i#16#1}"
7147 # integer-base-one-3Ar
7148 typeset -Uui16 -Z11 pos=0
7149 typeset -Uui16 -Z5 hv=2147483647
7151 if read -arN -1 line; then
7154 while (( i < ${#line[*]} )); do
7156 if (( (pos & 15) == 0 )); then
7157 (( pos )) && print "$dasc|"
7158 print -n "${pos#16#} "
7161 print -n "${hv#16#} "
7162 if (( (hv < 32) || (hv > 126) )); then
7165 dasc=$dasc${line[i-1]#1#}
7167 (( (pos++ & 15) == 7 )) && print -n -- '- '
7170 while (( pos & 15 )); do
7172 (( (pos++ & 15) == 7 )) && print -n -- '- '
7174 (( hv == 2147483647 )) || print "$dasc|"
7177 00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..|
7178 00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................|
7179 00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................|
7180 00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................|
7181 00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.|
7182 00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>|
7183 00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN|
7184 00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^|
7185 00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn|
7186 00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~|
7187 000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................|
7188 000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................|
7189 000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................|
7190 000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................|
7191 000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................|
7192 000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................|
7193 00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................|
7194 00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................|
7195 00000120 FF 00 7A 0A - |..z.|
7197 name: integer-base-one-3Wr
7199 some sample code for hexdumping Unicode; NUL and binary safe
7203 print 'Hello, World!\\\nこんにちは!'
7204 typeset -Uui16 i=0x100
7205 # change that to 0xFF once we can handle embedded
7206 # NUL characters in strings / here documents
7207 while (( i++ < 0x1FF )); do
7208 print -n "\u${i#16#1}"
7211 print \\xff # invalid utf-8
7212 print \\xc2 # invalid 2-byte
7213 print \\xef\\xbf\\xc0 # invalid 3-byte
7214 print \\xc0\\x80 # non-minimalistic
7215 print \\xe0\\x80\\x80 # non-minimalistic
7216 print '�' # end of range
7217 print '\0z' # embedded NUL
7219 # integer-base-one-3Wr
7220 typeset -Uui16 -Z11 pos=0
7221 typeset -Uui16 -Z7 hv=2147483647
7223 if read -arN -1 line; then
7226 while (( i < ${#line[*]} )); do
7228 if (( (hv < 32) || \
7229 ((hv > 126) && (hv < 160)) )); then
7231 elif (( (hv & 0xFF80) == 0xEF80 )); then
7236 if (( (pos & 7) == 7 )); then
7239 elif (( (pos & 7) == 0 )); then
7240 (( pos )) && print "$dasc|"
7241 print -n "${pos#16#} "
7244 print -n "${hv#16#} "
7245 (( (pos++ & 7) == 3 )) && \
7250 while (( pos & 7 )); do
7252 (( (pos++ & 7) == 3 )) && print -n -- '- '
7254 (( hv == 2147483647 )) || print "$dasc|"
7257 00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W|
7258 00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.こ|
7259 00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |んにちは!...|
7260 00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........|
7261 00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........|
7262 00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........|
7263 00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"|
7264 00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*|
7265 00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012|
7266 00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:|
7267 00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB|
7268 00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ|
7269 00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR|
7270 00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ|
7271 00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab|
7272 00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij|
7273 00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr|
7274 00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz|
7275 00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....|
7276 00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........|
7277 000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........|
7278 000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........|
7279 000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |..... ¡¢|
7280 000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA |£¤¥¦§¨©ª|
7281 000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 |«¬®¯°±²|
7282 000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA |³´µ¶·¸¹º|
7283 000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 |»¼½¾¿ÀÁÂ|
7284 000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA |ÃÄÅÆÇÈÉÊ|
7285 000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 |ËÌÍÎÏÐÑÒ|
7286 000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA |ÓÔÕÖ×ØÙÚ|
7287 000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 |ÛÜÝÞßàáâ|
7288 000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA |ãäåæçèéê|
7289 00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 |ëìíîïðñò|
7290 00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA |óôõö÷øùú|
7291 00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |ûüýþÿ.�.|
7292 00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |�.���.��|
7293 00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |.���.���|
7294 00000128 EFBE EFEF EFBF EFBF - 000A 0000 007A 000A |����..z.|
7296 name: integer-base-one-4
7298 Check if ksh93-style base-one integers work
7303 (echo 2f $(('aa'))) 2>&1 | sed "s/^[^']*'/2p '/"
7311 2p 'aa': multi-character character constant
7317 name: integer-base-one-5A
7319 Check to see that we’re NUL and Unicode safe
7322 print 'a\0b\xfdz' >x
7328 16#61 16#0 16#62 16#FD 16#7A .
7330 name: integer-base-one-5W
7332 Check to see that we’re NUL and Unicode safe
7341 16#61 16#0 16#62 16#20AC 16#63 .
7345 Check if we can use a specific syntax idiom for ulimit
7347 if ! x=$(ulimit -d) || [[ $x = unknown ]]; then
7348 #echo expected to fail on this OS
7351 ulimit -dS $x && echo okay
7358 Check if GNU bash-like I/O redirection works
7359 Part 1: this is also supported by GNU bash
7378 Check if GNU bash-like I/O redirection works
7379 Part 2: this is *not* supported by GNU bash
7398 Check if GNU bash-like I/O redirection works
7399 Part 2: this is *not* supported by GNU bash
7418 Check if GNU bash-like I/O redirection works
7419 Part 2: this is supported by GNU bash 4 only
7441 Check if GNU bash-like I/O redirection fails correctly
7442 Part 1: this is also supported by GNU bash
7458 expected-stderr-pattern: /.*: can't (create|overwrite) .*/
7462 Check if GNU bash-like I/O redirection fails correctly
7463 Part 2: this is *not* supported by GNU bash
7484 Check if GNU bash-like I/O redirection works
7485 Part 4: this is also supported by GNU bash,
7486 but failed in some mksh versions
7495 [[ -e bar ]] && threeout "$bf" &>foo
7510 Check for support of more than 9 file descriptors
7513 read -u10 foo 10<<< bar
7520 Check for support of more than 9 file descriptors
7533 src/regress/bin/ksh/shcrash.sh,v 1.1
7535 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"
7536 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"
7537 for deplib in $deplibs; do
7540 new_libs="$deplib $new_libs"
7543 case " $specialdeplibs " in
7545 new_libs="$deplib $new_libs";;
7551 name: oksh-varfunction-mod1
7553 $OpenBSD: varfunction.sh,v 1.1 2003/12/15 05:28:40 otto Exp $
7556 where f is a ksh style function, should not set FOO in the current
7557 env. If f is a Bourne style function, FOO should be set. Furthermore,
7558 the function should receive a correct value of FOO. However, differing
7559 from oksh, setting FOO in the function itself must change the value in
7560 setting FOO in the function itself should not change the value in
7562 Inspired by PR 2450.
7565 if [ x$FOO != xbar ]; then
7570 if [ "x$x" != "xFOO=bar" ]; then
7578 if [ x$FOO != xbar ]; then
7583 if [ "x$x" != "xFOO=bar" ]; then
7591 if [ $? != 0 ]; then
7594 if [ x$FOO != x ]; then
7598 if [ $? != 0 ]; then
7601 if [ x$FOO != xfoo ]; then
7606 if [ $? != 0 ]; then
7609 if [ x$FOO != xbarbar ]; then
7613 if [ $? != 0 ]; then
7616 if [ x$FOO != xfoo ]; then
7622 Verify that file descriptors > 2 are private for Korn shells
7623 AT&T ksh93 does this still, which means we must keep it as well
7624 file-setup: file 644 "test.sh"
7628 "$__progname" test.sh
7629 expected-exit: e != 0
7630 expected-stderr-pattern:
7631 /bad file descriptor/
7635 Verify that file descriptors > 2 are not private for POSIX shells
7636 See Debian Bug #154540, Closes: #499139
7637 file-setup: file 644 "test.sh"
7640 test -n "$POSH_VERSION" || set -o sh
7642 "$__progname" test.sh
7648 COMSUB are now parsed recursively, so this works
7649 see also regression-6: matching parenthesēs bug
7650 Fails on: pdksh bash2 bash3 zsh
7651 Passes on: bash4 ksh93 mksh(20110313+)
7653 echo $(case 1 in (1) echo yes;; (2) echo no;; esac)
7654 echo $(case 1 in 1) echo yes;; 2) echo no;; esac)
7655 TEST=1234; echo ${TEST: $(case 1 in (1) echo 1;; (*) echo 2;; esac)}
7656 TEST=5678; echo ${TEST: $(case 1 in 1) echo 1;; *) echo 2;; esac)}
7665 COMSUB are now parsed recursively, so this works
7666 Fails on GNU bash even, ksh93 passes
7668 echo $(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10))
7669 echo $(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20))
7670 (( a = $(case 1 in (1) echo 1;; (*) echo 2;; esac) )); echo $a.
7671 (( a = $(case 1 in 1) echo 1;; *) echo 2;; esac) )); echo $a.
7680 COMSUB are now parsed recursively, so this works (ksh93, mksh)
7681 First test passes on bash4, second fails there
7684 a=($(case 1 in (1) echo 1;; (*) echo 2;; esac)); echo ${a[0]}.
7685 a=($(case 1 in 1) echo 1;; *) echo 2;; esac)); echo ${a[0]}.
7686 a=($(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10))); echo ${a[0]}.
7687 a=($(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20))); echo ${a[0]}.
7696 RedHat BZ#496791 – another case of missing recursion
7697 in parsing COMSUB expressions
7698 Fails on: pdksh bash2 bash3¹ bash4¹ zsh
7699 Passes on: ksh93 mksh(20110305+)
7700 ① bash[34] seem to choke on comment ending with backslash-newline
7702 # a comment with " ' \
7705 # a comment with " ' \
7713 Extended test for COMSUB explaining why a recursive parser
7714 is a must (a non-recursive parser cannot pass all three of
7715 these test cases, especially the ‘#’ is difficult)
7717 echo $(typeset -i10 x=16#20; echo $x)
7718 echo $(typeset -Uui16 x=16#$(id -u)
7721 typeset -Uui16 a=36#foo; c=2
7722 typeset -Uui16 b=36 #foo; d=2
7731 Check the tree dump functions for !MKSH_SMALL functionality
7734 x() { case $1 in a) a+=b ;;& *) c+=(d e) ;; esac; }
7748 name: comsub-torture
7750 Check the tree dump functions work correctly
7752 if [[ -z $__progname ]]; then echo >&2 call me with __progname; exit 1; fi
7753 while IFS= read -r line; do
7754 if [[ $line = '#1' ]]; then
7757 elif [[ $line = EOFN* ]]; then
7758 fbody=$fbody$'\n'$line
7760 elif [[ $line != '#'* ]]; then
7761 fbody=$fbody$'\n\t'$line
7764 if (( lastf )); then
7765 x="inline_${nextf}() {"$fbody$'\n}\n'
7767 print -r -- "${x}typeset -f inline_$nextf" | "$__progname"
7768 x="function comsub_$nextf { x=\$("$fbody$'\n); }\n'
7770 print -r -- "${x}typeset -f comsub_$nextf" | "$__progname"
7771 x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n'
7773 print -r -- "${x}typeset -f reread_$nextf" | "$__progname"
7781 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
7783 (echo $foo | tr -dc 0-9; echo)
7785 cmd && echo ja || echo nein
7787 select file in *; do echo "<$file>" ; break ; done
7789 for i in {1,2,3} ; do time echo $i ; done
7791 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
7792 #TIF_TBANG_TDBRACKET_TELIF
7793 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
7795 i=1; while (( i < 10 )); do echo $i; let ++i; done
7797 i=10; until (( !--i )) ; do echo $i; done
7800 #TFUNCT_TBRACE_TASYNC
7801 function korn { echo eins; echo zwei ; }
7802 bourne () { logger * & }
7805 #IOWRITE_IOCLOB_IOHERE_noIOSKIP
7809 #IOWRITE_noIOCLOB_IOHERE_IOSKIP
7814 sh 1<>/dev/console 0<&1 2>&1
7816 echo $(true) $((1+ 2))
7817 #QCHAR_OQUOTE_CQUOTE
7818 echo fo\ob\"a\`r\'b\$az
7819 echo "fo\ob\"a\`r\'b\$az"
7820 echo 'fo\ob\"a\`r'\''b\$az'
7821 #OSUBST_CSUBST_OPAT_SPAT_CPAT
7822 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
7825 note there must be no space between EOFN and )
7829 note the space between EOFN and ) is actually part of the here document marker
7832 x=$(sysctl -n kern.version | sed 1q)
7833 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
7834 ed -s /etc/motd 2>&1 <<-EOF
7841 EOF)" = @(?) ]] && rm -f /etc/motd
7842 if [[ ! -s /etc/motd ]]; then
7843 install -c -o root -g wheel -m 664 /dev/null /etc/motd
7844 print -- "$x\n" >/etc/motd
7850 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
7853 vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4"
7855 function comsub_TCOM { x=$(
7856 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
7858 function comsub_TCOM {
7859 x=$(vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" )
7861 function reread_TCOM { x=$((
7862 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4"
7864 function reread_TCOM {
7865 x=$(( vara=1 varb="2 3" cmd arg1 $arg2 "$arg3 4" ) | tr u x )
7867 inline_TPAREN_TPIPE_TLIST() {
7868 (echo $foo | tr -dc 0-9; echo)
7870 inline_TPAREN_TPIPE_TLIST() {
7871 ( echo $foo | tr -dc 0-9
7874 function comsub_TPAREN_TPIPE_TLIST { x=$(
7875 (echo $foo | tr -dc 0-9; echo)
7877 function comsub_TPAREN_TPIPE_TLIST {
7878 x=$(( echo $foo | tr -dc 0-9 ; echo ) )
7880 function reread_TPAREN_TPIPE_TLIST { x=$((
7881 (echo $foo | tr -dc 0-9; echo)
7883 function reread_TPAREN_TPIPE_TLIST {
7884 x=$(( ( echo $foo | tr -dc 0-9 ; echo ) ) | tr u x )
7887 cmd && echo ja || echo nein
7890 cmd && echo ja || echo nein
7892 function comsub_TAND_TOR { x=$(
7893 cmd && echo ja || echo nein
7895 function comsub_TAND_TOR {
7896 x=$(cmd && echo ja || echo nein )
7898 function reread_TAND_TOR { x=$((
7899 cmd && echo ja || echo nein
7901 function reread_TAND_TOR {
7902 x=$(( cmd && echo ja || echo nein ) | tr u x )
7905 select file in *; do echo "<$file>" ; break ; done
7914 function comsub_TSELECT { x=$(
7915 select file in *; do echo "<$file>" ; break ; done
7917 function comsub_TSELECT {
7918 x=$(select file in * ; do echo "<$file>" ; break ; done )
7920 function reread_TSELECT { x=$((
7921 select file in *; do echo "<$file>" ; break ; done
7923 function reread_TSELECT {
7924 x=$(( select file in * ; do echo "<$file>" ; break ; done ) | tr u x )
7926 inline_TFOR_TTIME() {
7927 for i in {1,2,3} ; do time echo $i ; done
7929 inline_TFOR_TTIME() {
7935 function comsub_TFOR_TTIME { x=$(
7936 for i in {1,2,3} ; do time echo $i ; done
7938 function comsub_TFOR_TTIME {
7939 x=$(for i in {1,2,3} ; do time echo $i ; done )
7941 function reread_TFOR_TTIME { x=$((
7942 for i in {1,2,3} ; do time echo $i ; done
7944 function reread_TFOR_TTIME {
7945 x=$(( for i in {1,2,3} ; do time echo $i ; done ) | tr u x )
7948 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
7959 echo kann net bis drei zählen
7963 function comsub_TCASE { x=$(
7964 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
7966 function comsub_TCASE {
7967 x=$(case $foo in (1) echo eins ;& (2) echo zwei ;| (*) echo kann net bis drei zählen ;; esac )
7969 function reread_TCASE { x=$((
7970 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac
7972 function reread_TCASE {
7973 x=$(( case $foo in (1) echo eins ;& (2) echo zwei ;| (*) echo kann net bis drei zählen ;; esac ) | tr u x )
7975 inline_TIF_TBANG_TDBRACKET_TELIF() {
7976 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
7978 inline_TIF_TBANG_TDBRACKET_TELIF() {
7989 function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$(
7990 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
7992 function comsub_TIF_TBANG_TDBRACKET_TELIF {
7993 x=$(if ! [[ 1 = 1 ]] ; then echo eins ; elif [[ 1 = 2 ]] ; then echo zwei ; else echo drei ; fi )
7995 function reread_TIF_TBANG_TDBRACKET_TELIF { x=$((
7996 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi
7998 function reread_TIF_TBANG_TDBRACKET_TELIF {
7999 x=$(( if ! [[ 1 = 1 ]] ; then echo eins ; elif [[ 1 = 2 ]] ; then echo zwei ; else echo drei ; fi ) | tr u x )
8002 i=1; while (( i < 10 )); do echo $i; let ++i; done
8006 while let " i < 10 "
8012 function comsub_TWHILE { x=$(
8013 i=1; while (( i < 10 )); do echo $i; let ++i; done
8015 function comsub_TWHILE {
8016 x=$(i=1 ; while let " i < 10 " ; do echo $i ; let ++i ; done )
8018 function reread_TWHILE { x=$((
8019 i=1; while (( i < 10 )); do echo $i; let ++i; done
8021 function reread_TWHILE {
8022 x=$(( i=1 ; while let " i < 10 " ; do echo $i ; let ++i ; done ) | tr u x )
8025 i=10; until (( !--i )) ; do echo $i; done
8034 function comsub_TUNTIL { x=$(
8035 i=10; until (( !--i )) ; do echo $i; done
8037 function comsub_TUNTIL {
8038 x=$(i=10 ; until let " !--i " ; do echo $i ; done )
8040 function reread_TUNTIL { x=$((
8041 i=10; until (( !--i )) ; do echo $i; done
8043 function reread_TUNTIL {
8044 x=$(( i=10 ; until let " !--i " ; do echo $i ; done ) | tr u x )
8053 function comsub_TCOPROC { x=$(
8056 function comsub_TCOPROC {
8059 function reread_TCOPROC { x=$((
8062 function reread_TCOPROC {
8063 x=$(( cat * |& ls ) | tr u x )
8065 inline_TFUNCT_TBRACE_TASYNC() {
8066 function korn { echo eins; echo zwei ; }
8067 bourne () { logger * & }
8069 inline_TFUNCT_TBRACE_TASYNC() {
8078 function comsub_TFUNCT_TBRACE_TASYNC { x=$(
8079 function korn { echo eins; echo zwei ; }
8080 bourne () { logger * & }
8082 function comsub_TFUNCT_TBRACE_TASYNC {
8083 x=$(function korn { echo eins ; echo zwei ; } ; bourne() { logger * & } )
8085 function reread_TFUNCT_TBRACE_TASYNC { x=$((
8086 function korn { echo eins; echo zwei ; }
8087 bourne () { logger * & }
8089 function reread_TFUNCT_TBRACE_TASYNC {
8090 x=$(( function korn { echo eins ; echo zwei ; } ; bourne() { logger * & } ) | tr u x )
8092 inline_IOREAD_IOCAT() {
8095 inline_IOREAD_IOCAT() {
8098 function comsub_IOREAD_IOCAT { x=$(
8101 function comsub_IOREAD_IOCAT {
8102 x=$(tr x u <foo >>bar )
8104 function reread_IOREAD_IOCAT { x=$((
8107 function reread_IOREAD_IOCAT {
8108 x=$(( tr x u <foo >>bar ) | tr u x )
8110 inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
8115 inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() {
8121 function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$(
8126 function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
8127 x=$(cat >|bar <<"EOFN"
8132 function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$((
8137 function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP {
8138 x=$(( cat >|bar <<"EOFN"
8143 inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
8148 inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() {
8154 function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$(
8159 function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
8160 x=$(cat >bar <<-EOFI
8165 function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$((
8170 function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP {
8171 x=$(( cat >bar <<-EOFI
8176 inline_IORDWR_IODUP() {
8177 sh 1<>/dev/console 0<&1 2>&1
8179 inline_IORDWR_IODUP() {
8180 sh 1<>/dev/console <&1 2>&1
8182 function comsub_IORDWR_IODUP { x=$(
8183 sh 1<>/dev/console 0<&1 2>&1
8185 function comsub_IORDWR_IODUP {
8186 x=$(sh 1<>/dev/console <&1 2>&1 )
8188 function reread_IORDWR_IODUP { x=$((
8189 sh 1<>/dev/console 0<&1 2>&1
8191 function reread_IORDWR_IODUP {
8192 x=$(( sh 1<>/dev/console <&1 2>&1 ) | tr u x )
8194 inline_COMSUB_EXPRSUB() {
8195 echo $(true) $((1+ 2))
8197 inline_COMSUB_EXPRSUB() {
8198 echo $(true ) $((1+ 2))
8200 function comsub_COMSUB_EXPRSUB { x=$(
8201 echo $(true) $((1+ 2))
8203 function comsub_COMSUB_EXPRSUB {
8204 x=$(echo $(true ) $((1+ 2)) )
8206 function reread_COMSUB_EXPRSUB { x=$((
8207 echo $(true) $((1+ 2))
8209 function reread_COMSUB_EXPRSUB {
8210 x=$(( echo $(true ) $((1+ 2)) ) | tr u x )
8212 inline_QCHAR_OQUOTE_CQUOTE() {
8213 echo fo\ob\"a\`r\'b\$az
8214 echo "fo\ob\"a\`r\'b\$az"
8215 echo 'fo\ob\"a\`r'\''b\$az'
8217 inline_QCHAR_OQUOTE_CQUOTE() {
8218 echo fo\ob\"a\`r\'b\$az
8219 echo "fo\ob\"a\`r\'b\$az"
8220 echo "fo\\ob\\\"a\\\`r"\'"b\\\$az"
8222 function comsub_QCHAR_OQUOTE_CQUOTE { x=$(
8223 echo fo\ob\"a\`r\'b\$az
8224 echo "fo\ob\"a\`r\'b\$az"
8225 echo 'fo\ob\"a\`r'\''b\$az'
8227 function comsub_QCHAR_OQUOTE_CQUOTE {
8228 x=$(echo fo\ob\"a\`r\'b\$az ; echo "fo\ob\"a\`r\'b\$az" ; echo "fo\\ob\\\"a\\\`r"\'"b\\\$az" )
8230 function reread_QCHAR_OQUOTE_CQUOTE { x=$((
8231 echo fo\ob\"a\`r\'b\$az
8232 echo "fo\ob\"a\`r\'b\$az"
8233 echo 'fo\ob\"a\`r'\''b\$az'
8235 function reread_QCHAR_OQUOTE_CQUOTE {
8236 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 )
8238 inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() {
8239 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
8241 inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() {
8242 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
8244 function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$(
8245 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
8247 function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT {
8248 x=$([[ ${foo#bl\(u\)b} = @(bar|baz) ]] )
8250 function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$((
8251 [[ ${foo#bl\(u\)b} = @(bar|baz) ]]
8253 function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT {
8254 x=$(( [[ ${foo#bl\(u\)b} = @(bar|baz) ]] ) | tr u x )
8256 inline_heredoc_closed() {
8258 note there must be no space between EOFN and )
8261 inline_heredoc_closed() {
8263 note there must be no space between EOFN and )
8268 function comsub_heredoc_closed { x=$(
8270 note there must be no space between EOFN and )
8273 function comsub_heredoc_closed {
8275 note there must be no space between EOFN and )
8279 function reread_heredoc_closed { x=$((
8281 note there must be no space between EOFN and )
8284 function reread_heredoc_closed {
8285 x=$(( x=$(cat <<EOFN
8286 note there must be no space between EOFN and )
8288 ) ; echo $x ) | tr u x )
8290 inline_heredoc_space() {
8292 note the space between EOFN and ) is actually part of the here document marker
8295 inline_heredoc_space() {
8297 note the space between EOFN and ) is actually part of the here document marker
8302 function comsub_heredoc_space { x=$(
8304 note the space between EOFN and ) is actually part of the here document marker
8307 function comsub_heredoc_space {
8309 note the space between EOFN and ) is actually part of the here document marker
8313 function reread_heredoc_space { x=$((
8315 note the space between EOFN and ) is actually part of the here document marker
8318 function reread_heredoc_space {
8319 x=$(( x=$(cat <<EOFN\
8320 note the space between EOFN and ) is actually part of the here document marker
8322 ) ; echo $x ) | tr u x )
8324 inline_patch_motd() {
8325 x=$(sysctl -n kern.version | sed 1q)
8326 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
8327 ed -s /etc/motd 2>&1 <<-EOF
8334 EOF)" = @(?) ]] && rm -f /etc/motd
8335 if [[ ! -s /etc/motd ]]; then
8336 install -c -o root -g wheel -m 664 /dev/null /etc/motd
8337 print -- "$x\n" >/etc/motd
8340 inline_patch_motd() {
8341 x=$(sysctl -n kern.version | sed 1q )
8342 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
8350 )" = @(?) ]] && rm -f /etc/motd
8351 if [[ ! -s /etc/motd ]]
8353 install -c -o root -g wheel -m 664 /dev/null /etc/motd
8354 print -- "$x\n" >/etc/motd
8357 function comsub_patch_motd { x=$(
8358 x=$(sysctl -n kern.version | sed 1q)
8359 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
8360 ed -s /etc/motd 2>&1 <<-EOF
8367 EOF)" = @(?) ]] && rm -f /etc/motd
8368 if [[ ! -s /etc/motd ]]; then
8369 install -c -o root -g wheel -m 664 /dev/null /etc/motd
8370 print -- "$x\n" >/etc/motd
8373 function comsub_patch_motd {
8374 x=$(x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
8382 )" = @(?) ]] && 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 )
8384 function reread_patch_motd { x=$((
8385 x=$(sysctl -n kern.version | sed 1q)
8386 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \
8387 ed -s /etc/motd 2>&1 <<-EOF
8394 EOF)" = @(?) ]] && rm -f /etc/motd
8395 if [[ ! -s /etc/motd ]]; then
8396 install -c -o root -g wheel -m 664 /dev/null /etc/motd
8397 print -- "$x\n" >/etc/motd
8400 function reread_patch_motd {
8401 x=$(( x=$(sysctl -n kern.version | sed 1q ) ; [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd )" != $x ]] && ed -s /etc/motd 2>&1 <<-EOF
8409 )" = @(?) ]] && 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 )
8414 Check that the short form [ $x ] works
8418 rv=$?; echo $((++i)) $rv
8420 rv=$?; echo $((++i)) $rv
8422 rv=$?; echo $((++i)) $rv
8424 rv=$?; echo $((++i)) $rv
8427 rv=$?; echo $((++i)) $rv
8429 rv=$?; echo $((++i)) $rv
8431 rv=$?; echo $((++i)) $rv
8433 rv=$?; echo $((++i)) $rv
8436 rv=$?; echo $((++i)) $rv
8438 rv=$?; echo $((++i)) $rv
8440 rv=$?; echo $((++i)) $rv
8442 rv=$?; echo $((++i)) $rv
8459 Check that the short form [[ $x ]] works (ksh93 extension)
8463 rv=$?; echo $((++i)) $rv
8465 rv=$?; echo $((++i)) $rv
8467 rv=$?; echo $((++i)) $rv
8469 rv=$?; echo $((++i)) $rv
8472 rv=$?; echo $((++i)) $rv
8474 rv=$?; echo $((++i)) $rv
8476 rv=$?; echo $((++i)) $rv
8478 rv=$?; echo $((++i)) $rv
8481 rv=$?; echo $((++i)) $rv
8483 rv=$?; echo $((++i)) $rv
8485 rv=$?; echo $((++i)) $rv
8487 rv=$?; echo $((++i)) $rv
8502 name: event-subst-1a
8504 Check that '!' substitution in interactive mode works
8506 file-setup: file 755 "falsetto"
8510 file-setup: file 755 "!false"
8525 expected-stderr-pattern:
8528 name: event-subst-1b
8530 Check that '!' substitution in interactive mode works
8531 even when a space separates it from the search command,
8532 which is not what GNU bash provides but required for the
8533 other regression tests below to check
8535 file-setup: file 755 "falsetto"
8539 file-setup: file 755 "!"
8554 expected-stderr-pattern:
8559 Check that '!' substitution in interactive mode
8560 does not break things
8562 file-setup: file 755 "falsetto"
8566 file-setup: file 755 "!"
8571 env-setup: !ENV=./Env!
8572 file-setup: file 644 "Env"
8583 ! false; then echo foo; else echo bar; fi
8592 expected-stderr-pattern:
8597 Check that '!' substitution in noninteractive mode is ignored
8599 file-setup: file 755 "falsetto"
8603 file-setup: file 755 "!false"
8615 ! false; then echo foo; else echo bar; fi
8626 Check that "set -u" matches (future) SUSv4 requirement
8632 if [[ -n $v ]]; then
8667 (mypid=$$; try mypid)
8669 ) 2>&1 | sed -e 's/^[^]]*]//' -e 's/^[^:]*: *//'
8673 y: parameter not set
8677 y: parameter not set
8681 2: parameter not set
8683 1: parameter not set
8691 !: parameter not set
8702 Testsuite for nameref (bound variables)
8717 set|grep ^ir2|sed 's/^/s1: /'
8718 typeset|grep ' ir2'|sed -e 's/^/s2: /' -e 's/nameref/typeset -n/'
8719 set -A blub -- e1 e2 e3
8721 typeset -n ir2=blub[2]
8722 echo !ind[1]: ${!ind[1]}
8724 echo ind[1]: ${ind[1]}
8744 Testsuite for nameref (bound variables)
8745 Functions, argument given directly, after local
8748 typeset bar=lokal baz=auch
8780 Advanced testsuite for bound variables (ksh93 fails this)
8782 typeset -n foo=bar[i]
8784 for i in 0 1 2 3; do
8795 Ensure we don't run in an infinite loop
8810 name: better-parens-1a
8812 Check support for ((…)) and $((…)) vs (…) and $(…)
8814 if ( (echo fubar)|tr u x); then
8823 name: better-parens-1b
8825 Check support for ((…)) and $((…)) vs (…) and $(…)
8827 echo $( (echo fubar)|tr u x) $?
8831 name: better-parens-1c
8833 Check support for ((…)) and $((…)) vs (…) and $(…)
8835 x=$( (echo fubar)|tr u x); echo $x $?
8839 name: better-parens-2a
8841 Check support for ((…)) and $((…)) vs (…) and $(…)
8843 if ((echo fubar)|tr u x); then
8852 name: better-parens-2b
8854 Check support for ((…)) and $((…)) vs (…) and $(…)
8856 echo $((echo fubar)|tr u x) $?
8860 name: better-parens-2c
8862 Check support for ((…)) and $((…)) vs (…) and $(…)
8864 x=$((echo fubar)|tr u x); echo $x $?
8868 name: better-parens-3a
8870 Check support for ((…)) and $((…)) vs (…) and $(…)
8872 if ( (echo fubar)|(tr u x)); then
8881 name: better-parens-3b
8883 Check support for ((…)) and $((…)) vs (…) and $(…)
8885 echo $( (echo fubar)|(tr u x)) $?
8889 name: better-parens-3c
8891 Check support for ((…)) and $((…)) vs (…) and $(…)
8893 x=$( (echo fubar)|(tr u x)); echo $x $?
8897 name: better-parens-4a
8899 Check support for ((…)) and $((…)) vs (…) and $(…)
8901 if ((echo fubar)|(tr u x)); then
8910 name: better-parens-4b
8912 Check support for ((…)) and $((…)) vs (…) and $(…)
8914 echo $((echo fubar)|(tr u x)) $?
8918 name: better-parens-4c
8920 Check support for ((…)) and $((…)) vs (…) and $(…)
8922 x=$((echo fubar)|(tr u x)); echo $x $?
8928 Test what the echo builtin does (mksh)
8930 echo -n 'foo\x40bar'
8937 Test what the echo builtin does (POSIX)
8938 Note: this follows Debian Policy 10.4 which mandates
8939 that -n shall be treated as an option, not XSI which
8940 mandates it shall be treated as string but escapes
8943 test -n "$POSH_VERSION" || set -o sh
8944 echo -n 'foo\x40bar'
8949 name: utilities-getopts-1
8951 getopts sets OPTIND correctly for unparsed option
8954 while getopts :a optc; do
8955 echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
8959 OPTARG=, OPTIND=2, optc=a.
8960 OPTARG=, OPTIND=3, optc=a.
8961 OPTARG=x, OPTIND=4, optc=?.
8964 name: utilities-getopts-2
8969 while getopts a: optc; do
8970 echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
8974 OPTARG=Mary, OPTIND=3, optc=a.
8975 OPTARG=, OPTIND=4, optc=?.
8977 expected-stderr-pattern: /.*-x.*option/
8981 Check the new wcswidth feature
8985 print octets: ${#s} .
8986 print 8-bit width: ${%s} .
8988 print characters: ${#s} .
8989 print columns: ${%s} .
8992 print octets: ${#s} .
8993 print 8-bit width: ${%s} .
8995 print characters: ${#s} .
8996 print columns: ${%s} .
9009 Check some corner cases
9025 Check some corner cases
9028 expected-stderr-pattern:
9034 Check some corner cases
9037 expected-stderr-pattern:
9043 Check some corner cases
9046 expected-stderr-pattern:
9052 Check some corner cases
9061 Check proper return values for realpath
9075 x=$(realpath "$wd/$1" 2>&1); y=$?
9076 print $((++i)) "?$1" =${x##*$wd/} !$y
9102 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
9107 3 ?dir/file =dir/file !0
9108 4 ?dir/nix =dir/nix !0
9110 6 ?file/ =file/: Not a directory !20
9111 7 ?file/file =file/file: Not a directory !20
9112 8 ?file/nix =file/nix: Not a directory !20
9115 11 ?nix/file =nix/file: No such file or directory !2
9116 12 ?nix/nix =nix/nix: No such file or directory !2
9119 15 ?lndir/file =dir/file !0
9120 16 ?lndir/nix =dir/nix !0
9122 18 ?lnfile/ =lnfile/: Not a directory !20
9123 19 ?lnfile/file =lnfile/file: Not a directory !20
9124 20 ?lnfile/nix =lnfile/nix: Not a directory !20
9127 23 ?lnnix/file =lnnix/file: No such file or directory !2
9128 24 ?lnnix/nix =lnnix/nix: No such file or directory !2
9129 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
9133 Ensure that exactly two leading slashes are not collapsed
9134 POSIX guarantees this exception, e.g. for UNC paths on Cygwin
9154 realpath //usr/include/../bin
9171 Crashed during March 2011, fixed on vernal equinōx ☺
9172 category: os:mirbsd,os:openbsd
9174 export MALLOC_OPTIONS=FGJPRSX
9175 "$__progname" -c 'x=$(tr z r <<<baz); echo $x'
9181 Check test - bug#465250
9183 test \( ! -e \) ; echo $?
9189 Check test - bug#465250
9191 test \( -e \) ; echo $?
9197 Check test - bug#465250
9205 Check test - bug#465250
9213 Check that zsh case variants work