1 # $MirOS: src/bin/mksh/check.t,v 1.298 2009/08/01 21:57:52 tg Stab $
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
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 R39 2009/08/01 Debian 39.1-3
31 Check version of shell.
38 Regression test self-testing
46 Regression test self-testing
55 Regression test self-testing
56 env-setup: !ENV=fnord!
64 Just output the environment variables set (always fails)
71 Check that recursion is detected/avoided in aliases.
76 expected-stderr-pattern:
81 Check that recursion is detected/avoided in aliases.
88 expected-stderr-pattern:
89 /fooBar.*not found.*\n.*barFoo.*not found/
93 Check that recursion is detected/avoided in aliases.
108 Check that alias expansion isn't done on keywords (in keyword
114 while false; do echo hi ; done
121 Check that alias expansion done after alias with trailing space.
125 alias foo='bar stuff '
126 alias bar='Bar1 Bar2 '
135 Check that alias expansion done after alias with trailing space.
148 Check that alias expansion done after alias with trailing space
154 X Y in 'Y') echo is y ;; Z) echo is z ; esac
160 Check that newlines in an alias don't cause the command to be lost.
181 Check that recursion is detected/avoided in aliases.
182 This check fails for slow machines or Cygwin, raise
183 the time-limit clause (e.g. to 7) if this occurs.
198 Check that only one side of ternary operator is evaluated
204 echo $((1 ? 20 : (x+=2)))
206 echo $((0 ? (y+=2) : 30))
216 Check that assignments not done on non-evaluated side of ternary
223 echo $((1 ? 20 : (x+=2)))
225 echo $((0 ? (y+=2) : 30))
235 Check that assignments not done on non-evaluated side of ternary
236 operator and this construct is parsed correctly (Debian #445651)
244 name: arith-ternary-prec-1
246 Check precedence of ternary operator vs assignment
250 expected-exit: e != 0
251 expected-stderr-pattern:
252 /.*:.*1 \? 20 : x\+=2.*lvalue.*\n$/
254 name: arith-ternary-prec-2
256 Check precedence of ternary operator vs assignment
259 echo $((0 ? x+=2 : 20))
263 name: arith-div-assoc-1
265 Check associativity of division operator
271 name: arith-assop-assoc-1
273 Check associativity of assignment-operator operator
278 echo $((i += j += k))
284 name: arith-unsigned-1
286 Check if unsigned arithmetics work
290 print x1 $((-1)) $((#-1))
294 vs=4123456789; vu=4123456789
296 (( vs %= 2147483647 ))
297 (( vu %= 2147483647 ))
299 vs=4123456789; vu=4123456789
300 (( # vs %= 2147483647 ))
301 (( # vu %= 2147483647 ))
303 # make sure the calculation does not change unsigned flag
304 vs=4123456789; vu=4123456789
307 print x6 $((# vs % 2147483647)) $((# vu % 2147483647))
312 print x7 ${va[#4123456789%2147483647]}
315 x2 -171510507 4123456789
316 x3 -171510507 4123456789
317 x4 1975973142 1975973142
318 x5 -171510507 4123456789
319 x6 1975973142 1975973142
322 name: arith-limit32-1
324 Check if arithmetics are 32 bit
328 print x1 $((-1)) $((#-1))
332 vs=2147483647; vu=2147483647
336 vs=4294967295; vu=4294967295
344 x2 2147483647 2147483647
345 x3 -2147483648 2147483648
352 Check that \newline is not collasped after #
362 Check that \newline is not collasped inside single quotes
374 Check that \newline is not collasped inside single quotes
386 Check interaction of aliases, single quotes and here-documents
387 with backslash-newline
388 (don't know what posix has to say about this)
411 Check what happens with backslash at end of input
412 (the old bourne shell trashes them; so do we)
421 # Places \newline should be collapsed
425 Check that \newline is collasped before, in the middle of, and
437 Check that \newline is collasped in $ sequences
461 Check that \newline is collasped in $(..) and `...` sequences
486 Check that \newline is collasped in $((..)) sequences
497 echo $((1+2+3+4+5+6)\
508 Check that \newline is collasped in double quoted strings
523 Check that \newline is collasped in here document delimiters
524 (ksh93 fails second part of this)
546 Check that \newline is collasped in double-quoted here-document
565 Check that \newline is collasped in various 2+ character tokens
610 Check that \ at the end of an alias is collapsed when followed
612 (don't know what posix has to say about this)
623 Check that \newline in a keyword is collapsed
633 # Places \newline should be collapsed (ksh extensions)
637 Check that \newline is collapsed in extended globbing
655 Check that \newline is collapsed in ((...)) expressions
671 See if break breaks out of loops
673 for i in a b c; do echo $i; break; echo bad-$i; done
675 for i in a b c; do echo $i; break 1; echo bad-$i; done
701 See if break breaks out of nested loops
718 What if break used outside of any loops
719 (ksh88,ksh93 don't print error messages here)
722 expected-stderr-pattern:
727 What if break N used when only N-1 loops
728 (ksh88,ksh93 don't print error messages here)
730 for i in a b c; do echo $i; break 2; echo bad-$i; done
735 expected-stderr-pattern:
740 Error if break argument isn't a number
742 for i in a b c; do echo $i; break abc; echo more-$i; done
746 expected-exit: e != 0
747 expected-stderr-pattern:
752 See if continue continues loops
754 for i in a b c; do echo $i; continue; echo bad-$i ; done
756 for i in a b c; do echo $i; continue 1; echo bad-$i; done
792 See if continue breaks out of nested loops
811 What if continue used outside of any loops
812 (ksh88,ksh93 don't print error messages here)
815 expected-stderr-pattern:
820 What if continue N used when only N-1 loops
821 (ksh88,ksh93 don't print error messages here)
823 for i in a b c; do echo $i; continue 2; echo bad-$i; done
830 expected-stderr-pattern:
835 Error if continue argument isn't a number
837 for i in a b c; do echo $i; continue abc; echo more-$i; done
841 expected-exit: e != 0
842 expected-stderr-pattern:
847 Test someone's CD history package (uses arrays)
850 # go to known place before doing anything
864 if [ "$CDHISTFILE" -a -r "$CDHISTFILE" ] # if directory history exists
868 while read -r t # read directory history file
874 if [ "${CDHIST[0]}" != "$PWD" -a "$PWD" != "" ]
876 _cdins # insert $PWD into cd history
879 cdlen=${#CDHIST[*]} # number of elements in history
883 if [ "$OLDPWD" = "" ] && ((cdlen>1))
893 -l) # print directory list
899 'print' "$num ${CDHIST[i]}"
903 -[0-9]|-[0-9][0-9]) # cd to dir in list
904 if (((i=${1#-})<cdlen))
914 -*) # cd to matched dir in list
941 _cdins # insert $PWD into cd history
945 cdlen=${#CDHIST[*]} # number of elements in history
950 'print' -r ${CDHIST[i]} # update directory history
956 function _cdins # insert $PWD into cd history
957 { # meant to be called only by _cd
961 while ((i<${#CDHIST[*]})) # see if dir is already in list
963 if [ "${CDHIST[$i]}" = "$PWD" ]
970 if ((i>22)) # limit max size of list
975 while (((i=i-1)>=0)) # bump old dirs in list
977 CDHIST[i+1]=${CDHIST[i]}
980 CDHIST[0]=$PWD # insert new directory in list
1008 Check that prompt not printed when processing ENV
1010 env-setup: !ENV=./foo!
1011 file-setup: file 644 "foo"
1025 Check that weird ${foo+bar} constructs are parsed correctly
1027 (echo 1 ${IFS+'}'z}) 2>&- || echo failed in 1
1028 (echo 2 "${IFS+'}'z}") 2>&- || echo failed in 2
1029 (echo 3 "foo ${IFS+'bar} baz") 2>&- || echo failed in 3
1030 (echo -n '4 '; printf '%s\n' "foo ${IFS+"b c"} baz") 2>&- || echo failed in 4
1031 (echo -n '5 '; printf '%s\n' "foo ${IFS+b c} baz") 2>&- || echo failed in 5
1032 (echo 6 ${IFS+"}"z}) 2>&- || echo failed in 6
1033 (echo 7 "${IFS+"}"z}") 2>&- || echo failed in 7
1034 (echo 8 "${IFS+\"}\"z}") 2>&- || echo failed in 8
1035 (echo 9 "${IFS+\"\}\"z}") 2>&- || echo failed in 9
1036 (echo 10 foo ${IFS+'bar} baz'}) 2>&- || echo failed in 10
1037 (echo 11 "$(echo "${IFS+'}'z}")") 2>&- || echo failed in 11
1038 (echo 12 "$(echo ${IFS+'}'z})") 2>&- || echo failed in 12
1039 (echo 13 ${IFS+\}z}) 2>&- || echo failed in 13
1040 (echo 14 "${IFS+\}z}") 2>&- || echo failed in 14
1041 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
1042 l=t; (echo 16 ${IFS+h`echo -n i ${IFS+$l}h`ere}) 2>&- || echo failed in 16
1043 l=t; (echo 17 ${IFS+h$(echo -n i ${IFS+$l}h)ere}) 2>&- || echo failed in 17
1044 l=t; (echo 18 "${IFS+h`echo -n i ${IFS+$l}h`ere}") 2>&- || echo failed in 18
1045 l=t; (echo 19 "${IFS+h$(echo -n i ${IFS+$l}h)ere}") 2>&- || echo failed in 19
1046 l=t; (echo 20 ${IFS+h`echo -n i "${IFS+$l}"h`ere}) 2>&- || echo failed in 20
1047 l=t; (echo 21 ${IFS+h$(echo -n i "${IFS+$l}"h)ere}) 2>&- || echo failed in 21
1048 l=t; (echo 22 "${IFS+h`echo -n i "${IFS+$l}"h`ere}") 2>&- || echo failed in 22
1049 l=t; (echo 23 "${IFS+h$(echo -n i "${IFS+$l}"h)ere}") 2>&- || echo failed in 23
1050 key=value; (echo -n '24 '; printf '%s\n' "${IFS+'$key'}") 2>&- || echo failed in 24
1051 key=value; (echo -n '25 '; printf '%s\n' "${IFS+"'$key'"}") 2>&- || echo failed in 25 # ksh93: “'$key'”
1052 key=value; (echo -n '26 '; printf '%s\n' ${IFS+'$key'}) 2>&- || echo failed in 26
1053 key=value; (echo -n '27 '; printf '%s\n' ${IFS+"'$key'"}) 2>&- || echo failed in 27
1054 (echo -n '28 '; printf '%s\n' "${IFS+"'"x ~ x'}'x"'}"x}" #') 2>&- || echo failed in 28
1055 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
1056 (echo -n '30 '; printf '<%s> ' ${IFS+foo 'b\
1057 ar' baz}; echo .) 2>&- || (echo failed in 30; echo failed in 31)
1058 (echo -n '32 '; printf '<%s> ' ${IFS+foo "b\
1059 ar" baz}; echo .) 2>&- || (echo failed in 32; echo failed in 33)
1060 (echo -n '34 '; printf '<%s> ' "${IFS+foo 'b\
1061 ar' baz}"; echo .) 2>&- || (echo failed in 34; echo failed in 35)
1062 (echo -n '36 '; printf '<%s> ' "${IFS+foo "b\
1063 ar" baz}"; echo .) 2>&- || (echo failed in 36; echo failed in 37)
1079 15 <foo abx{ {{{}b c d{} bar> <}> <baz> .
1093 29 <foo> <abx{ {{> <{}b> <c> <d{}> <bar> <}> <baz> .
1096 32 <foo> <bar> <baz> .
1097 34 <foo 'bar' baz> .
1100 name: expand-unglob-dblq
1102 Check that regular "${foo+bar}" constructs are parsed correctly
1107 test x"$v" = x"-" && unset v
1108 (echo "$1 plus norm foo ${v+'bar'} baz")
1109 (echo "$1 dash norm foo ${v-'bar'} baz")
1110 (echo "$1 eqal norm foo ${v='bar'} baz")
1111 (echo "$1 qstn norm foo ${v?'bar'} baz") 2>&- || \
1112 echo "$1 qstn norm -> error"
1113 (echo "$1 PLUS norm foo ${v:+'bar'} baz")
1114 (echo "$1 DASH norm foo ${v:-'bar'} baz")
1115 (echo "$1 EQAL norm foo ${v:='bar'} baz")
1116 (echo "$1 QSTN norm foo ${v:?'bar'} baz") 2>&- || \
1117 echo "$1 QSTN norm -> error"
1121 test x"$v" = x"-" && unset v
1122 (echo "$1 plus parn foo ${v+(bar)} baz")
1123 (echo "$1 dash parn foo ${v-(bar)} baz")
1124 (echo "$1 eqal parn foo ${v=(bar)} baz")
1125 (echo "$1 qstn parn foo ${v?(bar)} baz") 2>&- || \
1126 echo "$1 qstn parn -> error"
1127 (echo "$1 PLUS parn foo ${v:+(bar)} baz")
1128 (echo "$1 DASH parn foo ${v:-(bar)} baz")
1129 (echo "$1 EQAL parn foo ${v:=(bar)} baz")
1130 (echo "$1 QSTN parn foo ${v:?(bar)} baz") 2>&- || \
1131 echo "$1 QSTN parn -> error"
1135 test x"$v" = x"-" && unset v
1136 (echo "$1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz")
1137 (echo "$1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz")
1138 (echo "$1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz")
1139 (echo "$1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz") 2>&- || \
1140 echo "$1 qstn brac -> error"
1141 (echo "$1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz")
1142 (echo "$1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz")
1143 (echo "$1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz")
1144 (echo "$1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz") 2>&- || \
1145 echo "$1 QSTN brac -> error"
1158 1 dash norm foo 'bar' baz
1159 1 eqal norm foo 'bar' baz
1160 1 qstn norm -> error
1162 1 DASH norm foo 'bar' baz
1163 1 EQAL norm foo 'bar' baz
1164 1 QSTN norm -> error
1165 2 plus norm foo 'bar' baz
1170 2 DASH norm foo 'bar' baz
1171 2 EQAL norm foo 'bar' baz
1172 2 QSTN norm -> error
1173 3 plus norm foo 'bar' baz
1174 3 dash norm foo x baz
1175 3 eqal norm foo x baz
1176 3 qstn norm foo x baz
1177 3 PLUS norm foo 'bar' baz
1178 3 DASH norm foo x baz
1179 3 EQAL norm foo x baz
1180 3 QSTN norm foo x baz
1182 4 dash parn foo (bar) baz
1183 4 eqal parn foo (bar) baz
1184 4 qstn parn -> error
1186 4 DASH parn foo (bar) baz
1187 4 EQAL parn foo (bar) baz
1188 4 QSTN parn -> error
1189 5 plus parn foo (bar) baz
1194 5 DASH parn foo (bar) baz
1195 5 EQAL parn foo (bar) baz
1196 5 QSTN parn -> error
1197 6 plus parn foo (bar) baz
1198 6 dash parn foo x baz
1199 6 eqal parn foo x baz
1200 6 qstn parn foo x baz
1201 6 PLUS parn foo (bar) baz
1202 6 DASH parn foo x baz
1203 6 EQAL parn foo x baz
1204 6 QSTN parn foo x baz
1205 7 plus brac foo c } baz
1206 7 dash brac foo ax{{{}b c d{} baz
1207 7 eqal brac foo ax{{{}b c ax{{{}b} baz
1208 7 qstn brac -> error
1209 7 PLUS brac foo c } baz
1210 7 DASH brac foo ax{{{}b c d{} baz
1211 7 EQAL brac foo ax{{{}b c ax{{{}b} baz
1212 7 QSTN brac -> error
1213 8 plus brac foo ax{{{}b c d{} baz
1214 8 dash brac foo c } baz
1215 8 eqal brac foo c } baz
1216 8 qstn brac foo c } baz
1217 8 PLUS brac foo c } baz
1218 8 DASH brac foo ax{{{}b c d{} baz
1219 8 EQAL brac foo ax{{{}b c ax{{{}b} baz
1220 8 QSTN brac -> error
1221 9 plus brac foo ax{{{}b c d{} baz
1222 9 dash brac foo x c x} baz
1223 9 eqal brac foo x c x} baz
1224 9 qstn brac foo x c x} baz
1225 9 PLUS brac foo ax{{{}b c d{} baz
1226 9 DASH brac foo x c x} baz
1227 9 EQAL brac foo x c x} baz
1228 9 QSTN brac foo x c x} baz
1230 name: expand-unglob-unq
1232 Check that regular ${foo+bar} constructs are parsed correctly
1237 test x"$v" = x"-" && unset v
1238 (echo $1 plus norm foo ${v+'bar'} baz)
1239 (echo $1 dash norm foo ${v-'bar'} baz)
1240 (echo $1 eqal norm foo ${v='bar'} baz)
1241 (echo $1 qstn norm foo ${v?'bar'} baz) 2>&- || \
1242 echo "$1 qstn norm -> error"
1243 (echo $1 PLUS norm foo ${v:+'bar'} baz)
1244 (echo $1 DASH norm foo ${v:-'bar'} baz)
1245 (echo $1 EQAL norm foo ${v:='bar'} baz)
1246 (echo $1 QSTN norm foo ${v:?'bar'} baz) 2>&- || \
1247 echo "$1 QSTN norm -> error"
1251 test x"$v" = x"-" && unset v
1252 (echo $1 plus parn foo ${v+\(bar')'} baz)
1253 (echo $1 dash parn foo ${v-\(bar')'} baz)
1254 (echo $1 eqal parn foo ${v=\(bar')'} baz)
1255 (echo $1 qstn parn foo ${v?\(bar')'} baz) 2>&- || \
1256 echo "$1 qstn parn -> error"
1257 (echo $1 PLUS parn foo ${v:+\(bar')'} baz)
1258 (echo $1 DASH parn foo ${v:-\(bar')'} baz)
1259 (echo $1 EQAL parn foo ${v:=\(bar')'} baz)
1260 (echo $1 QSTN parn foo ${v:?\(bar')'} baz) 2>&- || \
1261 echo "$1 QSTN parn -> error"
1265 test x"$v" = x"-" && unset v
1266 (echo $1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz)
1267 (echo $1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz)
1268 (echo $1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz)
1269 (echo $1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz) 2>&- || \
1270 echo "$1 qstn brac -> error"
1271 (echo $1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz)
1272 (echo $1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz)
1273 (echo $1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz)
1274 (echo $1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz) 2>&- || \
1275 echo "$1 QSTN brac -> error"
1288 1 dash norm foo bar baz
1289 1 eqal norm foo bar baz
1290 1 qstn norm -> error
1292 1 DASH norm foo bar baz
1293 1 EQAL norm foo bar baz
1294 1 QSTN norm -> error
1295 2 plus norm foo bar baz
1300 2 DASH norm foo bar baz
1301 2 EQAL norm foo bar baz
1302 2 QSTN norm -> error
1303 3 plus norm foo bar baz
1304 3 dash norm foo x baz
1305 3 eqal norm foo x baz
1306 3 qstn norm foo x baz
1307 3 PLUS norm foo bar baz
1308 3 DASH norm foo x baz
1309 3 EQAL norm foo x baz
1310 3 QSTN norm foo x baz
1312 4 dash parn foo (bar) baz
1313 4 eqal parn foo (bar) baz
1314 4 qstn parn -> error
1316 4 DASH parn foo (bar) baz
1317 4 EQAL parn foo (bar) baz
1318 4 QSTN parn -> error
1319 5 plus parn foo (bar) baz
1324 5 DASH parn foo (bar) baz
1325 5 EQAL parn foo (bar) baz
1326 5 QSTN parn -> error
1327 6 plus parn foo (bar) baz
1328 6 dash parn foo x baz
1329 6 eqal parn foo x baz
1330 6 qstn parn foo x baz
1331 6 PLUS parn foo (bar) baz
1332 6 DASH parn foo x baz
1333 6 EQAL parn foo x baz
1334 6 QSTN parn foo x baz
1335 7 plus brac foo c } baz
1336 7 dash brac foo ax{{{}b c d{} baz
1337 7 eqal brac foo ax{{{}b c ax{{{}b} baz
1338 7 qstn brac -> error
1339 7 PLUS brac foo c } baz
1340 7 DASH brac foo ax{{{}b c d{} baz
1341 7 EQAL brac foo ax{{{}b c ax{{{}b} baz
1342 7 QSTN brac -> error
1343 8 plus brac foo ax{{{}b c d{} baz
1344 8 dash brac foo c } baz
1345 8 eqal brac foo c } baz
1346 8 qstn brac foo c } baz
1347 8 PLUS brac foo c } baz
1348 8 DASH brac foo ax{{{}b c d{} baz
1349 8 EQAL brac foo ax{{{}b c ax{{{}b} baz
1350 8 QSTN brac -> error
1351 9 plus brac foo ax{{{}b c d{} baz
1352 9 dash brac foo x c x} baz
1353 9 eqal brac foo x c x} baz
1354 9 qstn brac foo x c x} baz
1355 9 PLUS brac foo ax{{{}b c d{} baz
1356 9 DASH brac foo x c x} baz
1357 9 EQAL brac foo x c x} baz
1358 9 QSTN brac foo x c x} baz
1362 Check that globbing isn't done when glob has syntax error
1363 file-setup: file 644 "abcx"
1364 file-setup: file 644 "abcz"
1365 file-setup: file 644 "bbc"
1375 Check that globbing isn't done when glob has syntax error
1376 (AT&T ksh fails this test)
1377 file-setup: file 644 "abcx"
1378 file-setup: file 644 "abcz"
1379 file-setup: file 644 "bbc"
1385 name: eglob-infinite-plus
1387 Check that shell doesn't go into infinite loop expanding +(...)
1389 file-setup: file 644 "abc"
1404 Check that eglobbing isn't done on substitution results
1405 file-setup: file 644 "abc"
1412 name: eglob-nomatch-1
1414 Check that the pattern doesn't match
1416 echo 1: no-file+(a|b)stuff
1417 echo 2: no-file+(a*(c)|b)stuff
1418 echo 3: no-file+((((c)))|b)stuff
1420 1: no-file+(a|b)stuff
1421 2: no-file+(a*(c)|b)stuff
1422 3: no-file+((((c)))|b)stuff
1426 Check that the pattern matches correctly
1427 file-setup: file 644 "abd"
1428 file-setup: file 644 "acd"
1429 file-setup: file 644 "abac"
1433 echo 3: *(a(b|c)) # (...|...) can be used within X(..)
1434 echo 4: a[b*(foo|bar)]d # patterns not special inside [...]
1443 Simple negation tests
1445 case foo in !(foo|bar)) echo yes;; *) echo no;; esac
1446 case bar in !(foo|bar)) echo yes;; *) echo no;; esac
1455 case foo in *(a|b[)) echo yes;; *) echo no;; esac
1456 case foo in *(a|b[)|f*) echo yes;; *) echo no;; esac
1457 case '*(a|b[)' in *(a|b[)) echo yes;; *) echo no;; esac
1465 Eglobbing in trim expressions...
1466 (AT&T ksh fails this - docs say # matches shortest string, ## matches
1483 Check eglobbing works in trims...
1487 echo 1: ${x#*(a|b)cd}
1488 echo 2: "${x#*(a|b)cd}"
1489 echo 3: ${x#"*(a|b)cd"}
1497 name: eglob-substrpl-1
1499 Check eglobbing works in substs... and they work at all
1502 [[ -n $BASH_VERSION ]] && shopt -s extglob
1503 x=1222321_ab/cde_b/c_1221
1512 echo 8: ${x//+(2)/4}
1513 echo 9: ${x/b/c/e/f}
1514 echo 10: ${x/b\/c/e/f}
1515 echo 11: ${x/b\/c/e\/f}
1516 echo 12: ${x/b\/c/e\\/f}
1517 echo 13: ${x/b\\/c/e\\/f}
1518 echo 14: ${x//b/c/e/f}
1519 echo 15: ${x//b\/c/e/f}
1520 echo 16: ${x//b\/c/e\/f}
1521 echo 17: ${x//b\/c/e\\/f}
1522 echo 18: ${x//b\\/c/e\\/f}
1523 echo 19: ${x/b\/*\/c/x}
1529 echo 25: ${x//\%1/9}
1530 echo 26: ${x//\\%1/9}
1532 echo 28: ${x//\\a/9}
1535 1: 122321_ab/cde_b/c_1221
1536 2: 131_ab/cde_b/c_11
1537 3: 1321_ab/cde_b/c_1221
1538 4: 131_ab/cde_b/c_11
1539 5: 1422321_ab/cde_b/c_1221
1540 6: 1444341_ab/cde_b/c_1441
1541 7: 14321_ab/cde_b/c_1221
1542 8: 14341_ab/cde_b/c_141
1543 9: 1222321_ac/e/f/cde_b/c_1221
1544 10: 1222321_ae/fde_b/c_1221
1545 11: 1222321_ae/fde_b/c_1221
1546 12: 1222321_ae\/fde_b/c_1221
1547 13: 1222321_ab/cde_b/c_1221
1548 14: 1222321_ac/e/f/cde_c/e/f/c_1221
1549 15: 1222321_ae/fde_e/f_1221
1550 16: 1222321_ae/fde_e/f_1221
1551 17: 1222321_ae\/fde_e\/f_1221
1552 18: 1222321_ab/cde_b/c_1221
1554 20: 1222321_ab.cde_b/c_1221
1555 21: 1222321_ab.cde_b.c_1221
1556 22: 1222321_ab/cde_b/c_1221
1557 23: 9222321_ab/cde_b/c_1221
1558 24: 1222321_ab/cde_b/c_1229
1559 25: 1222321_ab/cde_b/c_1229
1560 26: 1222321_ab/cde_b/c_1221
1561 27: 1222321_9b/cde_b/c_1221
1562 28: 1222321_9b/cde_b/c_1221
1563 29: 1xyz22321_ab/cde_b/c_1221
1565 name: eglob-substrpl-2
1567 Check anchored substring replacement works, corner cases
1585 name: eglob-substrpl-3a
1587 Check substring replacement works with variables and slashes, too
1592 echo "${wd/#$pfx/~}"
1593 echo "${wd/#\$pfx/~}"
1594 echo "${wd/#"$pfx"/~}"
1595 echo "${wd/#'$pfx'/~}"
1596 echo "${wd/#"\$pfx"/~}"
1597 echo "${wd/#'\$pfx'/~}"
1606 name: eglob-substrpl-3b
1608 More of this, bash fails it (bash4 passes)
1613 echo "${wd/#$(echo /home/user)/~}"
1614 echo "${wd/#"$(echo /home/user)"/~}"
1615 echo "${wd/#'$(echo /home/user)'/~}"
1621 name: eglob-substrpl-3c
1623 Even more weird cases
1628 echo 1: ${wd/#$pfx/~}
1629 echo 2: ${wd/#\$pfx/~}
1630 echo 3: ${wd/#"$pfx"/~}
1631 echo 4: ${wd/#'$pfx'/~}
1632 echo 5: ${wd/#"\$pfx"/~}
1633 echo 6: ${wd/#'\$pfx'/~}
1634 ts='a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)'
1637 [[ -n $BASH_VERSION ]] && shopt -s extglob
1638 echo 7: ${ts/a\/b/$tr}
1639 echo 8: ${ts/a\/b/\$tr}
1640 echo 9: ${ts/$tp/$tr}
1641 echo 10: ${ts/\$tp/$tr}
1642 echo 11: ${ts/\\$tp/$tr}
1643 echo 12: ${ts/$tp/c/d}
1644 echo 13: ${ts/$tp/c\/d}
1645 echo 14: ${ts/$tp/c\\/d}
1646 echo 15: ${ts/+(a\/b)/$tr}
1647 echo 16: ${ts/+(a\/b)/\$tr}
1648 echo 17: ${ts/+($tp)/$tr}
1649 echo 18: ${ts/+($tp)/c/d}
1650 echo 19: ${ts/+($tp)/c\/d}
1651 echo 25: ${ts//a\/b/$tr}
1652 echo 26: ${ts//a\/b/\$tr}
1653 echo 27: ${ts//$tp/$tr}
1654 echo 28: ${ts//$tp/c/d}
1655 echo 29: ${ts//$tp/c\/d}
1656 echo 30: ${ts//+(a\/b)/$tr}
1657 echo 31: ${ts//+(a\/b)/\$tr}
1658 echo 32: ${ts//+($tp)/$tr}
1659 echo 33: ${ts//+($tp)/c/d}
1660 echo 34: ${ts//+($tp)/c\/d}
1662 echo 40: ${ts/$tp/$tr}
1663 echo 41: ${ts//$tp/$tr}
1671 7: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1672 8: $tra/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1673 9: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1674 10: a/ba/bc/d$tp_a/b$tp_*(a/b)_*($tp)
1675 11: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1676 12: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1677 13: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1678 14: c\/da/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1679 15: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
1680 16: $tr$tp$tp_a/b$tp_*(a/b)_*($tp)
1681 17: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
1682 18: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
1683 19: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
1684 25: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1685 26: $tr$tr$tp$tp_$tr$tp_*($tr)_*($tp)
1686 27: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1687 28: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1688 29: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1689 30: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1690 31: $tr$tp$tp_$tr$tp_*($tr)_*($tp)
1691 32: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1692 33: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1693 34: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1694 40: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1695 41: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)
1696 # This is what GNU bash does:
1697 # 40: c/d$tp$tp_a/b$tp_*(a/b)_*($tp)
1698 # 41: c/d$tp$tp_c/d$tp_*(c/d)_*($tp)
1702 Check that globbing isn't done when glob has syntax error
1703 file-setup: dir 755 "[x"
1704 file-setup: file 644 "[x/foo"
1716 Check that symbolic links aren't stat()'d
1717 file-setup: dir 755 "dir"
1718 file-setup: symlink 644 "dir/abc"
1730 file-setup: file 644 ".bc"
1731 file-setup: file 644 "abc"
1732 file-setup: file 644 "bbc"
1733 file-setup: file 644 "cbc"
1734 file-setup: file 644 "-bc"
1751 (AT&T ksh fails this; POSIX says invalid)
1752 file-setup: file 644 "abc"
1760 Check that globbing matches the right things...
1761 # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
1762 category: !os:darwin
1763 file-setup: file 644 "aÂc"
1771 Results unspecified according to POSIX
1772 file-setup: file 644 ".bc"
1780 Results unspecified according to POSIX
1781 (AT&T ksh treats this like [a-cc-e]*)
1782 file-setup: file 644 "abc"
1783 file-setup: file 644 "bbc"
1784 file-setup: file 644 "cbc"
1785 file-setup: file 644 "dbc"
1786 file-setup: file 644 "ebc"
1787 file-setup: file 644 "-bc"
1795 Check ordering/content of redundent here documents.
1807 Check quoted here-doc is protected.
1826 Check that newline isn't needed after heredoc-delimiter marker.
1838 Check that an error occurs if the heredoc-delimiter is missing.
1843 expected-exit: e > 0
1844 expected-stderr-pattern: /.*/
1848 Check that backslash quotes a $, ` and \ and kills a \newline
1855 th\`echo not-run\`ere
1856 th\\`echo is-run`ere
1873 Check that \newline in initial here-delim word doesn't imply
1888 Check that double quoted $ expressions in here delimiters are
1889 not expanded and match the delimiter.
1890 POSIX says only quote removal is applied to the delimiter.
1907 Check that double quoted escaped $ expressions in here
1908 delimiters are not expanded and match the delimiter.
1909 POSIX says only quote removal is applied to the delimiter
1910 (\ counts as a quote).
1931 Check that here strings work.
1932 category: !no-herestrings
1936 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo
1937 "$__progname" -c "tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo"
1938 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$bar"
1939 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<'$bar'
1940 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$bar
1941 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<-foo
1953 Check that a corner case of here strings works like bash
1954 category: !no-herestrings
1959 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
1965 Check that a corner case of here strings works like ksh93, zsh
1966 category: !no-herestrings
1971 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar
1978 Check another corner case of here strings
1979 category: !no-herestrings
1981 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<< bar
1985 name: heredoc-quoting-unsubst
1987 Check for correct handling of quoted characters in
1988 here documents without substitution (marker is quoted).
1992 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
1995 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
1997 name: heredoc-quoting-subst
1999 Check for correct handling of quoted characters in
2000 here documents with substitution (marker is not quoted).
2004 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x
2007 x " \" \ \ $ $ baz `echo baz` bar $foo x
2009 name: heredoc-tmpfile-1
2011 Check that heredoc temp files aren't removed too soon or too late.
2012 Heredoc in simple command.
2033 name: heredoc-tmpfile-2
2035 Check that heredoc temp files aren't removed too soon or too late.
2036 Heredoc in function, multiple calls to function.
2055 name: heredoc-tmpfile-3
2057 Check that heredoc temp files aren't removed too soon or too late.
2058 Heredoc in function in loop, multiple calls to function.
2085 name: heredoc-tmpfile-4
2087 Check that heredoc temp files aren't removed too soon or too late.
2088 Backgrounded simple command with here doc
2102 name: heredoc-tmpfile-5
2104 Check that heredoc temp files aren't removed too soon or too late.
2105 Backgrounded subshell command with here doc
2110 sleep 1 # so parent exits
2126 name: heredoc-tmpfile-6
2128 Check that heredoc temp files aren't removed too soon or too late.
2129 Heredoc in pipeline.
2133 cat <<- EOF | sed "s/hi/HI/"
2143 name: heredoc-tmpfile-7
2145 Check that heredoc temp files aren't removed too soon or too late.
2146 Heredoc in backgrounded pipeline.
2150 cat <<- EOF | sed 's/hi/HI/' &
2160 name: heredoc-tmpfile-8
2162 Check that heredoc temp files aren't removed too soon or too
2163 late. Heredoc in function, backgrounded call to function.
2164 This check can fail on slow machines (<100 MHz), or Cygwin,
2168 # Background eval so main shell doesn't do parsing
2176 # sleep so eval can die
2192 See if we can test history at all
2195 env-setup: !ENV=./Env!HISTFILE=hist.file!
2196 file-setup: file 644 "Env"
2204 expected-stderr-pattern:
2209 Verify duplicates and spaces are not entered
2212 env-setup: !ENV=./Env!HISTFILE=hist.file!
2213 file-setup: file 644 "Env"
2225 expected-stderr-pattern:
2228 name: history-unlink
2230 Check if broken HISTFILEs do not cause trouble
2231 category: !no-history
2233 env-setup: !ENV=./Env!HISTFILE=foo/hist.file!
2234 file-setup: file 644 "Env"
2236 file-setup: dir 755 "foo"
2237 file-setup: file 644 "foo/hist.file"
2240 perl-setup: chmod(0555, "foo");
2248 expected-stderr-pattern:
2249 /(.*cannot unlink HISTFILE.*\n)?X*$/
2251 name: history-e-minus-1
2253 Check if more recent command is executed
2254 category: !no-history
2256 env-setup: !ENV=./Env!HISTFILE=hist.file!
2257 file-setup: file 644 "Env"
2267 expected-stderr-pattern:
2268 /^X*echo there\nX*$/
2270 name: history-e-minus-2
2272 Check that repeated command is printed before command
2274 category: !no-history
2276 env-setup: !ENV=./Env!HISTFILE=hist.file!
2277 file-setup: file 644 "Env"
2284 expected-stdout-pattern:
2285 /X*hi\nX*there\nX*echo there\nthere\nX*/
2286 expected-stderr-pattern:
2289 name: history-e-minus-3
2291 fc -e - fails when there is no history
2292 (ksh93 has a bug that causes this to fail)
2293 (ksh88 loops on this)
2294 category: !no-history
2296 env-setup: !ENV=./Env!HISTFILE=hist.file!
2297 file-setup: file 644 "Env"
2304 expected-stderr-pattern:
2305 /^X*.*:.*history.*\nX*$/
2307 name: history-e-minus-4
2309 Check if "fc -e -" command output goes to stdout.
2310 category: !no-history
2312 env-setup: !ENV=./Env!HISTFILE=hist.file!
2313 file-setup: file 644 "Env"
2317 fc -e - | (read x; echo "A $x")
2323 expected-stderr-pattern:
2326 name: history-e-minus-5
2328 fc is replaced in history by new command.
2329 category: !no-history
2331 env-setup: !ENV=./Env!HISTFILE=hist.file!
2332 file-setup: file 644 "Env"
2348 expected-stderr-pattern:
2349 /^X*echo ghi jkl\nX*$/
2351 name: history-list-1
2353 List lists correct range
2354 (ksh88 fails 'cause it lists the fc command)
2355 category: !no-history
2357 env-setup: !ENV=./Env!HISTFILE=hist.file!
2358 file-setup: file 644 "Env"
2371 expected-stderr-pattern:
2374 name: history-list-2
2376 Lists oldest history if given pre-historic number
2377 (ksh93 has a bug that causes this to fail)
2378 (ksh88 fails 'cause it lists the fc command)
2379 category: !no-history
2381 env-setup: !ENV=./Env!HISTFILE=hist.file!
2382 file-setup: file 644 "Env"
2396 expected-stderr-pattern:
2399 name: history-list-3
2401 Can give number 'options' to fc
2402 category: !no-history
2404 env-setup: !ENV=./Env!HISTFILE=hist.file!
2405 file-setup: file 644 "Env"
2420 expected-stderr-pattern:
2423 name: history-list-4
2425 -1 refers to previous command
2426 category: !no-history
2428 env-setup: !ENV=./Env!HISTFILE=hist.file!
2429 file-setup: file 644 "Env"
2443 expected-stderr-pattern:
2446 name: history-list-5
2448 List command stays in history
2449 category: !no-history
2451 env-setup: !ENV=./Env!HISTFILE=hist.file!
2452 file-setup: file 644 "Env"
2469 expected-stderr-pattern:
2472 name: history-list-6
2474 HISTSIZE limits about of history kept.
2475 (ksh88 fails 'cause it lists the fc command)
2476 category: !no-history
2478 env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3!
2479 file-setup: file 644 "Env"
2496 expected-stderr-pattern:
2499 name: history-list-7
2501 fc allows too old/new errors in range specification
2502 category: !no-history
2504 env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3!
2505 file-setup: file 644 "Env"
2523 expected-stderr-pattern:
2526 name: history-list-r-1
2528 test -r flag in history
2529 category: !no-history
2531 env-setup: !ENV=./Env!HISTFILE=hist.file!
2532 file-setup: file 644 "Env"
2550 expected-stderr-pattern:
2553 name: history-list-r-2
2555 If first is newer than last, -r is implied.
2556 category: !no-history
2558 env-setup: !ENV=./Env!HISTFILE=hist.file!
2559 file-setup: file 644 "Env"
2577 expected-stderr-pattern:
2580 name: history-list-r-3
2582 If first is newer than last, -r is cancelled.
2583 category: !no-history
2585 env-setup: !ENV=./Env!HISTFILE=hist.file!
2586 file-setup: file 644 "Env"
2604 expected-stderr-pattern:
2607 name: history-subst-1
2610 category: !no-history
2612 env-setup: !ENV=./Env!HISTFILE=hist.file!
2613 file-setup: file 644 "Env"
2618 fc -e - abc=AB 'echo a'
2623 expected-stderr-pattern:
2624 /^X*echo AB def\nX*$/
2626 name: history-subst-2
2628 Does subst find previous command?
2629 category: !no-history
2631 env-setup: !ENV=./Env!HISTFILE=hist.file!
2632 file-setup: file 644 "Env"
2637 fc -e - jkl=XYZQRT 'echo g'
2642 expected-stderr-pattern:
2643 /^X*echo ghi XYZQRT\nX*$/
2645 name: history-subst-3
2647 Does subst find previous command when no arguments given
2648 category: !no-history
2650 env-setup: !ENV=./Env!HISTFILE=hist.file!
2651 file-setup: file 644 "Env"
2661 expected-stderr-pattern:
2662 /^X*echo ghi XYZQRT\nX*$/
2664 name: history-subst-4
2666 Global substitutions work
2667 (ksh88 and ksh93 do not have -g option)
2668 category: !no-history
2670 env-setup: !ENV=./Env!HISTFILE=hist.file!
2671 file-setup: file 644 "Env"
2674 echo abc def asjj sadjhasdjh asdjhasd
2677 abc def asjj sadjhasdjh asdjhasd
2678 FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd
2679 expected-stderr-pattern:
2680 /^X*echo FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd\nX*$/
2682 name: history-subst-5
2684 Make sure searches don't find current (fc) command
2685 (ksh88/ksh93 don't have the ? prefix thing so they fail this test)
2686 category: !no-history
2688 env-setup: !ENV=./Env!HISTFILE=hist.file!
2689 file-setup: file 644 "Env"
2694 fc -e - abc=AB \?abc
2699 expected-stderr-pattern:
2700 /^X*echo AB def\nX*$/
2702 name: history-ed-1-old
2704 Basic (ed) editing works (assumes you have generic ed editor
2705 that prints no prompts). This is for oldish ed(1) which write
2706 the character count to stdout.
2709 env-setup: !ENV=./Env!HISTFILE=hist.file!
2710 file-setup: file 644 "Env"
2723 expected-stderr-pattern:
2724 /^X*echo FOOBAR def\nX*$/
2726 name: history-ed-2-old
2728 Correct command is edited when number given
2731 env-setup: !ENV=./Env!HISTFILE=hist.file!
2732 file-setup: file 644 "Env"
2740 s/is here/is changed/
2751 expected-stderr-pattern:
2752 /^X*echo line 2 is changed\nX*$/
2754 name: history-ed-3-old
2756 Newly created multi line commands show up as single command
2758 (NOTE: adjusted for COMPLEX HISTORY compile time option)
2759 (ksh88 fails 'cause it lists the fc command)
2762 env-setup: !ENV=./Env!HISTFILE=hist.file!
2763 file-setup: file 644 "Env"
2784 expected-stderr-pattern:
2785 /^X*echo FOOBAR def\necho a new line\nX*$/
2789 Basic (ed) editing works (assumes you have generic ed editor
2790 that prints no prompts). This is for newish ed(1) and stderr.
2791 category: !no-history
2793 env-setup: !ENV=./Env!HISTFILE=hist.file!
2794 file-setup: file 644 "Env"
2805 expected-stderr-pattern:
2806 /^X*13\n16\necho FOOBAR def\nX*$/
2810 Correct command is edited when number given
2811 category: !no-history
2813 env-setup: !ENV=./Env!HISTFILE=hist.file!
2814 file-setup: file 644 "Env"
2822 s/is here/is changed/
2831 expected-stderr-pattern:
2832 /^X*20\n23\necho line 2 is changed\nX*$/
2836 Newly created multi line commands show up as single command
2838 category: !no-history
2840 env-setup: !ENV=./Env!HISTFILE=hist.file!
2841 file-setup: file 644 "Env"
2860 expected-stderr-pattern:
2861 /^X*13\n32\necho FOOBAR def\necho a new line\nX*$/
2865 Simple test, default IFS
2867 showargs() { for i; do echo -n " <$i>"; done; echo; }
2883 showargs() { for i; do echo -n " <$i>"; done; echo; }
2900 showargs() { for i; do echo -n " <$i>"; done; echo; }
2913 name: IFS-space-colon-1
2915 Simple test, IFS=<white-space>:
2917 showargs() { for i; do echo -n " <$i>"; done; echo; }
2932 name: IFS-space-colon-2
2934 Simple test, IFS=<white-space>:
2935 AT&T ksh fails this, POSIX says the test is correct.
2937 showargs() { for i; do echo -n " <$i>"; done; echo; }
2944 name: IFS-space-colon-3
2946 Simple test, IFS=<white-space>:
2947 pdksh fails both of these tests
2948 not sure whether #2 is correct
2950 showargs() { for i; do echo -n " <$i>"; done; echo; }
2961 name: IFS-space-colon-4
2963 Simple test, IFS=<white-space>:
2965 showargs() { for i; do echo -n " <$i>"; done; echo; }
2972 name: IFS-space-colon-5
2974 Simple test, IFS=<white-space>:
2975 Don't know what POSIX thinks of this. AT&T ksh does not do this.
2977 showargs() { for i; do echo -n " <$i>"; done; echo; }
2986 Simple test, IFS=<white-space>:
2988 showargs() { for i; do echo -n " <$i>"; done; echo; }
2991 echo -n '1:'; for i in $x ; do echo -n " [$i]" ; done ; echo
2992 echo -n '2:'; for i in :b:: ; do echo -n " [$i]" ; done ; echo
2996 echo -n '5:'; for i in $x ; do echo -n " [$i]" ; done ; echo
2999 echo -n '7:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3001 echo -n '9:'; for i in ${FOO-`echo -n h:i`th:ere} ; do echo -n " [$i]" ; done ; echo
3002 showargs 10 ${FOO-`echo -n h:i`th:ere}
3003 showargs 11 "${FOO-`echo -n h:i`th:ere}"
3005 echo -n '12:'; for i in $x ; do echo -n " [$i]" ; done ; echo
3017 <10> <h> <ith> <ere>
3022 name: integer-base-err-1
3024 Can't have 0 base (causes shell to exit)
3026 expected-exit: e != 0
3032 expected-stderr-pattern:
3035 name: integer-base-err-2
3037 Can't have multiple bases in a 'constant' (causes shell to exit)
3038 (ksh88 fails this test)
3040 expected-exit: e != 0
3046 expected-stderr-pattern:
3047 /^.*:.*2#110#11.*\n$/
3049 name: integer-base-err-3
3051 Syntax errors in expressions and effects on bases
3052 (interactive so errors don't cause exits)
3053 (ksh88 fails this test - shell exits, even with -i)
3057 PS1= # minimise prompt hassles
3064 expected-stderr-pattern:
3065 /^([#\$] )?.*:.*2+.*\n.*:.*2+.*\n$/
3070 name: integer-base-err-4
3072 Are invalid digits (according to base) errors?
3073 (ksh93 fails this test)
3075 expected-exit: e != 0
3079 expected-stderr-pattern:
3080 /^([#\$] )?.*:.*3#4.*\n$/
3082 name: integer-base-1
3084 Missing number after base is treated as 0.
3094 name: integer-base-2
3096 Check 'stickyness' of base in various situations
3148 name: integer-base-3
3150 More base parsing (hmm doesn't test much..)
3171 name: integer-base-4
3173 Check that things not declared as integers are not made integers,
3174 also, check if base is not reset by -i with no arguments.
3175 (ksh93 fails - prints 10#20 - go figure)
3180 typeset -i | grep '^xx='
3187 name: integer-base-5
3204 for l in 1 2+3 4; do echo $l; done
3216 name: integer-base-6
3218 Even more base stuff
3219 (ksh93 fails this test - prints 0)
3228 name: integer-base-7
3230 Check that non-integer parameters don't get bases assigned
3233 echo $(( zz = 8#100 ))
3241 See if $LINENO is updated and can be modified.
3254 See if $LINENO is set for .'d files.
3255 file-setup: file 644 "dotfile"
3273 See if $LINENO is set for commands in a function.
3292 See if unsetting LINENO makes it non-magic.
3293 file-setup: file 644 "dotfile"
3316 name: lineno-unset-use
3318 See if unsetting LINENO makes it non-magic even
3320 file-setup: file 644 "dotfile"
3346 Simple test, default IFS
3351 echo 1: "x[$x] y[$y] z[$z]"
3352 echo 1a: ${z-z not set}
3362 If no var specified, REPLY is used
3373 Lex array code had problems with this.
3384 When PATH is set before running a command, the new path is
3385 not used in doing the path search
3386 $ echo echo hi > /tmp/q ; chmod a+rx /tmp/q
3390 in comexec() the two lines
3392 (void) typeset(*vp++, xxx, 0);
3393 need to be moved out of the switch to before findcom() is
3394 called - I don't know what this will break.
3396 : ${PWD:-`pwd 2> /dev/null`}
3397 : ${PWD:?"PWD not set - can't do test"}
3399 cat > Y/xxxscript << EOF
3401 # Need to restore path so echo can be found (some shells don't have
3407 chmod a+rx Y/xxxscript
3408 export OLDPATH="$PATH"
3409 PATH=$PWD/Y xxxscript
3416 Parsing of $(..) expressions is non-optimal. It is
3417 impossible to have any parentheses inside the expression.
3419 $ ksh -c 'echo $(echo \( )'
3421 $ ksh -c 'echo $(echo "(" )'
3424 The solution is to hack the parsing clode in lex.c, the
3425 question is how to hack it: should any parentheses be
3426 escaped by a backslash, or should recursive parsing be done
3427 (so quotes could also be used to hide hem). The former is
3428 easier, the later better...
3436 Continue in a for loop does not work right:
3438 if [ $i = b ] ; then
3447 if [ $i = b ] ; then
3448 if [ $first = no ] ; then
3449 echo 'continue in for loop broken'
3450 break # hope break isn't broken too :-)
3465 shoud not print 0. (according to /bin/sh, AT&T ksh88, and the
3466 getopt(1) man page - not according to POSIX)
3478 should echo blah but on some machines echos /foo/bar/blah.
3487 Both of the following echos produce the same output under sh/ksh.att:
3490 echo "`echo \"$x\"`"
3492 pdksh produces different output for the former (foo instead of foo\tbar)
3495 echo "`echo \"$x\"`"
3503 The following command hangs forever:
3504 $ (: ; cat /etc/termcap) | sleep 2
3505 This is because the shell forks a shell to run the (..) command
3506 and this shell has the pipe open. When the sleep dies, the cat
3507 doesn't get a SIGPIPE 'cause a process (ie, the second shell)
3508 still has the pipe open.
3510 NOTE: this test provokes a bizarre bug in ksh93 (shell starts reading
3511 commands from /etc/termcap..)
3514 echo A line of text that will be duplicated quite a number of times.> t1
3515 cat t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 > t2
3516 cat t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 > t1
3517 cat t1 t1 t1 t1 > t2
3518 (: ; cat t2 2>&-) | sleep 1
3523 $ (foobar) 2> /dev/null
3524 generates no output under /bin/sh, but pdksh produces the error
3527 $ foobar 2> /dev/null
3528 generates an error under /bin/sh and pdksh, but AT&T ksh88 produces
3529 no error (redirected to /dev/null).
3531 (you/should/not/see/this/error/1) 2> /dev/null
3532 you/should/not/see/this/error/2 2> /dev/null
3539 generates a blank line under pdksh and sets the exit status to 0.
3540 AT&T ksh88 generates no output and sets the exit status to 1. Also,
3543 generates no output under AT&T ksh88 (pdksh generates a blank line
3547 whence does/not/exist > /dev/null
3549 echo 2: $(whence does/not/exist | wc -l)
3550 echo 3: $(whence does/not/exist cat | wc -l)
3558 ${var%%expr} seems to be broken in many places. On the mips
3560 $ read line < /etc/passwd
3568 change the value of line. On sun4s & pas, the echo ${line%%:*} doesn't
3569 work. Haven't checked elsewhere...
3576 root:asdjhasdasjhs:0:1:Root:/:/bin/sh
3579 root:asdjhasdasjhs:0:1:Root:/:/bin/sh
3585 should set the exit status to non-zero (sh and AT&T ksh88 do).
3586 XXX doting a non existent file is a fatal error for a script
3589 expected-exit: e != 0
3590 expected-stderr-pattern: /.?/
3594 Both of the following echos should produce the same thing, but don't:
3608 backslash does not work as expected in case labels:
3627 Quoting backquotes inside backquotes doesn't work:
3628 $ echo `echo hi \`echo there\` folks`
3629 asks for more info. sh and AT&T ksh88 both echo
3632 echo `echo hi \`echo there\` folks`
3638 )) is not treated `correctly':
3639 $ (echo hi ; (echo there ; echo folks))
3642 instead of (as sh and ksh.att)
3643 $ (echo hi ; (echo there ; echo folks))
3649 ( : ; ( : ; echo hi))
3655 Check reading stdin in a while loop. The read should only read
3656 a single line, not a whole stdio buffer; the cat should get
3659 (echo a; echo b) | while read x ; do
3668 Check reading stdin in a while loop. The read should read both
3669 lines, not just the first.
3672 while [ "$a" != xxx ] ; do
3675 cat /dev/null | sed 's/x/y/'
3689 should cause a script to exit.
3693 expected-exit: e != 0
3694 expected-stderr-pattern: /does\/not\/exist/
3698 variable assignements not detected well
3701 expected-exit: e != 0
3702 expected-stderr-pattern: /a\.x=1/
3706 alias expansion different from AT&T ksh88
3707 category: !no-aliases
3709 alias a='for ' b='i in'
3710 a b hi ; do echo $i ; done
3716 strange characters allowed inside ${...}
3719 expected-exit: e != 0
3720 expected-stderr-pattern: /.?/
3724 Does read handle partial lines correctly
3727 while [ "$a" != xxx ] ; do
3744 Does read set variables to null at eof?
3747 while [ "$a" != xxx ] ; do
3751 echo 1: ${x-x not set} ${y-y not set} ${z-z not set}
3752 echo 2: ${x:+x not null} ${y:+y not null} ${z:+z not null}
3762 Does umask print a leading 0 when umask is 3 digits?
3771 Tempory files used for here-docs in functions get trashed after
3772 the function is parsed (before it is executed)
3795 Command substitution breaks reading in while loop
3796 (test from <sjg@void.zen.oz.au>)
3798 (echo abcdef; echo; echo 123) |
3801 # the following line breaks it
3802 c=`echo $line | wc -c`
3812 Machines with broken times() (reported by <sjg@void.zen.oz.au>)
3813 time does not report correct real time
3817 expected-stderr-pattern: !/^\s*0\.0[\s\d]+real|^\s*real[\s]+0+\.0/
3821 set -e doesn't ignore exit codes for if/while/until/&&/||/!.
3824 if false; then echo hi ; fi
3827 while false; do echo hi; done
3834 set -e: errors in command substitutions aren't ignored
3835 Not clear if they should be or not... bash passes here
3836 this may actually be required for make, so changed the
3837 test to make this an mksh feature, not a bug
3840 echo `false; echo hi`
3850 This used to cause a core dump
3851 env-setup: !RANDOM=12!
3859 foo should be set to bar (should not be empty)
3869 Can't use command line assignments to assign readonly parameters.
3873 foo=stuff env | grep '^foo'
3874 expected-exit: e != 0
3875 expected-stderr-pattern:
3880 Can subshells be prefixed by redirections (historical shells allow
3883 < /dev/null (sed 's/^/X/')
3887 getopts sets OPTIND correctly for unparsed option
3890 while getopts :a optc; do
3891 echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc."
3895 OPTARG=, OPTIND=2, optc=a.
3896 OPTARG=, OPTIND=3, optc=a.
3897 OPTARG=x, OPTIND=3, optc=?.
3902 Parameter assignments with [] recognised correctly
3920 Check that alias expansion works in command substitutions and
3922 category: !no-aliases
3934 Check that aliases are fully read.
3935 category: !no-aliases
3948 Check that (here doc) temp files are not left behind after an exec.
3951 TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
3953 sed 's/^/X /' << E_O_F
3960 echo=echo; [ -x /bin/echo ] && echo=/bin/echo
3961 exec $echo subtest-1 hi
3963 echo subtest-1 foo/*
3964 TMPDIR=$PWD/foo "$__progname" <<- 'EOF'
3965 echo=echo; [ -x /bin/echo ] && echo=/bin/echo
3966 sed 's/^/X /' << E_O_F; exec $echo subtest-2 hi
3972 echo subtest-2 foo/*
3984 Check that unset params with attributes are reported by set, those
3985 sans attributes are not.
3998 Check that aliases do not use continuation prompt after trailing
4000 category: !no-aliases
4001 file-setup: file 644 "env"
4004 env-setup: !ENV=./env!
4007 alias foo='echo hi ; '
4019 Check that set allows both +o and -o options on same command line.
4022 set -o noglob +o allexport
4029 Check that globbing works in pipelined commands
4030 file-setup: file 644 "env"
4032 file-setup: file 644 "abc"
4034 env-setup: !ENV=./env!
4039 sed 's/^/X /' < ab* | sed 's/^/Y /'
4051 Check that getopts works in functions
4054 echo bfunc: enter "(args: $*; OPTIND=$OPTIND)"
4055 while getopts B oc; do
4058 echo bfunc: B option
4061 echo bfunc: odd option "($oc)"
4069 echo "line 1: OPTIND=$OPTIND"
4071 echo "line 2: ret=$?, optc=$optc, OPTIND=$OPTIND"
4073 echo "line 3: OPTIND=$OPTIND"
4075 echo "line 4: ret=$?, optc=$optc, OPTIND=$OPTIND"
4080 echo "line 10: OPTIND=$OPTIND"
4082 echo "line 20: ret=$?, optc=$optc, OPTIND=$OPTIND"
4084 echo "line 30: OPTIND=$OPTIND"
4086 echo "line 40: ret=$?, optc=$optc, OPTIND=$OPTIND"
4089 line 2: ret=0, optc=f, OPTIND=2
4090 bfunc: enter (args: -BBB blah; OPTIND=2)
4095 line 4: ret=0, optc=b, OPTIND=3
4098 line 20: ret=0, optc=f, OPTIND=2
4099 bfunc: enter (args: -BBB blah; OPTIND=2)
4104 line 40: ret=1, optc=?, OPTIND=2
4108 Check that ; is not required before the then in if (( ... )) then ...
4123 Check ${foo:%bar} is allowed (ksh88 allows it...)
4147 Check eval vs substitution exit codes
4155 eval "eval $(false)"
4157 eval 'eval '"$(false)"
4160 eval $(echo :; false)
4172 Check if typeset output is correct for
4173 uninitialised array elements.
4178 typeset -i | grep xxx | sed 's/^/ /'
4180 typeset | grep xxx | sed 's/^/ /'
4184 typeset -i | grep xxx | sed 's/^/ /'
4186 typeset | grep xxx | sed 's/^/ /'
4199 Check if trap exit is ok (exit not mistaken for signal name)
4200 category: idontunderstand
4209 Check if ${#array[*]} is calculated correctly.
4219 Check if default exit status is previous command
4225 ( (exit 103) ; exit)
4234 Check if EXIT trap is executed for sub shells.
4236 trap 'echo parent exit' EXIT
4238 (echo A; echo A last)
4240 (echo C; trap 'echo sub exit' EXIT; echo C last)
4255 Check if test -nt/-ot succeeds if second(first) file is missing.
4259 test a -nt b && echo nt OK || echo nt BAD
4260 test b -ot a && echo ot OK || echo ot BAD
4267 Check if typeset, export, and readonly work
4278 export FNORD_A FNORD_C FNORD_D FNORD_G FNORD_H
4279 readonly FNORD_B FNORD_D FNORD_F FNORD_H
4318 Check that we can redefine functions calling time builtin
4330 Check that lone ampersand is a syntax error
4333 expected-exit: e != 0
4334 expected-stderr-pattern:
4337 name: xxx-quoted-newline-1
4339 Check that \<newline> works inside of ${}
4347 name: xxx-quoted-newline-2
4349 Check that \<newline> works at the start of a here document
4358 name: xxx-quoted-newline-3
4360 Check that \<newline> works at the end of a here document
4369 name: xxx-multi-assignment-cmd
4371 Check that assignments in a command affect subsequent assignments
4380 name: xxx-exec-environment-1
4382 Check to see if exec sets it's environment correctly
4385 expected-stdout-pattern:
4388 name: xxx-exec-environment-2
4390 Check to make sure exec doesn't change environment if a program
4393 sortprog=$(which sort) || sortprog=cat
4394 env | $sortprog >bar1
4395 FOO=bar exec; env | $sortprog >bar2
4398 name: xxx-what-do-you-call-this-1
4404 name: xxx-prefix-strip-1
4411 name: xxx-prefix-strip-2
4419 name: xxx-variable-syntax-1
4422 expected-stderr-pattern:
4426 name: xxx-substitution-eval-order
4428 Check order of evaluation of expressions
4432 set -A A abc def GHI j G k
4433 echo ${A[x=(i+=1)]#${A[y=(i+=2)]}}
4439 name: xxx-set-option-1
4441 Check option parsing in set
4452 Check that exec exits for built-ins
4459 expected-stderr-pattern: /.*/
4463 Check the return value of while loops
4464 XXX need to do same for for/select/until loops
4467 while [ $i != xxx ] ; do
4469 if [ $i = xxx ] ; then
4477 while [ $i != xxx ] ; do
4479 if [ $i = xxx ] ; then
4487 while [ $i != xxx ] ; do
4499 Check that blank lines don't clear $?
4511 expected-stderr-pattern: /.*/
4515 Check that $? is preserved in subshells, includes, traps.
4524 echo 'echo include: $?' > foo
4536 name: xxx-clean-chars-1
4538 Check MAGIC character is stuffed correctly
4544 name: xxx-param-subst-qmark-1
4546 Check suppresion of error message with null string. According to
4547 POSIX, it shouldn't print the error as 'word' isn't ommitted.
4548 ksh88, Solaris /bin/sh and /usr/xpg4/bin/sh all print the error,
4549 that's why the condition is reversed.
4557 #expected-stderr-pattern: !/not set/
4559 expected-stderr-pattern: /parameter null or not set/
4562 # fails due to weirdness of execv stuff
4563 category: !os:uwin-nt
4565 Check c flag is set.
4566 arguments: !-c!echo "[$-]"!
4567 expected-stdout-pattern: /^\[.*c.*\]$/
4569 name: tilde-expand-1
4571 Check tilde expansion after equal signs
4572 env-setup: !HOME=/sweet!
4574 echo ${A=a=}~ b=~ c=d~ ~
4580 Check some "exit on error" conditions
4583 /usr/bin/env false && echo something
4588 + /usr/bin/env false
4593 Check some "exit on error" edge conditions (POSIXly)
4596 if /usr/bin/env true; then
4597 /usr/bin/env false && echo something
4604 + /usr/bin/env false
4609 pdksh regression which AT&T ksh does right
4610 TFM says: [set] -e | errexit
4611 Exit (after executing the ERR trap) ...
4613 trap 'echo EXIT' EXIT
4615 cd /XXXXX 2>/dev/null
4620 expected-exit: e != 0
4624 "set -e" test suite (POSIX)
4638 "set -e" test suite (POSIX)
4644 [ "$1" = "$E" ] && { shift ; continue 2 ; }
4661 "set -e" test suite (BSD make)
4665 print 'all:\n\t@echo eins\n\t@exit 42\n' >zd/a/Makefile
4666 print 'all:\n\t@echo zwei\n' >zd/b/Makefile
4669 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"
4675 Stop in WD/zd/a (line 2 of Makefile).
4679 Check that test also can handle string1 < string2 etc.
4682 test 2005/10/08 '<' 2005/08/21 && echo ja || echo nein
4683 test 2005/08/21 \< 2005/10/08 && echo ja || echo nein
4684 test 2005/10/08 '>' 2005/08/21 && echo ja || echo nein
4685 test 2005/08/21 \> 2005/10/08 && echo ja || echo nein
4691 expected-stderr-pattern: !/unexpected op/
4693 name: test-precedence-1
4695 Check a precedence case (and POSIX echo)
4705 Check that ~/.mkshrc works correctly.
4706 Part 1: verify user environment is not read (internal)
4715 Check that ~/.mkshrc works correctly.
4716 Part 2: verify mkshrc is not read (non-interactive shells)
4718 file-setup: file 644 ".mkshrc"
4720 env-setup: !HOME=.!ENV=!
4728 Check that ~/.mkshrc works correctly.
4729 Part 2: verify mkshrc can be read (interactive shells)
4731 file-setup: file 644 ".mkshrc"
4734 env-setup: !HOME=.!ENV=!PS1=!
4739 expected-stderr-pattern:
4744 Check that ~/.mkshrc works correctly.
4745 Part 3: verify mkshrc can be turned off
4747 file-setup: file 644 ".mkshrc"
4749 env-setup: !HOME=.!ENV=nonexistant!
4757 Check that posix mode turns braceexpand off
4758 and that that works correctly
4766 Check that posix mode is *not* automatically turned on
4769 ln -s "$__progname" ksh
4770 ln -s "$__progname" sh
4771 ln -s "$__progname" ./-ksh
4772 ln -s "$__progname" ./-sh
4773 for shell in {,-}{,k}sh; do
4774 print -- $shell $(./$shell +l -c \
4775 '[[ $(set +o) == *@(-o posix)@(| *) ]] && echo posix || echo noposix')
4785 Check that posix mode is automatically turned on
4788 ln -s "$__progname" ksh
4789 ln -s "$__progname" sh
4790 ln -s "$__progname" ./-ksh
4791 ln -s "$__progname" ./-sh
4792 for shell in {,-}{,k}sh; do
4793 print -- $shell $(./$shell +l -c \
4794 '[[ $(set +o) == *@(-o posix)@(| *) ]] && echo posix || echo noposix')
4804 pdksh bug: last command of a pipeline is executed in a
4805 subshell - make sure it still is, scripts depend on it
4806 file-setup: file 644 "abcx"
4807 file-setup: file 644 "abcy"
4810 echo a | while read d; do
4830 check that co-processes work with TCOMs, TPIPEs and TPARENs
4831 category: !no-coprocs
4833 "$__progname" -c 'i=100; print hi |& while read -p line; do print "$((i++)) $line"; done'
4834 "$__progname" -c 'i=200; print hi | cat |& while read -p line; do print "$((i++)) $line"; done'
4835 "$__progname" -c 'i=300; (print hi | cat) |& while read -p line; do print "$((i++)) $line"; done'
4841 name: persist-history-1
4843 Check if persistent history saving works
4844 category: !no-history
4846 env-setup: !ENV=./Env!HISTFILE=hist.file!
4847 file-setup: file 644 "Env"
4851 expected-stdout-pattern:
4853 expected-stderr-pattern:
4856 name: typeset-padding-1
4858 Check if left/right justification works as per TFM
4859 category: !no-typeset
4861 typeset -L10 ln=0hall0
4862 typeset -R10 rn=0hall0
4863 typeset -ZL10 lz=0hall0
4864 typeset -ZR10 rz=0hall0
4865 typeset -Z10 rx=" hallo "
4866 print "<$ln> <$rn> <$lz> <$rz> <$rx>"
4868 <0hall0 > < 0hall0> <hall0 > <00000hall0> <0000 hallo>
4870 name: typeset-padding-2
4872 Check if base-!10 integers are padded right
4873 category: !no-typeset
4875 typeset -Uui16 -L9 ln=16#1
4876 typeset -Uui16 -R9 rn=16#1
4877 typeset -Uui16 -Z9 zn=16#1
4881 print "<$ln> <$rn> <$zn> <$ls> <$rs> <$zs>"
4883 <16#1 > < 16#1> <16#000001> <16#1 > < 16#1> <0000016#1>
4887 Check that the UTF-8 Byte Order Mark is ignored as the first
4888 multibyte character of the shell input (with -c, from standard
4889 input, as file, or as eval argument), but nowhere else
4890 # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition)
4891 category: !os:darwin
4894 echo '#!/bin/sh\necho ohne' >foo/fnord
4895 echo '#!/bin/sh\necho mit' >foo/fnord
4896 echo 'fnord\nfnord\nfnord\nfnord' >foo/bar
4897 echo eval \''fnord\nfnord\nfnord\nfnord'\' >foo/zoo
4899 export PATH=$(pwd)/foo:$PATH
4900 "$__progname" -c 'fnord'
4902 "$__progname" -c 'fnord; fnord; fnord; fnord'
4904 "$__progname" foo/bar
4906 "$__progname" <foo/bar
4908 "$__progname" foo/zoo
4910 "$__progname" -c 'echo : $(fnord)'
4939 Check that we can execute BOM-shebangs (failures not fatal)
4940 XXX if the OS can already execute them, we lose
4941 note: cygwin execve(2) doesn't return to us with ENOEXEC, we lose
4942 note: Ultrix perl5 t4 returns 65280 (exit-code 255) and no text
4943 category: !os:cygwin,!os:uwin-nt,!os:ultrix,!smksh
4945 env-setup: !FOO=BAR!
4947 echo '#!'"$__progname"'\necho "1 a=$ENV{FOO}";' >t1
4948 echo '#!'"$__progname"'\necho "2 a=$ENV{FOO}";' >t2
4949 echo '#!'"$__perlname"'\necho "3 a=$ENV{FOO}\n";' >t3
4950 echo '#!'"$__perlname"'\necho "4 a=$ENV{FOO}\n";' >t4
4957 1 a=/nonexistant{FOO}
4958 2 a=/nonexistant{FOO}
4961 expected-stderr-pattern:
4962 /(Unrecognized character .... ignored at \..t4 line 1)*/
4966 Reading the UTF-8 BOM should enable the utf8-mode flag
4969 "$__progname" -c ':; if [[ $- = *U* ]]; then print 1 on; else print 1 off; fi'
4970 "$__progname" -c ':; if [[ $- = *U* ]]; then print 2 on; else print 2 off; fi'
4977 Check that the utf8-mode flag is not set at non-interactive startup
4979 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8!
4981 if [[ $- = *U* ]]; then
4991 Check that the utf8-mode flag is not set at non-interactive startup
4993 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.utf8!
4995 if [[ $- = *U* ]]; then
5005 Check that the utf8-mode flag is set at interactive startup.
5006 -DMKSH_ASSUME_UTF8=0 => expected failure, please ignore
5007 -DMKSH_ASSUME_UTF8=1 => not expected, please investigate
5008 -UMKSH_ASSUME_UTF8 => not expected, but if your OS is old,
5009 try passing HAVE_SETLOCALE_CTYPE=0 to Build.sh
5012 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8!
5014 if [[ $- = *U* ]]; then
5021 expected-stderr-pattern:
5026 Check that the utf8-mode flag is set at interactive startup
5027 Expected failure if -DMKSH_ASSUME_UTF8=0
5030 env-setup: !PS1=!PS2=!LC_CTYPE=en_US.utf8!
5032 if [[ $- = *U* ]]; then
5039 expected-stderr-pattern:
5044 Check if built-in shell aliases are okay
5045 category: !no-aliases
5050 autoload='typeset -fu'
5051 functions='typeset -f'
5054 integer='typeset -i'
5059 source='PATH=$PATH:. command .'
5061 suspend='kill -STOP $$'
5064 name: aliases-1-hartz4
5066 Check if built-in shell aliases are okay
5067 category: !no-aliases
5072 autoload='typeset -fu'
5073 functions='typeset -f'
5076 integer='typeset -i'
5081 source='PATH=$PATH:. command .'
5086 Check if “set -o posix” disables built-in aliases (except a few)
5088 arguments: !-o!posix!
5093 integer='typeset -i'
5098 Check if running as sh disables built-in aliases (except a few)
5100 arguments: !-o!posix!
5103 ./sh -c 'alias; typeset -f'
5106 integer='typeset -i'
5111 Check if “set -o posix” does not influence built-in aliases
5112 category: !no-aliases
5113 arguments: !-o!posix!
5118 autoload='typeset -fu'
5119 functions='typeset -f'
5122 integer='typeset -i'
5127 source='PATH=$PATH:. command .'
5129 suspend='kill -STOP $$'
5134 Check if running as sh does not influence built-in aliases
5135 category: !no-aliases
5136 arguments: !-o!posix!
5139 ./sh -c 'alias; typeset -f'
5142 autoload='typeset -fu'
5143 functions='typeset -f'
5146 integer='typeset -i'
5151 source='PATH=$PATH:. command .'
5153 suspend='kill -STOP $$'
5156 name: aliases-2b-hartz4
5158 Check if “set -o posix” does not influence built-in aliases
5159 category: !no-aliases
5160 arguments: !-o!posix!
5165 autoload='typeset -fu'
5166 functions='typeset -f'
5169 integer='typeset -i'
5174 source='PATH=$PATH:. command .'
5177 name: aliases-3b-hartz4
5179 Check if running as sh does not influence built-in aliases
5180 category: !no-aliases
5181 arguments: !-o!posix!
5184 ./sh -c 'alias; typeset -f'
5187 autoload='typeset -fu'
5188 functions='typeset -f'
5191 integer='typeset -i'
5196 source='PATH=$PATH:. command .'
5199 name: aliases-funcdef-1
5201 Check if POSIX functions take precedences over aliases
5202 category: !no-aliases
5204 alias foo='echo makro'
5212 name: aliases-funcdef-2
5214 Check if POSIX functions take precedences over aliases
5215 category: !no-aliases
5217 alias foo='echo makro'
5225 name: aliases-funcdef-3
5227 Check if aliases take precedences over Korn functions
5228 category: !no-aliases
5230 alias foo='echo makro'
5240 Check if Korn Shell arrays work as expected
5241 category: !no-arrays
5244 set -A foo -- a \$v "$v" '$v' b
5245 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
5251 Check if bash-style arrays work as expected
5252 category: !no-arrays
5255 foo=(a \$v "$v" '$v' b)
5256 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|"
5262 Check if array bounds are uint32_t
5263 category: !no-arrays
5270 print ${foo[4294967295]} g ${foo[*]}
5275 name: varexpand-substr-1
5277 Check if bash-style substring expansion works
5278 when using positive numerics
5282 typeset -i y=123456789
5283 typeset -i 16 z=123456789 # 16#75bcd15
5284 print a t${x:2:2} ${y:2:3} ${z:2:3} a
5285 print b ${x::3} ${y::3} ${z::3} b
5286 print c ${x:2:} ${y:2:} ${z:2:} c
5287 print d ${x:2} ${y:2} ${z:2} d
5288 print e ${x:2:6} ${y:2:6} ${z:2:7} e
5289 print f ${x:2:7} ${y:2:7} ${z:2:8} f
5290 print g ${x:2:8} ${y:2:8} ${z:2:9} g
5295 d cdefghi 3456789 #75bcd15 d
5296 e cdefgh 345678 #75bcd1 e
5297 f cdefghi 3456789 #75bcd15 f
5298 g cdefghi 3456789 #75bcd15 g
5300 name: varexpand-substr-2
5302 Check if bash-style substring expansion works
5303 when using negative numerics or expressions
5307 typeset -i y=123456789
5308 typeset -i 16 z=123456789 # 16#75bcd15
5310 print a ${x:$n:3} ${y:$n:3} ${z:$n:3} a
5311 print b ${x:(n):3} ${y:(n):3} ${z:(n):3} b
5312 print c ${x:(-2):1} ${y:(-2):1} ${z:(-2):1} c
5313 print d t${x: n:2} ${y: n:3} ${z: n:3} d
5320 name: varexpand-substr-3
5322 Check that some things that work in bash fail.
5323 This is by design. And that some things fail in both.
5326 export x=abcdefghi n=2
5327 "$__progname" -c 'echo v${x:(n)}x'
5328 "$__progname" -c 'echo w${x: n}x'
5329 "$__progname" -c 'echo x${x:n}x'
5330 "$__progname" -c 'echo y${x:}x'
5331 "$__progname" -c 'echo z${x}x'
5332 "$__progname" -c 'x=abcdef;y=123;echo ${x:${y:2:1}:2}' >/dev/null 2>&1; echo $?
5338 expected-stderr-pattern:
5339 /x:n.*bad substitution.*\n.*bad substitution/
5341 name: varexpand-substr-4
5343 Check corner cases for substring expansion
5348 print a ${x:(y == 1 ? 2 : 3):4} a
5352 name: varexpand-substr-5A
5354 Check that substring expansions work on characters
5359 print a ${x::1} ${x: -1} a
5360 print b ${x::3} ${x: -3} b
5361 print c ${x:1:2} ${x: -3:2} c
5369 name: varexpand-substr-5W
5371 Check that substring expansions work on characters
5376 print a ${x::1} ${x: -1} a
5377 print b ${x::2} ${x: -2} b
5378 print c ${x:1:1} ${x: -2:1} c
5386 name: print-funny-chars
5388 Check print builtin's capability to output designated characters
5391 print '<\0144\0344\xDB\u00DB\u20AC\uDB\x40>'
5395 name: print-nul-chars
5397 Check handling of NUL characters for print and read
5398 note: second line should output “4 3” but we cannot
5399 handle NUL characters in strings yet
5401 echo $(($(echo '<\0>' | wc -c)))
5403 echo $(($(echo "$x" | wc -c))) ${#x}
5408 name: dot-needs-argument
5410 check Debian #415167 solution: '.' without arguments should fail
5413 "$__progname" -c source
5414 expected-exit: e != 0
5415 expected-stderr-pattern:
5416 /.*\.: no file specified for sourcing\n.*source: not found/
5418 name: alias-function-no-conflict
5420 make aliases not conflict with functions
5421 note: for ksh-like functions, the order of preference is
5422 different; bash outputs baz instead of bar in line 2 below
5423 category: !no-aliases
5425 alias foo='echo bar'
5429 alias korn='echo bar'
5436 foo 2>&- || echo rab
5442 name: bash-function-parens
5444 ensure the keyword function is ignored when preceding
5445 POSIX style function declarations (bashism)
5449 echo '#!'"$__progname"
5451 echo ' echo "bar='\''$0'\'\"
5455 mk 'function foo' >f-korn
5457 mk 'function foo ()' >f-bash
5458 mk 'function stop ()' stop >f-stop
5460 echo "korn: $(./f-korn)"
5461 echo "dash: $(./f-dash)"
5462 echo "bash: $(./f-bash)"
5463 echo "stop: $(./f-stop)"
5466 dash: bar='./f-dash'
5467 bash: bar='./f-bash'
5468 stop: bar='./f-stop'
5470 name: integer-base-one-1
5472 check if the use of fake integer base 1 works
5476 typeset -Uui16 i0=1#ï i1=1#€
5478 typeset -i1 o1a=0x263A
5479 typeset -Uui1 o0b=0x7E
5480 typeset -Uui1 o1b=0xFDD0
5481 integer px=0xCAFE 'p0=1# ' p1=1#… pl=1#f
5482 print "in <$i0> <$i1>"
5483 print "out <${o0a#1#}|${o0b#1#}> <${o1a#1#}|${o1b#1#}>"
5485 print "pass <$px> <$p0> <$p1> <$pl> <${i0#1#}|${i1#1#}>"
5486 typeset -Uui16 tv1=1#~ tv2=1#
\x7f tv3=1#€ tv4=1#� tv5=1#À tv6=1#Á tv7=1# tv8=1#€
5487 print "specX <${tv1#16#}> <${tv2#16#}> <${tv3#16#}> <${tv4#16#}> <${tv5#16#}> <${tv6#16#}> <${tv7#16#}> <${tv8#16#}>"
5488 typeset -i1 tv1 tv2 tv3 tv4 tv5 tv6 tv7 tv8
5489 print "specW <${tv1#1#}> <${tv2#1#}> <${tv3#1#}> <${tv4#1#}> <${tv5#1#}> <${tv6#1#}> <${tv7#1#}> <${tv8#1#}>"
5490 typeset -i1 xs1=0xEF7F xs2=0xEF80 xs3=0xFDD0
5491 print "specU <${xs1#1#}> <${xs2#1#}> <${xs3#1#}>"
5493 in <16#EFEF> <16#20AC>
5495 pass <16#cafe> <1# > <1#…> <1#f> <ï|€>
5496 specX <7E> <7F> <EF80> <EF81> <EFC0> <EFC1> <A0> <80>
5497 specW <~> <
\x7f> <€> <�> <À> <Á> < > <€>
5498 specU <> <€> <ï·�>
5500 name: integer-base-one-2a
5502 check if the use of fake integer base 1 stops at correct characters
5508 expected-stderr-pattern:
5509 /1#foo: unexpected 'oo'/
5510 expected-exit: e != 0
5512 name: integer-base-one-2b
5514 check if the use of fake integer base 1 stops at correct characters
5520 expected-stderr-pattern:
5521 /1#À€: unexpected '€'/
5522 expected-exit: e != 0
5524 name: integer-base-one-2c1
5526 check if the use of fake integer base 1 stops at correct characters
5535 name: integer-base-one-2c2
5537 check if the use of fake integer base 1 stops at correct characters
5543 expected-stderr-pattern:
5544 /1#…: unexpected '€'/
5545 expected-exit: e != 0
5547 name: integer-base-one-2d1
5549 check if the use of fake integer base 1 handles octets okay
5554 print /$x/ # invalid utf-8
5558 name: integer-base-one-2d2
5560 check if the use of fake integer base 1 handles octets
5565 print /$x/ # invalid 2-byte
5569 name: integer-base-one-2d3
5571 check if the use of fake integer base 1 handles octets
5576 print /$x/ # invalid 2-byte
5580 name: integer-base-one-2d4
5582 check if the use of fake integer base 1 stops at invalid input
5586 typeset -i16 x=1#ï¿À
5587 print /$x/ # invalid 3-byte
5588 expected-stderr-pattern:
5589 /1#ï¿À: unexpected '¿'/
5590 expected-exit: e != 0
5592 name: integer-base-one-2d5
5594 check if the use of fake integer base 1 stops at invalid input
5599 print /$x/ # non-minimalistic
5600 expected-stderr-pattern:
5601 /1#À€: unexpected '€'/
5602 expected-exit: e != 0
5604 name: integer-base-one-2d6
5606 check if the use of fake integer base 1 stops at invalid input
5610 typeset -i16 x=1#à€€
5611 print /$x/ # non-minimalistic
5612 expected-stderr-pattern:
5613 /1#à€€: unexpected '€'/
5614 expected-exit: e != 0
5616 name: integer-base-one-3A
5618 some sample code for hexdumping
5622 print 'Hello, World!\\\nこんにちは!'
5623 typeset -Uui16 i=0x100
5624 # change that to 0xFF once we can handle embedded
5625 # NUL characters in strings / here documents
5626 while (( i++ < 0x1FF )); do
5627 print -n "\x${i#16#1}"
5631 typeset -Uui16 -Z11 pos=0
5632 typeset -Uui16 -Z5 hv
5636 while IFS= read -r line; do
5638 while [[ -n $line ]]; do
5640 if (( (pos & 15) == 0 )); then
5641 (( pos )) && print "$dasc|"
5642 print -n "${pos#16#} "
5645 print -n "${hv#16#} "
5646 if (( (hv < 32) || (hv > 126) )); then
5649 dasc=$dasc${line::1}
5651 (( (pos++ & 15) == 7 )) && print -n -- '- '
5655 if (( (pos & 15) != 1 )); then
5656 while (( pos & 15 )); do
5658 (( (pos++ & 15) == 7 )) && print -n -- '- '
5664 00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..|
5665 00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................|
5666 00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................|
5667 00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................|
5668 00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.|
5669 00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>|
5670 00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN|
5671 00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^|
5672 00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn|
5673 00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~|
5674 000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................|
5675 000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................|
5676 000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................|
5677 000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................|
5678 000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................|
5679 000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................|
5680 00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................|
5681 00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................|
5682 00000120 FF 0A - |..|
5684 name: integer-base-one-3W
5686 some sample code for hexdumping Unicode
5691 print 'Hello, World!\\\nこんにちは!'
5692 typeset -Uui16 i=0x100
5693 # change that to 0xFF once we can handle embedded
5694 # NUL characters in strings / here documents
5695 while (( i++ < 0x1FF )); do
5696 print -n "\u${i#16#1}"
5699 print \\xff # invalid utf-8
5700 print \\xc2 # invalid 2-byte
5701 print \\xef\\xbf\\xc0 # invalid 3-byte
5702 print \\xc0\\x80 # non-minimalistic
5703 print \\xe0\\x80\\x80 # non-minimalistic
5704 print '�' # end of range
5706 typeset -Uui16 -Z11 pos=0
5707 typeset -Uui16 -Z7 hv
5712 while IFS= read -r line; do
5715 while (( lpos < ${#line} )); do
5716 wc=1#${line:(lpos++):1}
5717 if (( (wc < 32) || \
5718 ((wc > 126) && (wc < 160)) )); then
5720 elif (( (wc & 0xFF80) == 0xEF80 )); then
5725 if (( (pos & 7) == 7 )); then
5728 elif (( (pos & 7) == 0 )); then
5729 (( pos )) && print "$dasc|"
5730 print -n "${pos#16#} "
5734 print -n "${hv#16#} "
5735 (( (pos++ & 7) == 3 )) && \
5740 if (( pos & 7 )); then
5741 while (( pos & 7 )); do
5743 (( (pos++ & 7) == 3 )) && print -n -- '- '
5749 00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W|
5750 00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.こ|
5751 00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |んにちは!...|
5752 00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........|
5753 00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........|
5754 00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........|
5755 00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"|
5756 00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*|
5757 00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012|
5758 00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:|
5759 00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB|
5760 00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ|
5761 00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR|
5762 00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ|
5763 00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab|
5764 00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij|
5765 00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr|
5766 00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz|
5767 00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....|
5768 00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........|
5769 000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........|
5770 000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........|
5771 000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |..... ¡¢|
5772 000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA |£¤¥¦§¨©ª|
5773 000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 |«¬®¯°±²|
5774 000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA |³´µ¶·¸¹º|
5775 000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 |»¼½¾¿ÀÁÂ|
5776 000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA |ÃÄÅÆÇÈÉÊ|
5777 000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 |ËÌÍÎÏÐÑÒ|
5778 000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA |ÓÔÕÖ×ØÙÚ|
5779 000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 |ÛÜÝÞßàáâ|
5780 000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA |ãäåæçèéê|
5781 00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 |ëìíîïðñò|
5782 00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA |óôõö÷øùú|
5783 00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |ûüýþÿ.�.|
5784 00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |�.���.��|
5785 00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |.���.���|
5786 00000128 EFBE EFEF EFBF EFBF - 000A |����.|
5790 Check if we can use a specific syntax idiom for ulimit
5791 category: !no-ulimit
5793 if ! x=$(ulimit -d); then
5794 print expected to fail on this OS
5796 ulimit -dS $x && print okay
5803 Check if GNU bash-like I/O redirection works
5804 Part 1: this is also supported by GNU bash
5824 Check if GNU bash-like I/O redirection works
5825 Part 2: this is *not* supported by GNU bash
5845 Check if GNU bash-like I/O redirection works
5846 Part 2: this is *not* supported by GNU bash
5866 Check if GNU bash-like I/O redirection works
5867 Part 2: this is supported by GNU bash 4 only
5890 Check if GNU bash-like I/O redirection fails correctly
5891 Part 1: this is also supported by GNU bash
5908 expected-stderr-pattern: /.*: cannot (create|overwrite) .*/
5912 Check if GNU bash-like I/O redirection fails correctly
5913 Part 2: this is *not* supported by GNU bash
5935 Check if GNU bash-like I/O redirection works
5936 Part 4: this is also supported by GNU bash,
5937 but failed in some mksh versions
5947 [[ -e bar ]] && threeout "$bf" &>foo
5962 Check for support of more than 9 file descriptors
5965 read -u10 foo 10<<< bar
5972 Check for support of more than 9 file descriptors
5985 src/regress/bin/ksh/shcrash.sh,v 1.1
5987 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"
5988 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"
5989 for deplib in $deplibs; do
5992 new_libs="$deplib $new_libs"
5995 case " $specialdeplibs " in
5997 new_libs="$deplib $new_libs";;
6003 name: oksh-varfunction
6005 $OpenBSD: varfunction.sh,v 1.1 2003/12/15 05:28:40 otto Exp $
6008 where f is a ksh style function, should not set FOO in the current
6009 env. If f is a bourne style function, FOO should be set. Furthermore,
6010 the function should receive a correct value of FOO. Additionally,
6011 setting FOO in the function itself should not change the value in
6013 Inspired by PR 2450.
6017 if [ x$FOO != xbar ]; then
6022 if [ "x$x" != "xFOO=bar" ]; then
6030 if [ x$FOO != xbar ]; then
6035 if [ "x$x" != "xFOO=bar" ]; then
6043 if [ $? != 0 ]; then
6046 if [ x$FOO != x ]; then
6050 if [ $? != 0 ]; then
6053 if [ x$FOO != xbar ]; then
6058 if [ $? != 0 ]; then
6061 if [ x$FOO != xbarbar ]; then
6065 if [ $? != 0 ]; then
6068 if [ x$FOO != xbar ]; then
6074 Verify that file descriptors > 2 are private for Korn shells
6076 file-setup: file 644 "test.sh"
6080 "$__progname" test.sh
6081 expected-exit: e != 0
6083 test.sh[1]: print: -u: 3: bad file descriptor
6087 Verify that file descriptors > 2 are not private for POSIX shells
6088 See Debian Bug #154540, Closes: #499139
6090 file-setup: file 644 "test.sh"
6095 "$__progname" test.sh
6101 COMSUB are currently parsed by hacking lex.c instead of
6102 recursively (see regression-6): matching parenthesēs bug
6103 Fails on: pdksh mksh bash2 bash3 zsh
6104 Passes on: bash4 ksh93
6107 echo $(case 1 in (1) echo yes;; (2) echo no;; esac)
6108 echo $(case 1 in 1) echo yes;; 2) echo no;; esac)
6115 RedHat BZ#496791 – another case of missing recursion
6116 in parsing COMSUB expressions
6117 Fails on: pdksh mksh bash2 bash3¹ bash4¹ zsh
6119 ① bash[34] seem to choke on comment ending with backslash-newline
6122 # a comment with " ' \
6125 # a comment with " ' \
6133 Check that the short form [ $x ] works
6137 rv=$?; echo $((++i)) $rv
6139 rv=$?; echo $((++i)) $rv
6141 rv=$?; echo $((++i)) $rv
6143 rv=$?; echo $((++i)) $rv
6146 rv=$?; echo $((++i)) $rv
6148 rv=$?; echo $((++i)) $rv
6150 rv=$?; echo $((++i)) $rv
6152 rv=$?; echo $((++i)) $rv
6155 rv=$?; echo $((++i)) $rv
6157 rv=$?; echo $((++i)) $rv
6159 rv=$?; echo $((++i)) $rv
6161 rv=$?; echo $((++i)) $rv
6178 Check that the short form [[ $x ]] works (ksh93 extension)
6183 rv=$?; echo $((++i)) $rv
6185 rv=$?; echo $((++i)) $rv
6187 rv=$?; echo $((++i)) $rv
6189 rv=$?; echo $((++i)) $rv
6192 rv=$?; echo $((++i)) $rv
6194 rv=$?; echo $((++i)) $rv
6196 rv=$?; echo $((++i)) $rv
6198 rv=$?; echo $((++i)) $rv
6201 rv=$?; echo $((++i)) $rv
6203 rv=$?; echo $((++i)) $rv
6205 rv=$?; echo $((++i)) $rv
6207 rv=$?; echo $((++i)) $rv
6222 name: event-subst-1a
6224 Check that '!' substitution in interactive mode works
6226 file-setup: file 755 "falsetto"
6230 file-setup: file 755 "!false"
6244 expected-stderr-pattern:
6247 name: event-subst-1b
6249 Check that '!' substitution in interactive mode works
6250 even when a space separates it from the search command,
6251 which is not what GNU bash provides but required for the
6252 other regression tests below to check
6254 file-setup: file 755 "falsetto"
6258 file-setup: file 755 "!"
6272 expected-stderr-pattern:
6277 Check that '!' substitution in interactive mode
6278 does not break things
6280 file-setup: file 755 "falsetto"
6284 file-setup: file 755 "!"
6288 env-setup: !ENV=./Env!
6289 file-setup: file 644 "Env"
6300 ! false; then echo foo; else echo bar; fi
6309 expected-stderr-pattern:
6314 Check that '!' substitution in noninteractive mode is ignored
6316 file-setup: file 755 "falsetto"
6320 file-setup: file 755 "!false"
6332 ! false; then echo foo; else echo bar; fi
6343 Check that "set -u" matches (future) POSIX requirement
6384 (mypid=$$; try mypid)
6386 ) 2>&1 | sed -e 's/^[^]]*]//' -e 's/^[^:]*: *//'
6390 <stdin>:42: y: parameter not set
6394 y: parameter not set
6398 2: parameter not set
6400 <stdin>:42: 1: parameter not set
6408 <stdin>:42: !: parameter not set