Elliott Hughes | 4708626 | 2019-03-26 12:34:31 -0700 | [diff] [blame] | 1 | # $MirOS: src/bin/mksh/check.t,v 1.812 2019/03/01 16:17:29 tg Exp $ |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 2 | # -*- mode: sh -*- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 3 | #- |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 4 | # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, |
Elliott Hughes | 4708626 | 2019-03-26 12:34:31 -0700 | [diff] [blame] | 5 | # 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, |
| 6 | # 2019 |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 7 | # mirabilos <m@mirbsd.org> |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8 | # |
| 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. |
| 14 | # |
| 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. |
| 23 | #- |
| 24 | # You may also want to test IFS with the script at |
| 25 | # http://www.research.att.com/~gsf/public/ifs.sh |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 26 | # |
| 27 | # More testsuites at: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 28 | # http://svnweb.freebsd.org/base/head/bin/test/tests/legacy_test.sh?view=co&content-type=text%2Fplain |
| 29 | # |
| 30 | # Integrated testsuites from: |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 31 | # (2013/12/02 20:39:44) http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 32 | |
| 33 | expected-stdout: |
Elliott Hughes | 4708626 | 2019-03-26 12:34:31 -0700 | [diff] [blame] | 34 | @(#)MIRBSD KSH R57 2019/03/01 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 35 | description: |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 36 | Check base version of full shell |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 37 | stdin: |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 38 | echo ${KSH_VERSION%%' +'*} |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 39 | name: KSH_VERSION |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 40 | category: !shell:legacy-yes |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 41 | --- |
| 42 | expected-stdout: |
Elliott Hughes | 4708626 | 2019-03-26 12:34:31 -0700 | [diff] [blame] | 43 | @(#)LEGACY KSH R57 2019/03/01 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 44 | description: |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 45 | Check base version of legacy shell |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 46 | stdin: |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 47 | echo ${KSH_VERSION%%' +'*} |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 48 | name: KSH_VERSION-legacy |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 49 | category: !shell:legacy-no |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 50 | --- |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 51 | name: KSH_VERSION-ascii |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 52 | description: |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 53 | Check that the shell version tag does not include EBCDIC |
| 54 | category: !shell:ebcdic-yes |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 55 | stdin: |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 56 | for x in $KSH_VERSION; do |
| 57 | [[ $x = '+EBCDIC' ]] && exit 1 |
| 58 | done |
| 59 | exit 0 |
| 60 | --- |
| 61 | name: KSH_VERSION-ebcdic |
| 62 | description: |
| 63 | Check that the shell version tag includes EBCDIC |
| 64 | category: !shell:ebcdic-no |
| 65 | stdin: |
| 66 | for x in $KSH_VERSION; do |
| 67 | [[ $x = '+EBCDIC' ]] && exit 0 |
| 68 | done |
| 69 | exit 1 |
| 70 | --- |
| 71 | name: KSH_VERSION-binmode |
| 72 | description: |
| 73 | Check that the shell version tag does not include TEXTMODE |
| 74 | category: !shell:textmode-yes |
| 75 | stdin: |
| 76 | for x in $KSH_VERSION; do |
| 77 | [[ $x = '+TEXTMODE' ]] && exit 1 |
| 78 | done |
| 79 | exit 0 |
| 80 | --- |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 81 | name: KSH_VERSION-textmode |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 82 | description: |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 83 | Check that the shell version tag includes TEXTMODE |
| 84 | category: !shell:textmode-no |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 85 | stdin: |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 86 | for x in $KSH_VERSION; do |
| 87 | [[ $x = '+TEXTMODE' ]] && exit 0 |
| 88 | done |
| 89 | exit 1 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 90 | --- |
| 91 | name: selftest-1 |
| 92 | description: |
| 93 | Regression test self-testing |
| 94 | stdin: |
| 95 | echo ${foo:-baz} |
| 96 | expected-stdout: |
| 97 | baz |
| 98 | --- |
| 99 | name: selftest-2 |
| 100 | description: |
| 101 | Regression test self-testing |
| 102 | env-setup: !foo=bar! |
| 103 | stdin: |
| 104 | echo ${foo:-baz} |
| 105 | expected-stdout: |
| 106 | bar |
| 107 | --- |
| 108 | name: selftest-3 |
| 109 | description: |
| 110 | Regression test self-testing |
| 111 | env-setup: !ENV=fnord! |
| 112 | stdin: |
| 113 | echo "<$ENV>" |
| 114 | expected-stdout: |
| 115 | <fnord> |
| 116 | --- |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 117 | name: selftest-exec |
| 118 | description: |
| 119 | Ensure that the test run directory (default /tmp but can be changed |
| 120 | with check.pl flag -T or test.sh $TMPDIR) is not mounted noexec, as |
| 121 | we execute scripts from the scratch directory during several tests. |
| 122 | stdin: |
| 123 | print '#!'"$__progname"'\necho tf' >lq |
| 124 | chmod +x lq |
| 125 | ./lq |
| 126 | expected-stdout: |
| 127 | tf |
| 128 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 129 | name: selftest-env |
| 130 | description: |
| 131 | Just output the environment variables set (always fails) |
| 132 | category: disabled |
| 133 | stdin: |
| 134 | set |
| 135 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 136 | name: selftest-direct-builtin-call |
| 137 | description: |
| 138 | Check that direct builtin calls work |
| 139 | stdin: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 140 | ln -s "$__progname" cat || cp "$__progname" cat |
| 141 | ln -s "$__progname" echo || cp "$__progname" echo |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 142 | ./echo -c 'echo foo' | ./cat -u |
| 143 | expected-stdout: |
| 144 | -c echo foo |
| 145 | --- |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 146 | name: selftest-pathsep-unix |
| 147 | description: |
| 148 | Check that $PATHSEP is set correctly. |
| 149 | category: !os:os2 |
| 150 | stdin: |
| 151 | PATHSEP=.; export PATHSEP |
| 152 | "$__progname" -c 'print -r -- $PATHSEP' |
| 153 | expected-stdout: |
| 154 | : |
| 155 | --- |
| 156 | name: selftest-pathsep-dospath |
| 157 | description: |
| 158 | Check that $PATHSEP is set correctly. |
| 159 | category: os:os2 |
| 160 | stdin: |
| 161 | PATHSEP=.; export PATHSEP |
| 162 | "$__progname" -c 'print -r -- $PATHSEP' |
| 163 | expected-stdout: |
| 164 | ; |
| 165 | --- |
Elliott Hughes | 4708626 | 2019-03-26 12:34:31 -0700 | [diff] [blame] | 166 | name: selftest-tty-absent |
| 167 | description: |
| 168 | Check that a controlling tty is not present as regress:no-ctty was used |
| 169 | (if this test fails for you DO NOT PASS regress:no-ctty and fix every |
| 170 | other test that fails: why u use it if u haz ctty?) |
| 171 | category: regress:no-ctty |
| 172 | env-setup: !ENV=./envf! |
| 173 | file-setup: file 644 "envf" |
| 174 | PS1=X |
| 175 | arguments: !-i! |
| 176 | stdin: |
| 177 | echo ok |
| 178 | expected-stdout: |
| 179 | ok |
| 180 | expected-stderr-pattern: |
| 181 | /mksh: warning: won't have full job control\nXX/ |
| 182 | --- |
| 183 | name: selftest-tty-present |
| 184 | description: |
| 185 | Check that a controlling tty is present as regress:no-ctty was not used |
| 186 | need-ctty: yes |
| 187 | env-setup: !ENV=./envf! |
| 188 | file-setup: file 644 "envf" |
| 189 | PS1=X |
| 190 | arguments: !-i! |
| 191 | stdin: |
| 192 | echo ok |
| 193 | expected-stdout: |
| 194 | ok |
| 195 | expected-stderr: ! |
| 196 | XX |
| 197 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 198 | name: alias-1 |
| 199 | description: |
| 200 | Check that recursion is detected/avoided in aliases. |
| 201 | stdin: |
| 202 | alias fooBar=fooBar |
| 203 | fooBar |
| 204 | exit 0 |
| 205 | expected-stderr-pattern: |
| 206 | /fooBar.*not found.*/ |
| 207 | --- |
| 208 | name: alias-2 |
| 209 | description: |
| 210 | Check that recursion is detected/avoided in aliases. |
| 211 | stdin: |
| 212 | alias fooBar=barFoo |
| 213 | alias barFoo=fooBar |
| 214 | fooBar |
| 215 | barFoo |
| 216 | exit 0 |
| 217 | expected-stderr-pattern: |
| 218 | /fooBar.*not found.*\n.*barFoo.*not found/ |
| 219 | --- |
| 220 | name: alias-3 |
| 221 | description: |
| 222 | Check that recursion is detected/avoided in aliases. |
| 223 | stdin: |
| 224 | alias Echo='echo ' |
| 225 | alias fooBar=barFoo |
| 226 | alias barFoo=fooBar |
| 227 | Echo fooBar |
| 228 | unalias barFoo |
| 229 | Echo fooBar |
| 230 | expected-stdout: |
| 231 | fooBar |
| 232 | barFoo |
| 233 | --- |
| 234 | name: alias-4 |
| 235 | description: |
| 236 | Check that alias expansion isn't done on keywords (in keyword |
| 237 | postitions). |
| 238 | stdin: |
| 239 | alias Echo='echo ' |
| 240 | alias while=While |
| 241 | while false; do echo hi ; done |
| 242 | Echo while |
| 243 | expected-stdout: |
| 244 | While |
| 245 | --- |
| 246 | name: alias-5 |
| 247 | description: |
| 248 | Check that alias expansion done after alias with trailing space. |
| 249 | stdin: |
| 250 | alias Echo='echo ' |
| 251 | alias foo='bar stuff ' |
| 252 | alias bar='Bar1 Bar2 ' |
| 253 | alias stuff='Stuff' |
| 254 | alias blah='Blah' |
| 255 | Echo foo blah |
| 256 | expected-stdout: |
| 257 | Bar1 Bar2 Stuff Blah |
| 258 | --- |
| 259 | name: alias-6 |
| 260 | description: |
| 261 | Check that alias expansion done after alias with trailing space. |
| 262 | stdin: |
| 263 | alias Echo='echo ' |
| 264 | alias foo='bar bar' |
| 265 | alias bar='Bar ' |
| 266 | alias blah=Blah |
| 267 | Echo foo blah |
| 268 | expected-stdout: |
| 269 | Bar Bar Blah |
| 270 | --- |
| 271 | name: alias-7 |
| 272 | description: |
| 273 | Check that alias expansion done after alias with trailing space |
| 274 | after a keyword. |
| 275 | stdin: |
| 276 | alias X='case ' |
| 277 | alias Y=Z |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 278 | X Y in 'Y') echo is y ;; Z) echo is z ;; esac |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 279 | expected-stdout: |
| 280 | is z |
| 281 | --- |
| 282 | name: alias-8 |
| 283 | description: |
| 284 | Check that newlines in an alias don't cause the command to be lost. |
| 285 | stdin: |
| 286 | alias foo=' |
| 287 | |
| 288 | |
| 289 | echo hi |
| 290 | |
| 291 | |
| 292 | |
| 293 | echo there |
| 294 | |
| 295 | |
| 296 | ' |
| 297 | foo |
| 298 | expected-stdout: |
| 299 | hi |
| 300 | there |
| 301 | --- |
| 302 | name: alias-9 |
| 303 | description: |
| 304 | Check that recursion is detected/avoided in aliases. |
| 305 | This check fails for slow machines or Cygwin, raise |
| 306 | the time-limit clause (e.g. to 7) if this occurs. |
| 307 | time-limit: 3 |
| 308 | stdin: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 309 | print '#!'"$__progname"'\necho tf' >lq |
| 310 | chmod +x lq |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 311 | PATH=$PWD$PATHSEP$PATH |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 312 | alias lq=lq |
| 313 | lq |
| 314 | echo = now |
| 315 | i=`lq` |
| 316 | print -r -- $i |
| 317 | echo = out |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 318 | exit 0 |
| 319 | expected-stdout: |
| 320 | tf |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 321 | = now |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 322 | tf |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 323 | = out |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 324 | --- |
| 325 | name: alias-10 |
| 326 | description: |
| 327 | Check that recursion is detected/avoided in aliases. |
| 328 | Regression, introduced during an old bugfix. |
| 329 | stdin: |
| 330 | alias foo='print hello ' |
| 331 | alias bar='foo world' |
| 332 | echo $(bar) |
| 333 | expected-stdout: |
| 334 | hello world |
| 335 | --- |
Elliott Hughes | b27ce95 | 2015-04-21 13:39:18 -0700 | [diff] [blame] | 336 | name: alias-11 |
| 337 | description: |
| 338 | Check that special argument handling still applies with escaped aliases |
| 339 | stdin: |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 340 | alias local1='\typeset' |
| 341 | alias local2='\\builtin typeset' |
| 342 | function fooa { |
| 343 | local1 x=$1 y=z |
Elliott Hughes | b27ce95 | 2015-04-21 13:39:18 -0700 | [diff] [blame] | 344 | print -r -- "$x,$y" |
| 345 | } |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 346 | function foob { |
| 347 | local2 x=$1 y=z |
| 348 | print -r -- "$x,$y" |
| 349 | } |
| 350 | x=1 y=2; fooa 'bar - baz' |
| 351 | x=1 y=2; foob 'bar - baz' |
Elliott Hughes | b27ce95 | 2015-04-21 13:39:18 -0700 | [diff] [blame] | 352 | expected-stdout: |
| 353 | bar - baz,z |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 354 | bar - baz,z |
| 355 | --- |
| 356 | name: alias-12 |
| 357 | description: |
| 358 | Something weird from Martijn Dekker |
| 359 | stdin: |
| 360 | alias echo=print |
| 361 | x() { echo a; (echo b); x=$(echo c); } |
| 362 | typeset -f x |
| 363 | alias OPEN='{' CLOSE='};' |
| 364 | { OPEN echo hi1; CLOSE } |
| 365 | var=`{ OPEN echo hi2; CLOSE }` && echo "$var" |
| 366 | var=$({ OPEN echo hi3; CLOSE }) && echo "$var" |
| 367 | expected-stdout: |
| 368 | x() { |
| 369 | \print a |
| 370 | ( \print b ) |
| 371 | x=$(\print c ) |
| 372 | } |
| 373 | hi1 |
| 374 | hi2 |
| 375 | hi3 |
Elliott Hughes | b27ce95 | 2015-04-21 13:39:18 -0700 | [diff] [blame] | 376 | --- |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 377 | name: arith-compound |
| 378 | description: |
| 379 | Check that arithmetic expressions are compound constructs |
| 380 | stdin: |
| 381 | { ! (( 0$(cat >&2) )) <<<1; } <<<2 |
| 382 | expected-stderr: |
| 383 | 1 |
| 384 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 385 | name: arith-lazy-1 |
| 386 | description: |
| 387 | Check that only one side of ternary operator is evaluated |
| 388 | stdin: |
| 389 | x=i+=2 |
| 390 | y=j+=2 |
| 391 | typeset -i i=1 j=1 |
| 392 | echo $((1 ? 20 : (x+=2))) |
| 393 | echo $i,$x |
| 394 | echo $((0 ? (y+=2) : 30)) |
| 395 | echo $j,$y |
| 396 | expected-stdout: |
| 397 | 20 |
| 398 | 1,i+=2 |
| 399 | 30 |
| 400 | 1,j+=2 |
| 401 | --- |
| 402 | name: arith-lazy-2 |
| 403 | description: |
| 404 | Check that assignments not done on non-evaluated side of ternary |
| 405 | operator |
| 406 | stdin: |
| 407 | x=i+=2 |
| 408 | y=j+=2 |
| 409 | typeset -i i=1 j=1 |
| 410 | echo $((1 ? 20 : (x+=2))) |
| 411 | echo $i,$x |
| 412 | echo $((0 ? (y+=2) : 30)) |
| 413 | echo $i,$y |
| 414 | expected-stdout: |
| 415 | 20 |
| 416 | 1,i+=2 |
| 417 | 30 |
| 418 | 1,j+=2 |
| 419 | --- |
| 420 | name: arith-lazy-3 |
| 421 | description: |
| 422 | Check that assignments not done on non-evaluated side of ternary |
| 423 | operator and this construct is parsed correctly (Debian #445651) |
| 424 | stdin: |
| 425 | x=4 |
| 426 | y=$((0 ? x=1 : 2)) |
| 427 | echo = $x $y = |
| 428 | expected-stdout: |
| 429 | = 4 2 = |
| 430 | --- |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 431 | name: arith-lazy-4 |
| 432 | description: |
| 433 | Check that preun/postun not done on non-evaluated side of ternary |
| 434 | operator |
| 435 | stdin: |
| 436 | (( m = n = 0, 1 ? n++ : m++ ? 2 : 3 )) |
| 437 | echo "($n, $m)" |
| 438 | m=0; echo $(( 0 ? ++m : 2 )); echo $m |
| 439 | m=0; echo $(( 0 ? m++ : 2 )); echo $m |
| 440 | expected-stdout: |
| 441 | (1, 0) |
| 442 | 2 |
| 443 | 0 |
| 444 | 2 |
| 445 | 0 |
| 446 | --- |
Elliott Hughes | 966dd55 | 2016-12-08 15:56:04 -0800 | [diff] [blame] | 447 | name: arith-lazy-5-arr-n |
| 448 | description: Check lazy evaluation with side effects |
| 449 | stdin: |
| 450 | a=0; echo "$((0&&b[a++],a))" |
| 451 | expected-stdout: |
| 452 | 0 |
| 453 | --- |
| 454 | name: arith-lazy-5-arr-p |
| 455 | description: Check lazy evaluation with side effects |
| 456 | stdin: |
| 457 | a=0; echo "$((0&&(b[a++]),a))" |
| 458 | expected-stdout: |
| 459 | 0 |
| 460 | --- |
| 461 | name: arith-lazy-5-str-n |
| 462 | description: Check lazy evaluation with side effects |
| 463 | stdin: |
| 464 | a=0 b=a++; ((0&&b)); echo $a |
| 465 | expected-stdout: |
| 466 | 0 |
| 467 | --- |
| 468 | name: arith-lazy-5-str-p |
| 469 | description: Check lazy evaluation with side effects |
| 470 | stdin: |
| 471 | a=0 b=a++; ((0&&(b))); echo $a |
| 472 | expected-stdout: |
| 473 | 0 |
| 474 | --- |
| 475 | name: arith-lazy-5-tern-l-n |
| 476 | description: Check lazy evaluation with side effects |
| 477 | stdin: |
| 478 | a=0; echo "$((0?b[a++]:999,a))" |
| 479 | expected-stdout: |
| 480 | 0 |
| 481 | --- |
| 482 | name: arith-lazy-5-tern-l-p |
| 483 | description: Check lazy evaluation with side effects |
| 484 | stdin: |
| 485 | a=0; echo "$((0?(b[a++]):999,a))" |
| 486 | expected-stdout: |
| 487 | 0 |
| 488 | --- |
| 489 | name: arith-lazy-5-tern-r-n |
| 490 | description: Check lazy evaluation with side effects |
| 491 | stdin: |
| 492 | a=0; echo "$((1?999:b[a++],a))" |
| 493 | expected-stdout: |
| 494 | 0 |
| 495 | --- |
| 496 | name: arith-lazy-5-tern-r-p |
| 497 | description: Check lazy evaluation with side effects |
| 498 | stdin: |
| 499 | a=0; echo "$((1?999:(b[a++]),a))" |
| 500 | expected-stdout: |
| 501 | 0 |
| 502 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 503 | name: arith-ternary-prec-1 |
| 504 | description: |
| 505 | Check precedence of ternary operator vs assignment |
| 506 | stdin: |
| 507 | typeset -i x=2 |
| 508 | y=$((1 ? 20 : x+=2)) |
| 509 | expected-exit: e != 0 |
| 510 | expected-stderr-pattern: |
| 511 | /.*:.*1 \? 20 : x\+=2.*lvalue.*\n$/ |
| 512 | --- |
| 513 | name: arith-ternary-prec-2 |
| 514 | description: |
| 515 | Check precedence of ternary operator vs assignment |
| 516 | stdin: |
| 517 | typeset -i x=2 |
| 518 | echo $((0 ? x+=2 : 20)) |
| 519 | expected-stdout: |
| 520 | 20 |
| 521 | --- |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 522 | name: arith-prec-1 |
| 523 | description: |
| 524 | Prove arithmetic expressions with embedded parameter |
| 525 | substitutions cannot be parsed ahead of time |
| 526 | stdin: |
| 527 | a='3 + 4' |
| 528 | print 1 $((2 * a)) . |
| 529 | print 2 $((2 * $a)) . |
| 530 | expected-stdout: |
| 531 | 1 14 . |
| 532 | 2 10 . |
| 533 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 534 | name: arith-div-assoc-1 |
| 535 | description: |
| 536 | Check associativity of division operator |
| 537 | stdin: |
| 538 | echo $((20 / 2 / 2)) |
| 539 | expected-stdout: |
| 540 | 5 |
| 541 | --- |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 542 | name: arith-div-byzero |
| 543 | description: |
| 544 | Check division by zero errors out |
| 545 | stdin: |
| 546 | x=$(echo $((1 / 0))) |
| 547 | echo =$?:$x. |
| 548 | expected-stdout: |
| 549 | =1:. |
| 550 | expected-stderr-pattern: |
| 551 | /.*divisor/ |
| 552 | --- |
| 553 | name: arith-div-intmin-by-minusone |
| 554 | description: |
| 555 | Check division overflow wraps around silently |
| 556 | category: int:32 |
| 557 | stdin: |
| 558 | echo signed:$((-2147483648 / -1))r$((-2147483648 % -1)). |
| 559 | echo unsigned:$((# -2147483648 / -1))r$((# -2147483648 % -1)). |
| 560 | expected-stdout: |
| 561 | signed:-2147483648r0. |
| 562 | unsigned:0r2147483648. |
| 563 | --- |
| 564 | name: arith-div-intmin-by-minusone-64 |
| 565 | description: |
| 566 | Check division overflow wraps around silently |
| 567 | category: int:64 |
| 568 | stdin: |
| 569 | echo signed:$((-9223372036854775808 / -1))r$((-9223372036854775808 % -1)). |
| 570 | echo unsigned:$((# -9223372036854775808 / -1))r$((# -9223372036854775808 % -1)). |
| 571 | expected-stdout: |
| 572 | signed:-9223372036854775808r0. |
| 573 | unsigned:0r9223372036854775808. |
| 574 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 575 | name: arith-assop-assoc-1 |
| 576 | description: |
| 577 | Check associativity of assignment-operator operator |
| 578 | stdin: |
| 579 | typeset -i i=1 j=2 k=3 |
| 580 | echo $((i += j += k)) |
| 581 | echo $i,$j,$k |
| 582 | expected-stdout: |
| 583 | 6 |
| 584 | 6,5,3 |
| 585 | --- |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 586 | name: arith-mandatory |
| 587 | description: |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 588 | Passing of this test is *mandatory* for a valid mksh executable! |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 589 | category: shell:legacy-no |
| 590 | stdin: |
| 591 | typeset -i sari=0 |
| 592 | typeset -Ui uari=0 |
| 593 | typeset -i x=0 |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 594 | print -r -- $((x++)):$sari=$uari. #0 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 595 | let --sari --uari |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 596 | print -r -- $((x++)):$sari=$uari. #1 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 597 | sari=2147483647 uari=2147483647 |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 598 | print -r -- $((x++)):$sari=$uari. #2 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 599 | let ++sari ++uari |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 600 | print -r -- $((x++)):$sari=$uari. #3 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 601 | let --sari --uari |
| 602 | let 'sari *= 2' 'uari *= 2' |
| 603 | let ++sari ++uari |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 604 | print -r -- $((x++)):$sari=$uari. #4 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 605 | let ++sari ++uari |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 606 | print -r -- $((x++)):$sari=$uari. #5 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 607 | sari=-2147483648 uari=-2147483648 |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 608 | print -r -- $((x++)):$sari=$uari. #6 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 609 | let --sari --uari |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 610 | print -r -- $((x++)):$sari=$uari. #7 |
| 611 | (( sari = -5 >> 1 )) |
| 612 | ((# uari = -5 >> 1 )) |
| 613 | print -r -- $((x++)):$sari=$uari. #8 |
| 614 | (( sari = -2 )) |
| 615 | ((# uari = sari )) |
| 616 | print -r -- $((x++)):$sari=$uari. #9 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 617 | expected-stdout: |
| 618 | 0:0=0. |
| 619 | 1:-1=4294967295. |
| 620 | 2:2147483647=2147483647. |
| 621 | 3:-2147483648=2147483648. |
| 622 | 4:-1=4294967295. |
| 623 | 5:0=0. |
| 624 | 6:-2147483648=2147483648. |
| 625 | 7:2147483647=2147483647. |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 626 | 8:-3=2147483645. |
| 627 | 9:-2=4294967294. |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 628 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 629 | name: arith-unsigned-1 |
| 630 | description: |
| 631 | Check if unsigned arithmetics work |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 632 | category: int:32 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 633 | stdin: |
| 634 | # signed vs unsigned |
| 635 | echo x1 $((-1)) $((#-1)) |
| 636 | # calculating |
| 637 | typeset -i vs |
| 638 | typeset -Ui vu |
| 639 | vs=4123456789; vu=4123456789 |
| 640 | echo x2 $vs $vu |
| 641 | (( vs %= 2147483647 )) |
| 642 | (( vu %= 2147483647 )) |
| 643 | echo x3 $vs $vu |
| 644 | vs=4123456789; vu=4123456789 |
| 645 | (( # vs %= 2147483647 )) |
| 646 | (( # vu %= 2147483647 )) |
| 647 | echo x4 $vs $vu |
| 648 | # make sure the calculation does not change unsigned flag |
| 649 | vs=4123456789; vu=4123456789 |
| 650 | echo x5 $vs $vu |
| 651 | # short form |
| 652 | echo x6 $((# vs % 2147483647)) $((# vu % 2147483647)) |
| 653 | # array refs |
| 654 | set -A va |
| 655 | va[1975973142]=right |
| 656 | va[4123456789]=wrong |
| 657 | echo x7 ${va[#4123456789%2147483647]} |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 658 | # make sure multiple calculations don't interfere with each other |
| 659 | let '# mca = -4 % -2' ' mcb = -4 % -2' |
| 660 | echo x8 $mca $mcb |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 661 | expected-stdout: |
| 662 | x1 -1 4294967295 |
| 663 | x2 -171510507 4123456789 |
| 664 | x3 -171510507 4123456789 |
| 665 | x4 1975973142 1975973142 |
| 666 | x5 -171510507 4123456789 |
| 667 | x6 1975973142 1975973142 |
| 668 | x7 right |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 669 | x8 -4 0 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 670 | --- |
| 671 | name: arith-limit32-1 |
| 672 | description: |
| 673 | Check if arithmetics are 32 bit |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 674 | category: int:32 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 675 | stdin: |
| 676 | # signed vs unsigned |
| 677 | echo x1 $((-1)) $((#-1)) |
| 678 | # calculating |
| 679 | typeset -i vs |
| 680 | typeset -Ui vu |
| 681 | vs=2147483647; vu=2147483647 |
| 682 | echo x2 $vs $vu |
| 683 | let vs++ vu++ |
| 684 | echo x3 $vs $vu |
| 685 | vs=4294967295; vu=4294967295 |
| 686 | echo x4 $vs $vu |
| 687 | let vs++ vu++ |
| 688 | echo x5 $vs $vu |
| 689 | let vs++ vu++ |
| 690 | echo x6 $vs $vu |
| 691 | expected-stdout: |
| 692 | x1 -1 4294967295 |
| 693 | x2 2147483647 2147483647 |
| 694 | x3 -2147483648 2147483648 |
| 695 | x4 -1 4294967295 |
| 696 | x5 0 0 |
| 697 | x6 1 1 |
| 698 | --- |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 699 | name: arith-limit64-1 |
| 700 | description: |
| 701 | Check if arithmetics are 64 bit |
| 702 | category: int:64 |
| 703 | stdin: |
| 704 | # signed vs unsigned |
| 705 | echo x1 $((-1)) $((#-1)) |
| 706 | # calculating |
| 707 | typeset -i vs |
| 708 | typeset -Ui vu |
| 709 | vs=9223372036854775807; vu=9223372036854775807 |
| 710 | echo x2 $vs $vu |
| 711 | let vs++ vu++ |
| 712 | echo x3 $vs $vu |
| 713 | vs=18446744073709551615; vu=18446744073709551615 |
| 714 | echo x4 $vs $vu |
| 715 | let vs++ vu++ |
| 716 | echo x5 $vs $vu |
| 717 | let vs++ vu++ |
| 718 | echo x6 $vs $vu |
| 719 | expected-stdout: |
| 720 | x1 -1 18446744073709551615 |
| 721 | x2 9223372036854775807 9223372036854775807 |
| 722 | x3 -9223372036854775808 9223372036854775808 |
| 723 | x4 -1 18446744073709551615 |
| 724 | x5 0 0 |
| 725 | x6 1 1 |
| 726 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 727 | name: bksl-nl-ign-1 |
| 728 | description: |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 729 | Check that \newline is not collapsed after # |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 730 | stdin: |
| 731 | echo hi #there \ |
| 732 | echo folks |
| 733 | expected-stdout: |
| 734 | hi |
| 735 | folks |
| 736 | --- |
| 737 | name: bksl-nl-ign-2 |
| 738 | description: |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 739 | Check that \newline is not collapsed inside single quotes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 740 | stdin: |
| 741 | echo 'hi \ |
| 742 | there' |
| 743 | echo folks |
| 744 | expected-stdout: |
| 745 | hi \ |
| 746 | there |
| 747 | folks |
| 748 | --- |
| 749 | name: bksl-nl-ign-3 |
| 750 | description: |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 751 | Check that \newline is not collapsed inside single quotes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 752 | stdin: |
| 753 | cat << \EOF |
| 754 | hi \ |
| 755 | there |
| 756 | EOF |
| 757 | expected-stdout: |
| 758 | hi \ |
| 759 | there |
| 760 | --- |
| 761 | name: bksl-nl-ign-4 |
| 762 | description: |
| 763 | Check interaction of aliases, single quotes and here-documents |
| 764 | with backslash-newline |
| 765 | (don't know what POSIX has to say about this) |
| 766 | stdin: |
| 767 | a=2 |
| 768 | alias x='echo hi |
| 769 | cat << "EOF" |
| 770 | foo\ |
| 771 | bar |
| 772 | some' |
| 773 | x |
| 774 | more\ |
| 775 | stuff$a |
| 776 | EOF |
| 777 | expected-stdout: |
| 778 | hi |
| 779 | foo\ |
| 780 | bar |
| 781 | some |
| 782 | more\ |
| 783 | stuff$a |
| 784 | --- |
| 785 | name: bksl-nl-ign-5 |
| 786 | description: |
| 787 | Check what happens with backslash at end of input |
| 788 | (the old Bourne shell trashes them; so do we) |
| 789 | stdin: ! |
| 790 | echo `echo foo\\`bar |
| 791 | echo hi\ |
| 792 | expected-stdout: |
| 793 | foobar |
| 794 | hi |
| 795 | --- |
| 796 | # |
| 797 | # Places \newline should be collapsed |
| 798 | # |
| 799 | name: bksl-nl-1 |
| 800 | description: |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 801 | Check that \newline is collapsed before, in the middle of, and |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 802 | after words |
| 803 | stdin: |
| 804 | \ |
| 805 | echo hi\ |
| 806 | There, \ |
| 807 | folks |
| 808 | expected-stdout: |
| 809 | hiThere, folks |
| 810 | --- |
| 811 | name: bksl-nl-2 |
| 812 | description: |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 813 | Check that \newline is collapsed in $ sequences |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 814 | (ksh93 fails this) |
| 815 | stdin: |
| 816 | a=12 |
| 817 | ab=19 |
| 818 | echo $\ |
| 819 | a |
| 820 | echo $a\ |
| 821 | b |
| 822 | echo $\ |
| 823 | {a} |
| 824 | echo ${a\ |
| 825 | b} |
| 826 | echo ${ab\ |
| 827 | } |
| 828 | expected-stdout: |
| 829 | 12 |
| 830 | 19 |
| 831 | 12 |
| 832 | 19 |
| 833 | 19 |
| 834 | --- |
| 835 | name: bksl-nl-3 |
| 836 | description: |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 837 | Check that \newline is collapsed in $(..) and `...` sequences |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 838 | (ksh93 fails this) |
| 839 | stdin: |
| 840 | echo $\ |
| 841 | (echo foobar1) |
| 842 | echo $(\ |
| 843 | echo foobar2) |
| 844 | echo $(echo foo\ |
| 845 | bar3) |
| 846 | echo $(echo foobar4\ |
| 847 | ) |
| 848 | echo ` |
| 849 | echo stuff1` |
| 850 | echo `echo st\ |
| 851 | uff2` |
| 852 | expected-stdout: |
| 853 | foobar1 |
| 854 | foobar2 |
| 855 | foobar3 |
| 856 | foobar4 |
| 857 | stuff1 |
| 858 | stuff2 |
| 859 | --- |
| 860 | name: bksl-nl-4 |
| 861 | description: |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 862 | Check that \newline is collapsed in $((..)) sequences |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 863 | (ksh93 fails this) |
| 864 | stdin: |
| 865 | echo $\ |
| 866 | ((1+2)) |
| 867 | echo $(\ |
| 868 | (1+2+3)) |
| 869 | echo $((\ |
| 870 | 1+2+3+4)) |
| 871 | echo $((1+\ |
| 872 | 2+3+4+5)) |
| 873 | echo $((1+2+3+4+5+6)\ |
| 874 | ) |
| 875 | expected-stdout: |
| 876 | 3 |
| 877 | 6 |
| 878 | 10 |
| 879 | 15 |
| 880 | 21 |
| 881 | --- |
| 882 | name: bksl-nl-5 |
| 883 | description: |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 884 | Check that \newline is collapsed in double quoted strings |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 885 | stdin: |
| 886 | echo "\ |
| 887 | hi" |
| 888 | echo "foo\ |
| 889 | bar" |
| 890 | echo "folks\ |
| 891 | " |
| 892 | expected-stdout: |
| 893 | hi |
| 894 | foobar |
| 895 | folks |
| 896 | --- |
| 897 | name: bksl-nl-6 |
| 898 | description: |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 899 | Check that \newline is collapsed in here document delimiters |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 900 | (ksh93 fails second part of this) |
| 901 | stdin: |
| 902 | a=12 |
| 903 | cat << EO\ |
| 904 | F |
| 905 | a=$a |
| 906 | foo\ |
| 907 | bar |
| 908 | EOF |
| 909 | cat << E_O_F |
| 910 | foo |
| 911 | E_O_\ |
| 912 | F |
| 913 | echo done |
| 914 | expected-stdout: |
| 915 | a=12 |
| 916 | foobar |
| 917 | foo |
| 918 | done |
| 919 | --- |
| 920 | name: bksl-nl-7 |
| 921 | description: |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 922 | Check that \newline is collapsed in double-quoted here-document |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 923 | delimiter. |
| 924 | stdin: |
| 925 | a=12 |
| 926 | cat << "EO\ |
| 927 | F" |
| 928 | a=$a |
| 929 | foo\ |
| 930 | bar |
| 931 | EOF |
| 932 | echo done |
| 933 | expected-stdout: |
| 934 | a=$a |
| 935 | foo\ |
| 936 | bar |
| 937 | done |
| 938 | --- |
| 939 | name: bksl-nl-8 |
| 940 | description: |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 941 | Check that \newline is collapsed in various 2+ character tokens |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 942 | delimiter. |
| 943 | (ksh93 fails this) |
| 944 | stdin: |
| 945 | echo hi &\ |
| 946 | & echo there |
| 947 | echo foo |\ |
| 948 | | echo bar |
| 949 | cat <\ |
| 950 | < EOF |
| 951 | stuff |
| 952 | EOF |
| 953 | cat <\ |
| 954 | <\ |
| 955 | - EOF |
| 956 | more stuff |
| 957 | EOF |
| 958 | cat <<\ |
| 959 | EOF |
| 960 | abcdef |
| 961 | EOF |
| 962 | echo hi >\ |
| 963 | > /dev/null |
| 964 | echo $? |
| 965 | i=1 |
| 966 | case $i in |
| 967 | (\ |
| 968 | x|\ |
| 969 | 1\ |
| 970 | ) echo hi;\ |
| 971 | ; |
| 972 | (*) echo oops |
| 973 | esac |
| 974 | expected-stdout: |
| 975 | hi |
| 976 | there |
| 977 | foo |
| 978 | stuff |
| 979 | more stuff |
| 980 | abcdef |
| 981 | 0 |
| 982 | hi |
| 983 | --- |
| 984 | name: bksl-nl-9 |
| 985 | description: |
| 986 | Check that \ at the end of an alias is collapsed when followed |
| 987 | by a newline |
| 988 | (don't know what POSIX has to say about this) |
| 989 | stdin: |
| 990 | alias x='echo hi\' |
| 991 | x |
| 992 | echo there |
| 993 | expected-stdout: |
| 994 | hiecho there |
| 995 | --- |
| 996 | name: bksl-nl-10 |
| 997 | description: |
| 998 | Check that \newline in a keyword is collapsed |
| 999 | stdin: |
| 1000 | i\ |
| 1001 | f true; then\ |
| 1002 | echo pass; el\ |
| 1003 | se echo fail; fi |
| 1004 | expected-stdout: |
| 1005 | pass |
| 1006 | --- |
| 1007 | # |
| 1008 | # Places \newline should be collapsed (ksh extensions) |
| 1009 | # |
| 1010 | name: bksl-nl-ksh-1 |
| 1011 | description: |
| 1012 | Check that \newline is collapsed in extended globbing |
| 1013 | (ksh93 fails this) |
| 1014 | stdin: |
| 1015 | xxx=foo |
| 1016 | case $xxx in |
| 1017 | (f*\ |
| 1018 | (\ |
| 1019 | o\ |
| 1020 | )\ |
| 1021 | ) echo ok ;; |
| 1022 | *) echo bad |
| 1023 | esac |
| 1024 | expected-stdout: |
| 1025 | ok |
| 1026 | --- |
| 1027 | name: bksl-nl-ksh-2 |
| 1028 | description: |
| 1029 | Check that \newline is collapsed in ((...)) expressions |
| 1030 | (ksh93 fails this) |
| 1031 | stdin: |
| 1032 | i=1 |
| 1033 | (\ |
| 1034 | (\ |
| 1035 | i=i+2\ |
| 1036 | )\ |
| 1037 | ) |
| 1038 | echo $i |
| 1039 | expected-stdout: |
| 1040 | 3 |
| 1041 | --- |
| 1042 | name: break-1 |
| 1043 | description: |
| 1044 | See if break breaks out of loops |
| 1045 | stdin: |
| 1046 | for i in a b c; do echo $i; break; echo bad-$i; done |
| 1047 | echo end-1 |
| 1048 | for i in a b c; do echo $i; break 1; echo bad-$i; done |
| 1049 | echo end-2 |
| 1050 | for i in a b c; do |
| 1051 | for j in x y z; do |
| 1052 | echo $i:$j |
| 1053 | break |
| 1054 | echo bad-$i |
| 1055 | done |
| 1056 | echo end-$i |
| 1057 | done |
| 1058 | echo end-3 |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 1059 | for i in a b c; do echo $i; eval break; echo bad-$i; done |
| 1060 | echo end-4 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 1061 | expected-stdout: |
| 1062 | a |
| 1063 | end-1 |
| 1064 | a |
| 1065 | end-2 |
| 1066 | a:x |
| 1067 | end-a |
| 1068 | b:x |
| 1069 | end-b |
| 1070 | c:x |
| 1071 | end-c |
| 1072 | end-3 |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 1073 | a |
| 1074 | end-4 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 1075 | --- |
| 1076 | name: break-2 |
| 1077 | description: |
| 1078 | See if break breaks out of nested loops |
| 1079 | stdin: |
| 1080 | for i in a b c; do |
| 1081 | for j in x y z; do |
| 1082 | echo $i:$j |
| 1083 | break 2 |
| 1084 | echo bad-$i |
| 1085 | done |
| 1086 | echo end-$i |
| 1087 | done |
| 1088 | echo end |
| 1089 | expected-stdout: |
| 1090 | a:x |
| 1091 | end |
| 1092 | --- |
| 1093 | name: break-3 |
| 1094 | description: |
| 1095 | What if break used outside of any loops |
| 1096 | (ksh88,ksh93 don't print error messages here) |
| 1097 | stdin: |
| 1098 | break |
| 1099 | expected-stderr-pattern: |
| 1100 | /.*break.*/ |
| 1101 | --- |
| 1102 | name: break-4 |
| 1103 | description: |
| 1104 | What if break N used when only N-1 loops |
| 1105 | (ksh88,ksh93 don't print error messages here) |
| 1106 | stdin: |
| 1107 | for i in a b c; do echo $i; break 2; echo bad-$i; done |
| 1108 | echo end |
| 1109 | expected-stdout: |
| 1110 | a |
| 1111 | end |
| 1112 | expected-stderr-pattern: |
| 1113 | /.*break.*/ |
| 1114 | --- |
| 1115 | name: break-5 |
| 1116 | description: |
| 1117 | Error if break argument isn't a number |
| 1118 | stdin: |
| 1119 | for i in a b c; do echo $i; break abc; echo more-$i; done |
| 1120 | echo end |
| 1121 | expected-stdout: |
| 1122 | a |
| 1123 | expected-exit: e != 0 |
| 1124 | expected-stderr-pattern: |
| 1125 | /.*break.*/ |
| 1126 | --- |
| 1127 | name: continue-1 |
| 1128 | description: |
| 1129 | See if continue continues loops |
| 1130 | stdin: |
| 1131 | for i in a b c; do echo $i; continue; echo bad-$i ; done |
| 1132 | echo end-1 |
| 1133 | for i in a b c; do echo $i; continue 1; echo bad-$i; done |
| 1134 | echo end-2 |
| 1135 | for i in a b c; do |
| 1136 | for j in x y z; do |
| 1137 | echo $i:$j |
| 1138 | continue |
| 1139 | echo bad-$i-$j |
| 1140 | done |
| 1141 | echo end-$i |
| 1142 | done |
| 1143 | echo end-3 |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 1144 | for i in a b c; do echo $i; eval continue; echo bad-$i ; done |
| 1145 | echo end-4 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 1146 | expected-stdout: |
| 1147 | a |
| 1148 | b |
| 1149 | c |
| 1150 | end-1 |
| 1151 | a |
| 1152 | b |
| 1153 | c |
| 1154 | end-2 |
| 1155 | a:x |
| 1156 | a:y |
| 1157 | a:z |
| 1158 | end-a |
| 1159 | b:x |
| 1160 | b:y |
| 1161 | b:z |
| 1162 | end-b |
| 1163 | c:x |
| 1164 | c:y |
| 1165 | c:z |
| 1166 | end-c |
| 1167 | end-3 |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 1168 | a |
| 1169 | b |
| 1170 | c |
| 1171 | end-4 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 1172 | --- |
| 1173 | name: continue-2 |
| 1174 | description: |
| 1175 | See if continue breaks out of nested loops |
| 1176 | stdin: |
| 1177 | for i in a b c; do |
| 1178 | for j in x y z; do |
| 1179 | echo $i:$j |
| 1180 | continue 2 |
| 1181 | echo bad-$i-$j |
| 1182 | done |
| 1183 | echo end-$i |
| 1184 | done |
| 1185 | echo end |
| 1186 | expected-stdout: |
| 1187 | a:x |
| 1188 | b:x |
| 1189 | c:x |
| 1190 | end |
| 1191 | --- |
| 1192 | name: continue-3 |
| 1193 | description: |
| 1194 | What if continue used outside of any loops |
| 1195 | (ksh88,ksh93 don't print error messages here) |
| 1196 | stdin: |
| 1197 | continue |
| 1198 | expected-stderr-pattern: |
| 1199 | /.*continue.*/ |
| 1200 | --- |
| 1201 | name: continue-4 |
| 1202 | description: |
| 1203 | What if continue N used when only N-1 loops |
| 1204 | (ksh88,ksh93 don't print error messages here) |
| 1205 | stdin: |
| 1206 | for i in a b c; do echo $i; continue 2; echo bad-$i; done |
| 1207 | echo end |
| 1208 | expected-stdout: |
| 1209 | a |
| 1210 | b |
| 1211 | c |
| 1212 | end |
| 1213 | expected-stderr-pattern: |
| 1214 | /.*continue.*/ |
| 1215 | --- |
| 1216 | name: continue-5 |
| 1217 | description: |
| 1218 | Error if continue argument isn't a number |
| 1219 | stdin: |
| 1220 | for i in a b c; do echo $i; continue abc; echo more-$i; done |
| 1221 | echo end |
| 1222 | expected-stdout: |
| 1223 | a |
| 1224 | expected-exit: e != 0 |
| 1225 | expected-stderr-pattern: |
| 1226 | /.*continue.*/ |
| 1227 | --- |
| 1228 | name: cd-history |
| 1229 | description: |
| 1230 | Test someone's CD history package (uses arrays) |
| 1231 | stdin: |
| 1232 | # go to known place before doing anything |
| 1233 | cd / |
| 1234 | |
| 1235 | alias cd=_cd |
| 1236 | function _cd |
| 1237 | { |
| 1238 | typeset -i cdlen i |
| 1239 | typeset t |
| 1240 | |
| 1241 | if [ $# -eq 0 ] |
| 1242 | then |
| 1243 | set -- $HOME |
| 1244 | fi |
| 1245 | |
| 1246 | if [ "$CDHISTFILE" -a -r "$CDHISTFILE" ] # if directory history exists |
| 1247 | then |
| 1248 | typeset CDHIST |
| 1249 | i=-1 |
| 1250 | while read -r t # read directory history file |
| 1251 | do |
| 1252 | CDHIST[i=i+1]=$t |
| 1253 | done <$CDHISTFILE |
| 1254 | fi |
| 1255 | |
| 1256 | if [ "${CDHIST[0]}" != "$PWD" -a "$PWD" != "" ] |
| 1257 | then |
| 1258 | _cdins # insert $PWD into cd history |
| 1259 | fi |
| 1260 | |
| 1261 | cdlen=${#CDHIST[*]} # number of elements in history |
| 1262 | |
| 1263 | case "$@" in |
| 1264 | -) # cd to new dir |
| 1265 | if [ "$OLDPWD" = "" ] && ((cdlen>1)) |
| 1266 | then |
| 1267 | 'print' ${CDHIST[1]} |
| 1268 | 'cd' ${CDHIST[1]} |
| 1269 | _pwd |
| 1270 | else |
| 1271 | 'cd' $@ |
| 1272 | _pwd |
| 1273 | fi |
| 1274 | ;; |
| 1275 | -l) # print directory list |
| 1276 | typeset -R3 num |
| 1277 | ((i=cdlen)) |
| 1278 | while (((i=i-1)>=0)) |
| 1279 | do |
| 1280 | num=$i |
| 1281 | 'print' "$num ${CDHIST[i]}" |
| 1282 | done |
| 1283 | return |
| 1284 | ;; |
| 1285 | -[0-9]|-[0-9][0-9]) # cd to dir in list |
| 1286 | if (((i=${1#-})<cdlen)) |
| 1287 | then |
| 1288 | 'print' ${CDHIST[i]} |
| 1289 | 'cd' ${CDHIST[i]} |
| 1290 | _pwd |
| 1291 | else |
| 1292 | 'cd' $@ |
| 1293 | _pwd |
| 1294 | fi |
| 1295 | ;; |
| 1296 | -*) # cd to matched dir in list |
| 1297 | t=${1#-} |
| 1298 | i=1 |
| 1299 | while ((i<cdlen)) |
| 1300 | do |
| 1301 | case ${CDHIST[i]} in |
| 1302 | *$t*) |
| 1303 | 'print' ${CDHIST[i]} |
| 1304 | 'cd' ${CDHIST[i]} |
| 1305 | _pwd |
| 1306 | break |
| 1307 | ;; |
| 1308 | esac |
| 1309 | ((i=i+1)) |
| 1310 | done |
| 1311 | if ((i>=cdlen)) |
| 1312 | then |
| 1313 | 'cd' $@ |
| 1314 | _pwd |
| 1315 | fi |
| 1316 | ;; |
| 1317 | *) # cd to new dir |
| 1318 | 'cd' $@ |
| 1319 | _pwd |
| 1320 | ;; |
| 1321 | esac |
| 1322 | |
| 1323 | _cdins # insert $PWD into cd history |
| 1324 | |
| 1325 | if [ "$CDHISTFILE" ] |
| 1326 | then |
| 1327 | cdlen=${#CDHIST[*]} # number of elements in history |
| 1328 | |
| 1329 | i=0 |
| 1330 | while ((i<cdlen)) |
| 1331 | do |
| 1332 | 'print' -r ${CDHIST[i]} # update directory history |
| 1333 | ((i=i+1)) |
| 1334 | done >$CDHISTFILE |
| 1335 | fi |
| 1336 | } |
| 1337 | |
| 1338 | function _cdins # insert $PWD into cd history |
| 1339 | { # meant to be called only by _cd |
| 1340 | typeset -i i |
| 1341 | |
| 1342 | ((i=0)) |
| 1343 | while ((i<${#CDHIST[*]})) # see if dir is already in list |
| 1344 | do |
| 1345 | if [ "${CDHIST[$i]}" = "$PWD" ] |
| 1346 | then |
| 1347 | break |
| 1348 | fi |
| 1349 | ((i=i+1)) |
| 1350 | done |
| 1351 | |
| 1352 | if ((i>22)) # limit max size of list |
| 1353 | then |
| 1354 | i=22 |
| 1355 | fi |
| 1356 | |
| 1357 | while (((i=i-1)>=0)) # bump old dirs in list |
| 1358 | do |
| 1359 | CDHIST[i+1]=${CDHIST[i]} |
| 1360 | done |
| 1361 | |
| 1362 | CDHIST[0]=$PWD # insert new directory in list |
| 1363 | } |
| 1364 | |
| 1365 | |
| 1366 | function _pwd |
| 1367 | { |
| 1368 | if [ -n "$ECD" ] |
| 1369 | then |
| 1370 | pwd 1>&6 |
| 1371 | fi |
| 1372 | } |
| 1373 | # Start of test |
| 1374 | cd /tmp |
| 1375 | cd /bin |
| 1376 | cd /etc |
| 1377 | cd - |
| 1378 | cd -2 |
| 1379 | cd -l |
| 1380 | expected-stdout: |
| 1381 | /bin |
| 1382 | /tmp |
| 1383 | 3 / |
| 1384 | 2 /etc |
| 1385 | 1 /bin |
| 1386 | 0 /tmp |
| 1387 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 1388 | name: cd-pe |
| 1389 | description: |
| 1390 | Check package for cd -Pe |
| 1391 | need-pass: no |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 1392 | # the mv command fails on Cygwin and z/OS |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 1393 | # Hurd aborts the testsuite (permission denied) |
| 1394 | # QNX does not find subdir to cd into |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 1395 | category: !os:cygwin,!os:gnu,!os:msys,!os:nto,!os:os390,!nosymlink |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 1396 | file-setup: file 644 "x" |
| 1397 | mkdir noread noread/target noread/target/subdir |
| 1398 | ln -s noread link |
| 1399 | chmod 311 noread |
| 1400 | cd -P$1 . |
| 1401 | echo 0=$? |
| 1402 | bwd=$PWD |
| 1403 | cd -P$1 link/target |
| 1404 | echo 1=$?,${PWD#$bwd/} |
| 1405 | epwd=$($TSHELL -c pwd 2>/dev/null) |
| 1406 | # This unexpectedly succeeds on GNU/Linux and MidnightBSD |
| 1407 | #echo pwd=$?,$epwd |
| 1408 | # expect: pwd=1, |
| 1409 | mv ../../noread ../../renamed |
| 1410 | cd -P$1 subdir |
| 1411 | echo 2=$?,${PWD#$bwd/} |
| 1412 | cd $bwd |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 1413 | chmod 755 noread renamed 2>/dev/null |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 1414 | rm -rf noread link renamed |
| 1415 | stdin: |
| 1416 | export TSHELL="$__progname" |
| 1417 | "$__progname" x |
| 1418 | echo "now with -e:" |
| 1419 | "$__progname" x e |
| 1420 | expected-stdout: |
| 1421 | 0=0 |
| 1422 | 1=0,noread/target |
| 1423 | 2=0,noread/target/subdir |
| 1424 | now with -e: |
| 1425 | 0=0 |
| 1426 | 1=0,noread/target |
| 1427 | 2=1,noread/target/subdir |
| 1428 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 1429 | name: env-prompt |
| 1430 | description: |
| 1431 | Check that prompt not printed when processing ENV |
| 1432 | env-setup: !ENV=./foo! |
| 1433 | file-setup: file 644 "foo" |
| 1434 | XXX=_ |
| 1435 | PS1=X |
| 1436 | false && echo hmmm |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 1437 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 1438 | arguments: !-i! |
| 1439 | stdin: |
| 1440 | echo hi${XXX}there |
| 1441 | expected-stdout: |
| 1442 | hi_there |
| 1443 | expected-stderr: ! |
| 1444 | XX |
| 1445 | --- |
| 1446 | name: expand-ugly |
| 1447 | description: |
| 1448 | Check that weird ${foo+bar} constructs are parsed correctly |
| 1449 | stdin: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 1450 | print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn |
| 1451 | print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "<$x> "; done' >pfs |
| 1452 | chmod +x pfn pfs |
| 1453 | (echo 1 ${IFS+'}'z}) 2>/dev/null || echo failed in 1 |
| 1454 | (echo 2 "${IFS+'}'z}") 2>/dev/null || echo failed in 2 |
| 1455 | (echo 3 "foo ${IFS+'bar} baz") 2>/dev/null || echo failed in 3 |
| 1456 | (echo -n '4 '; ./pfn "foo ${IFS+"b c"} baz") 2>/dev/null || echo failed in 4 |
| 1457 | (echo -n '5 '; ./pfn "foo ${IFS+b c} baz") 2>/dev/null || echo failed in 5 |
| 1458 | (echo 6 ${IFS+"}"z}) 2>/dev/null || echo failed in 6 |
| 1459 | (echo 7 "${IFS+"}"z}") 2>/dev/null || echo failed in 7 |
| 1460 | (echo 8 "${IFS+\"}\"z}") 2>/dev/null || echo failed in 8 |
| 1461 | (echo 9 "${IFS+\"\}\"z}") 2>/dev/null || echo failed in 9 |
| 1462 | (echo 10 foo ${IFS+'bar} baz'}) 2>/dev/null || echo failed in 10 |
| 1463 | (echo 11 "$(echo "${IFS+'}'z}")") 2>/dev/null || echo failed in 11 |
| 1464 | (echo 12 "$(echo ${IFS+'}'z})") 2>/dev/null || echo failed in 12 |
| 1465 | (echo 13 ${IFS+\}z}) 2>/dev/null || echo failed in 13 |
| 1466 | (echo 14 "${IFS+\}z}") 2>/dev/null || echo failed in 14 |
| 1467 | u=x; (echo -n '15 '; ./pfs "foo ${IFS+a"b$u{ {"{{\}b} c ${IFS+d{}} bar" ${IFS-e{}} baz; echo .) 2>/dev/null || echo failed in 15 |
| 1468 | l=t; (echo 16 ${IFS+h`echo -n i ${IFS+$l}h`ere}) 2>/dev/null || echo failed in 16 |
| 1469 | l=t; (echo 17 ${IFS+h$(echo -n i ${IFS+$l}h)ere}) 2>/dev/null || echo failed in 17 |
| 1470 | l=t; (echo 18 "${IFS+h`echo -n i ${IFS+$l}h`ere}") 2>/dev/null || echo failed in 18 |
| 1471 | l=t; (echo 19 "${IFS+h$(echo -n i ${IFS+$l}h)ere}") 2>/dev/null || echo failed in 19 |
| 1472 | l=t; (echo 20 ${IFS+h`echo -n i "${IFS+$l}"h`ere}) 2>/dev/null || echo failed in 20 |
| 1473 | l=t; (echo 21 ${IFS+h$(echo -n i "${IFS+$l}"h)ere}) 2>/dev/null || echo failed in 21 |
| 1474 | l=t; (echo 22 "${IFS+h`echo -n i "${IFS+$l}"h`ere}") 2>/dev/null || echo failed in 22 |
| 1475 | l=t; (echo 23 "${IFS+h$(echo -n i "${IFS+$l}"h)ere}") 2>/dev/null || echo failed in 23 |
| 1476 | key=value; (echo -n '24 '; ./pfn "${IFS+'$key'}") 2>/dev/null || echo failed in 24 |
| 1477 | key=value; (echo -n '25 '; ./pfn "${IFS+"'$key'"}") 2>/dev/null || echo failed in 25 # ksh93: â'$key'â |
| 1478 | key=value; (echo -n '26 '; ./pfn ${IFS+'$key'}) 2>/dev/null || echo failed in 26 |
| 1479 | key=value; (echo -n '27 '; ./pfn ${IFS+"'$key'"}) 2>/dev/null || echo failed in 27 |
| 1480 | (echo -n '28 '; ./pfn "${IFS+"'"x ~ x'}'x"'}"x}" #') 2>/dev/null || echo failed in 28 |
| 1481 | u=x; (echo -n '29 '; ./pfs foo ${IFS+a"b$u{ {"{ {\}b} c ${IFS+d{}} bar ${IFS-e{}} baz; echo .) 2>/dev/null || echo failed in 29 |
| 1482 | (echo -n '30 '; ./pfs ${IFS+foo 'b\ |
| 1483 | ar' baz}; echo .) 2>/dev/null || (echo failed in 30; echo failed in 31) |
| 1484 | (echo -n '32 '; ./pfs ${IFS+foo "b\ |
| 1485 | ar" baz}; echo .) 2>/dev/null || echo failed in 32 |
| 1486 | (echo -n '33 '; ./pfs "${IFS+foo 'b\ |
| 1487 | ar' baz}"; echo .) 2>/dev/null || echo failed in 33 |
| 1488 | (echo -n '34 '; ./pfs "${IFS+foo "b\ |
| 1489 | ar" baz}"; echo .) 2>/dev/null || echo failed in 34 |
| 1490 | (echo -n '35 '; ./pfs ${v=a\ b} x ${v=c\ d}; echo .) 2>/dev/null || echo failed in 35 |
| 1491 | (echo -n '36 '; ./pfs "${v=a\ b}" x "${v=c\ d}"; echo .) 2>/dev/null || echo failed in 36 |
| 1492 | (echo -n '37 '; ./pfs ${v-a\ b} x ${v-c\ d}; echo .) 2>/dev/null || echo failed in 37 |
| 1493 | (echo 38 ${IFS+x'a'y} / "${IFS+x'a'y}" .) 2>/dev/null || echo failed in 38 |
| 1494 | foo="x'a'y"; (echo 39 ${foo%*'a'*} / "${foo%*'a'*}" .) 2>/dev/null || echo failed in 39 |
| 1495 | foo="a b c"; (echo -n '40 '; ./pfs "${foo#a}"; echo .) 2>/dev/null || echo failed in 40 |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 1496 | (foo() { return 100; }; foo; echo 41 ${#+${#:+${#?}}\ \}\}\}}) 2>/dev/null || echo failed in 41 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 1497 | expected-stdout: |
| 1498 | 1 }z |
| 1499 | 2 ''z} |
| 1500 | 3 foo 'bar baz |
| 1501 | 4 foo b c baz |
| 1502 | 5 foo b c baz |
| 1503 | 6 }z |
| 1504 | 7 }z |
| 1505 | 8 ""z} |
| 1506 | 9 "}"z |
| 1507 | 10 foo bar} baz |
| 1508 | 11 ''z} |
| 1509 | 12 }z |
| 1510 | 13 }z |
| 1511 | 14 }z |
| 1512 | 15 <foo abx{ {{{}b c d{} bar> <}> <baz> . |
| 1513 | 16 hi there |
| 1514 | 17 hi there |
| 1515 | 18 hi there |
| 1516 | 19 hi there |
| 1517 | 20 hi there |
| 1518 | 21 hi there |
| 1519 | 22 hi there |
| 1520 | 23 hi there |
| 1521 | 24 'value' |
| 1522 | 25 'value' |
| 1523 | 26 $key |
| 1524 | 27 'value' |
| 1525 | 28 'x ~ x''x}"x}" # |
| 1526 | 29 <foo> <abx{ {{> <{}b> <c> <d{}> <bar> <}> <baz> . |
| 1527 | 30 <foo> <b\ |
| 1528 | ar> <baz> . |
| 1529 | 32 <foo> <bar> <baz> . |
| 1530 | 33 <foo 'bar' baz> . |
| 1531 | 34 <foo bar baz> . |
| 1532 | 35 <a> <b> <x> <a> <b> . |
| 1533 | 36 <a\ b> <x> <a\ b> . |
| 1534 | 37 <a b> <x> <c d> . |
| 1535 | 38 xay / x'a'y . |
| 1536 | 39 x' / x' . |
| 1537 | 40 < b c> . |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 1538 | 41 3 }}} |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 1539 | --- |
| 1540 | name: expand-unglob-dblq |
| 1541 | description: |
| 1542 | Check that regular "${foo+bar}" constructs are parsed correctly |
| 1543 | stdin: |
| 1544 | u=x |
| 1545 | tl_norm() { |
| 1546 | v=$2 |
| 1547 | test x"$v" = x"-" && unset v |
| 1548 | (echo "$1 plus norm foo ${v+'bar'} baz") |
| 1549 | (echo "$1 dash norm foo ${v-'bar'} baz") |
| 1550 | (echo "$1 eqal norm foo ${v='bar'} baz") |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 1551 | (echo "$1 qstn norm foo ${v?'bar'} baz") 2>/dev/null || \ |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 1552 | echo "$1 qstn norm -> error" |
| 1553 | (echo "$1 PLUS norm foo ${v:+'bar'} baz") |
| 1554 | (echo "$1 DASH norm foo ${v:-'bar'} baz") |
| 1555 | (echo "$1 EQAL norm foo ${v:='bar'} baz") |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 1556 | (echo "$1 QSTN norm foo ${v:?'bar'} baz") 2>/dev/null || \ |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 1557 | echo "$1 QSTN norm -> error" |
| 1558 | } |
| 1559 | tl_paren() { |
| 1560 | v=$2 |
| 1561 | test x"$v" = x"-" && unset v |
| 1562 | (echo "$1 plus parn foo ${v+(bar)} baz") |
| 1563 | (echo "$1 dash parn foo ${v-(bar)} baz") |
| 1564 | (echo "$1 eqal parn foo ${v=(bar)} baz") |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 1565 | (echo "$1 qstn parn foo ${v?(bar)} baz") 2>/dev/null || \ |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 1566 | echo "$1 qstn parn -> error" |
| 1567 | (echo "$1 PLUS parn foo ${v:+(bar)} baz") |
| 1568 | (echo "$1 DASH parn foo ${v:-(bar)} baz") |
| 1569 | (echo "$1 EQAL parn foo ${v:=(bar)} baz") |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 1570 | (echo "$1 QSTN parn foo ${v:?(bar)} baz") 2>/dev/null || \ |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 1571 | echo "$1 QSTN parn -> error" |
| 1572 | } |
| 1573 | tl_brace() { |
| 1574 | v=$2 |
| 1575 | test x"$v" = x"-" && unset v |
| 1576 | (echo "$1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz") |
| 1577 | (echo "$1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz") |
| 1578 | (echo "$1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz") |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 1579 | (echo "$1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz") 2>/dev/null || \ |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 1580 | echo "$1 qstn brac -> error" |
| 1581 | (echo "$1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz") |
| 1582 | (echo "$1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz") |
| 1583 | (echo "$1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz") |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 1584 | (echo "$1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz") 2>/dev/null || \ |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 1585 | echo "$1 QSTN brac -> error" |
| 1586 | } |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 1587 | : '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 1588 | tl_norm 1 - |
| 1589 | tl_norm 2 '' |
| 1590 | tl_norm 3 x |
| 1591 | tl_paren 4 - |
| 1592 | tl_paren 5 '' |
| 1593 | tl_paren 6 x |
| 1594 | tl_brace 7 - |
| 1595 | tl_brace 8 '' |
| 1596 | tl_brace 9 x |
| 1597 | expected-stdout: |
| 1598 | 1 plus norm foo baz |
| 1599 | 1 dash norm foo 'bar' baz |
| 1600 | 1 eqal norm foo 'bar' baz |
| 1601 | 1 qstn norm -> error |
| 1602 | 1 PLUS norm foo baz |
| 1603 | 1 DASH norm foo 'bar' baz |
| 1604 | 1 EQAL norm foo 'bar' baz |
| 1605 | 1 QSTN norm -> error |
| 1606 | 2 plus norm foo 'bar' baz |
| 1607 | 2 dash norm foo baz |
| 1608 | 2 eqal norm foo baz |
| 1609 | 2 qstn norm foo baz |
| 1610 | 2 PLUS norm foo baz |
| 1611 | 2 DASH norm foo 'bar' baz |
| 1612 | 2 EQAL norm foo 'bar' baz |
| 1613 | 2 QSTN norm -> error |
| 1614 | 3 plus norm foo 'bar' baz |
| 1615 | 3 dash norm foo x baz |
| 1616 | 3 eqal norm foo x baz |
| 1617 | 3 qstn norm foo x baz |
| 1618 | 3 PLUS norm foo 'bar' baz |
| 1619 | 3 DASH norm foo x baz |
| 1620 | 3 EQAL norm foo x baz |
| 1621 | 3 QSTN norm foo x baz |
| 1622 | 4 plus parn foo baz |
| 1623 | 4 dash parn foo (bar) baz |
| 1624 | 4 eqal parn foo (bar) baz |
| 1625 | 4 qstn parn -> error |
| 1626 | 4 PLUS parn foo baz |
| 1627 | 4 DASH parn foo (bar) baz |
| 1628 | 4 EQAL parn foo (bar) baz |
| 1629 | 4 QSTN parn -> error |
| 1630 | 5 plus parn foo (bar) baz |
| 1631 | 5 dash parn foo baz |
| 1632 | 5 eqal parn foo baz |
| 1633 | 5 qstn parn foo baz |
| 1634 | 5 PLUS parn foo baz |
| 1635 | 5 DASH parn foo (bar) baz |
| 1636 | 5 EQAL parn foo (bar) baz |
| 1637 | 5 QSTN parn -> error |
| 1638 | 6 plus parn foo (bar) baz |
| 1639 | 6 dash parn foo x baz |
| 1640 | 6 eqal parn foo x baz |
| 1641 | 6 qstn parn foo x baz |
| 1642 | 6 PLUS parn foo (bar) baz |
| 1643 | 6 DASH parn foo x baz |
| 1644 | 6 EQAL parn foo x baz |
| 1645 | 6 QSTN parn foo x baz |
| 1646 | 7 plus brac foo c } baz |
| 1647 | 7 dash brac foo ax{{{}b c d{} baz |
| 1648 | 7 eqal brac foo ax{{{}b c ax{{{}b} baz |
| 1649 | 7 qstn brac -> error |
| 1650 | 7 PLUS brac foo c } baz |
| 1651 | 7 DASH brac foo ax{{{}b c d{} baz |
| 1652 | 7 EQAL brac foo ax{{{}b c ax{{{}b} baz |
| 1653 | 7 QSTN brac -> error |
| 1654 | 8 plus brac foo ax{{{}b c d{} baz |
| 1655 | 8 dash brac foo c } baz |
| 1656 | 8 eqal brac foo c } baz |
| 1657 | 8 qstn brac foo c } baz |
| 1658 | 8 PLUS brac foo c } baz |
| 1659 | 8 DASH brac foo ax{{{}b c d{} baz |
| 1660 | 8 EQAL brac foo ax{{{}b c ax{{{}b} baz |
| 1661 | 8 QSTN brac -> error |
| 1662 | 9 plus brac foo ax{{{}b c d{} baz |
| 1663 | 9 dash brac foo x c x} baz |
| 1664 | 9 eqal brac foo x c x} baz |
| 1665 | 9 qstn brac foo x c x} baz |
| 1666 | 9 PLUS brac foo ax{{{}b c d{} baz |
| 1667 | 9 DASH brac foo x c x} baz |
| 1668 | 9 EQAL brac foo x c x} baz |
| 1669 | 9 QSTN brac foo x c x} baz |
| 1670 | --- |
| 1671 | name: expand-unglob-unq |
| 1672 | description: |
| 1673 | Check that regular ${foo+bar} constructs are parsed correctly |
| 1674 | stdin: |
| 1675 | u=x |
| 1676 | tl_norm() { |
| 1677 | v=$2 |
| 1678 | test x"$v" = x"-" && unset v |
| 1679 | (echo $1 plus norm foo ${v+'bar'} baz) |
| 1680 | (echo $1 dash norm foo ${v-'bar'} baz) |
| 1681 | (echo $1 eqal norm foo ${v='bar'} baz) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 1682 | (echo $1 qstn norm foo ${v?'bar'} baz) 2>/dev/null || \ |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 1683 | echo "$1 qstn norm -> error" |
| 1684 | (echo $1 PLUS norm foo ${v:+'bar'} baz) |
| 1685 | (echo $1 DASH norm foo ${v:-'bar'} baz) |
| 1686 | (echo $1 EQAL norm foo ${v:='bar'} baz) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 1687 | (echo $1 QSTN norm foo ${v:?'bar'} baz) 2>/dev/null || \ |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 1688 | echo "$1 QSTN norm -> error" |
| 1689 | } |
| 1690 | tl_paren() { |
| 1691 | v=$2 |
| 1692 | test x"$v" = x"-" && unset v |
| 1693 | (echo $1 plus parn foo ${v+\(bar')'} baz) |
| 1694 | (echo $1 dash parn foo ${v-\(bar')'} baz) |
| 1695 | (echo $1 eqal parn foo ${v=\(bar')'} baz) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 1696 | (echo $1 qstn parn foo ${v?\(bar')'} baz) 2>/dev/null || \ |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 1697 | echo "$1 qstn parn -> error" |
| 1698 | (echo $1 PLUS parn foo ${v:+\(bar')'} baz) |
| 1699 | (echo $1 DASH parn foo ${v:-\(bar')'} baz) |
| 1700 | (echo $1 EQAL parn foo ${v:=\(bar')'} baz) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 1701 | (echo $1 QSTN parn foo ${v:?\(bar')'} baz) 2>/dev/null || \ |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 1702 | echo "$1 QSTN parn -> error" |
| 1703 | } |
| 1704 | tl_brace() { |
| 1705 | v=$2 |
| 1706 | test x"$v" = x"-" && unset v |
| 1707 | (echo $1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz) |
| 1708 | (echo $1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz) |
| 1709 | (echo $1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 1710 | (echo $1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz) 2>/dev/null || \ |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 1711 | echo "$1 qstn brac -> error" |
| 1712 | (echo $1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz) |
| 1713 | (echo $1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz) |
| 1714 | (echo $1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 1715 | (echo $1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz) 2>/dev/null || \ |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 1716 | echo "$1 QSTN brac -> error" |
| 1717 | } |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 1718 | : '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 1719 | tl_norm 1 - |
| 1720 | tl_norm 2 '' |
| 1721 | tl_norm 3 x |
| 1722 | tl_paren 4 - |
| 1723 | tl_paren 5 '' |
| 1724 | tl_paren 6 x |
| 1725 | tl_brace 7 - |
| 1726 | tl_brace 8 '' |
| 1727 | tl_brace 9 x |
| 1728 | expected-stdout: |
| 1729 | 1 plus norm foo baz |
| 1730 | 1 dash norm foo bar baz |
| 1731 | 1 eqal norm foo bar baz |
| 1732 | 1 qstn norm -> error |
| 1733 | 1 PLUS norm foo baz |
| 1734 | 1 DASH norm foo bar baz |
| 1735 | 1 EQAL norm foo bar baz |
| 1736 | 1 QSTN norm -> error |
| 1737 | 2 plus norm foo bar baz |
| 1738 | 2 dash norm foo baz |
| 1739 | 2 eqal norm foo baz |
| 1740 | 2 qstn norm foo baz |
| 1741 | 2 PLUS norm foo baz |
| 1742 | 2 DASH norm foo bar baz |
| 1743 | 2 EQAL norm foo bar baz |
| 1744 | 2 QSTN norm -> error |
| 1745 | 3 plus norm foo bar baz |
| 1746 | 3 dash norm foo x baz |
| 1747 | 3 eqal norm foo x baz |
| 1748 | 3 qstn norm foo x baz |
| 1749 | 3 PLUS norm foo bar baz |
| 1750 | 3 DASH norm foo x baz |
| 1751 | 3 EQAL norm foo x baz |
| 1752 | 3 QSTN norm foo x baz |
| 1753 | 4 plus parn foo baz |
| 1754 | 4 dash parn foo (bar) baz |
| 1755 | 4 eqal parn foo (bar) baz |
| 1756 | 4 qstn parn -> error |
| 1757 | 4 PLUS parn foo baz |
| 1758 | 4 DASH parn foo (bar) baz |
| 1759 | 4 EQAL parn foo (bar) baz |
| 1760 | 4 QSTN parn -> error |
| 1761 | 5 plus parn foo (bar) baz |
| 1762 | 5 dash parn foo baz |
| 1763 | 5 eqal parn foo baz |
| 1764 | 5 qstn parn foo baz |
| 1765 | 5 PLUS parn foo baz |
| 1766 | 5 DASH parn foo (bar) baz |
| 1767 | 5 EQAL parn foo (bar) baz |
| 1768 | 5 QSTN parn -> error |
| 1769 | 6 plus parn foo (bar) baz |
| 1770 | 6 dash parn foo x baz |
| 1771 | 6 eqal parn foo x baz |
| 1772 | 6 qstn parn foo x baz |
| 1773 | 6 PLUS parn foo (bar) baz |
| 1774 | 6 DASH parn foo x baz |
| 1775 | 6 EQAL parn foo x baz |
| 1776 | 6 QSTN parn foo x baz |
| 1777 | 7 plus brac foo c } baz |
| 1778 | 7 dash brac foo ax{{{}b c d{} baz |
| 1779 | 7 eqal brac foo ax{{{}b c ax{{{}b} baz |
| 1780 | 7 qstn brac -> error |
| 1781 | 7 PLUS brac foo c } baz |
| 1782 | 7 DASH brac foo ax{{{}b c d{} baz |
| 1783 | 7 EQAL brac foo ax{{{}b c ax{{{}b} baz |
| 1784 | 7 QSTN brac -> error |
| 1785 | 8 plus brac foo ax{{{}b c d{} baz |
| 1786 | 8 dash brac foo c } baz |
| 1787 | 8 eqal brac foo c } baz |
| 1788 | 8 qstn brac foo c } baz |
| 1789 | 8 PLUS brac foo c } baz |
| 1790 | 8 DASH brac foo ax{{{}b c d{} baz |
| 1791 | 8 EQAL brac foo ax{{{}b c ax{{{}b} baz |
| 1792 | 8 QSTN brac -> error |
| 1793 | 9 plus brac foo ax{{{}b c d{} baz |
| 1794 | 9 dash brac foo x c x} baz |
| 1795 | 9 eqal brac foo x c x} baz |
| 1796 | 9 qstn brac foo x c x} baz |
| 1797 | 9 PLUS brac foo ax{{{}b c d{} baz |
| 1798 | 9 DASH brac foo x c x} baz |
| 1799 | 9 EQAL brac foo x c x} baz |
| 1800 | 9 QSTN brac foo x c x} baz |
| 1801 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 1802 | name: expand-threecolons-dblq |
| 1803 | description: |
| 1804 | Check for a particular thing that used to segfault |
| 1805 | stdin: |
| 1806 | TEST=1234 |
| 1807 | echo "${TEST:1:2:3}" |
| 1808 | echo $? but still living |
| 1809 | expected-stderr-pattern: |
| 1810 | /bad substitution/ |
| 1811 | expected-exit: 1 |
| 1812 | --- |
| 1813 | name: expand-threecolons-unq |
| 1814 | description: |
| 1815 | Check for a particular thing that used to not error out |
| 1816 | stdin: |
| 1817 | TEST=1234 |
| 1818 | echo ${TEST:1:2:3} |
| 1819 | echo $? but still living |
| 1820 | expected-stderr-pattern: |
| 1821 | /bad substitution/ |
| 1822 | expected-exit: 1 |
| 1823 | --- |
| 1824 | name: expand-weird-1 |
| 1825 | description: |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 1826 | Check corner cases of trim expansion vs. $# vs. ${#var} vs. ${var?} |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 1827 | stdin: |
| 1828 | set 1 2 3 4 5 6 7 8 9 10 11 |
| 1829 | echo ${#} # value of $# |
| 1830 | echo ${##} # length of $# |
| 1831 | echo ${##1} # $# trimmed 1 |
| 1832 | set 1 2 3 4 5 6 7 8 9 10 11 12 |
| 1833 | echo ${##1} |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 1834 | (exit 0) |
| 1835 | echo $? = ${#?} . |
| 1836 | (exit 111) |
| 1837 | echo $? = ${#?} . |
| 1838 | expected-stdout: |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 1839 | 11 |
| 1840 | 2 |
| 1841 | 1 |
| 1842 | 2 |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 1843 | 0 = 1 . |
| 1844 | 111 = 3 . |
| 1845 | --- |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 1846 | name: expand-weird-2 |
| 1847 | description: |
| 1848 | Check more substitution and extension corner cases |
| 1849 | stdin: |
| 1850 | :& set -C; pid=$$; sub=$!; flg=$-; set -- i; exec 3>x.tmp |
| 1851 | #echo "D: !=$! #=$# \$=$$ -=$- ?=$?" |
| 1852 | echo >&3 3 = s^${!-word} , ${#-word} , p^${$-word} , f^${--word} , ${?-word} . |
| 1853 | echo >&3 4 = ${!+word} , ${#+word} , ${$+word} , ${-+word} , ${?+word} . |
| 1854 | echo >&3 5 = s^${!=word} , ${#=word} , p^${$=word} , f^${-=word} , ${?=word} . |
| 1855 | echo >&3 6 = s^${!?word} , ${#?word} , p^${$?word} , f^${-?word} , ${??word} . |
| 1856 | echo >&3 7 = sl^${#!} , ${##} , pl^${#$} , fl^${#-} , ${#?} . |
| 1857 | echo >&3 8 = sw^${%!} , ${%#} , pw^${%$} , fw^${%-} , ${%?} . |
| 1858 | echo >&3 9 = ${!!} , s^${!#} , ${!$} , s^${!-} , s^${!?} . |
| 1859 | echo >&3 10 = s^${!#pattern} , ${##pattern} , p^${$#pattern} , f^${-#pattern} , ${?#pattern} . |
| 1860 | echo >&3 11 = s^${!%pattern} , ${#%pattern} , p^${$%pattern} , f^${-%pattern} , ${?%pattern} . |
| 1861 | echo >&3 12 = $# : ${##} , ${##1} . |
| 1862 | set -- |
| 1863 | echo >&3 14 = $# : ${##} , ${##1} . |
| 1864 | set -- 1 2 3 4 5 |
| 1865 | echo >&3 16 = $# : ${##} , ${##1} . |
| 1866 | set -- 1 2 3 4 5 6 7 8 9 a b c d e |
| 1867 | echo >&3 18 = $# : ${##} , ${##1} . |
| 1868 | exec 3>&- |
| 1869 | <x.tmp sed \ |
| 1870 | -e "s/ pl^${#pid} / PID /g" -e "s/ sl^${#sub} / SUB /g" -e "s/ fl^${#flg} / FLG /g" \ |
| 1871 | -e "s/ pw^${%pid} / PID /g" -e "s/ sw^${%sub} / SUB /g" -e "s/ fw^${%flg} / FLG /g" \ |
| 1872 | -e "s/ p^$pid / PID /g" -e "s/ s^$sub / SUB /g" -e "s/ f^$flg / FLG /g" |
| 1873 | expected-stdout: |
| 1874 | 3 = SUB , 1 , PID , FLG , 0 . |
| 1875 | 4 = word , word , word , word , word . |
| 1876 | 5 = SUB , 1 , PID , FLG , 0 . |
| 1877 | 6 = SUB , 1 , PID , FLG , 0 . |
| 1878 | 7 = SUB , 1 , PID , FLG , 1 . |
| 1879 | 8 = SUB , 1 , PID , FLG , 1 . |
| 1880 | 9 = ! , SUB , $ , SUB , SUB . |
| 1881 | 10 = SUB , 1 , PID , FLG , 0 . |
| 1882 | 11 = SUB , 1 , PID , FLG , 0 . |
| 1883 | 12 = 1 : 1 , . |
| 1884 | 14 = 0 : 1 , 0 . |
| 1885 | 16 = 5 : 1 , 5 . |
| 1886 | 18 = 14 : 2 , 4 . |
| 1887 | --- |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 1888 | name: expand-weird-3 |
| 1889 | description: |
| 1890 | Check that trimming works with positional parameters (Debian #48453) |
| 1891 | stdin: |
| 1892 | A=9999-02 |
| 1893 | B=9999 |
| 1894 | echo 1=${A#$B?}. |
| 1895 | set -- $A $B |
| 1896 | echo 2=${1#$2?}. |
| 1897 | expected-stdout: |
| 1898 | 1=02. |
| 1899 | 2=02. |
| 1900 | --- |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 1901 | name: expand-weird-4 |
| 1902 | description: |
| 1903 | Check that tilde expansion is enabled in ${x#~} |
| 1904 | and cases that are modelled after it (${x/~/~}) |
| 1905 | stdin: |
| 1906 | HOME=/etc |
| 1907 | a="~/x" |
| 1908 | echo "<${a#~}> <${a#\~}> <${b:-~}> <${b:-\~}> <${c:=~}><$c> <${a/~}> <${a/x/~}> <${a/x/\~}>" |
| 1909 | expected-stdout: |
| 1910 | <~/x> </x> <~> <\~> <~><~> <~/x> <~//etc> <~/~> |
| 1911 | --- |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 1912 | name: expand-bang-1 |
| 1913 | description: |
| 1914 | Check corner case of ${!?} with ! being var vs. op |
| 1915 | stdin: |
| 1916 | echo ${!?} |
| 1917 | expected-exit: 1 |
| 1918 | expected-stderr-pattern: /not set/ |
| 1919 | --- |
| 1920 | name: expand-bang-2 |
| 1921 | description: |
| 1922 | Check corner case of ${!var} vs. ${var op} with var=! |
| 1923 | stdin: |
| 1924 | echo 1 $! . |
| 1925 | echo 2 ${!#} . |
| 1926 | echo 3 ${!#[0-9]} . |
| 1927 | echo 4 ${!-foo} . |
| 1928 | # get an at least three-digit bg pid |
| 1929 | while :; do |
| 1930 | :& |
| 1931 | x=$! |
| 1932 | if [[ $x != +([0-9]) ]]; then |
| 1933 | echo >&2 "cannot test, pid '$x' not numeric" |
| 1934 | echo >&2 report this with as many details as possible |
| 1935 | exit 1 |
| 1936 | fi |
| 1937 | [[ $x = [0-9][0-9][0-9]* ]] && break |
| 1938 | done |
| 1939 | y=${x#?} |
| 1940 | t=$!; [[ $t = $x ]]; echo 5 $? . |
| 1941 | t=${!#}; [[ $t = $x ]]; echo 6 $? . |
| 1942 | t=${!#[0-9]}; [[ $t = $y ]]; echo 7 $? . |
| 1943 | t=${!-foo}; [[ $t = $x ]]; echo 8 $? . |
| 1944 | t=${!?bar}; [[ $t = $x ]]; echo 9 $? . |
| 1945 | expected-stdout: |
| 1946 | 1 . |
| 1947 | 2 . |
| 1948 | 3 . |
| 1949 | 4 foo . |
| 1950 | 5 0 . |
| 1951 | 6 0 . |
| 1952 | 7 0 . |
| 1953 | 8 0 . |
| 1954 | 9 0 . |
| 1955 | --- |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 1956 | name: expand-number-1 |
| 1957 | description: |
| 1958 | Check that positional arguments do not overflow |
| 1959 | stdin: |
| 1960 | echo "1 ${12345678901234567890} ." |
| 1961 | expected-stdout: |
| 1962 | 1 . |
| 1963 | --- |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 1964 | name: expand-slashes-1 |
| 1965 | description: |
| 1966 | Check that side effects in substring replacement are handled correctly |
| 1967 | stdin: |
| 1968 | foo=n1n1n1n2n3 |
| 1969 | i=2 |
| 1970 | n=1 |
| 1971 | echo 1 ${foo//n$((n++))/[$((++i))]} . |
| 1972 | echo 2 $n , $i . |
| 1973 | expected-stdout: |
| 1974 | 1 [3][3][3]n2n3 . |
| 1975 | 2 2 , 3 . |
| 1976 | --- |
| 1977 | name: expand-slashes-2 |
| 1978 | description: |
| 1979 | Check that side effects in substring replacement are handled correctly |
| 1980 | stdin: |
| 1981 | foo=n1n1n1n2n3 |
| 1982 | i=2 |
| 1983 | n=1 |
| 1984 | echo 1 ${foo@/n$((n++))/[$((++i))]} . |
| 1985 | echo 2 $n , $i . |
| 1986 | expected-stdout: |
| 1987 | 1 [3]n1n1[4][5] . |
| 1988 | 2 5 , 5 . |
| 1989 | --- |
| 1990 | name: expand-slashes-3 |
| 1991 | description: |
| 1992 | Check that we can access the replaced string |
| 1993 | stdin: |
| 1994 | foo=n1n1n1n2n3 |
| 1995 | echo 1 ${foo@/n[12]/[$KSH_MATCH]} . |
| 1996 | expected-stdout: |
| 1997 | 1 [n1][n1][n1][n2]n3 . |
| 1998 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 1999 | name: eglob-bad-1 |
| 2000 | description: |
| 2001 | Check that globbing isn't done when glob has syntax error |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 2002 | category: !os:cygwin,!os:msys,!os:os2 |
| 2003 | file-setup: file 644 "@(a[b|)c]foo" |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2004 | stdin: |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 2005 | echo @(a[b|)c]* |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2006 | expected-stdout: |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 2007 | @(a[b|)c]* |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2008 | --- |
| 2009 | name: eglob-bad-2 |
| 2010 | description: |
| 2011 | Check that globbing isn't done when glob has syntax error |
| 2012 | (AT&T ksh fails this test) |
| 2013 | file-setup: file 644 "abcx" |
| 2014 | file-setup: file 644 "abcz" |
| 2015 | file-setup: file 644 "bbc" |
| 2016 | stdin: |
| 2017 | echo [a*(]*)z |
| 2018 | expected-stdout: |
| 2019 | [a*(]*)z |
| 2020 | --- |
| 2021 | name: eglob-infinite-plus |
| 2022 | description: |
| 2023 | Check that shell doesn't go into infinite loop expanding +(...) |
| 2024 | expressions. |
| 2025 | file-setup: file 644 "abc" |
| 2026 | time-limit: 3 |
| 2027 | stdin: |
| 2028 | echo +()c |
| 2029 | echo +()x |
| 2030 | echo +(*)c |
| 2031 | echo +(*)x |
| 2032 | expected-stdout: |
| 2033 | +()c |
| 2034 | +()x |
| 2035 | abc |
| 2036 | +(*)x |
| 2037 | --- |
| 2038 | name: eglob-subst-1 |
| 2039 | description: |
| 2040 | Check that eglobbing isn't done on substitution results |
| 2041 | file-setup: file 644 "abc" |
| 2042 | stdin: |
| 2043 | x='@(*)' |
| 2044 | echo $x |
| 2045 | expected-stdout: |
| 2046 | @(*) |
| 2047 | --- |
| 2048 | name: eglob-nomatch-1 |
| 2049 | description: |
| 2050 | Check that the pattern doesn't match |
| 2051 | stdin: |
| 2052 | echo 1: no-file+(a|b)stuff |
| 2053 | echo 2: no-file+(a*(c)|b)stuff |
| 2054 | echo 3: no-file+((((c)))|b)stuff |
| 2055 | expected-stdout: |
| 2056 | 1: no-file+(a|b)stuff |
| 2057 | 2: no-file+(a*(c)|b)stuff |
| 2058 | 3: no-file+((((c)))|b)stuff |
| 2059 | --- |
| 2060 | name: eglob-match-1 |
| 2061 | description: |
| 2062 | Check that the pattern matches correctly |
| 2063 | file-setup: file 644 "abd" |
| 2064 | file-setup: file 644 "acd" |
| 2065 | file-setup: file 644 "abac" |
| 2066 | stdin: |
| 2067 | echo 1: a+(b|c)d |
| 2068 | echo 2: a!(@(b|B))d |
| 2069 | echo 3: *(a(b|c)) # (...|...) can be used within X(..) |
| 2070 | echo 4: a[b*(foo|bar)]d # patterns not special inside [...] |
| 2071 | expected-stdout: |
| 2072 | 1: abd acd |
| 2073 | 2: acd |
| 2074 | 3: abac |
| 2075 | 4: abd |
| 2076 | --- |
| 2077 | name: eglob-case-1 |
| 2078 | description: |
| 2079 | Simple negation tests |
| 2080 | stdin: |
| 2081 | case foo in !(foo|bar)) echo yes;; *) echo no;; esac |
| 2082 | case bar in !(foo|bar)) echo yes;; *) echo no;; esac |
| 2083 | expected-stdout: |
| 2084 | no |
| 2085 | no |
| 2086 | --- |
| 2087 | name: eglob-case-2 |
| 2088 | description: |
| 2089 | Simple kleene tests |
| 2090 | stdin: |
| 2091 | case foo in *(a|b[)) echo yes;; *) echo no;; esac |
| 2092 | case foo in *(a|b[)|f*) echo yes;; *) echo no;; esac |
| 2093 | case '*(a|b[)' in *(a|b[)) echo yes;; *) echo no;; esac |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 2094 | case 'aab[b[ab[a' in *(a|b[)) echo yes;; *) echo no;; esac |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2095 | expected-stdout: |
| 2096 | no |
| 2097 | yes |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 2098 | no |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2099 | yes |
| 2100 | --- |
| 2101 | name: eglob-trim-1 |
| 2102 | description: |
| 2103 | Eglobbing in trim expressions... |
| 2104 | (AT&T ksh fails this - docs say # matches shortest string, ## matches |
| 2105 | longest...) |
| 2106 | stdin: |
| 2107 | x=abcdef |
| 2108 | echo 1: ${x#a|abc} |
| 2109 | echo 2: ${x##a|abc} |
| 2110 | echo 3: ${x%def|f} |
| 2111 | echo 4: ${x%%f|def} |
| 2112 | expected-stdout: |
| 2113 | 1: bcdef |
| 2114 | 2: def |
| 2115 | 3: abcde |
| 2116 | 4: abc |
| 2117 | --- |
| 2118 | name: eglob-trim-2 |
| 2119 | description: |
| 2120 | Check eglobbing works in trims... |
| 2121 | stdin: |
| 2122 | x=abcdef |
| 2123 | echo 1: ${x#*(a|b)cd} |
| 2124 | echo 2: "${x#*(a|b)cd}" |
| 2125 | echo 3: ${x#"*(a|b)cd"} |
| 2126 | echo 4: ${x#a(b|c)} |
| 2127 | expected-stdout: |
| 2128 | 1: ef |
| 2129 | 2: ef |
| 2130 | 3: abcdef |
| 2131 | 4: cdef |
| 2132 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 2133 | name: eglob-trim-3 |
| 2134 | description: |
| 2135 | Check eglobbing works in trims, for Korn Shell |
| 2136 | Ensure eglobbing does not work for reduced-feature /bin/sh |
| 2137 | stdin: |
| 2138 | set +o sh |
| 2139 | x=foobar |
| 2140 | y=foobaz |
| 2141 | z=fooba\? |
| 2142 | echo "<${x%bar|baz},${y%bar|baz},${z%\?}>" |
| 2143 | echo "<${x%ba(r|z)},${y%ba(r|z)}>" |
| 2144 | set -o sh |
| 2145 | echo "<${x%bar|baz},${y%bar|baz},${z%\?}>" |
| 2146 | z='foo(bar' |
| 2147 | echo "<${z%(*}>" |
| 2148 | expected-stdout: |
| 2149 | <foo,foo,fooba> |
| 2150 | <foo,foo> |
| 2151 | <foobar,foobaz,fooba> |
| 2152 | <foo> |
| 2153 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2154 | name: eglob-substrpl-1 |
| 2155 | description: |
| 2156 | Check eglobbing works in substs... and they work at all |
| 2157 | stdin: |
| 2158 | [[ -n $BASH_VERSION ]] && shopt -s extglob |
| 2159 | x=1222321_ab/cde_b/c_1221 |
| 2160 | y=xyz |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 2161 | echo 1: ${x/2} . ${x/} |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2162 | echo 2: ${x//2} |
| 2163 | echo 3: ${x/+(2)} |
| 2164 | echo 4: ${x//+(2)} |
| 2165 | echo 5: ${x/2/4} |
| 2166 | echo 6: ${x//2/4} |
| 2167 | echo 7: ${x/+(2)/4} |
| 2168 | echo 8: ${x//+(2)/4} |
| 2169 | echo 9: ${x/b/c/e/f} |
| 2170 | echo 10: ${x/b\/c/e/f} |
| 2171 | echo 11: ${x/b\/c/e\/f} |
| 2172 | echo 12: ${x/b\/c/e\\/f} |
| 2173 | echo 13: ${x/b\\/c/e\\/f} |
| 2174 | echo 14: ${x//b/c/e/f} |
| 2175 | echo 15: ${x//b\/c/e/f} |
| 2176 | echo 16: ${x//b\/c/e\/f} |
| 2177 | echo 17: ${x//b\/c/e\\/f} |
| 2178 | echo 18: ${x//b\\/c/e\\/f} |
| 2179 | echo 19: ${x/b\/*\/c/x} |
| 2180 | echo 20: ${x/\//.} |
| 2181 | echo 21: ${x//\//.} |
| 2182 | echo 22: ${x///.} |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 2183 | echo 23: ${x/#1/9} |
| 2184 | echo 24: ${x//#1/9} |
| 2185 | echo 25: ${x/%1/9} |
| 2186 | echo 26: ${x//%1/9} |
| 2187 | echo 27: ${x//\%1/9} |
| 2188 | echo 28: ${x//\\%1/9} |
| 2189 | echo 29: ${x//\a/9} |
| 2190 | echo 30: ${x//\\a/9} |
| 2191 | echo 31: ${x/2/$y} |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2192 | expected-stdout: |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 2193 | 1: 122321_ab/cde_b/c_1221 . 1222321_ab/cde_b/c_1221 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2194 | 2: 131_ab/cde_b/c_11 |
| 2195 | 3: 1321_ab/cde_b/c_1221 |
| 2196 | 4: 131_ab/cde_b/c_11 |
| 2197 | 5: 1422321_ab/cde_b/c_1221 |
| 2198 | 6: 1444341_ab/cde_b/c_1441 |
| 2199 | 7: 14321_ab/cde_b/c_1221 |
| 2200 | 8: 14341_ab/cde_b/c_141 |
| 2201 | 9: 1222321_ac/e/f/cde_b/c_1221 |
| 2202 | 10: 1222321_ae/fde_b/c_1221 |
| 2203 | 11: 1222321_ae/fde_b/c_1221 |
| 2204 | 12: 1222321_ae\/fde_b/c_1221 |
| 2205 | 13: 1222321_ab/cde_b/c_1221 |
| 2206 | 14: 1222321_ac/e/f/cde_c/e/f/c_1221 |
| 2207 | 15: 1222321_ae/fde_e/f_1221 |
| 2208 | 16: 1222321_ae/fde_e/f_1221 |
| 2209 | 17: 1222321_ae\/fde_e\/f_1221 |
| 2210 | 18: 1222321_ab/cde_b/c_1221 |
| 2211 | 19: 1222321_ax_1221 |
| 2212 | 20: 1222321_ab.cde_b/c_1221 |
| 2213 | 21: 1222321_ab.cde_b.c_1221 |
| 2214 | 22: 1222321_ab/cde_b/c_1221 |
| 2215 | 23: 9222321_ab/cde_b/c_1221 |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 2216 | 24: 1222321_ab/cde_b/c_1221 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2217 | 25: 1222321_ab/cde_b/c_1229 |
| 2218 | 26: 1222321_ab/cde_b/c_1221 |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 2219 | 27: 1222321_ab/cde_b/c_1221 |
| 2220 | 28: 1222321_ab/cde_b/c_1221 |
| 2221 | 29: 1222321_9b/cde_b/c_1221 |
| 2222 | 30: 1222321_ab/cde_b/c_1221 |
| 2223 | 31: 1xyz22321_ab/cde_b/c_1221 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2224 | --- |
| 2225 | name: eglob-substrpl-2 |
| 2226 | description: |
| 2227 | Check anchored substring replacement works, corner cases |
| 2228 | stdin: |
| 2229 | foo=123 |
| 2230 | echo 1: ${foo/#/x} |
| 2231 | echo 2: ${foo/%/x} |
| 2232 | echo 3: ${foo/#/} |
| 2233 | echo 4: ${foo/#} |
| 2234 | echo 5: ${foo/%/} |
| 2235 | echo 6: ${foo/%} |
| 2236 | expected-stdout: |
| 2237 | 1: x123 |
| 2238 | 2: 123x |
| 2239 | 3: 123 |
| 2240 | 4: 123 |
| 2241 | 5: 123 |
| 2242 | 6: 123 |
| 2243 | --- |
| 2244 | name: eglob-substrpl-3a |
| 2245 | description: |
| 2246 | Check substring replacement works with variables and slashes, too |
| 2247 | stdin: |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 2248 | HOME=/etc |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2249 | pfx=/home/user |
| 2250 | wd=/home/user/tmp |
| 2251 | echo "${wd/#$pfx/~}" |
| 2252 | echo "${wd/#\$pfx/~}" |
| 2253 | echo "${wd/#"$pfx"/~}" |
| 2254 | echo "${wd/#'$pfx'/~}" |
| 2255 | echo "${wd/#"\$pfx"/~}" |
| 2256 | echo "${wd/#'\$pfx'/~}" |
| 2257 | expected-stdout: |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 2258 | /etc/tmp |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2259 | /home/user/tmp |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 2260 | /etc/tmp |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2261 | /home/user/tmp |
| 2262 | /home/user/tmp |
| 2263 | /home/user/tmp |
| 2264 | --- |
| 2265 | name: eglob-substrpl-3b |
| 2266 | description: |
| 2267 | More of this, bash fails it (bash4 passes) |
| 2268 | stdin: |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 2269 | HOME=/etc |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2270 | pfx=/home/user |
| 2271 | wd=/home/user/tmp |
| 2272 | echo "${wd/#$(echo /home/user)/~}" |
| 2273 | echo "${wd/#"$(echo /home/user)"/~}" |
| 2274 | echo "${wd/#'$(echo /home/user)'/~}" |
| 2275 | expected-stdout: |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 2276 | /etc/tmp |
| 2277 | /etc/tmp |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2278 | /home/user/tmp |
| 2279 | --- |
| 2280 | name: eglob-substrpl-3c |
| 2281 | description: |
| 2282 | Even more weird cases |
| 2283 | stdin: |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 2284 | HOME=/etc |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2285 | pfx=/home/user |
| 2286 | wd='$pfx/tmp' |
| 2287 | echo 1: ${wd/#$pfx/~} |
| 2288 | echo 2: ${wd/#\$pfx/~} |
| 2289 | echo 3: ${wd/#"$pfx"/~} |
| 2290 | echo 4: ${wd/#'$pfx'/~} |
| 2291 | echo 5: ${wd/#"\$pfx"/~} |
| 2292 | echo 6: ${wd/#'\$pfx'/~} |
| 2293 | ts='a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)' |
| 2294 | tp=a/b |
| 2295 | tr=c/d |
| 2296 | [[ -n $BASH_VERSION ]] && shopt -s extglob |
| 2297 | echo 7: ${ts/a\/b/$tr} |
| 2298 | echo 8: ${ts/a\/b/\$tr} |
| 2299 | echo 9: ${ts/$tp/$tr} |
| 2300 | echo 10: ${ts/\$tp/$tr} |
| 2301 | echo 11: ${ts/\\$tp/$tr} |
| 2302 | echo 12: ${ts/$tp/c/d} |
| 2303 | echo 13: ${ts/$tp/c\/d} |
| 2304 | echo 14: ${ts/$tp/c\\/d} |
| 2305 | echo 15: ${ts/+(a\/b)/$tr} |
| 2306 | echo 16: ${ts/+(a\/b)/\$tr} |
| 2307 | echo 17: ${ts/+($tp)/$tr} |
| 2308 | echo 18: ${ts/+($tp)/c/d} |
| 2309 | echo 19: ${ts/+($tp)/c\/d} |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 2310 | echo 20: ${ts//a\/b/$tr} |
| 2311 | echo 21: ${ts//a\/b/\$tr} |
| 2312 | echo 22: ${ts//$tp/$tr} |
| 2313 | echo 23: ${ts//$tp/c/d} |
| 2314 | echo 24: ${ts//$tp/c\/d} |
| 2315 | echo 25: ${ts//+(a\/b)/$tr} |
| 2316 | echo 26: ${ts//+(a\/b)/\$tr} |
| 2317 | echo 27: ${ts//+($tp)/$tr} |
| 2318 | echo 28: ${ts//+($tp)/c/d} |
| 2319 | echo 29: ${ts//+($tp)/c\/d} |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2320 | tp="+($tp)" |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 2321 | echo 30: ${ts/$tp/$tr} |
| 2322 | echo 31: ${ts//$tp/$tr} |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2323 | expected-stdout: |
| 2324 | 1: $pfx/tmp |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 2325 | 2: /etc/tmp |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2326 | 3: $pfx/tmp |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 2327 | 4: /etc/tmp |
| 2328 | 5: /etc/tmp |
| 2329 | 6: $pfx/tmp |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2330 | 7: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 2331 | 8: $tra/b$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 2332 | 9: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 2333 | 10: a/ba/bc/d$tp_a/b$tp_*(a/b)_*($tp) |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 2334 | 11: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp) |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2335 | 12: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 2336 | 13: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 2337 | 14: c\/da/b$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 2338 | 15: c/d$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 2339 | 16: $tr$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 2340 | 17: c/d$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 2341 | 18: c/d$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 2342 | 19: c/d$tp$tp_a/b$tp_*(a/b)_*($tp) |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 2343 | 20: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp) |
| 2344 | 21: $tr$tr$tp$tp_$tr$tp_*($tr)_*($tp) |
| 2345 | 22: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp) |
| 2346 | 23: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp) |
| 2347 | 24: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp) |
| 2348 | 25: c/d$tp$tp_c/d$tp_*(c/d)_*($tp) |
| 2349 | 26: $tr$tp$tp_$tr$tp_*($tr)_*($tp) |
| 2350 | 27: c/d$tp$tp_c/d$tp_*(c/d)_*($tp) |
| 2351 | 28: c/d$tp$tp_c/d$tp_*(c/d)_*($tp) |
| 2352 | 29: c/d$tp$tp_c/d$tp_*(c/d)_*($tp) |
| 2353 | 30: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 2354 | 31: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp) |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2355 | # This is what GNU bash does: |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 2356 | # 30: c/d$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 2357 | # 31: c/d$tp$tp_c/d$tp_*(c/d)_*($tp) |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2358 | --- |
| 2359 | name: eglob-utf8-1 |
| 2360 | description: |
| 2361 | UTF-8 mode differences for eglobbing |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 2362 | category: !shell:ebcdic-yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2363 | stdin: |
| 2364 | s=blöd |
| 2365 | set +U |
| 2366 | print 1: ${s%???} . |
| 2367 | print 2: ${s/b???d/x} . |
| 2368 | set -U |
| 2369 | print 3: ${s%???} . |
| 2370 | print 4: ${s/b??d/x} . |
| 2371 | x=nö |
| 2372 | print 5: ${x%?} ${x%%?} . |
| 2373 | x=äh |
| 2374 | print 6: ${x#?} ${x##?} . |
| 2375 | x= |
| 2376 | print 7: ${x%?} ${x%%?} . |
| 2377 | x=mä |
| 2378 | print 8: ${x%?} ${x%%?} . |
| 2379 | x=ä½ |
| 2380 | print 9: ${x%?} ${x%%?} . |
| 2381 | expected-stdout: |
| 2382 | 1: bl . |
| 2383 | 2: x . |
| 2384 | 3: b . |
| 2385 | 4: x . |
| 2386 | 5: n n . |
| 2387 | 6: h h . |
| 2388 | 7: . |
| 2389 | 8: mä mä . |
| 2390 | 9: . |
| 2391 | --- |
| 2392 | name: glob-bad-1 |
| 2393 | description: |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 2394 | Check that [ matches itself if it's not a valid bracket expr |
| 2395 | but does not prevent globbing, while backslash-escaping does |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2396 | file-setup: dir 755 "[x" |
| 2397 | file-setup: file 644 "[x/foo" |
| 2398 | stdin: |
| 2399 | echo [* |
| 2400 | echo *[x |
| 2401 | echo [x/* |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 2402 | :>'ab[x' |
| 2403 | :>'a[a-z][x' |
| 2404 | echo a[a-z][* |
| 2405 | echo a[a-z]* |
| 2406 | echo a[a\-z]* |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2407 | expected-stdout: |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 2408 | [x |
| 2409 | [x |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2410 | [x/foo |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 2411 | ab[x |
| 2412 | ab[x |
| 2413 | a[a-z]* |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2414 | --- |
| 2415 | name: glob-bad-2 |
| 2416 | description: |
| 2417 | Check that symbolic links aren't stat()'d |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 2418 | # breaks on Dell UNIX 4.0 R2.2 (SVR4) where unlink also fails |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 2419 | # breaks on FreeMiNT (cannot unlink dangling symlinks) |
| 2420 | # breaks on MSYS, OS/2 (do not support symlinks) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 2421 | category: !os:mint,!os:msys,!os:svr4.0,!nosymlink |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2422 | file-setup: dir 755 "dir" |
| 2423 | file-setup: symlink 644 "dir/abc" |
| 2424 | non-existent-file |
| 2425 | stdin: |
| 2426 | echo d*/* |
| 2427 | echo d*/abc |
| 2428 | expected-stdout: |
| 2429 | dir/abc |
| 2430 | dir/abc |
| 2431 | --- |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 2432 | name: glob-bad-3 |
| 2433 | description: |
| 2434 | Check that the slash is parsed before the glob |
| 2435 | stdin: |
| 2436 | mkdir a 'a[b' |
| 2437 | (cd 'a[b'; echo ok >'c]d') |
| 2438 | echo nok >abd |
| 2439 | echo fail >a/d |
| 2440 | cat a[b/c]d |
| 2441 | expected-stdout: |
| 2442 | ok |
| 2443 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2444 | name: glob-range-1 |
| 2445 | description: |
| 2446 | Test range matching |
| 2447 | file-setup: file 644 ".bc" |
| 2448 | file-setup: file 644 "abc" |
| 2449 | file-setup: file 644 "bbc" |
| 2450 | file-setup: file 644 "cbc" |
| 2451 | file-setup: file 644 "-bc" |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 2452 | file-setup: file 644 "!bc" |
| 2453 | file-setup: file 644 "^bc" |
| 2454 | file-setup: file 644 "+bc" |
| 2455 | file-setup: file 644 ",bc" |
| 2456 | file-setup: file 644 "0bc" |
| 2457 | file-setup: file 644 "1bc" |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2458 | stdin: |
| 2459 | echo [ab-]* |
| 2460 | echo [-ab]* |
| 2461 | echo [!-ab]* |
| 2462 | echo [!ab]* |
| 2463 | echo []ab]* |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 2464 | echo [^ab]* |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 2465 | echo [+--]* |
| 2466 | echo [--1]* |
| 2467 | |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2468 | expected-stdout: |
| 2469 | -bc abc bbc |
| 2470 | -bc abc bbc |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 2471 | !bc +bc ,bc 0bc 1bc ^bc cbc |
| 2472 | !bc +bc ,bc -bc 0bc 1bc ^bc cbc |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2473 | abc bbc |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 2474 | ^bc abc bbc |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 2475 | +bc ,bc -bc |
| 2476 | -bc 0bc 1bc |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2477 | --- |
| 2478 | name: glob-range-2 |
| 2479 | description: |
| 2480 | Test range matching |
| 2481 | (AT&T ksh fails this; POSIX says invalid) |
| 2482 | file-setup: file 644 "abc" |
| 2483 | stdin: |
| 2484 | echo [a--]* |
| 2485 | expected-stdout: |
| 2486 | [a--]* |
| 2487 | --- |
| 2488 | name: glob-range-3 |
| 2489 | description: |
| 2490 | Check that globbing matches the right things... |
Elliott Hughes | 4708626 | 2019-03-26 12:34:31 -0700 | [diff] [blame] | 2491 | # breaks on Mac OSX (HFS+ non-standard UTF-8 canonical decomposition) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 2492 | # breaks on Cygwin 1.7 (files are now UTF-16 or something) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 2493 | # breaks on QNX 6.4.1 (says RT) |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 2494 | category: !os:cygwin,!os:darwin,!os:msys,!os:nto,!os:os2,!os:os390 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 2495 | need-pass: no |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2496 | file-setup: file 644 "aÂc" |
| 2497 | stdin: |
| 2498 | echo a[Á-Ú]* |
| 2499 | expected-stdout: |
| 2500 | aÂc |
| 2501 | --- |
| 2502 | name: glob-range-4 |
| 2503 | description: |
| 2504 | Results unspecified according to POSIX |
| 2505 | file-setup: file 644 ".bc" |
| 2506 | stdin: |
| 2507 | echo [a.]* |
| 2508 | expected-stdout: |
| 2509 | [a.]* |
| 2510 | --- |
| 2511 | name: glob-range-5 |
| 2512 | description: |
| 2513 | Results unspecified according to POSIX |
| 2514 | (AT&T ksh treats this like [a-cc-e]*) |
| 2515 | file-setup: file 644 "abc" |
| 2516 | file-setup: file 644 "bbc" |
| 2517 | file-setup: file 644 "cbc" |
| 2518 | file-setup: file 644 "dbc" |
| 2519 | file-setup: file 644 "ebc" |
| 2520 | file-setup: file 644 "-bc" |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 2521 | file-setup: file 644 "@bc" |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2522 | stdin: |
| 2523 | echo [a-c-e]* |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 2524 | echo [a--@]* |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2525 | expected-stdout: |
| 2526 | -bc abc bbc cbc ebc |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 2527 | @bc |
| 2528 | --- |
| 2529 | name: glob-word-1 |
| 2530 | description: |
| 2531 | Check BSD word boundary matches |
| 2532 | stdin: |
| 2533 | t() { [[ $1 = *[[:\<:]]bar[[:\>:]]* ]]; echo =$?; } |
| 2534 | t 'foo bar baz' |
| 2535 | t 'foobar baz' |
| 2536 | t 'foo barbaz' |
| 2537 | t 'bar' |
| 2538 | t '_bar' |
| 2539 | t 'bar_' |
| 2540 | expected-stdout: |
| 2541 | =0 |
| 2542 | =1 |
| 2543 | =1 |
| 2544 | =0 |
| 2545 | =1 |
| 2546 | =1 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2547 | --- |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 2548 | name: glob-trim-1 |
| 2549 | description: |
| 2550 | Check against a regression from fixing IFS-subst-2 |
| 2551 | stdin: |
| 2552 | x='#foo' |
| 2553 | print -r "before='$x'" |
| 2554 | x=${x%%#*} |
| 2555 | print -r "after ='$x'" |
| 2556 | expected-stdout: |
| 2557 | before='#foo' |
| 2558 | after ='' |
| 2559 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2560 | name: heredoc-1 |
| 2561 | description: |
| 2562 | Check ordering/content of redundent here documents. |
| 2563 | stdin: |
| 2564 | cat << EOF1 << EOF2 |
| 2565 | hi |
| 2566 | EOF1 |
| 2567 | there |
| 2568 | EOF2 |
| 2569 | expected-stdout: |
| 2570 | there |
| 2571 | --- |
| 2572 | name: heredoc-2 |
| 2573 | description: |
| 2574 | Check quoted here-doc is protected. |
| 2575 | stdin: |
| 2576 | a=foo |
| 2577 | cat << 'EOF' |
| 2578 | hi\ |
| 2579 | there$a |
| 2580 | stuff |
| 2581 | EO\ |
| 2582 | F |
| 2583 | EOF |
| 2584 | expected-stdout: |
| 2585 | hi\ |
| 2586 | there$a |
| 2587 | stuff |
| 2588 | EO\ |
| 2589 | F |
| 2590 | --- |
| 2591 | name: heredoc-3 |
| 2592 | description: |
| 2593 | Check that newline isn't needed after heredoc-delimiter marker. |
| 2594 | stdin: ! |
| 2595 | cat << EOF |
| 2596 | hi |
| 2597 | there |
| 2598 | EOF |
| 2599 | expected-stdout: |
| 2600 | hi |
| 2601 | there |
| 2602 | --- |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 2603 | name: heredoc-4a |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2604 | description: |
| 2605 | Check that an error occurs if the heredoc-delimiter is missing. |
| 2606 | stdin: ! |
| 2607 | cat << EOF |
| 2608 | hi |
| 2609 | there |
| 2610 | expected-exit: e > 0 |
| 2611 | expected-stderr-pattern: /.*/ |
| 2612 | --- |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 2613 | name: heredoc-4an |
| 2614 | description: |
| 2615 | Check that an error occurs if the heredoc-delimiter is missing. |
| 2616 | arguments: !-n! |
| 2617 | stdin: ! |
| 2618 | cat << EOF |
| 2619 | hi |
| 2620 | there |
| 2621 | expected-exit: e > 0 |
| 2622 | expected-stderr-pattern: /.*/ |
| 2623 | --- |
| 2624 | name: heredoc-4b |
| 2625 | description: |
| 2626 | Check that an error occurs if the heredoc is missing. |
| 2627 | stdin: ! |
| 2628 | cat << EOF |
| 2629 | expected-exit: e > 0 |
| 2630 | expected-stderr-pattern: /.*/ |
| 2631 | --- |
| 2632 | name: heredoc-4bn |
| 2633 | description: |
| 2634 | Check that an error occurs if the heredoc is missing. |
| 2635 | arguments: !-n! |
| 2636 | stdin: ! |
| 2637 | cat << EOF |
| 2638 | expected-exit: e > 0 |
| 2639 | expected-stderr-pattern: /.*/ |
| 2640 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2641 | name: heredoc-5 |
| 2642 | description: |
| 2643 | Check that backslash quotes a $, ` and \ and kills a \newline |
| 2644 | stdin: |
| 2645 | a=BAD |
| 2646 | b=ok |
| 2647 | cat << EOF |
| 2648 | h\${a}i |
| 2649 | h\\${b}i |
| 2650 | th\`echo not-run\`ere |
| 2651 | th\\`echo is-run`ere |
| 2652 | fol\\ks |
| 2653 | more\\ |
| 2654 | last \ |
| 2655 | line |
| 2656 | EOF |
| 2657 | expected-stdout: |
| 2658 | h${a}i |
| 2659 | h\oki |
| 2660 | th`echo not-run`ere |
| 2661 | th\is-runere |
| 2662 | fol\ks |
| 2663 | more\ |
| 2664 | last line |
| 2665 | --- |
| 2666 | name: heredoc-6 |
| 2667 | description: |
| 2668 | Check that \newline in initial here-delim word doesn't imply |
| 2669 | a quoted here-doc. |
| 2670 | stdin: |
| 2671 | a=i |
| 2672 | cat << EO\ |
| 2673 | F |
| 2674 | h$a |
| 2675 | there |
| 2676 | EOF |
| 2677 | expected-stdout: |
| 2678 | hi |
| 2679 | there |
| 2680 | --- |
| 2681 | name: heredoc-7 |
| 2682 | description: |
| 2683 | Check that double quoted $ expressions in here delimiters are |
| 2684 | not expanded and match the delimiter. |
| 2685 | POSIX says only quote removal is applied to the delimiter. |
| 2686 | stdin: |
| 2687 | a=b |
| 2688 | cat << "E$a" |
| 2689 | hi |
| 2690 | h$a |
| 2691 | hb |
| 2692 | E$a |
| 2693 | echo done |
| 2694 | expected-stdout: |
| 2695 | hi |
| 2696 | h$a |
| 2697 | hb |
| 2698 | done |
| 2699 | --- |
| 2700 | name: heredoc-8 |
| 2701 | description: |
| 2702 | Check that double quoted escaped $ expressions in here |
| 2703 | delimiters are not expanded and match the delimiter. |
| 2704 | POSIX says only quote removal is applied to the delimiter |
| 2705 | (\ counts as a quote). |
| 2706 | stdin: |
| 2707 | a=b |
| 2708 | cat << "E\$a" |
| 2709 | hi |
| 2710 | h$a |
| 2711 | h\$a |
| 2712 | hb |
| 2713 | h\b |
| 2714 | E$a |
| 2715 | echo done |
| 2716 | expected-stdout: |
| 2717 | hi |
| 2718 | h$a |
| 2719 | h\$a |
| 2720 | hb |
| 2721 | h\b |
| 2722 | done |
| 2723 | --- |
| 2724 | name: heredoc-9a |
| 2725 | description: |
| 2726 | Check that here strings work. |
| 2727 | stdin: |
| 2728 | bar="bar |
| 2729 | baz" |
| 2730 | tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo |
| 2731 | "$__progname" -c "tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo" |
| 2732 | tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$bar" |
| 2733 | tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<'$bar' |
| 2734 | tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$bar |
| 2735 | tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<-foo |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 2736 | tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$(echo "foo bar")" |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 2737 | tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"A $(echo "foo bar") B" |
| 2738 | tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$b\$b$bar |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2739 | expected-stdout: |
| 2740 | sbb |
| 2741 | sbb |
| 2742 | one |
| 2743 | onm |
| 2744 | $one |
| 2745 | $one |
| 2746 | -sbb |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 2747 | sbb one |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 2748 | A sbb one B |
| 2749 | $o$oone |
| 2750 | onm |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 2751 | --- |
| 2752 | name: heredoc-9b |
| 2753 | description: |
| 2754 | Check that a corner case of here strings works like bash |
| 2755 | stdin: |
| 2756 | fnord=42 |
| 2757 | bar="bar |
| 2758 | \$fnord baz" |
| 2759 | tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar |
| 2760 | expected-stdout: |
| 2761 | one $sabeq onm |
| 2762 | category: bash |
| 2763 | --- |
| 2764 | name: heredoc-9c |
| 2765 | description: |
| 2766 | Check that a corner case of here strings works like ksh93, zsh |
| 2767 | stdin: |
| 2768 | fnord=42 |
| 2769 | bar="bar |
| 2770 | \$fnord baz" |
| 2771 | tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar |
| 2772 | expected-stdout: |
| 2773 | one |
| 2774 | $sabeq onm |
| 2775 | --- |
| 2776 | name: heredoc-9d |
| 2777 | description: |
| 2778 | Check another corner case of here strings |
| 2779 | stdin: |
| 2780 | tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<< bar |
| 2781 | expected-stdout: |
| 2782 | one |
| 2783 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 2784 | name: heredoc-9e |
| 2785 | description: |
| 2786 | Check here string related regression with multiple iops |
| 2787 | stdin: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 2788 | echo $(tr r z <<<'bar' 2>/dev/null) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 2789 | expected-stdout: |
| 2790 | baz |
| 2791 | --- |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 2792 | name: heredoc-9f |
| 2793 | description: |
| 2794 | Check long here strings |
| 2795 | stdin: |
| 2796 | cat <<< "$( : )aa" |
| 2797 | expected-stdout: |
| 2798 | aa |
| 2799 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 2800 | name: heredoc-10 |
| 2801 | description: |
| 2802 | Check direct here document assignment |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 2803 | category: !shell:ebcdic-yes |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 2804 | stdin: |
| 2805 | x=u |
| 2806 | va=<<EOF |
| 2807 | =a $x \x40= |
| 2808 | EOF |
| 2809 | vb=<<'EOF' |
| 2810 | =b $x \x40= |
| 2811 | EOF |
| 2812 | function foo { |
| 2813 | vc=<<-EOF |
| 2814 | =c $x \x40= |
| 2815 | EOF |
| 2816 | } |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 2817 | fnd=$(typeset -f foo) |
| 2818 | print -r -- "$fnd" |
| 2819 | function foo { |
| 2820 | echo blub |
| 2821 | } |
| 2822 | foo |
| 2823 | eval "$fnd" |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 2824 | foo |
| 2825 | # rather nonsensical, but⦠|
| 2826 | vd=<<<"=d $x \x40=" |
| 2827 | ve=<<<'=e $x \x40=' |
| 2828 | vf=<<<$'=f $x \x40=' |
| 2829 | # now check |
| 2830 | print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} ve={$ve} vf={$vf} |" |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 2831 | # check append |
| 2832 | v=<<-EOF |
| 2833 | vapp1 |
| 2834 | EOF |
| 2835 | v+=<<-EOF |
| 2836 | vapp2 |
| 2837 | EOF |
| 2838 | print -r -- "| ${v//$'\n'/^} |" |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 2839 | expected-stdout: |
| 2840 | function foo { |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 2841 | vc=<<-EOF |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 2842 | =c $x \x40= |
| 2843 | EOF |
| 2844 | |
| 2845 | } |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 2846 | blub |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 2847 | | va={=a u \x40= |
| 2848 | } vb={=b $x \x40= |
| 2849 | } vc={=c u \x40= |
| 2850 | } vd={=d u \x40= |
| 2851 | } ve={=e $x \x40= |
| 2852 | } vf={=f $x @= |
| 2853 | } | |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 2854 | | vapp1^vapp2^ | |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 2855 | --- |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 2856 | name: heredoc-10-ebcdic |
| 2857 | description: |
| 2858 | Check direct here document assignment |
| 2859 | category: !shell:ebcdic-no |
| 2860 | stdin: |
| 2861 | x=u |
| 2862 | va=<<EOF |
| 2863 | =a $x \x7C= |
| 2864 | EOF |
| 2865 | vb=<<'EOF' |
| 2866 | =b $x \x7C= |
| 2867 | EOF |
| 2868 | function foo { |
| 2869 | vc=<<-EOF |
| 2870 | =c $x \x7C= |
| 2871 | EOF |
| 2872 | } |
| 2873 | fnd=$(typeset -f foo) |
| 2874 | print -r -- "$fnd" |
| 2875 | function foo { |
| 2876 | echo blub |
| 2877 | } |
| 2878 | foo |
| 2879 | eval "$fnd" |
| 2880 | foo |
| 2881 | # rather nonsensical, but⦠|
| 2882 | vd=<<<"=d $x \x7C=" |
| 2883 | ve=<<<'=e $x \x7C=' |
| 2884 | vf=<<<$'=f $x \x7C=' |
| 2885 | # now check |
| 2886 | print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} ve={$ve} vf={$vf} |" |
| 2887 | # check append |
| 2888 | v=<<-EOF |
| 2889 | vapp1 |
| 2890 | EOF |
| 2891 | v+=<<-EOF |
| 2892 | vapp2 |
| 2893 | EOF |
| 2894 | print -r -- "| ${v//$'\n'/^} |" |
| 2895 | expected-stdout: |
| 2896 | function foo { |
| 2897 | vc=<<-EOF |
| 2898 | =c $x \x7C= |
| 2899 | EOF |
| 2900 | |
| 2901 | } |
| 2902 | blub |
| 2903 | | va={=a u \x7C= |
| 2904 | } vb={=b $x \x7C= |
| 2905 | } vc={=c u \x7C= |
| 2906 | } vd={=d u \x7C= |
| 2907 | } ve={=e $x \x7C= |
| 2908 | } vf={=f $x @= |
| 2909 | } | |
| 2910 | | vapp1^vapp2^ | |
| 2911 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 2912 | name: heredoc-11 |
| 2913 | description: |
| 2914 | Check here documents with no or empty delimiter |
| 2915 | stdin: |
| 2916 | x=u |
| 2917 | va=<< |
| 2918 | =a $x \x40= |
| 2919 | << |
| 2920 | vb=<<'' |
| 2921 | =b $x \x40= |
| 2922 | |
| 2923 | function foo { |
| 2924 | vc=<<- |
| 2925 | =c $x \x40= |
| 2926 | << |
| 2927 | vd=<<-'' |
| 2928 | =d $x \x40= |
| 2929 | |
| 2930 | } |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 2931 | fnd=$(typeset -f foo) |
| 2932 | print -r -- "$fnd" |
| 2933 | function foo { |
| 2934 | echo blub |
| 2935 | } |
| 2936 | foo |
| 2937 | eval "$fnd" |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 2938 | foo |
| 2939 | print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} |" |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 2940 | x=y |
| 2941 | foo |
| 2942 | typeset -f foo |
| 2943 | print -r -- "| vc={$vc} vd={$vd} |" |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 2944 | # check append |
| 2945 | v=<<- |
| 2946 | vapp1 |
| 2947 | << |
| 2948 | v+=<<-'' |
| 2949 | vapp2 |
| 2950 | |
| 2951 | print -r -- "| ${v//$'\n'/^} |" |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 2952 | expected-stdout: |
| 2953 | function foo { |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 2954 | vc=<<- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 2955 | =c $x \x40= |
| 2956 | << |
| 2957 | |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 2958 | vd=<<-"" |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 2959 | =d $x \x40= |
| 2960 | |
| 2961 | |
| 2962 | } |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 2963 | blub |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 2964 | | va={=a u \x40= |
| 2965 | } vb={=b $x \x40= |
| 2966 | } vc={=c u \x40= |
| 2967 | } vd={=d $x \x40= |
| 2968 | } | |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 2969 | function foo { |
| 2970 | vc=<<- |
| 2971 | =c $x \x40= |
| 2972 | << |
| 2973 | |
| 2974 | vd=<<-"" |
| 2975 | =d $x \x40= |
| 2976 | |
| 2977 | |
| 2978 | } |
| 2979 | | vc={=c y \x40= |
| 2980 | } vd={=d $x \x40= |
| 2981 | } | |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 2982 | | vapp1^vapp2^ | |
| 2983 | --- |
| 2984 | name: heredoc-12 |
| 2985 | description: |
| 2986 | Check here documents can use $* and $@; note shells vary: |
| 2987 | ⢠pdksh 5.2.14 acts the same |
| 2988 | ⢠dash has 1 and 2 the same but 3 lacks the space |
| 2989 | ⢠ksh93, bash4 differ in 2 by using space ipv colon |
| 2990 | stdin: |
| 2991 | set -- a b |
| 2992 | nl=' |
| 2993 | ' |
| 2994 | IFS=" $nl"; n=1 |
| 2995 | cat <<EOF |
| 2996 | $n foo $* foo |
| 2997 | $n bar "$*" bar |
| 2998 | $n baz $@ baz |
| 2999 | $n bla "$@" bla |
| 3000 | EOF |
| 3001 | IFS=":"; n=2 |
| 3002 | cat <<EOF |
| 3003 | $n foo $* foo |
| 3004 | $n bar "$*" bar |
| 3005 | $n baz $@ baz |
| 3006 | $n bla "$@" bla |
| 3007 | EOF |
| 3008 | IFS=; n=3 |
| 3009 | cat <<EOF |
| 3010 | $n foo $* foo |
| 3011 | $n bar "$*" bar |
| 3012 | $n baz $@ baz |
| 3013 | $n bla "$@" bla |
| 3014 | EOF |
| 3015 | expected-stdout: |
| 3016 | 1 foo a b foo |
| 3017 | 1 bar "a b" bar |
| 3018 | 1 baz a b baz |
| 3019 | 1 bla "a b" bla |
| 3020 | 2 foo a:b foo |
| 3021 | 2 bar "a:b" bar |
| 3022 | 2 baz a:b baz |
| 3023 | 2 bla "a:b" bla |
| 3024 | 3 foo a b foo |
| 3025 | 3 bar "a b" bar |
| 3026 | 3 baz a b baz |
| 3027 | 3 bla "a b" bla |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 3028 | --- |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 3029 | name: heredoc-14 |
| 3030 | description: |
| 3031 | Check that using multiple here documents works |
| 3032 | stdin: |
| 3033 | foo() { |
| 3034 | echo "got $(cat) on stdin" |
| 3035 | echo "got $(cat <&4) on fd#4" |
| 3036 | echo "got $(cat <&5) on fd#5" |
| 3037 | } |
| 3038 | bar() { |
| 3039 | foo 4<<-a <<-b 5<<-c |
| 3040 | four |
| 3041 | a |
| 3042 | zero |
| 3043 | b |
| 3044 | five |
| 3045 | c |
| 3046 | } |
| 3047 | x=$(typeset -f bar) |
| 3048 | eval "$x" |
| 3049 | y=$(typeset -f bar) |
| 3050 | [[ $x = "$y" ]]; echo $? |
| 3051 | typeset -f bar |
| 3052 | bar |
| 3053 | expected-stdout: |
| 3054 | 0 |
| 3055 | bar() { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 3056 | \foo 4<<-a <<-b 5<<-c |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 3057 | four |
| 3058 | a |
| 3059 | zero |
| 3060 | b |
| 3061 | five |
| 3062 | c |
| 3063 | |
| 3064 | } |
| 3065 | got zero on stdin |
| 3066 | got four on fd#4 |
| 3067 | got five on fd#5 |
| 3068 | --- |
Elliott Hughes | 4708626 | 2019-03-26 12:34:31 -0700 | [diff] [blame] | 3069 | name: heredoc-15 |
| 3070 | description: |
| 3071 | Check high-bit7 separators work |
| 3072 | stdin: |
| 3073 | u=ä |
| 3074 | tr a-z A-Z <<-⦠|
| 3075 | m${u}h |
| 3076 | ⦠|
| 3077 | echo ok |
| 3078 | expected-stdout: |
| 3079 | MäH |
| 3080 | ok |
| 3081 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 3082 | name: heredoc-comsub-1 |
| 3083 | description: |
| 3084 | Tests for here documents in COMSUB, taken from Austin ML |
| 3085 | stdin: |
| 3086 | text=$(cat <<EOF |
| 3087 | here is the text |
| 3088 | EOF) |
| 3089 | echo = $text = |
| 3090 | expected-stdout: |
| 3091 | = here is the text = |
| 3092 | --- |
| 3093 | name: heredoc-comsub-2 |
| 3094 | description: |
| 3095 | Tests for here documents in COMSUB, taken from Austin ML |
| 3096 | stdin: |
| 3097 | unbalanced=$(cat <<EOF |
| 3098 | this paren ) is a problem |
| 3099 | EOF) |
| 3100 | echo = $unbalanced = |
| 3101 | expected-stdout: |
| 3102 | = this paren ) is a problem = |
| 3103 | --- |
| 3104 | name: heredoc-comsub-3 |
| 3105 | description: |
| 3106 | Tests for here documents in COMSUB, taken from Austin ML |
| 3107 | stdin: |
| 3108 | balanced=$(cat <<EOF |
| 3109 | these parens ( ) are not a problem |
| 3110 | EOF) |
| 3111 | echo = $balanced = |
| 3112 | expected-stdout: |
| 3113 | = these parens ( ) are not a problem = |
| 3114 | --- |
| 3115 | name: heredoc-comsub-4 |
| 3116 | description: |
| 3117 | Tests for here documents in COMSUB, taken from Austin ML |
| 3118 | stdin: |
| 3119 | balanced=$(cat <<EOF |
| 3120 | these parens \( ) are a problem |
| 3121 | EOF) |
| 3122 | echo = $balanced = |
| 3123 | expected-stdout: |
| 3124 | = these parens \( ) are a problem = |
| 3125 | --- |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 3126 | name: heredoc-comsub-5 |
| 3127 | description: |
| 3128 | Check heredoc and COMSUB mixture in input |
| 3129 | stdin: |
| 3130 | prefix() { sed -e "s/^/$1:/"; } |
| 3131 | XXX() { echo x-en; } |
| 3132 | YYY() { echo y-es; } |
| 3133 | |
| 3134 | prefix A <<XXX && echo "$(prefix B <<XXX |
| 3135 | echo line 1 |
| 3136 | XXX |
| 3137 | echo line 2)" && prefix C <<YYY |
| 3138 | echo line 3 |
| 3139 | XXX |
| 3140 | echo line 4)" |
| 3141 | echo line 5 |
| 3142 | YYY |
| 3143 | XXX |
| 3144 | expected-stdout: |
| 3145 | A:echo line 3 |
| 3146 | B:echo line 1 |
| 3147 | line 2 |
| 3148 | C:echo line 4)" |
| 3149 | C:echo line 5 |
| 3150 | x-en |
| 3151 | --- |
| 3152 | name: heredoc-comsub-6 |
| 3153 | description: |
| 3154 | Check here documents and here strings can be used |
| 3155 | without a specific command, like $(<â¦) (extension) |
| 3156 | stdin: |
| 3157 | foo=bar |
| 3158 | x=$(<<<EO${foo}F) |
| 3159 | echo "3<$x>" |
| 3160 | y=$(<<-EOF |
| 3161 | hi! |
| 3162 | |
| 3163 | $foo) is not a problem |
| 3164 | |
| 3165 | |
| 3166 | EOF) |
| 3167 | echo "7<$y>" |
| 3168 | expected-stdout: |
| 3169 | 3<EObarF> |
| 3170 | 7<hi! |
| 3171 | |
| 3172 | bar) is not a problem> |
| 3173 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 3174 | name: heredoc-subshell-1 |
| 3175 | description: |
| 3176 | Tests for here documents in subshells, taken from Austin ML |
| 3177 | stdin: |
| 3178 | (cat <<EOF |
| 3179 | some text |
| 3180 | EOF) |
| 3181 | echo end |
| 3182 | expected-stdout: |
| 3183 | some text |
| 3184 | end |
| 3185 | --- |
| 3186 | name: heredoc-subshell-2 |
| 3187 | description: |
| 3188 | Tests for here documents in subshells, taken from Austin ML |
| 3189 | stdin: |
| 3190 | (cat <<EOF |
| 3191 | some text |
| 3192 | EOF |
| 3193 | ) |
| 3194 | echo end |
| 3195 | expected-stdout: |
| 3196 | some text |
| 3197 | end |
| 3198 | --- |
| 3199 | name: heredoc-subshell-3 |
| 3200 | description: |
| 3201 | Tests for here documents in subshells, taken from Austin ML |
| 3202 | stdin: |
| 3203 | (cat <<EOF; ) |
| 3204 | some text |
| 3205 | EOF |
| 3206 | echo end |
| 3207 | expected-stdout: |
| 3208 | some text |
| 3209 | end |
| 3210 | --- |
| 3211 | name: heredoc-weird-1 |
| 3212 | description: |
| 3213 | Tests for here documents, taken from Austin ML |
| 3214 | Documents current state in mksh, *NOT* necessarily correct! |
| 3215 | stdin: |
| 3216 | cat <<END |
| 3217 | hello |
| 3218 | END\ |
| 3219 | END |
| 3220 | END |
| 3221 | echo end |
| 3222 | expected-stdout: |
| 3223 | hello |
| 3224 | ENDEND |
| 3225 | end |
| 3226 | --- |
| 3227 | name: heredoc-weird-2 |
| 3228 | description: |
| 3229 | Tests for here documents, taken from Austin ML |
| 3230 | stdin: |
| 3231 | cat <<' END ' |
| 3232 | hello |
| 3233 | END |
| 3234 | echo end |
| 3235 | expected-stdout: |
| 3236 | hello |
| 3237 | end |
| 3238 | --- |
| 3239 | name: heredoc-weird-4 |
| 3240 | description: |
| 3241 | Tests for here documents, taken from Austin ML |
| 3242 | Documents current state in mksh, *NOT* necessarily correct! |
| 3243 | stdin: |
| 3244 | cat <<END |
| 3245 | hello\ |
| 3246 | END |
| 3247 | END |
| 3248 | echo end |
| 3249 | expected-stdout: |
| 3250 | helloEND |
| 3251 | end |
| 3252 | --- |
| 3253 | name: heredoc-weird-5 |
| 3254 | description: |
| 3255 | Tests for here documents, taken from Austin ML |
| 3256 | Documents current state in mksh, *NOT* necessarily correct! |
| 3257 | stdin: |
| 3258 | cat <<END |
| 3259 | hello |
| 3260 | \END |
| 3261 | END |
| 3262 | echo end |
| 3263 | expected-stdout: |
| 3264 | hello |
| 3265 | \END |
| 3266 | end |
| 3267 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 3268 | name: heredoc-tmpfile-1 |
| 3269 | description: |
| 3270 | Check that heredoc temp files aren't removed too soon or too late. |
| 3271 | Heredoc in simple command. |
| 3272 | stdin: |
| 3273 | TMPDIR=$PWD |
| 3274 | eval ' |
| 3275 | cat <<- EOF |
| 3276 | hi |
| 3277 | EOF |
| 3278 | for i in a b ; do |
| 3279 | cat <<- EOF |
| 3280 | more |
| 3281 | EOF |
| 3282 | done |
| 3283 | ' & |
| 3284 | sleep 1 |
| 3285 | echo Left overs: * |
| 3286 | expected-stdout: |
| 3287 | hi |
| 3288 | more |
| 3289 | more |
| 3290 | Left overs: * |
| 3291 | --- |
| 3292 | name: heredoc-tmpfile-2 |
| 3293 | description: |
| 3294 | Check that heredoc temp files aren't removed too soon or too late. |
| 3295 | Heredoc in function, multiple calls to function. |
| 3296 | stdin: |
| 3297 | TMPDIR=$PWD |
| 3298 | eval ' |
| 3299 | foo() { |
| 3300 | cat <<- EOF |
| 3301 | hi |
| 3302 | EOF |
| 3303 | } |
| 3304 | foo |
| 3305 | foo |
| 3306 | ' & |
| 3307 | sleep 1 |
| 3308 | echo Left overs: * |
| 3309 | expected-stdout: |
| 3310 | hi |
| 3311 | hi |
| 3312 | Left overs: * |
| 3313 | --- |
| 3314 | name: heredoc-tmpfile-3 |
| 3315 | description: |
| 3316 | Check that heredoc temp files aren't removed too soon or too late. |
| 3317 | Heredoc in function in loop, multiple calls to function. |
| 3318 | stdin: |
| 3319 | TMPDIR=$PWD |
| 3320 | eval ' |
| 3321 | foo() { |
| 3322 | cat <<- EOF |
| 3323 | hi |
| 3324 | EOF |
| 3325 | } |
| 3326 | for i in a b; do |
| 3327 | foo |
| 3328 | foo() { |
| 3329 | cat <<- EOF |
| 3330 | folks $i |
| 3331 | EOF |
| 3332 | } |
| 3333 | done |
| 3334 | foo |
| 3335 | ' & |
| 3336 | sleep 1 |
| 3337 | echo Left overs: * |
| 3338 | expected-stdout: |
| 3339 | hi |
| 3340 | folks b |
| 3341 | folks b |
| 3342 | Left overs: * |
| 3343 | --- |
| 3344 | name: heredoc-tmpfile-4 |
| 3345 | description: |
| 3346 | Check that heredoc temp files aren't removed too soon or too late. |
| 3347 | Backgrounded simple command with here doc |
| 3348 | stdin: |
| 3349 | TMPDIR=$PWD |
| 3350 | eval ' |
| 3351 | cat <<- EOF & |
| 3352 | hi |
| 3353 | EOF |
| 3354 | ' & |
| 3355 | sleep 1 |
| 3356 | echo Left overs: * |
| 3357 | expected-stdout: |
| 3358 | hi |
| 3359 | Left overs: * |
| 3360 | --- |
| 3361 | name: heredoc-tmpfile-5 |
| 3362 | description: |
| 3363 | Check that heredoc temp files aren't removed too soon or too late. |
| 3364 | Backgrounded subshell command with here doc |
| 3365 | stdin: |
| 3366 | TMPDIR=$PWD |
| 3367 | eval ' |
| 3368 | ( |
| 3369 | sleep 1 # so parent exits |
| 3370 | echo A |
| 3371 | cat <<- EOF |
| 3372 | hi |
| 3373 | EOF |
| 3374 | echo B |
| 3375 | ) & |
| 3376 | ' & |
Elliott Hughes | dd4abe0 | 2018-02-05 15:55:19 -0800 | [diff] [blame] | 3377 | sleep 5 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 3378 | echo Left overs: * |
| 3379 | expected-stdout: |
| 3380 | A |
| 3381 | hi |
| 3382 | B |
| 3383 | Left overs: * |
| 3384 | --- |
| 3385 | name: heredoc-tmpfile-6 |
| 3386 | description: |
| 3387 | Check that heredoc temp files aren't removed too soon or too late. |
| 3388 | Heredoc in pipeline. |
| 3389 | stdin: |
| 3390 | TMPDIR=$PWD |
| 3391 | eval ' |
| 3392 | cat <<- EOF | sed "s/hi/HI/" |
| 3393 | hi |
| 3394 | EOF |
| 3395 | ' & |
| 3396 | sleep 1 |
| 3397 | echo Left overs: * |
| 3398 | expected-stdout: |
| 3399 | HI |
| 3400 | Left overs: * |
| 3401 | --- |
| 3402 | name: heredoc-tmpfile-7 |
| 3403 | description: |
| 3404 | Check that heredoc temp files aren't removed too soon or too late. |
| 3405 | Heredoc in backgrounded pipeline. |
| 3406 | stdin: |
| 3407 | TMPDIR=$PWD |
| 3408 | eval ' |
| 3409 | cat <<- EOF | sed 's/hi/HI/' & |
| 3410 | hi |
| 3411 | EOF |
| 3412 | ' & |
| 3413 | sleep 1 |
| 3414 | echo Left overs: * |
| 3415 | expected-stdout: |
| 3416 | HI |
| 3417 | Left overs: * |
| 3418 | --- |
| 3419 | name: heredoc-tmpfile-8 |
| 3420 | description: |
| 3421 | Check that heredoc temp files aren't removed too soon or too |
| 3422 | late. Heredoc in function, backgrounded call to function. |
| 3423 | This check can fail on slow machines (<100 MHz), or Cygwin, |
| 3424 | that's normal. |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 3425 | need-pass: no |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 3426 | stdin: |
| 3427 | TMPDIR=$PWD |
| 3428 | # Background eval so main shell doesn't do parsing |
| 3429 | eval ' |
| 3430 | foo() { |
| 3431 | cat <<- EOF |
| 3432 | hi |
| 3433 | EOF |
| 3434 | } |
| 3435 | foo |
| 3436 | # sleep so eval can die |
| 3437 | (sleep 1; foo) & |
| 3438 | (sleep 1; foo) & |
| 3439 | foo |
| 3440 | ' & |
Elliott Hughes | dd4abe0 | 2018-02-05 15:55:19 -0800 | [diff] [blame] | 3441 | sleep 5 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 3442 | echo Left overs: * |
| 3443 | expected-stdout: |
| 3444 | hi |
| 3445 | hi |
| 3446 | hi |
| 3447 | hi |
| 3448 | Left overs: * |
| 3449 | --- |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 3450 | name: heredoc-quoting-unsubst |
| 3451 | description: |
| 3452 | Check for correct handling of quoted characters in |
| 3453 | here documents without substitution (marker is quoted). |
| 3454 | stdin: |
| 3455 | foo=bar |
| 3456 | cat <<-'EOF' |
| 3457 | x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x |
| 3458 | EOF |
| 3459 | expected-stdout: |
| 3460 | x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x |
| 3461 | --- |
| 3462 | name: heredoc-quoting-subst |
| 3463 | description: |
| 3464 | Check for correct handling of quoted characters in |
| 3465 | here documents with substitution (marker is not quoted). |
| 3466 | stdin: |
| 3467 | foo=bar |
| 3468 | cat <<-EOF |
| 3469 | x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x |
| 3470 | EOF |
| 3471 | expected-stdout: |
| 3472 | x " \" \ \ $ $ baz `echo baz` bar $foo x |
| 3473 | --- |
| 3474 | name: single-quotes-in-braces |
| 3475 | description: |
| 3476 | Check that single quotes inside unquoted {} are treated as quotes |
| 3477 | stdin: |
| 3478 | foo=1 |
| 3479 | echo ${foo:+'blah $foo'} |
| 3480 | expected-stdout: |
| 3481 | blah $foo |
| 3482 | --- |
| 3483 | name: single-quotes-in-quoted-braces |
| 3484 | description: |
| 3485 | Check that single quotes inside quoted {} are treated as |
| 3486 | normal char |
| 3487 | stdin: |
| 3488 | foo=1 |
| 3489 | echo "${foo:+'blah $foo'}" |
| 3490 | expected-stdout: |
| 3491 | 'blah 1' |
| 3492 | --- |
| 3493 | name: single-quotes-in-braces-nested |
| 3494 | description: |
| 3495 | Check that single quotes inside unquoted {} are treated as quotes, |
| 3496 | even if that's inside a double-quoted command expansion |
| 3497 | stdin: |
| 3498 | foo=1 |
| 3499 | echo "$( echo ${foo:+'blah $foo'})" |
| 3500 | expected-stdout: |
| 3501 | blah $foo |
| 3502 | --- |
| 3503 | name: single-quotes-in-brace-pattern |
| 3504 | description: |
| 3505 | Check that single quotes inside {} pattern are treated as quotes |
| 3506 | stdin: |
| 3507 | foo=1234 |
| 3508 | echo ${foo%'2'*} "${foo%'2'*}" ${foo%2'*'} "${foo%2'*'}" |
| 3509 | expected-stdout: |
| 3510 | 1 1 1234 1234 |
| 3511 | --- |
| 3512 | name: single-quotes-in-heredoc-braces |
| 3513 | description: |
| 3514 | Check that single quotes inside {} in heredoc are treated |
| 3515 | as normal char |
| 3516 | stdin: |
| 3517 | foo=1 |
| 3518 | cat <<EOM |
| 3519 | ${foo:+'blah $foo'} |
| 3520 | EOM |
| 3521 | expected-stdout: |
| 3522 | 'blah 1' |
| 3523 | --- |
| 3524 | name: single-quotes-in-nested-braces |
| 3525 | description: |
| 3526 | Check that single quotes inside nested unquoted {} are |
| 3527 | treated as quotes |
| 3528 | stdin: |
| 3529 | foo=1 |
| 3530 | echo ${foo:+${foo:+'blah $foo'}} |
| 3531 | expected-stdout: |
| 3532 | blah $foo |
| 3533 | --- |
| 3534 | name: single-quotes-in-nested-quoted-braces |
| 3535 | description: |
| 3536 | Check that single quotes inside nested quoted {} are treated |
| 3537 | as normal char |
| 3538 | stdin: |
| 3539 | foo=1 |
| 3540 | echo "${foo:+${foo:+'blah $foo'}}" |
| 3541 | expected-stdout: |
| 3542 | 'blah 1' |
| 3543 | --- |
| 3544 | name: single-quotes-in-nested-braces-nested |
| 3545 | description: |
| 3546 | Check that single quotes inside nested unquoted {} are treated |
| 3547 | as quotes, even if that's inside a double-quoted command expansion |
| 3548 | stdin: |
| 3549 | foo=1 |
| 3550 | echo "$( echo ${foo:+${foo:+'blah $foo'}})" |
| 3551 | expected-stdout: |
| 3552 | blah $foo |
| 3553 | --- |
| 3554 | name: single-quotes-in-nested-brace-pattern |
| 3555 | description: |
| 3556 | Check that single quotes inside nested {} pattern are treated as quotes |
| 3557 | stdin: |
| 3558 | foo=1234 |
| 3559 | echo ${foo:+${foo%'2'*}} "${foo:+${foo%'2'*}}" ${foo:+${foo%2'*'}} "${foo:+${foo%2'*'}}" |
| 3560 | expected-stdout: |
| 3561 | 1 1 1234 1234 |
| 3562 | --- |
| 3563 | name: single-quotes-in-heredoc-nested-braces |
| 3564 | description: |
| 3565 | Check that single quotes inside nested {} in heredoc are treated |
| 3566 | as normal char |
| 3567 | stdin: |
| 3568 | foo=1 |
| 3569 | cat <<EOM |
| 3570 | ${foo:+${foo:+'blah $foo'}} |
| 3571 | EOM |
| 3572 | expected-stdout: |
| 3573 | 'blah 1' |
| 3574 | --- |
Elliott Hughes | 4708626 | 2019-03-26 12:34:31 -0700 | [diff] [blame] | 3575 | name: single-quotes-in-heredoc-trim |
| 3576 | description: |
| 3577 | In some cases, single quotes inside {} in heredoc are not normal |
| 3578 | stdin: |
| 3579 | x=notOK |
| 3580 | cat <<EOF |
| 3581 | 1: ${x#not} ${x:+${x#not}} |
| 3582 | 2: ${x#\n\o\t} ${x:+${x#\n\o\t}} |
| 3583 | 3: ${x#"not"} ${x:+${x#"not"}} |
| 3584 | 4: ${x#'not'} ${x:+${x#'not'}} |
| 3585 | 5: ${x#$'not'} ${x:+${x#$'not'}} |
| 3586 | EOF |
| 3587 | expected-stdout: |
| 3588 | 1: OK OK |
| 3589 | 2: OK OK |
| 3590 | 3: OK OK |
| 3591 | 4: OK OK |
| 3592 | 5: OK OK |
| 3593 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 3594 | name: history-basic |
| 3595 | description: |
| 3596 | See if we can test history at all |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 3597 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 3598 | arguments: !-i! |
| 3599 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 3600 | file-setup: file 644 "Env" |
| 3601 | PS1=X |
| 3602 | stdin: |
| 3603 | echo hi |
| 3604 | fc -l |
| 3605 | expected-stdout: |
| 3606 | hi |
| 3607 | 1 echo hi |
| 3608 | expected-stderr-pattern: |
| 3609 | /^X*$/ |
| 3610 | --- |
| 3611 | name: history-dups |
| 3612 | description: |
| 3613 | Verify duplicates and spaces are not entered |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 3614 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 3615 | arguments: !-i! |
| 3616 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 3617 | file-setup: file 644 "Env" |
| 3618 | PS1=X |
| 3619 | stdin: |
| 3620 | echo hi |
| 3621 | echo yo |
| 3622 | echo hi |
| 3623 | fc -l |
| 3624 | expected-stdout: |
| 3625 | hi |
| 3626 | yo |
| 3627 | hi |
| 3628 | 1 echo hi |
| 3629 | expected-stderr-pattern: |
| 3630 | /^X*$/ |
| 3631 | --- |
| 3632 | name: history-unlink |
| 3633 | description: |
| 3634 | Check if broken HISTFILEs do not cause trouble |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 3635 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 3636 | arguments: !-i! |
| 3637 | env-setup: !ENV=./Env!HISTFILE=foo/hist.file! |
| 3638 | file-setup: file 644 "Env" |
| 3639 | PS1=X |
| 3640 | file-setup: dir 755 "foo" |
| 3641 | file-setup: file 644 "foo/hist.file" |
| 3642 | sometext |
| 3643 | time-limit: 5 |
| 3644 | perl-setup: chmod(0555, "foo"); |
| 3645 | stdin: |
| 3646 | echo hi |
| 3647 | fc -l |
| 3648 | chmod 0755 foo |
| 3649 | expected-stdout: |
| 3650 | hi |
| 3651 | 1 echo hi |
| 3652 | expected-stderr-pattern: |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 3653 | /(.*can't unlink HISTFILE.*\n)?X*$/ |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 3654 | --- |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 3655 | name: history-multiline |
| 3656 | description: |
| 3657 | Check correct multiline history, Debian #783978 |
| 3658 | need-ctty: yes |
| 3659 | arguments: !-i! |
| 3660 | env-setup: !ENV=./Env! |
| 3661 | file-setup: file 644 "Env" |
| 3662 | PS1=X |
| 3663 | PS2=Y |
| 3664 | stdin: |
| 3665 | for i in A B C |
| 3666 | do |
| 3667 | print $i |
| 3668 | print $i |
| 3669 | done |
| 3670 | fc -l |
| 3671 | expected-stdout: |
| 3672 | A |
| 3673 | A |
| 3674 | B |
| 3675 | B |
| 3676 | C |
| 3677 | C |
| 3678 | 1 for i in A B C |
| 3679 | do |
| 3680 | print $i |
| 3681 | print $i |
| 3682 | done |
| 3683 | expected-stderr-pattern: |
| 3684 | /^XYYYYXX$/ |
| 3685 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 3686 | name: history-e-minus-1 |
| 3687 | description: |
| 3688 | Check if more recent command is executed |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 3689 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 3690 | arguments: !-i! |
| 3691 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 3692 | file-setup: file 644 "Env" |
| 3693 | PS1=X |
| 3694 | stdin: |
| 3695 | echo hi |
| 3696 | echo there |
| 3697 | fc -e - |
| 3698 | expected-stdout: |
| 3699 | hi |
| 3700 | there |
| 3701 | there |
| 3702 | expected-stderr-pattern: |
| 3703 | /^X*echo there\nX*$/ |
| 3704 | --- |
| 3705 | name: history-e-minus-2 |
| 3706 | description: |
| 3707 | Check that repeated command is printed before command |
| 3708 | is re-executed. |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 3709 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 3710 | arguments: !-i! |
| 3711 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 3712 | file-setup: file 644 "Env" |
| 3713 | PS1=X |
| 3714 | stdin: |
| 3715 | exec 2>&1 |
| 3716 | echo hi |
| 3717 | echo there |
| 3718 | fc -e - |
| 3719 | expected-stdout-pattern: |
| 3720 | /X*hi\nX*there\nX*echo there\nthere\nX*/ |
| 3721 | expected-stderr-pattern: |
| 3722 | /^X*$/ |
| 3723 | --- |
| 3724 | name: history-e-minus-3 |
| 3725 | description: |
| 3726 | fc -e - fails when there is no history |
| 3727 | (ksh93 has a bug that causes this to fail) |
| 3728 | (ksh88 loops on this) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 3729 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 3730 | arguments: !-i! |
| 3731 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 3732 | file-setup: file 644 "Env" |
| 3733 | PS1=X |
| 3734 | stdin: |
| 3735 | fc -e - |
| 3736 | echo ok |
| 3737 | expected-stdout: |
| 3738 | ok |
| 3739 | expected-stderr-pattern: |
| 3740 | /^X*.*:.*history.*\nX*$/ |
| 3741 | --- |
| 3742 | name: history-e-minus-4 |
| 3743 | description: |
| 3744 | Check if "fc -e -" command output goes to stdout. |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 3745 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 3746 | arguments: !-i! |
| 3747 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 3748 | file-setup: file 644 "Env" |
| 3749 | PS1=X |
| 3750 | stdin: |
| 3751 | echo abc |
| 3752 | fc -e - | (read x; echo "A $x") |
| 3753 | echo ok |
| 3754 | expected-stdout: |
| 3755 | abc |
| 3756 | A abc |
| 3757 | ok |
| 3758 | expected-stderr-pattern: |
| 3759 | /^X*echo abc\nX*/ |
| 3760 | --- |
| 3761 | name: history-e-minus-5 |
| 3762 | description: |
| 3763 | fc is replaced in history by new command. |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 3764 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 3765 | arguments: !-i! |
| 3766 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 3767 | file-setup: file 644 "Env" |
| 3768 | PS1=X |
| 3769 | stdin: |
| 3770 | echo abc def |
| 3771 | echo ghi jkl |
| 3772 | : |
| 3773 | fc -e - echo |
| 3774 | fc -l 2 5 |
| 3775 | expected-stdout: |
| 3776 | abc def |
| 3777 | ghi jkl |
| 3778 | ghi jkl |
| 3779 | 2 echo ghi jkl |
| 3780 | 3 : |
| 3781 | 4 echo ghi jkl |
| 3782 | 5 fc -l 2 5 |
| 3783 | expected-stderr-pattern: |
| 3784 | /^X*echo ghi jkl\nX*$/ |
| 3785 | --- |
| 3786 | name: history-list-1 |
| 3787 | description: |
| 3788 | List lists correct range |
| 3789 | (ksh88 fails 'cause it lists the fc command) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 3790 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 3791 | arguments: !-i! |
| 3792 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 3793 | file-setup: file 644 "Env" |
| 3794 | PS1=X |
| 3795 | stdin: |
| 3796 | echo line 1 |
| 3797 | echo line 2 |
| 3798 | echo line 3 |
| 3799 | fc -l -- -2 |
| 3800 | expected-stdout: |
| 3801 | line 1 |
| 3802 | line 2 |
| 3803 | line 3 |
| 3804 | 2 echo line 2 |
| 3805 | 3 echo line 3 |
| 3806 | expected-stderr-pattern: |
| 3807 | /^X*$/ |
| 3808 | --- |
| 3809 | name: history-list-2 |
| 3810 | description: |
| 3811 | Lists oldest history if given pre-historic number |
| 3812 | (ksh93 has a bug that causes this to fail) |
| 3813 | (ksh88 fails 'cause it lists the fc command) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 3814 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 3815 | arguments: !-i! |
| 3816 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 3817 | file-setup: file 644 "Env" |
| 3818 | PS1=X |
| 3819 | stdin: |
| 3820 | echo line 1 |
| 3821 | echo line 2 |
| 3822 | echo line 3 |
| 3823 | fc -l -- -40 |
| 3824 | expected-stdout: |
| 3825 | line 1 |
| 3826 | line 2 |
| 3827 | line 3 |
| 3828 | 1 echo line 1 |
| 3829 | 2 echo line 2 |
| 3830 | 3 echo line 3 |
| 3831 | expected-stderr-pattern: |
| 3832 | /^X*$/ |
| 3833 | --- |
| 3834 | name: history-list-3 |
| 3835 | description: |
| 3836 | Can give number 'options' to fc |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 3837 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 3838 | arguments: !-i! |
| 3839 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 3840 | file-setup: file 644 "Env" |
| 3841 | PS1=X |
| 3842 | stdin: |
| 3843 | echo line 1 |
| 3844 | echo line 2 |
| 3845 | echo line 3 |
| 3846 | echo line 4 |
| 3847 | fc -l -3 -2 |
| 3848 | expected-stdout: |
| 3849 | line 1 |
| 3850 | line 2 |
| 3851 | line 3 |
| 3852 | line 4 |
| 3853 | 2 echo line 2 |
| 3854 | 3 echo line 3 |
| 3855 | expected-stderr-pattern: |
| 3856 | /^X*$/ |
| 3857 | --- |
| 3858 | name: history-list-4 |
| 3859 | description: |
| 3860 | -1 refers to previous command |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 3861 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 3862 | arguments: !-i! |
| 3863 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 3864 | file-setup: file 644 "Env" |
| 3865 | PS1=X |
| 3866 | stdin: |
| 3867 | echo line 1 |
| 3868 | echo line 2 |
| 3869 | echo line 3 |
| 3870 | echo line 4 |
| 3871 | fc -l -1 -1 |
| 3872 | expected-stdout: |
| 3873 | line 1 |
| 3874 | line 2 |
| 3875 | line 3 |
| 3876 | line 4 |
| 3877 | 4 echo line 4 |
| 3878 | expected-stderr-pattern: |
| 3879 | /^X*$/ |
| 3880 | --- |
| 3881 | name: history-list-5 |
| 3882 | description: |
| 3883 | List command stays in history |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 3884 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 3885 | arguments: !-i! |
| 3886 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 3887 | file-setup: file 644 "Env" |
| 3888 | PS1=X |
| 3889 | stdin: |
| 3890 | echo line 1 |
| 3891 | echo line 2 |
| 3892 | echo line 3 |
| 3893 | echo line 4 |
| 3894 | fc -l -1 -1 |
| 3895 | fc -l -2 -1 |
| 3896 | expected-stdout: |
| 3897 | line 1 |
| 3898 | line 2 |
| 3899 | line 3 |
| 3900 | line 4 |
| 3901 | 4 echo line 4 |
| 3902 | 4 echo line 4 |
| 3903 | 5 fc -l -1 -1 |
| 3904 | expected-stderr-pattern: |
| 3905 | /^X*$/ |
| 3906 | --- |
| 3907 | name: history-list-6 |
| 3908 | description: |
| 3909 | HISTSIZE limits about of history kept. |
| 3910 | (ksh88 fails 'cause it lists the fc command) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 3911 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 3912 | arguments: !-i! |
| 3913 | env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3! |
| 3914 | file-setup: file 644 "Env" |
| 3915 | PS1=X |
| 3916 | stdin: |
| 3917 | echo line 1 |
| 3918 | echo line 2 |
| 3919 | echo line 3 |
| 3920 | echo line 4 |
| 3921 | echo line 5 |
| 3922 | fc -l |
| 3923 | expected-stdout: |
| 3924 | line 1 |
| 3925 | line 2 |
| 3926 | line 3 |
| 3927 | line 4 |
| 3928 | line 5 |
| 3929 | 4 echo line 4 |
| 3930 | 5 echo line 5 |
| 3931 | expected-stderr-pattern: |
| 3932 | /^X*$/ |
| 3933 | --- |
| 3934 | name: history-list-7 |
| 3935 | description: |
| 3936 | fc allows too old/new errors in range specification |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 3937 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 3938 | arguments: !-i! |
| 3939 | env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3! |
| 3940 | file-setup: file 644 "Env" |
| 3941 | PS1=X |
| 3942 | stdin: |
| 3943 | echo line 1 |
| 3944 | echo line 2 |
| 3945 | echo line 3 |
| 3946 | echo line 4 |
| 3947 | echo line 5 |
| 3948 | fc -l 1 30 |
| 3949 | expected-stdout: |
| 3950 | line 1 |
| 3951 | line 2 |
| 3952 | line 3 |
| 3953 | line 4 |
| 3954 | line 5 |
| 3955 | 4 echo line 4 |
| 3956 | 5 echo line 5 |
| 3957 | 6 fc -l 1 30 |
| 3958 | expected-stderr-pattern: |
| 3959 | /^X*$/ |
| 3960 | --- |
| 3961 | name: history-list-r-1 |
| 3962 | description: |
| 3963 | test -r flag in history |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 3964 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 3965 | arguments: !-i! |
| 3966 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 3967 | file-setup: file 644 "Env" |
| 3968 | PS1=X |
| 3969 | stdin: |
| 3970 | echo line 1 |
| 3971 | echo line 2 |
| 3972 | echo line 3 |
| 3973 | echo line 4 |
| 3974 | echo line 5 |
| 3975 | fc -l -r 2 4 |
| 3976 | expected-stdout: |
| 3977 | line 1 |
| 3978 | line 2 |
| 3979 | line 3 |
| 3980 | line 4 |
| 3981 | line 5 |
| 3982 | 4 echo line 4 |
| 3983 | 3 echo line 3 |
| 3984 | 2 echo line 2 |
| 3985 | expected-stderr-pattern: |
| 3986 | /^X*$/ |
| 3987 | --- |
| 3988 | name: history-list-r-2 |
| 3989 | description: |
| 3990 | If first is newer than last, -r is implied. |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 3991 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 3992 | arguments: !-i! |
| 3993 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 3994 | file-setup: file 644 "Env" |
| 3995 | PS1=X |
| 3996 | stdin: |
| 3997 | echo line 1 |
| 3998 | echo line 2 |
| 3999 | echo line 3 |
| 4000 | echo line 4 |
| 4001 | echo line 5 |
| 4002 | fc -l 4 2 |
| 4003 | expected-stdout: |
| 4004 | line 1 |
| 4005 | line 2 |
| 4006 | line 3 |
| 4007 | line 4 |
| 4008 | line 5 |
| 4009 | 4 echo line 4 |
| 4010 | 3 echo line 3 |
| 4011 | 2 echo line 2 |
| 4012 | expected-stderr-pattern: |
| 4013 | /^X*$/ |
| 4014 | --- |
| 4015 | name: history-list-r-3 |
| 4016 | description: |
| 4017 | If first is newer than last, -r is cancelled. |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 4018 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4019 | arguments: !-i! |
| 4020 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 4021 | file-setup: file 644 "Env" |
| 4022 | PS1=X |
| 4023 | stdin: |
| 4024 | echo line 1 |
| 4025 | echo line 2 |
| 4026 | echo line 3 |
| 4027 | echo line 4 |
| 4028 | echo line 5 |
| 4029 | fc -l -r 4 2 |
| 4030 | expected-stdout: |
| 4031 | line 1 |
| 4032 | line 2 |
| 4033 | line 3 |
| 4034 | line 4 |
| 4035 | line 5 |
| 4036 | 2 echo line 2 |
| 4037 | 3 echo line 3 |
| 4038 | 4 echo line 4 |
| 4039 | expected-stderr-pattern: |
| 4040 | /^X*$/ |
| 4041 | --- |
| 4042 | name: history-subst-1 |
| 4043 | description: |
| 4044 | Basic substitution |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 4045 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4046 | arguments: !-i! |
| 4047 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 4048 | file-setup: file 644 "Env" |
| 4049 | PS1=X |
| 4050 | stdin: |
| 4051 | echo abc def |
| 4052 | echo ghi jkl |
| 4053 | fc -e - abc=AB 'echo a' |
| 4054 | expected-stdout: |
| 4055 | abc def |
| 4056 | ghi jkl |
| 4057 | AB def |
| 4058 | expected-stderr-pattern: |
| 4059 | /^X*echo AB def\nX*$/ |
| 4060 | --- |
| 4061 | name: history-subst-2 |
| 4062 | description: |
| 4063 | Does subst find previous command? |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 4064 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4065 | arguments: !-i! |
| 4066 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 4067 | file-setup: file 644 "Env" |
| 4068 | PS1=X |
| 4069 | stdin: |
| 4070 | echo abc def |
| 4071 | echo ghi jkl |
| 4072 | fc -e - jkl=XYZQRT 'echo g' |
| 4073 | expected-stdout: |
| 4074 | abc def |
| 4075 | ghi jkl |
| 4076 | ghi XYZQRT |
| 4077 | expected-stderr-pattern: |
| 4078 | /^X*echo ghi XYZQRT\nX*$/ |
| 4079 | --- |
| 4080 | name: history-subst-3 |
| 4081 | description: |
| 4082 | Does subst find previous command when no arguments given |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 4083 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4084 | arguments: !-i! |
| 4085 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 4086 | file-setup: file 644 "Env" |
| 4087 | PS1=X |
| 4088 | stdin: |
| 4089 | echo abc def |
| 4090 | echo ghi jkl |
| 4091 | fc -e - jkl=XYZQRT |
| 4092 | expected-stdout: |
| 4093 | abc def |
| 4094 | ghi jkl |
| 4095 | ghi XYZQRT |
| 4096 | expected-stderr-pattern: |
| 4097 | /^X*echo ghi XYZQRT\nX*$/ |
| 4098 | --- |
| 4099 | name: history-subst-4 |
| 4100 | description: |
| 4101 | Global substitutions work |
| 4102 | (ksh88 and ksh93 do not have -g option) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 4103 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4104 | arguments: !-i! |
| 4105 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 4106 | file-setup: file 644 "Env" |
| 4107 | PS1=X |
| 4108 | stdin: |
| 4109 | echo abc def asjj sadjhasdjh asdjhasd |
| 4110 | fc -e - -g a=FooBAR |
| 4111 | expected-stdout: |
| 4112 | abc def asjj sadjhasdjh asdjhasd |
| 4113 | FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd |
| 4114 | expected-stderr-pattern: |
| 4115 | /^X*echo FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd\nX*$/ |
| 4116 | --- |
| 4117 | name: history-subst-5 |
| 4118 | description: |
| 4119 | Make sure searches don't find current (fc) command |
| 4120 | (ksh88/ksh93 don't have the ? prefix thing so they fail this test) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 4121 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4122 | arguments: !-i! |
| 4123 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 4124 | file-setup: file 644 "Env" |
| 4125 | PS1=X |
| 4126 | stdin: |
| 4127 | echo abc def |
| 4128 | echo ghi jkl |
| 4129 | fc -e - abc=AB \?abc |
| 4130 | expected-stdout: |
| 4131 | abc def |
| 4132 | ghi jkl |
| 4133 | AB def |
| 4134 | expected-stderr-pattern: |
| 4135 | /^X*echo AB def\nX*$/ |
| 4136 | --- |
| 4137 | name: history-ed-1-old |
| 4138 | description: |
| 4139 | Basic (ed) editing works (assumes you have generic ed editor |
| 4140 | that prints no prompts). This is for oldish ed(1) which write |
| 4141 | the character count to stdout. |
| 4142 | category: stdout-ed |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 4143 | need-ctty: yes |
| 4144 | need-pass: no |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4145 | arguments: !-i! |
| 4146 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 4147 | file-setup: file 644 "Env" |
| 4148 | PS1=X |
| 4149 | stdin: |
| 4150 | echo abc def |
| 4151 | fc echo |
| 4152 | s/abc/FOOBAR/ |
| 4153 | w |
| 4154 | q |
| 4155 | expected-stdout: |
| 4156 | abc def |
| 4157 | 13 |
| 4158 | 16 |
| 4159 | FOOBAR def |
| 4160 | expected-stderr-pattern: |
| 4161 | /^X*echo FOOBAR def\nX*$/ |
| 4162 | --- |
| 4163 | name: history-ed-2-old |
| 4164 | description: |
| 4165 | Correct command is edited when number given |
| 4166 | category: stdout-ed |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 4167 | need-ctty: yes |
| 4168 | need-pass: no |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4169 | arguments: !-i! |
| 4170 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 4171 | file-setup: file 644 "Env" |
| 4172 | PS1=X |
| 4173 | stdin: |
| 4174 | echo line 1 |
| 4175 | echo line 2 is here |
| 4176 | echo line 3 |
| 4177 | echo line 4 |
| 4178 | fc 2 |
| 4179 | s/is here/is changed/ |
| 4180 | w |
| 4181 | q |
| 4182 | expected-stdout: |
| 4183 | line 1 |
| 4184 | line 2 is here |
| 4185 | line 3 |
| 4186 | line 4 |
| 4187 | 20 |
| 4188 | 23 |
| 4189 | line 2 is changed |
| 4190 | expected-stderr-pattern: |
| 4191 | /^X*echo line 2 is changed\nX*$/ |
| 4192 | --- |
| 4193 | name: history-ed-3-old |
| 4194 | description: |
| 4195 | Newly created multi line commands show up as single command |
| 4196 | in history. |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4197 | (ksh88 fails 'cause it lists the fc command) |
| 4198 | category: stdout-ed |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 4199 | need-ctty: yes |
| 4200 | need-pass: no |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4201 | arguments: !-i! |
| 4202 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 4203 | file-setup: file 644 "Env" |
| 4204 | PS1=X |
| 4205 | stdin: |
| 4206 | echo abc def |
| 4207 | fc echo |
| 4208 | s/abc/FOOBAR/ |
| 4209 | $a |
| 4210 | echo a new line |
| 4211 | . |
| 4212 | w |
| 4213 | q |
| 4214 | fc -l |
| 4215 | expected-stdout: |
| 4216 | abc def |
| 4217 | 13 |
| 4218 | 32 |
| 4219 | FOOBAR def |
| 4220 | a new line |
| 4221 | 1 echo abc def |
| 4222 | 2 echo FOOBAR def |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 4223 | echo a new line |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4224 | expected-stderr-pattern: |
| 4225 | /^X*echo FOOBAR def\necho a new line\nX*$/ |
| 4226 | --- |
| 4227 | name: history-ed-1 |
| 4228 | description: |
| 4229 | Basic (ed) editing works (assumes you have generic ed editor |
| 4230 | that prints no prompts). This is for newish ed(1) and stderr. |
| 4231 | category: !no-stderr-ed |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 4232 | need-ctty: yes |
| 4233 | need-pass: no |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4234 | arguments: !-i! |
| 4235 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 4236 | file-setup: file 644 "Env" |
| 4237 | PS1=X |
| 4238 | stdin: |
| 4239 | echo abc def |
| 4240 | fc echo |
| 4241 | s/abc/FOOBAR/ |
| 4242 | w |
| 4243 | q |
| 4244 | expected-stdout: |
| 4245 | abc def |
| 4246 | FOOBAR def |
| 4247 | expected-stderr-pattern: |
| 4248 | /^X*13\n16\necho FOOBAR def\nX*$/ |
| 4249 | --- |
| 4250 | name: history-ed-2 |
| 4251 | description: |
| 4252 | Correct command is edited when number given |
| 4253 | category: !no-stderr-ed |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 4254 | need-ctty: yes |
| 4255 | need-pass: no |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4256 | arguments: !-i! |
| 4257 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 4258 | file-setup: file 644 "Env" |
| 4259 | PS1=X |
| 4260 | stdin: |
| 4261 | echo line 1 |
| 4262 | echo line 2 is here |
| 4263 | echo line 3 |
| 4264 | echo line 4 |
| 4265 | fc 2 |
| 4266 | s/is here/is changed/ |
| 4267 | w |
| 4268 | q |
| 4269 | expected-stdout: |
| 4270 | line 1 |
| 4271 | line 2 is here |
| 4272 | line 3 |
| 4273 | line 4 |
| 4274 | line 2 is changed |
| 4275 | expected-stderr-pattern: |
| 4276 | /^X*20\n23\necho line 2 is changed\nX*$/ |
| 4277 | --- |
| 4278 | name: history-ed-3 |
| 4279 | description: |
| 4280 | Newly created multi line commands show up as single command |
| 4281 | in history. |
| 4282 | category: !no-stderr-ed |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 4283 | need-ctty: yes |
| 4284 | need-pass: no |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4285 | arguments: !-i! |
| 4286 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 4287 | file-setup: file 644 "Env" |
| 4288 | PS1=X |
| 4289 | stdin: |
| 4290 | echo abc def |
| 4291 | fc echo |
| 4292 | s/abc/FOOBAR/ |
| 4293 | $a |
| 4294 | echo a new line |
| 4295 | . |
| 4296 | w |
| 4297 | q |
| 4298 | fc -l |
| 4299 | expected-stdout: |
| 4300 | abc def |
| 4301 | FOOBAR def |
| 4302 | a new line |
| 4303 | 1 echo abc def |
| 4304 | 2 echo FOOBAR def |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 4305 | echo a new line |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4306 | expected-stderr-pattern: |
| 4307 | /^X*13\n32\necho FOOBAR def\necho a new line\nX*$/ |
| 4308 | --- |
| 4309 | name: IFS-space-1 |
| 4310 | description: |
| 4311 | Simple test, default IFS |
| 4312 | stdin: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4313 | showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4314 | set -- A B C |
| 4315 | showargs 1 $* |
| 4316 | showargs 2 "$*" |
| 4317 | showargs 3 $@ |
| 4318 | showargs 4 "$@" |
| 4319 | expected-stdout: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4320 | <1> <A> <B> <C> . |
| 4321 | <2> <A B C> . |
| 4322 | <3> <A> <B> <C> . |
| 4323 | <4> <A> <B> <C> . |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4324 | --- |
| 4325 | name: IFS-colon-1 |
| 4326 | description: |
| 4327 | Simple test, IFS=: |
| 4328 | stdin: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4329 | showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4330 | IFS=: |
| 4331 | set -- A B C |
| 4332 | showargs 1 $* |
| 4333 | showargs 2 "$*" |
| 4334 | showargs 3 $@ |
| 4335 | showargs 4 "$@" |
| 4336 | expected-stdout: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4337 | <1> <A> <B> <C> . |
| 4338 | <2> <A:B:C> . |
| 4339 | <3> <A> <B> <C> . |
| 4340 | <4> <A> <B> <C> . |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4341 | --- |
| 4342 | name: IFS-null-1 |
| 4343 | description: |
| 4344 | Simple test, IFS="" |
| 4345 | stdin: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4346 | showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4347 | IFS="" |
| 4348 | set -- A B C |
| 4349 | showargs 1 $* |
| 4350 | showargs 2 "$*" |
| 4351 | showargs 3 $@ |
| 4352 | showargs 4 "$@" |
| 4353 | expected-stdout: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4354 | <1> <A> <B> <C> . |
| 4355 | <2> <ABC> . |
| 4356 | <3> <A> <B> <C> . |
| 4357 | <4> <A> <B> <C> . |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4358 | --- |
| 4359 | name: IFS-space-colon-1 |
| 4360 | description: |
| 4361 | Simple test, IFS=<white-space>: |
| 4362 | stdin: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4363 | showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4364 | IFS="$IFS:" |
| 4365 | set -- |
| 4366 | showargs 1 $* |
| 4367 | showargs 2 "$*" |
| 4368 | showargs 3 $@ |
| 4369 | showargs 4 "$@" |
| 4370 | showargs 5 : "$@" |
| 4371 | expected-stdout: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4372 | <1> . |
| 4373 | <2> <> . |
| 4374 | <3> . |
| 4375 | <4> . |
| 4376 | <5> <:> . |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4377 | --- |
| 4378 | name: IFS-space-colon-2 |
| 4379 | description: |
| 4380 | Simple test, IFS=<white-space>: |
| 4381 | AT&T ksh fails this, POSIX says the test is correct. |
| 4382 | stdin: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4383 | showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4384 | IFS="$IFS:" |
| 4385 | set -- |
| 4386 | showargs :"$@" |
| 4387 | expected-stdout: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4388 | <:> . |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4389 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4390 | name: IFS-space-colon-4 |
| 4391 | description: |
| 4392 | Simple test, IFS=<white-space>: |
| 4393 | stdin: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4394 | showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4395 | IFS="$IFS:" |
| 4396 | set -- |
| 4397 | showargs "$@$@" |
| 4398 | expected-stdout: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4399 | . |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4400 | --- |
| 4401 | name: IFS-space-colon-5 |
| 4402 | description: |
| 4403 | Simple test, IFS=<white-space>: |
| 4404 | Don't know what POSIX thinks of this. AT&T ksh does not do this. |
| 4405 | stdin: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4406 | showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4407 | IFS="$IFS:" |
| 4408 | set -- |
| 4409 | showargs "${@:-}" |
| 4410 | expected-stdout: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4411 | <> . |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4412 | --- |
| 4413 | name: IFS-subst-1 |
| 4414 | description: |
| 4415 | Simple test, IFS=<white-space>: |
| 4416 | stdin: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4417 | showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4418 | IFS="$IFS:" |
| 4419 | x=":b: :" |
| 4420 | echo -n '1:'; for i in $x ; do echo -n " [$i]" ; done ; echo |
| 4421 | echo -n '2:'; for i in :b:: ; do echo -n " [$i]" ; done ; echo |
| 4422 | showargs 3 $x |
| 4423 | showargs 4 :b:: |
| 4424 | x="a:b:" |
| 4425 | echo -n '5:'; for i in $x ; do echo -n " [$i]" ; done ; echo |
| 4426 | showargs 6 $x |
| 4427 | x="a::c" |
| 4428 | echo -n '7:'; for i in $x ; do echo -n " [$i]" ; done ; echo |
| 4429 | showargs 8 $x |
| 4430 | echo -n '9:'; for i in ${FOO-`echo -n h:i`th:ere} ; do echo -n " [$i]" ; done ; echo |
| 4431 | showargs 10 ${FOO-`echo -n h:i`th:ere} |
| 4432 | showargs 11 "${FOO-`echo -n h:i`th:ere}" |
| 4433 | x=" A : B::D" |
| 4434 | echo -n '12:'; for i in $x ; do echo -n " [$i]" ; done ; echo |
| 4435 | showargs 13 $x |
| 4436 | expected-stdout: |
| 4437 | 1: [] [b] [] |
| 4438 | 2: [:b::] |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4439 | <3> <> <b> <> . |
| 4440 | <4> <:b::> . |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4441 | 5: [a] [b] |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4442 | <6> <a> <b> . |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4443 | 7: [a] [] [c] |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4444 | <8> <a> <> <c> . |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4445 | 9: [h] [ith] [ere] |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4446 | <10> <h> <ith> <ere> . |
| 4447 | <11> <h:ith:ere> . |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4448 | 12: [A] [B] [] [D] |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4449 | <13> <A> <B> <> <D> . |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4450 | --- |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 4451 | name: IFS-subst-2 |
| 4452 | description: |
| 4453 | Check leading whitespace after trim does not make a field |
| 4454 | stdin: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4455 | showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 4456 | x="X 1 2" |
| 4457 | showargs 1 shift ${x#X} |
| 4458 | expected-stdout: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4459 | <1> <shift> <1> <2> . |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 4460 | --- |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4461 | name: IFS-subst-3-arr |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4462 | description: |
| 4463 | Check leading IFS non-whitespace after trim does make a field |
Elliott Hughes | f7f7956 | 2014-10-07 15:04:14 -0700 | [diff] [blame] | 4464 | but leading IFS whitespace does not, nor empty replacements |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4465 | stdin: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4466 | showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } |
Elliott Hughes | f7f7956 | 2014-10-07 15:04:14 -0700 | [diff] [blame] | 4467 | showargs 0 ${-+} |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4468 | IFS=: |
| 4469 | showargs 1 ${-+:foo:bar} |
Elliott Hughes | f7f7956 | 2014-10-07 15:04:14 -0700 | [diff] [blame] | 4470 | IFS=' ' |
| 4471 | showargs 2 ${-+ foo bar} |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4472 | expected-stdout: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4473 | <0> . |
| 4474 | <1> <> <foo> <bar> . |
| 4475 | <2> <foo> <bar> . |
| 4476 | --- |
| 4477 | name: IFS-subst-3-ass |
| 4478 | description: |
| 4479 | Check non-field semantics |
| 4480 | stdin: |
| 4481 | showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } |
| 4482 | showargs 0 x=${-+} |
| 4483 | IFS=: |
| 4484 | showargs 1 x=${-+:foo:bar} |
| 4485 | IFS=' ' |
| 4486 | showargs 2 x=${-+ foo bar} |
| 4487 | expected-stdout: |
| 4488 | <0> <x=> . |
| 4489 | <1> <x=> <foo> <bar> . |
| 4490 | <2> <x=> <foo> <bar> . |
| 4491 | --- |
| 4492 | name: IFS-subst-3-lcl |
| 4493 | description: |
| 4494 | Check non-field semantics, smaller corner case (LP#1381965) |
| 4495 | stdin: |
| 4496 | set -x |
| 4497 | local regex=${2:-} |
| 4498 | exit 1 |
| 4499 | expected-exit: e != 0 |
| 4500 | expected-stderr-pattern: |
| 4501 | /regex=/ |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4502 | --- |
| 4503 | name: IFS-subst-4-1 |
| 4504 | description: |
| 4505 | reported by mikeserv |
| 4506 | stdin: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4507 | pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; } |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4508 | a='space divded argument |
| 4509 | here' |
| 4510 | IFS=\ ; set -- $a |
| 4511 | IFS= ; q="$*" ; nq=$* |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4512 | pfn "$*" $* "$q" "$nq" |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4513 | [ "$q" = "$nq" ] && echo =true || echo =false |
| 4514 | expected-stdout: |
| 4515 | <spacedivdedargument |
| 4516 | here> |
| 4517 | <space> |
| 4518 | <divded> |
| 4519 | <argument |
| 4520 | here> |
| 4521 | <spacedivdedargument |
| 4522 | here> |
| 4523 | <spacedivdedargument |
| 4524 | here> |
| 4525 | =true |
| 4526 | --- |
| 4527 | name: IFS-subst-4-2 |
| 4528 | description: |
| 4529 | extended testsuite based on problem by mikeserv |
| 4530 | stdin: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4531 | pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; } |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4532 | a='space divded argument |
| 4533 | here' |
| 4534 | IFS=\ ; set -- $a |
| 4535 | IFS= ; q="$@" ; nq=$@ |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4536 | pfn "$*" $* "$q" "$nq" |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4537 | [ "$q" = "$nq" ] && echo =true || echo =false |
| 4538 | expected-stdout: |
| 4539 | <spacedivdedargument |
| 4540 | here> |
| 4541 | <space> |
| 4542 | <divded> |
| 4543 | <argument |
| 4544 | here> |
| 4545 | <space divded argument |
| 4546 | here> |
| 4547 | <space divded argument |
| 4548 | here> |
| 4549 | =true |
| 4550 | --- |
| 4551 | name: IFS-subst-4-3 |
| 4552 | description: |
| 4553 | extended testsuite based on problem by mikeserv |
| 4554 | stdin: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4555 | pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; } |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4556 | a='space divded argument |
| 4557 | here' |
| 4558 | IFS=\ ; set -- $a; IFS= |
| 4559 | qs="$*" |
| 4560 | nqs=$* |
| 4561 | qk="$@" |
| 4562 | nqk=$@ |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4563 | print -nr -- '= qs '; pfn "$qs" |
| 4564 | print -nr -- '=nqs '; pfn "$nqs" |
| 4565 | print -nr -- '= qk '; pfn "$qk" |
| 4566 | print -nr -- '=nqk '; pfn "$nqk" |
| 4567 | print -nr -- '~ qs '; pfn "$*" |
| 4568 | print -nr -- '~nqs '; pfn $* |
| 4569 | print -nr -- '~ qk '; pfn "$@" |
| 4570 | print -nr -- '~nqk '; pfn $@ |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4571 | expected-stdout: |
| 4572 | = qs <spacedivdedargument |
| 4573 | here> |
| 4574 | =nqs <spacedivdedargument |
| 4575 | here> |
| 4576 | = qk <space divded argument |
| 4577 | here> |
| 4578 | =nqk <space divded argument |
| 4579 | here> |
| 4580 | ~ qs <spacedivdedargument |
| 4581 | here> |
| 4582 | ~nqs <space> |
| 4583 | <divded> |
| 4584 | <argument |
| 4585 | here> |
| 4586 | ~ qk <space> |
| 4587 | <divded> |
| 4588 | <argument |
| 4589 | here> |
| 4590 | ~nqk <space> |
| 4591 | <divded> |
| 4592 | <argument |
| 4593 | here> |
| 4594 | --- |
| 4595 | name: IFS-subst-4-4 |
| 4596 | description: |
| 4597 | extended testsuite based on problem by mikeserv |
| 4598 | stdin: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4599 | pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; } |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4600 | a='space divded argument |
| 4601 | here' |
| 4602 | IFS=\ ; set -- $a; IFS= |
| 4603 | qs="$*" |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4604 | print -nr -- '= qs '; pfn "$qs" |
| 4605 | print -nr -- '~ qs '; pfn "$*" |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4606 | nqs=$* |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4607 | print -nr -- '=nqs '; pfn "$nqs" |
| 4608 | print -nr -- '~nqs '; pfn $* |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4609 | qk="$@" |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4610 | print -nr -- '= qk '; pfn "$qk" |
| 4611 | print -nr -- '~ qk '; pfn "$@" |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4612 | nqk=$@ |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4613 | print -nr -- '=nqk '; pfn "$nqk" |
| 4614 | print -nr -- '~nqk '; pfn $@ |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4615 | expected-stdout: |
| 4616 | = qs <spacedivdedargument |
| 4617 | here> |
| 4618 | ~ qs <spacedivdedargument |
| 4619 | here> |
| 4620 | =nqs <spacedivdedargument |
| 4621 | here> |
| 4622 | ~nqs <space> |
| 4623 | <divded> |
| 4624 | <argument |
| 4625 | here> |
| 4626 | = qk <space divded argument |
| 4627 | here> |
| 4628 | ~ qk <space> |
| 4629 | <divded> |
| 4630 | <argument |
| 4631 | here> |
| 4632 | =nqk <space divded argument |
| 4633 | here> |
| 4634 | ~nqk <space> |
| 4635 | <divded> |
| 4636 | <argument |
| 4637 | here> |
| 4638 | --- |
| 4639 | name: IFS-subst-4-4p |
| 4640 | description: |
| 4641 | extended testsuite based on problem by mikeserv |
| 4642 | stdin: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4643 | pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; } |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4644 | a='space divded argument |
| 4645 | here' |
| 4646 | IFS=\ ; set -- $a; IFS= |
| 4647 | unset v |
| 4648 | qs=${v:-"$*"} |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4649 | print -nr -- '= qs '; pfn "$qs" |
| 4650 | print -nr -- '~ qs '; pfn ${v:-"$*"} |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4651 | nqs=${v:-$*} |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4652 | print -nr -- '=nqs '; pfn "$nqs" |
| 4653 | print -nr -- '~nqs '; pfn ${v:-$*} |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4654 | qk=${v:-"$@"} |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4655 | print -nr -- '= qk '; pfn "$qk" |
| 4656 | print -nr -- '~ qk '; pfn ${v:-"$@"} |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4657 | nqk=${v:-$@} |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4658 | print -nr -- '=nqk '; pfn "$nqk" |
| 4659 | print -nr -- '~nqk '; pfn ${v:-$@} |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4660 | expected-stdout: |
| 4661 | = qs <spacedivdedargument |
| 4662 | here> |
| 4663 | ~ qs <spacedivdedargument |
| 4664 | here> |
| 4665 | =nqs <spacedivdedargument |
| 4666 | here> |
| 4667 | ~nqs <space> |
| 4668 | <divded> |
| 4669 | <argument |
| 4670 | here> |
| 4671 | = qk <space divded argument |
| 4672 | here> |
| 4673 | ~ qk <space> |
| 4674 | <divded> |
| 4675 | <argument |
| 4676 | here> |
| 4677 | =nqk <space divded argument |
| 4678 | here> |
| 4679 | ~nqk <space> |
| 4680 | <divded> |
| 4681 | <argument |
| 4682 | here> |
| 4683 | --- |
| 4684 | name: IFS-subst-4-5 |
| 4685 | description: |
| 4686 | extended testsuite based on problem by mikeserv |
| 4687 | stdin: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4688 | pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; } |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4689 | a='space divded argument |
| 4690 | here' |
| 4691 | IFS=\ ; set -- $a; IFS=, |
| 4692 | qs="$*" |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4693 | print -nr -- '= qs '; pfn "$qs" |
| 4694 | print -nr -- '~ qs '; pfn "$*" |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4695 | nqs=$* |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4696 | print -nr -- '=nqs '; pfn "$nqs" |
| 4697 | print -nr -- '~nqs '; pfn $* |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4698 | qk="$@" |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4699 | print -nr -- '= qk '; pfn "$qk" |
| 4700 | print -nr -- '~ qk '; pfn "$@" |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4701 | nqk=$@ |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4702 | print -nr -- '=nqk '; pfn "$nqk" |
| 4703 | print -nr -- '~nqk '; pfn $@ |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4704 | expected-stdout: |
| 4705 | = qs <space,divded,argument |
| 4706 | here> |
| 4707 | ~ qs <space,divded,argument |
| 4708 | here> |
| 4709 | =nqs <space,divded,argument |
| 4710 | here> |
| 4711 | ~nqs <space> |
| 4712 | <divded> |
| 4713 | <argument |
| 4714 | here> |
| 4715 | = qk <space divded argument |
| 4716 | here> |
| 4717 | ~ qk <space> |
| 4718 | <divded> |
| 4719 | <argument |
| 4720 | here> |
| 4721 | =nqk <space divded argument |
| 4722 | here> |
| 4723 | ~nqk <space> |
| 4724 | <divded> |
| 4725 | <argument |
| 4726 | here> |
| 4727 | --- |
| 4728 | name: IFS-subst-4-5p |
| 4729 | description: |
| 4730 | extended testsuite based on problem by mikeserv |
| 4731 | stdin: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4732 | pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; } |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4733 | a='space divded argument |
| 4734 | here' |
| 4735 | IFS=\ ; set -- $a; IFS=, |
| 4736 | unset v |
| 4737 | qs=${v:-"$*"} |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4738 | print -nr -- '= qs '; pfn "$qs" |
| 4739 | print -nr -- '~ qs '; pfn ${v:-"$*"} |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4740 | nqs=${v:-$*} |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4741 | print -nr -- '=nqs '; pfn "$nqs" |
| 4742 | print -nr -- '~nqs '; pfn ${v:-$*} |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4743 | qk=${v:-"$@"} |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4744 | print -nr -- '= qk '; pfn "$qk" |
| 4745 | print -nr -- '~ qk '; pfn ${v:-"$@"} |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4746 | nqk=${v:-$@} |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4747 | print -nr -- '=nqk '; pfn "$nqk" |
| 4748 | print -nr -- '~nqk '; pfn ${v:-$@} |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4749 | expected-stdout: |
| 4750 | = qs <space,divded,argument |
| 4751 | here> |
| 4752 | ~ qs <space,divded,argument |
| 4753 | here> |
| 4754 | =nqs <space,divded,argument |
| 4755 | here> |
| 4756 | ~nqs <space> |
| 4757 | <divded> |
| 4758 | <argument |
| 4759 | here> |
| 4760 | = qk <space divded argument |
| 4761 | here> |
| 4762 | ~ qk <space> |
| 4763 | <divded> |
| 4764 | <argument |
| 4765 | here> |
| 4766 | =nqk <space divded argument |
| 4767 | here> |
| 4768 | ~nqk <space> |
| 4769 | <divded> |
| 4770 | <argument |
| 4771 | here> |
| 4772 | --- |
| 4773 | name: IFS-subst-5 |
| 4774 | description: |
| 4775 | extended testsuite based on IFS-subst-3 |
| 4776 | differs slightly from ksh93: |
| 4777 | - omit trailing field in a3zna, a7ina (unquoted $@ expansion) |
| 4778 | - has extra middle fields in b5ins, b7ina (IFS_NWS unquoted expansion) |
| 4779 | differs slightly from bash: |
| 4780 | - omit leading field in a5ins, a7ina (IFS_NWS unquoted expansion) |
| 4781 | differs slightly from zsh: |
| 4782 | - differs in assignment, not expansion; probably zsh bug |
| 4783 | - has extra middle fields in b5ins, b7ina (IFS_NWS unquoted expansion) |
| 4784 | 'emulate sh' zsh has extra fields in |
| 4785 | - a5ins (IFS_NWS unquoted $*) |
| 4786 | - b5ins, matching mkshâs |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4787 | !!WARNING!! more to come: http://austingroupbugs.net/view.php?id=888 |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4788 | stdin: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4789 | "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; |
| 4790 | IFS=; set -- "" 2 ""; pfb $*; x=$*; pfn "$x"' |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4791 | echo '=a1zns' |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4792 | "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; |
| 4793 | IFS=; set -- "" 2 ""; pfb "$*"; x="$*"; pfn "$x"' |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4794 | echo '=a2zqs' |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4795 | "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; |
| 4796 | IFS=; set -- "" 2 ""; pfb $@; x=$@; pfn "$x"' |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4797 | echo '=a3zna' |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4798 | "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; |
| 4799 | IFS=; set -- "" 2 ""; pfb "$@"; x="$@"; pfn "$x"' |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4800 | echo '=a4zqa' |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4801 | "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; |
| 4802 | IFS=,; set -- "" 2 ""; pfb $*; x=$*; pfn "$x"' |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4803 | echo '=a5ins' |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4804 | "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; |
| 4805 | IFS=,; set -- "" 2 ""; pfb "$*"; x="$*"; pfn "$x"' |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4806 | echo '=a6iqs' |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4807 | "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; |
| 4808 | IFS=,; set -- "" 2 ""; pfb $@; x=$@; pfn "$x"' |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4809 | echo '=a7ina' |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4810 | "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; |
| 4811 | IFS=,; set -- "" 2 ""; pfb "$@"; x="$@"; pfn "$x"' |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4812 | echo '=a8iqa' |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4813 | "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; |
| 4814 | IFS=; set -- A B "" "" C; pfb $*; x=$*; pfn "$x"' |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4815 | echo '=b1zns' |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4816 | "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; |
| 4817 | IFS=; set -- A B "" "" C; pfb "$*"; x="$*"; pfn "$x"' |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4818 | echo '=b2zqs' |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4819 | "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; |
| 4820 | IFS=; set -- A B "" "" C; pfb $@; x=$@; pfn "$x"' |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4821 | echo '=b3zna' |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4822 | "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; |
| 4823 | IFS=; set -- A B "" "" C; pfb "$@"; x="$@"; pfn "$x"' |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4824 | echo '=b4zqa' |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4825 | "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; |
| 4826 | IFS=,; set -- A B "" "" C; pfb $*; x=$*; pfn "$x"' |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4827 | echo '=b5ins' |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4828 | "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; |
| 4829 | IFS=,; set -- A B "" "" C; pfb "$*"; x="$*"; pfn "$x"' |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4830 | echo '=b6iqs' |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4831 | "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; |
| 4832 | IFS=,; set -- A B "" "" C; pfb $@; x=$@; pfn "$x"' |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4833 | echo '=b7ina' |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4834 | "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; |
| 4835 | IFS=,; set -- A B "" "" C; pfb "$@"; x="$@"; pfn "$x"' |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 4836 | echo '=b8iqa' |
| 4837 | expected-stdout: |
| 4838 | [2] |
| 4839 | <2> |
| 4840 | =a1zns |
| 4841 | [2] |
| 4842 | <2> |
| 4843 | =a2zqs |
| 4844 | [2] |
| 4845 | < 2 > |
| 4846 | =a3zna |
| 4847 | [] |
| 4848 | [2] |
| 4849 | [] |
| 4850 | < 2 > |
| 4851 | =a4zqa |
| 4852 | [2] |
| 4853 | <,2,> |
| 4854 | =a5ins |
| 4855 | [,2,] |
| 4856 | <,2,> |
| 4857 | =a6iqs |
| 4858 | [2] |
| 4859 | < 2 > |
| 4860 | =a7ina |
| 4861 | [] |
| 4862 | [2] |
| 4863 | [] |
| 4864 | < 2 > |
| 4865 | =a8iqa |
| 4866 | [A] |
| 4867 | [B] |
| 4868 | [C] |
| 4869 | <ABC> |
| 4870 | =b1zns |
| 4871 | [ABC] |
| 4872 | <ABC> |
| 4873 | =b2zqs |
| 4874 | [A] |
| 4875 | [B] |
| 4876 | [C] |
| 4877 | <A B C> |
| 4878 | =b3zna |
| 4879 | [A] |
| 4880 | [B] |
| 4881 | [] |
| 4882 | [] |
| 4883 | [C] |
| 4884 | <A B C> |
| 4885 | =b4zqa |
| 4886 | [A] |
| 4887 | [B] |
| 4888 | [] |
| 4889 | [] |
| 4890 | [C] |
| 4891 | <A,B,,,C> |
| 4892 | =b5ins |
| 4893 | [A,B,,,C] |
| 4894 | <A,B,,,C> |
| 4895 | =b6iqs |
| 4896 | [A] |
| 4897 | [B] |
| 4898 | [] |
| 4899 | [] |
| 4900 | [C] |
| 4901 | <A B C> |
| 4902 | =b7ina |
| 4903 | [A] |
| 4904 | [B] |
| 4905 | [] |
| 4906 | [] |
| 4907 | [C] |
| 4908 | <A B C> |
| 4909 | =b8iqa |
| 4910 | --- |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4911 | name: IFS-subst-6 |
| 4912 | description: |
| 4913 | Regression wrt. vector expansion in trim |
| 4914 | stdin: |
| 4915 | showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } |
| 4916 | IFS= |
| 4917 | x=abc |
| 4918 | set -- a b |
| 4919 | showargs ${x#$*} |
| 4920 | expected-stdout: |
| 4921 | <c> . |
| 4922 | --- |
| 4923 | name: IFS-subst-7 |
| 4924 | description: |
| 4925 | ksh93 bug wrt. vector expansion in trim |
| 4926 | stdin: |
| 4927 | showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } |
| 4928 | IFS="*" |
| 4929 | a=abcd |
| 4930 | set -- '' c |
| 4931 | showargs "$*" ${a##"$*"} |
| 4932 | expected-stdout: |
| 4933 | <*c> <abcd> . |
| 4934 | --- |
| 4935 | name: IFS-subst-8 |
| 4936 | description: |
| 4937 | http://austingroupbugs.net/view.php?id=221 |
| 4938 | stdin: |
| 4939 | n() { echo "$#"; }; n "${foo-$@}" |
| 4940 | expected-stdout: |
| 4941 | 1 |
| 4942 | --- |
| 4943 | name: IFS-subst-9 |
| 4944 | description: |
| 4945 | Scalar context for $*/$@ in [[ and case |
| 4946 | stdin: |
| 4947 | "$__progname" -c 'IFS=; set a b; [[ $* = "$1$2" ]]; echo 1 $?' sh a b |
| 4948 | "$__progname" -c 'IFS=; [[ $* = ab ]]; echo 2 "$?"' sh a b |
| 4949 | "$__progname" -c 'IFS=; [[ "$*" = ab ]]; echo 3 "$?"' sh a b |
| 4950 | "$__progname" -c 'IFS=; [[ $* = a ]]; echo 4 "$?"' sh a b |
| 4951 | "$__progname" -c 'IFS=; [[ "$*" = a ]]; echo 5 "$?"' sh a b |
| 4952 | "$__progname" -c 'IFS=; [[ "$@" = a ]]; echo 6 "$?"' sh a b |
| 4953 | "$__progname" -c 'IFS=; case "$@" in a) echo 7 a;; ab) echo 7 b;; a\ b) echo 7 ok;; esac' sh a b |
| 4954 | "$__progname" -c 'IFS=; case $* in a) echo 8 a;; ab) echo 8 ok;; esac' sh a b |
| 4955 | "$__progname" -c 'pfsp() { for s_arg in "$@"; do print -nr -- "<$s_arg> "; done; print .; }; IFS=; star=$* at="$@"; pfsp 9 "$star" "$at"' sh a b |
| 4956 | expected-stdout: |
| 4957 | 1 0 |
| 4958 | 2 0 |
| 4959 | 3 0 |
| 4960 | 4 1 |
| 4961 | 5 1 |
| 4962 | 6 1 |
| 4963 | 7 ok |
| 4964 | 8 ok |
| 4965 | <9> <ab> <a b> . |
| 4966 | --- |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 4967 | name: IFS-subst-10 |
| 4968 | description: |
| 4969 | Scalar context in ${var=$subst} |
| 4970 | stdin: |
| 4971 | showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } |
| 4972 | set -- one "two three" four |
| 4973 | unset -v var |
| 4974 | save_IFS=$IFS |
| 4975 | IFS= |
| 4976 | set -- ${var=$*} |
| 4977 | IFS=$save_IFS |
| 4978 | echo "var=$var" |
| 4979 | showargs "$@" |
| 4980 | expected-stdout: |
| 4981 | var=onetwo threefour |
| 4982 | <onetwo threefour> . |
| 4983 | --- |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 4984 | name: IFS-arith-1 |
| 4985 | description: |
| 4986 | http://austingroupbugs.net/view.php?id=832 |
| 4987 | stdin: |
| 4988 | ${ZSH_VERSION+false} || emulate sh |
| 4989 | ${BASH_VERSION+set -o posix} |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 4990 | showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 4991 | IFS=0 |
| 4992 | showargs $((1230456)) |
| 4993 | expected-stdout: |
| 4994 | <123> <456> . |
| 4995 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 4996 | name: integer-base-err-1 |
| 4997 | description: |
| 4998 | Can't have 0 base (causes shell to exit) |
| 4999 | expected-exit: e != 0 |
| 5000 | stdin: |
| 5001 | typeset -i i |
| 5002 | i=3 |
| 5003 | i=0#4 |
| 5004 | echo $i |
| 5005 | expected-stderr-pattern: |
| 5006 | /^.*:.*0#4.*\n$/ |
| 5007 | --- |
| 5008 | name: integer-base-err-2 |
| 5009 | description: |
| 5010 | Can't have multiple bases in a 'constant' (causes shell to exit) |
| 5011 | (ksh88 fails this test) |
| 5012 | expected-exit: e != 0 |
| 5013 | stdin: |
| 5014 | typeset -i i |
| 5015 | i=3 |
| 5016 | i=2#110#11 |
| 5017 | echo $i |
| 5018 | expected-stderr-pattern: |
| 5019 | /^.*:.*2#110#11.*\n$/ |
| 5020 | --- |
| 5021 | name: integer-base-err-3 |
| 5022 | description: |
| 5023 | Syntax errors in expressions and effects on bases |
| 5024 | (interactive so errors don't cause exits) |
| 5025 | (ksh88 fails this test - shell exits, even with -i) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 5026 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 5027 | arguments: !-i! |
| 5028 | stdin: |
| 5029 | PS1= # minimise prompt hassles |
| 5030 | typeset -i4 a=10 |
| 5031 | typeset -i a=2+ |
| 5032 | echo $a |
| 5033 | typeset -i4 a=10 |
| 5034 | typeset -i2 a=2+ |
| 5035 | echo $a |
| 5036 | expected-stderr-pattern: |
| 5037 | /^([#\$] )?.*:.*2+.*\n.*:.*2+.*\n$/ |
| 5038 | expected-stdout: |
| 5039 | 4#22 |
| 5040 | 4#22 |
| 5041 | --- |
| 5042 | name: integer-base-err-4 |
| 5043 | description: |
| 5044 | Are invalid digits (according to base) errors? |
| 5045 | (ksh93 fails this test) |
| 5046 | expected-exit: e != 0 |
| 5047 | stdin: |
| 5048 | typeset -i i; |
| 5049 | i=3#4 |
| 5050 | expected-stderr-pattern: |
| 5051 | /^([#\$] )?.*:.*3#4.*\n$/ |
| 5052 | --- |
| 5053 | name: integer-base-1 |
| 5054 | description: |
| 5055 | Missing number after base is treated as 0. |
| 5056 | stdin: |
| 5057 | typeset -i i |
| 5058 | i=3 |
| 5059 | i=2# |
| 5060 | echo $i |
| 5061 | expected-stdout: |
| 5062 | 0 |
| 5063 | --- |
| 5064 | name: integer-base-2 |
| 5065 | description: |
| 5066 | Check 'stickyness' of base in various situations |
| 5067 | stdin: |
| 5068 | typeset -i i=8 |
| 5069 | echo $i |
| 5070 | echo ---------- A |
| 5071 | typeset -i4 j=8 |
| 5072 | echo $j |
| 5073 | echo ---------- B |
| 5074 | typeset -i k=8 |
| 5075 | typeset -i4 k=8 |
| 5076 | echo $k |
| 5077 | echo ---------- C |
| 5078 | typeset -i4 l |
| 5079 | l=3#10 |
| 5080 | echo $l |
| 5081 | echo ---------- D |
| 5082 | typeset -i m |
| 5083 | m=3#10 |
| 5084 | echo $m |
| 5085 | echo ---------- E |
| 5086 | n=2#11 |
| 5087 | typeset -i n |
| 5088 | echo $n |
| 5089 | n=10 |
| 5090 | echo $n |
| 5091 | echo ---------- F |
| 5092 | typeset -i8 o=12 |
| 5093 | typeset -i4 o |
| 5094 | echo $o |
| 5095 | echo ---------- G |
| 5096 | typeset -i p |
| 5097 | let p=8#12 |
| 5098 | echo $p |
| 5099 | expected-stdout: |
| 5100 | 8 |
| 5101 | ---------- A |
| 5102 | 4#20 |
| 5103 | ---------- B |
| 5104 | 4#20 |
| 5105 | ---------- C |
| 5106 | 4#3 |
| 5107 | ---------- D |
| 5108 | 3#10 |
| 5109 | ---------- E |
| 5110 | 2#11 |
| 5111 | 2#1010 |
| 5112 | ---------- F |
| 5113 | 4#30 |
| 5114 | ---------- G |
| 5115 | 8#12 |
| 5116 | --- |
| 5117 | name: integer-base-3 |
| 5118 | description: |
| 5119 | More base parsing (hmm doesn't test much..) |
| 5120 | stdin: |
| 5121 | typeset -i aa |
| 5122 | aa=1+12#10+2 |
| 5123 | echo $aa |
| 5124 | typeset -i bb |
| 5125 | bb=1+$aa |
| 5126 | echo $bb |
| 5127 | typeset -i bb |
| 5128 | bb=$aa |
| 5129 | echo $bb |
| 5130 | typeset -i cc |
| 5131 | cc=$aa |
| 5132 | echo $cc |
| 5133 | expected-stdout: |
| 5134 | 15 |
| 5135 | 16 |
| 5136 | 15 |
| 5137 | 15 |
| 5138 | --- |
| 5139 | name: integer-base-4 |
| 5140 | description: |
| 5141 | Check that things not declared as integers are not made integers, |
| 5142 | also, check if base is not reset by -i with no arguments. |
| 5143 | (ksh93 fails - prints 10#20 - go figure) |
| 5144 | stdin: |
| 5145 | xx=20 |
| 5146 | let xx=10 |
| 5147 | typeset -i | grep '^xx=' |
| 5148 | typeset -i4 a=10 |
| 5149 | typeset -i a=20 |
| 5150 | echo $a |
| 5151 | expected-stdout: |
| 5152 | 4#110 |
| 5153 | --- |
| 5154 | name: integer-base-5 |
| 5155 | description: |
| 5156 | More base stuff |
| 5157 | stdin: |
| 5158 | typeset -i4 a=3#10 |
| 5159 | echo $a |
| 5160 | echo -- |
| 5161 | typeset -i j=3 |
| 5162 | j='~3' |
| 5163 | echo $j |
| 5164 | echo -- |
| 5165 | typeset -i k=1 |
| 5166 | x[k=k+1]=3 |
| 5167 | echo $k |
| 5168 | echo -- |
| 5169 | typeset -i l |
| 5170 | for l in 1 2+3 4; do echo $l; done |
| 5171 | expected-stdout: |
| 5172 | 4#3 |
| 5173 | -- |
| 5174 | -4 |
| 5175 | -- |
| 5176 | 2 |
| 5177 | -- |
| 5178 | 1 |
| 5179 | 5 |
| 5180 | 4 |
| 5181 | --- |
| 5182 | name: integer-base-6 |
| 5183 | description: |
| 5184 | Even more base stuff |
| 5185 | (ksh93 fails this test - prints 0) |
| 5186 | stdin: |
| 5187 | typeset -i7 i |
| 5188 | i= |
| 5189 | echo $i |
| 5190 | expected-stdout: |
| 5191 | 7#0 |
| 5192 | --- |
| 5193 | name: integer-base-7 |
| 5194 | description: |
| 5195 | Check that non-integer parameters don't get bases assigned |
| 5196 | stdin: |
| 5197 | echo $(( zz = 8#100 )) |
| 5198 | echo $zz |
| 5199 | expected-stdout: |
| 5200 | 64 |
| 5201 | 64 |
| 5202 | --- |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 5203 | name: integer-base-8 |
| 5204 | description: |
| 5205 | Check that base-36 works (full span) |
| 5206 | stdin: |
| 5207 | echo 1:$((36#109AZ)). |
| 5208 | typeset -i36 x=1691675 |
| 5209 | echo 2:$x. |
| 5210 | typeset -Uui36 x |
| 5211 | echo 3:$x. |
| 5212 | expected-stdout: |
| 5213 | 1:1691675. |
| 5214 | 2:36#109az. |
| 5215 | 3:36#109AZ. |
| 5216 | --- |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 5217 | name: integer-base-check-flat |
| 5218 | description: |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 5219 | Check behaviour does not match POSuX (except if set -o posix), |
| 5220 | because a not type-safe scripting language has *no* business |
Elliott Hughes | 966dd55 | 2016-12-08 15:56:04 -0800 | [diff] [blame] | 5221 | interpreting the string "010" as octal number eight (dangerous). |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 5222 | stdin: |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 5223 | echo 1 "$("$__progname" -c 'echo :$((10))/$((010)),$((0x10)):')" . |
| 5224 | echo 2 "$("$__progname" -o posix -c 'echo :$((10))/$((010)),$((0x10)):')" . |
| 5225 | echo 3 "$("$__progname" -o sh -c 'echo :$((10))/$((010)),$((0x10)):')" . |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 5226 | expected-stdout: |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 5227 | 1 :10/10,16: . |
| 5228 | 2 :10/8,16: . |
| 5229 | 3 :10/10,16: . |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 5230 | --- |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 5231 | name: integer-base-check-numeric-from-1 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 5232 | description: |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 5233 | Check behaviour for base one |
| 5234 | category: !shell:ebcdic-yes |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 5235 | stdin: |
| 5236 | echo 1:$((1#1))0. |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 5237 | expected-stdout: |
| 5238 | 1:490. |
| 5239 | --- |
| 5240 | name: integer-base-check-numeric-from-1-ebcdic |
| 5241 | description: |
| 5242 | Check behaviour for base one |
| 5243 | category: !shell:ebcdic-no |
| 5244 | stdin: |
| 5245 | echo 1:$((1#1))0. |
| 5246 | expected-stdout: |
| 5247 | 1:2410. |
| 5248 | --- |
| 5249 | name: integer-base-check-numeric-from-2 |
| 5250 | description: |
| 5251 | Check behaviour for base two to 36, and that 37 degrades to 10 |
| 5252 | stdin: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 5253 | i=1 |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 5254 | while (( ++i <= 37 )); do |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 5255 | eval 'echo '$i':$(('$i'#10)).' |
| 5256 | done |
| 5257 | echo 37:$($__progname -c 'echo $((37#10))').$?: |
| 5258 | expected-stdout: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 5259 | 2:2. |
| 5260 | 3:3. |
| 5261 | 4:4. |
| 5262 | 5:5. |
| 5263 | 6:6. |
| 5264 | 7:7. |
| 5265 | 8:8. |
| 5266 | 9:9. |
| 5267 | 10:10. |
| 5268 | 11:11. |
| 5269 | 12:12. |
| 5270 | 13:13. |
| 5271 | 14:14. |
| 5272 | 15:15. |
| 5273 | 16:16. |
| 5274 | 17:17. |
| 5275 | 18:18. |
| 5276 | 19:19. |
| 5277 | 20:20. |
| 5278 | 21:21. |
| 5279 | 22:22. |
| 5280 | 23:23. |
| 5281 | 24:24. |
| 5282 | 25:25. |
| 5283 | 26:26. |
| 5284 | 27:27. |
| 5285 | 28:28. |
| 5286 | 29:29. |
| 5287 | 30:30. |
| 5288 | 31:31. |
| 5289 | 32:32. |
| 5290 | 33:33. |
| 5291 | 34:34. |
| 5292 | 35:35. |
| 5293 | 36:36. |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 5294 | 37:10. |
| 5295 | 37:10.0: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 5296 | --- |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 5297 | name: integer-base-check-numeric-to-1 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 5298 | description: |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 5299 | Check behaviour for base one |
| 5300 | category: !shell:ebcdic-yes |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 5301 | stdin: |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 5302 | i=1 |
| 5303 | typeset -Uui$i x=0x40 |
| 5304 | eval "typeset -i10 y=$x" |
| 5305 | print $i:$x.$y. |
| 5306 | expected-stdout: |
| 5307 | 1:1#@.64. |
| 5308 | --- |
| 5309 | name: integer-base-check-numeric-to-1-ebcdic |
| 5310 | description: |
| 5311 | Check behaviour for base one |
| 5312 | category: !shell:ebcdic-no |
| 5313 | stdin: |
| 5314 | i=1 |
| 5315 | typeset -Uui$i x=0x7C |
| 5316 | eval "typeset -i10 y=$x" |
| 5317 | print $i:$x.$y. |
| 5318 | expected-stdout: |
| 5319 | 1:1#@.124. |
| 5320 | --- |
| 5321 | name: integer-base-check-numeric-to-2 |
| 5322 | description: |
| 5323 | Check behaviour for base two to 36, and that 37 degrades to 10 |
| 5324 | stdin: |
| 5325 | i=1 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 5326 | while (( ++i <= 37 )); do |
| 5327 | typeset -Uui$i x=0x40 |
| 5328 | eval "typeset -i10 y=$x" |
| 5329 | print $i:$x.$y. |
| 5330 | done |
| 5331 | expected-stdout: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 5332 | 2:2#1000000.64. |
| 5333 | 3:3#2101.64. |
| 5334 | 4:4#1000.64. |
| 5335 | 5:5#224.64. |
| 5336 | 6:6#144.64. |
| 5337 | 7:7#121.64. |
| 5338 | 8:8#100.64. |
| 5339 | 9:9#71.64. |
| 5340 | 10:64.64. |
| 5341 | 11:11#59.64. |
| 5342 | 12:12#54.64. |
| 5343 | 13:13#4C.64. |
| 5344 | 14:14#48.64. |
| 5345 | 15:15#44.64. |
| 5346 | 16:16#40.64. |
| 5347 | 17:17#3D.64. |
| 5348 | 18:18#3A.64. |
| 5349 | 19:19#37.64. |
| 5350 | 20:20#34.64. |
| 5351 | 21:21#31.64. |
| 5352 | 22:22#2K.64. |
| 5353 | 23:23#2I.64. |
| 5354 | 24:24#2G.64. |
| 5355 | 25:25#2E.64. |
| 5356 | 26:26#2C.64. |
| 5357 | 27:27#2A.64. |
| 5358 | 28:28#28.64. |
| 5359 | 29:29#26.64. |
| 5360 | 30:30#24.64. |
| 5361 | 31:31#22.64. |
| 5362 | 32:32#20.64. |
| 5363 | 33:33#1V.64. |
| 5364 | 34:34#1U.64. |
| 5365 | 35:35#1T.64. |
| 5366 | 36:36#1S.64. |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 5367 | 37:64.64. |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 5368 | --- |
| 5369 | name: integer-arithmetic-span |
| 5370 | description: |
| 5371 | Check wraparound and size that is defined in mksh |
| 5372 | category: int:32 |
| 5373 | stdin: |
| 5374 | echo s:$((2147483647+1)).$(((2147483647*2)+1)).$(((2147483647*2)+2)). |
| 5375 | echo u:$((#2147483647+1)).$((#(2147483647*2)+1)).$((#(2147483647*2)+2)). |
| 5376 | expected-stdout: |
| 5377 | s:-2147483648.-1.0. |
| 5378 | u:2147483648.4294967295.0. |
| 5379 | --- |
| 5380 | name: integer-arithmetic-span-64 |
| 5381 | description: |
| 5382 | Check wraparound and size that is defined in mksh |
| 5383 | category: int:64 |
| 5384 | stdin: |
| 5385 | echo s:$((9223372036854775807+1)).$(((9223372036854775807*2)+1)).$(((9223372036854775807*2)+2)). |
| 5386 | echo u:$((#9223372036854775807+1)).$((#(9223372036854775807*2)+1)).$((#(9223372036854775807*2)+2)). |
| 5387 | expected-stdout: |
| 5388 | s:-9223372036854775808.-1.0. |
| 5389 | u:9223372036854775808.18446744073709551615.0. |
| 5390 | --- |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 5391 | name: integer-size-FAIL-to-detect |
| 5392 | description: |
| 5393 | Notify the user that their ints are not 32 or 64 bit |
| 5394 | category: int:u |
| 5395 | stdin: |
| 5396 | : |
| 5397 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 5398 | name: lineno-stdin |
| 5399 | description: |
| 5400 | See if $LINENO is updated and can be modified. |
| 5401 | stdin: |
| 5402 | echo A $LINENO |
| 5403 | echo B $LINENO |
| 5404 | LINENO=20 |
| 5405 | echo C $LINENO |
| 5406 | expected-stdout: |
| 5407 | A 1 |
| 5408 | B 2 |
| 5409 | C 20 |
| 5410 | --- |
| 5411 | name: lineno-inc |
| 5412 | description: |
| 5413 | See if $LINENO is set for .'d files. |
| 5414 | file-setup: file 644 "dotfile" |
| 5415 | echo dot A $LINENO |
| 5416 | echo dot B $LINENO |
| 5417 | LINENO=20 |
| 5418 | echo dot C $LINENO |
| 5419 | stdin: |
| 5420 | echo A $LINENO |
| 5421 | echo B $LINENO |
| 5422 | . ./dotfile |
| 5423 | expected-stdout: |
| 5424 | A 1 |
| 5425 | B 2 |
| 5426 | dot A 1 |
| 5427 | dot B 2 |
| 5428 | dot C 20 |
| 5429 | --- |
| 5430 | name: lineno-func |
| 5431 | description: |
| 5432 | See if $LINENO is set for commands in a function. |
| 5433 | stdin: |
| 5434 | echo A $LINENO |
| 5435 | echo B $LINENO |
| 5436 | bar() { |
| 5437 | echo func A $LINENO |
| 5438 | echo func B $LINENO |
| 5439 | } |
| 5440 | bar |
| 5441 | echo C $LINENO |
| 5442 | expected-stdout: |
| 5443 | A 1 |
| 5444 | B 2 |
| 5445 | func A 4 |
| 5446 | func B 5 |
| 5447 | C 8 |
| 5448 | --- |
| 5449 | name: lineno-unset |
| 5450 | description: |
| 5451 | See if unsetting LINENO makes it non-magic. |
| 5452 | file-setup: file 644 "dotfile" |
| 5453 | echo dot A $LINENO |
| 5454 | echo dot B $LINENO |
| 5455 | stdin: |
| 5456 | unset LINENO |
| 5457 | echo A $LINENO |
| 5458 | echo B $LINENO |
| 5459 | bar() { |
| 5460 | echo func A $LINENO |
| 5461 | echo func B $LINENO |
| 5462 | } |
| 5463 | bar |
| 5464 | . ./dotfile |
| 5465 | echo C $LINENO |
| 5466 | expected-stdout: |
| 5467 | A |
| 5468 | B |
| 5469 | func A |
| 5470 | func B |
| 5471 | dot A |
| 5472 | dot B |
| 5473 | C |
| 5474 | --- |
| 5475 | name: lineno-unset-use |
| 5476 | description: |
| 5477 | See if unsetting LINENO makes it non-magic even |
| 5478 | when it is re-used. |
| 5479 | file-setup: file 644 "dotfile" |
| 5480 | echo dot A $LINENO |
| 5481 | echo dot B $LINENO |
| 5482 | stdin: |
| 5483 | unset LINENO |
| 5484 | LINENO=3 |
| 5485 | echo A $LINENO |
| 5486 | echo B $LINENO |
| 5487 | bar() { |
| 5488 | echo func A $LINENO |
| 5489 | echo func B $LINENO |
| 5490 | } |
| 5491 | bar |
| 5492 | . ./dotfile |
| 5493 | echo C $LINENO |
| 5494 | expected-stdout: |
| 5495 | A 3 |
| 5496 | B 3 |
| 5497 | func A 3 |
| 5498 | func B 3 |
| 5499 | dot A 3 |
| 5500 | dot B 3 |
| 5501 | C 3 |
| 5502 | --- |
| 5503 | name: lineno-trap |
| 5504 | description: |
| 5505 | Check if LINENO is tracked in traps |
| 5506 | stdin: |
| 5507 | fail() { |
| 5508 | echo "line <$1>" |
| 5509 | exit 1 |
| 5510 | } |
| 5511 | trap 'fail $LINENO' INT ERR |
| 5512 | false |
| 5513 | expected-stdout: |
| 5514 | line <6> |
| 5515 | expected-exit: 1 |
| 5516 | --- |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 5517 | name: lineno-eval-alias |
| 5518 | description: |
| 5519 | Check if LINENO is trapped in eval and aliases |
| 5520 | stdin: |
| 5521 | ${ZSH_VERSION+false} || emulate sh; echo $LINENO |
| 5522 | echo $LINENO |
| 5523 | eval ' echo $LINENO |
| 5524 | echo $LINENO |
| 5525 | echo $LINENO' |
| 5526 | echo $LINENO |
| 5527 | expected-stdout: |
| 5528 | 1 |
| 5529 | 2 |
| 5530 | 3 |
| 5531 | 3 |
| 5532 | 3 |
| 5533 | 6 |
| 5534 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 5535 | name: unknown-trap |
| 5536 | description: |
| 5537 | Ensure unknown traps are not a syntax error |
| 5538 | stdin: |
| 5539 | ( |
| 5540 | trap "echo trap 1 executed" UNKNOWNSIGNAL || echo "foo" |
| 5541 | echo =1 |
| 5542 | trap "echo trap 2 executed" UNKNOWNSIGNAL EXIT 999999 FNORD |
| 5543 | echo = $? |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 5544 | ) 2>&1 | sed "s^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]PROG" |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 5545 | expected-stdout: |
| 5546 | PROG: trap: bad signal 'UNKNOWNSIGNAL' |
| 5547 | foo |
| 5548 | =1 |
| 5549 | PROG: trap: bad signal 'UNKNOWNSIGNAL' |
| 5550 | PROG: trap: bad signal '999999' |
| 5551 | PROG: trap: bad signal 'FNORD' |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 5552 | = 1 |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 5553 | trap 2 executed |
| 5554 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 5555 | name: read-IFS-1 |
| 5556 | description: |
| 5557 | Simple test, default IFS |
| 5558 | stdin: |
| 5559 | echo "A B " > IN |
| 5560 | unset x y z |
| 5561 | read x y z < IN |
| 5562 | echo 1: "x[$x] y[$y] z[$z]" |
| 5563 | echo 1a: ${z-z not set} |
| 5564 | read x < IN |
| 5565 | echo 2: "x[$x]" |
| 5566 | expected-stdout: |
| 5567 | 1: x[A] y[B] z[] |
| 5568 | 1a: |
| 5569 | 2: x[A B] |
| 5570 | --- |
Elliott Hughes | b27ce95 | 2015-04-21 13:39:18 -0700 | [diff] [blame] | 5571 | name: read-IFS-2 |
| 5572 | description: |
| 5573 | Complex tests, IFS either colon (IFS-NWS) or backslash (tricky) |
| 5574 | stdin: |
| 5575 | n=0 |
| 5576 | showargs() { print -nr "$1"; shift; for s_arg in "$@"; do print -nr -- " [$s_arg]"; done; print; } |
| 5577 | (IFS=\\ a=\<\\\>; showargs 3 $a) |
| 5578 | (IFS=: b=\<:\>; showargs 4 $b) |
| 5579 | print -r '<\>' | (IFS=\\ read f g; showargs 5 "$f" "$g") |
| 5580 | print -r '<\\>' | (IFS=\\ read f g; showargs 6 "$f" "$g") |
| 5581 | print '<\\\n>' | (IFS=\\ read f g; showargs 7 "$f" "$g") |
| 5582 | print -r '<\>' | (IFS=\\ read f; showargs 8 "$f") |
| 5583 | print -r '<\\>' | (IFS=\\ read f; showargs 9 "$f") |
| 5584 | print '<\\\n>' | (IFS=\\ read f; showargs 10 "$f") |
| 5585 | print -r '<\>' | (IFS=\\ read -r f g; showargs 11 "$f" "$g") |
| 5586 | print -r '<\\>' | (IFS=\\ read -r f g; showargs 12 "$f" "$g") |
| 5587 | print '<\\\n>' | (IFS=\\ read -r f g; showargs 13 "$f" "$g") |
| 5588 | print -r '<\>' | (IFS=\\ read -r f; showargs 14 "$f") |
| 5589 | print -r '<\\>' | (IFS=\\ read -r f; showargs 15 "$f") |
| 5590 | print '<\\\n>' | (IFS=\\ read -r f; showargs 16 "$f") |
| 5591 | print -r '<:>' | (IFS=: read f g; showargs 17 "$f" "$g") |
| 5592 | print -r '<::>' | (IFS=: read f g; showargs 18 "$f" "$g") |
| 5593 | print '<:\n>' | (IFS=: read f g; showargs 19 "$f" "$g") |
| 5594 | print -r '<:>' | (IFS=: read f; showargs 20 "$f") |
| 5595 | print -r '<::>' | (IFS=: read f; showargs 21 "$f") |
| 5596 | print '<:\n>' | (IFS=: read f; showargs 22 "$f") |
| 5597 | print -r '<:>' | (IFS=: read -r f g; showargs 23 "$f" "$g") |
| 5598 | print -r '<::>' | (IFS=: read -r f g; showargs 24 "$f" "$g") |
| 5599 | print '<:\n>' | (IFS=: read -r f g; showargs 25 "$f" "$g") |
| 5600 | print -r '<:>' | (IFS=: read -r f; showargs 26 "$f") |
| 5601 | print -r '<::>' | (IFS=: read -r f; showargs 27 "$f") |
| 5602 | print '<:\n>' | (IFS=: read -r f; showargs 28 "$f") |
| 5603 | expected-stdout: |
| 5604 | 3 [<] [>] |
| 5605 | 4 [<] [>] |
| 5606 | 5 [<] [>] |
| 5607 | 6 [<] [>] |
| 5608 | 7 [<>] [] |
| 5609 | 8 [<>] |
| 5610 | 9 [<\>] |
| 5611 | 10 [<>] |
| 5612 | 11 [<] [>] |
| 5613 | 12 [<] [\>] |
| 5614 | 13 [<] [] |
| 5615 | 14 [<\>] |
| 5616 | 15 [<\\>] |
| 5617 | 16 [<] |
| 5618 | 17 [<] [>] |
| 5619 | 18 [<] [:>] |
| 5620 | 19 [<] [] |
| 5621 | 20 [<:>] |
| 5622 | 21 [<::>] |
| 5623 | 22 [<] |
| 5624 | 23 [<] [>] |
| 5625 | 24 [<] [:>] |
| 5626 | 25 [<] [] |
| 5627 | 26 [<:>] |
| 5628 | 27 [<::>] |
| 5629 | 28 [<] |
| 5630 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 5631 | name: read-ksh-1 |
| 5632 | description: |
| 5633 | If no var specified, REPLY is used |
| 5634 | stdin: |
| 5635 | echo "abc" > IN |
| 5636 | read < IN |
| 5637 | echo "[$REPLY]"; |
| 5638 | expected-stdout: |
| 5639 | [abc] |
| 5640 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 5641 | name: read-regress-1 |
| 5642 | description: |
| 5643 | Check a regression of read |
| 5644 | file-setup: file 644 "foo" |
| 5645 | foo bar |
| 5646 | baz |
| 5647 | blah |
| 5648 | stdin: |
| 5649 | while read a b c; do |
| 5650 | read d |
| 5651 | break |
| 5652 | done <foo |
| 5653 | echo "<$a|$b|$c><$d>" |
| 5654 | expected-stdout: |
| 5655 | <foo|bar|><baz> |
| 5656 | --- |
| 5657 | name: read-delim-1 |
| 5658 | description: |
| 5659 | Check read with delimiters |
| 5660 | stdin: |
| 5661 | emit() { |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 5662 | print -n 'foo bar\tbaz\nblah \0blub\tblech\nmyok meck \0' |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 5663 | } |
| 5664 | emit | while IFS= read -d "" foo; do print -r -- "<$foo>"; done |
| 5665 | emit | while read -d "" foo; do print -r -- "<$foo>"; done |
| 5666 | emit | while read -d "eh?" foo; do print -r -- "<$foo>"; done |
| 5667 | expected-stdout: |
| 5668 | <foo bar baz |
| 5669 | blah > |
| 5670 | <blub blech |
| 5671 | myok meck > |
| 5672 | <foo bar baz |
| 5673 | blah> |
| 5674 | <blub blech |
| 5675 | myok meck> |
| 5676 | <foo bar baz |
| 5677 | blah blub bl> |
| 5678 | <ch |
| 5679 | myok m> |
| 5680 | --- |
| 5681 | name: read-ext-1 |
| 5682 | description: |
| 5683 | Check read with number of bytes specified, and -A |
| 5684 | stdin: |
| 5685 | print 'foo\nbar' >x1 |
| 5686 | print -n x >x2 |
| 5687 | print 'foo\\ bar baz' >x3 |
| 5688 | x1a=u; read x1a <x1 |
| 5689 | x1b=u; read -N-1 x1b <x1 |
| 5690 | x2a=u; read x2a <x2; r2a=$? |
| 5691 | x2b=u; read -N2 x2c <x2; r2b=$? |
| 5692 | x2c=u; read -n2 x2c <x2; r2c=$? |
| 5693 | x3a=u; read -A x3a <x3 |
| 5694 | print -r "x1a=<$x1a>" |
| 5695 | print -r "x1b=<$x1b>" |
| 5696 | print -r "x2a=$r2a<$x2a>" |
| 5697 | print -r "x2b=$r2b<$x2b>" |
| 5698 | print -r "x2c=$r2c<$x2c>" |
| 5699 | print -r "x3a=<${x3a[0]}|${x3a[1]}|${x3a[2]}>" |
| 5700 | expected-stdout: |
| 5701 | x1a=<foo> |
| 5702 | x1b=<foo |
| 5703 | bar> |
| 5704 | x2a=1<x> |
| 5705 | x2b=1<u> |
| 5706 | x2c=0<x> |
| 5707 | x3a=<foo bar|baz|> |
| 5708 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 5709 | name: regression-1 |
| 5710 | description: |
| 5711 | Lex array code had problems with this. |
| 5712 | stdin: |
| 5713 | echo foo[ |
| 5714 | n=bar |
| 5715 | echo "hi[ $n ]=1" |
| 5716 | expected-stdout: |
| 5717 | foo[ |
| 5718 | hi[ bar ]=1 |
| 5719 | --- |
| 5720 | name: regression-2 |
| 5721 | description: |
| 5722 | When PATH is set before running a command, the new path is |
| 5723 | not used in doing the path search |
| 5724 | $ echo echo hi > /tmp/q ; chmod a+rx /tmp/q |
| 5725 | $ PATH=/tmp q |
| 5726 | q: not found |
| 5727 | $ |
| 5728 | in comexec() the two lines |
| 5729 | while (*vp != NULL) |
| 5730 | (void) typeset(*vp++, xxx, 0); |
| 5731 | need to be moved out of the switch to before findcom() is |
| 5732 | called - I don't know what this will break. |
| 5733 | stdin: |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 5734 | : "${PWD:-`pwd 2> /dev/null`}" |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 5735 | : "${PWD:?"PWD not set - cannot do test"}" |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 5736 | mkdir Y |
| 5737 | cat > Y/xxxscript << EOF |
| 5738 | #!/bin/sh |
| 5739 | # Need to restore path so echo can be found (some shells don't have |
| 5740 | # it as a built-in) |
| 5741 | PATH=\$OLDPATH |
| 5742 | echo hi |
| 5743 | exit 0 |
| 5744 | EOF |
| 5745 | chmod a+rx Y/xxxscript |
| 5746 | export OLDPATH="$PATH" |
| 5747 | PATH=$PWD/Y xxxscript |
| 5748 | exit $? |
| 5749 | expected-stdout: |
| 5750 | hi |
| 5751 | --- |
| 5752 | name: regression-6 |
| 5753 | description: |
| 5754 | Parsing of $(..) expressions is non-optimal. It is |
| 5755 | impossible to have any parentheses inside the expression. |
| 5756 | I.e., |
| 5757 | $ ksh -c 'echo $(echo \( )' |
| 5758 | no closing quote |
| 5759 | $ ksh -c 'echo $(echo "(" )' |
| 5760 | no closing quote |
| 5761 | $ |
| 5762 | The solution is to hack the parsing clode in lex.c, the |
| 5763 | question is how to hack it: should any parentheses be |
| 5764 | escaped by a backslash, or should recursive parsing be done |
| 5765 | (so quotes could also be used to hide hem). The former is |
| 5766 | easier, the later better... |
| 5767 | stdin: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 5768 | echo $(echo \( ) |
| 5769 | echo $(echo "(" ) |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 5770 | expected-stdout: |
| 5771 | ( |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 5772 | ( |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 5773 | --- |
| 5774 | name: regression-9 |
| 5775 | description: |
| 5776 | Continue in a for loop does not work right: |
| 5777 | for i in a b c ; do |
| 5778 | if [ $i = b ] ; then |
| 5779 | continue |
| 5780 | fi |
| 5781 | echo $i |
| 5782 | done |
| 5783 | Prints a forever... |
| 5784 | stdin: |
| 5785 | first=yes |
| 5786 | for i in a b c ; do |
| 5787 | if [ $i = b ] ; then |
| 5788 | if [ $first = no ] ; then |
| 5789 | echo 'continue in for loop broken' |
| 5790 | break # hope break isn't broken too :-) |
| 5791 | fi |
| 5792 | first=no |
| 5793 | continue |
| 5794 | fi |
| 5795 | done |
| 5796 | echo bye |
| 5797 | expected-stdout: |
| 5798 | bye |
| 5799 | --- |
| 5800 | name: regression-10 |
| 5801 | description: |
| 5802 | The following: |
| 5803 | set -- `false` |
| 5804 | echo $? |
| 5805 | should print 0 according to POSIX (dash, bash, ksh93, posh) |
| 5806 | but not 0 according to the getopt(1) manual page, ksh88, and |
| 5807 | Bourne sh (such as /bin/sh on Solaris). |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 5808 | We honour POSIX except when -o sh is set. |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 5809 | category: shell:legacy-no |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 5810 | stdin: |
| 5811 | showf() { |
| 5812 | [[ -o posix ]]; FPOSIX=$((1-$?)) |
| 5813 | [[ -o sh ]]; FSH=$((1-$?)) |
| 5814 | echo -n "FPOSIX=$FPOSIX FSH=$FSH " |
| 5815 | } |
| 5816 | set +o posix +o sh |
| 5817 | showf |
| 5818 | set -- `false` |
| 5819 | echo rv=$? |
| 5820 | set -o sh |
| 5821 | showf |
| 5822 | set -- `false` |
| 5823 | echo rv=$? |
| 5824 | set -o posix |
| 5825 | showf |
| 5826 | set -- `false` |
| 5827 | echo rv=$? |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 5828 | set -o posix -o sh |
| 5829 | showf |
| 5830 | set -- `false` |
| 5831 | echo rv=$? |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 5832 | expected-stdout: |
| 5833 | FPOSIX=0 FSH=0 rv=0 |
| 5834 | FPOSIX=0 FSH=1 rv=1 |
| 5835 | FPOSIX=1 FSH=0 rv=0 |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 5836 | FPOSIX=1 FSH=1 rv=0 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 5837 | --- |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 5838 | name: regression-10-legacy |
| 5839 | description: |
| 5840 | The following: |
| 5841 | set -- `false` |
| 5842 | echo $? |
| 5843 | should print 0 according to POSIX (dash, bash, ksh93, posh) |
| 5844 | but not 0 according to the getopt(1) manual page, ksh88, and |
| 5845 | Bourne sh (such as /bin/sh on Solaris). |
| 5846 | category: shell:legacy-yes |
| 5847 | stdin: |
| 5848 | showf() { |
| 5849 | [[ -o posix ]]; FPOSIX=$((1-$?)) |
| 5850 | [[ -o sh ]]; FSH=$((1-$?)) |
| 5851 | echo -n "FPOSIX=$FPOSIX FSH=$FSH " |
| 5852 | } |
| 5853 | set +o posix +o sh |
| 5854 | showf |
| 5855 | set -- `false` |
| 5856 | echo rv=$? |
| 5857 | set -o sh |
| 5858 | showf |
| 5859 | set -- `false` |
| 5860 | echo rv=$? |
| 5861 | set -o posix |
| 5862 | showf |
| 5863 | set -- `false` |
| 5864 | echo rv=$? |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 5865 | set -o posix -o sh |
| 5866 | showf |
| 5867 | set -- `false` |
| 5868 | echo rv=$? |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 5869 | expected-stdout: |
| 5870 | FPOSIX=0 FSH=0 rv=1 |
| 5871 | FPOSIX=0 FSH=1 rv=1 |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 5872 | FPOSIX=1 FSH=0 rv=0 |
| 5873 | FPOSIX=1 FSH=1 rv=0 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 5874 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 5875 | name: regression-11 |
| 5876 | description: |
| 5877 | The following: |
| 5878 | x=/foo/bar/blah |
| 5879 | echo ${x##*/} |
| 5880 | should echo blah but on some machines echos /foo/bar/blah. |
| 5881 | stdin: |
| 5882 | x=/foo/bar/blah |
| 5883 | echo ${x##*/} |
| 5884 | expected-stdout: |
| 5885 | blah |
| 5886 | --- |
| 5887 | name: regression-12 |
| 5888 | description: |
| 5889 | Both of the following echos produce the same output under sh/ksh.att: |
| 5890 | #!/bin/sh |
| 5891 | x="foo bar" |
| 5892 | echo "`echo \"$x\"`" |
| 5893 | echo "`echo "$x"`" |
| 5894 | pdksh produces different output for the former (foo instead of foo\tbar) |
| 5895 | stdin: |
| 5896 | x="foo bar" |
| 5897 | echo "`echo \"$x\"`" |
| 5898 | echo "`echo "$x"`" |
| 5899 | expected-stdout: |
| 5900 | foo bar |
| 5901 | foo bar |
| 5902 | --- |
| 5903 | name: regression-13 |
| 5904 | description: |
| 5905 | The following command hangs forever: |
| 5906 | $ (: ; cat /etc/termcap) | sleep 2 |
| 5907 | This is because the shell forks a shell to run the (..) command |
| 5908 | and this shell has the pipe open. When the sleep dies, the cat |
| 5909 | doesn't get a SIGPIPE 'cause a process (ie, the second shell) |
| 5910 | still has the pipe open. |
| 5911 | |
| 5912 | NOTE: this test provokes a bizarre bug in ksh93 (shell starts reading |
| 5913 | commands from /etc/termcap..) |
| 5914 | time-limit: 10 |
| 5915 | stdin: |
| 5916 | echo A line of text that will be duplicated quite a number of times.> t1 |
| 5917 | cat t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 > t2 |
| 5918 | cat t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 > t1 |
| 5919 | cat t1 t1 t1 t1 > t2 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 5920 | (: ; cat t2 2>/dev/null) | sleep 1 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 5921 | --- |
| 5922 | name: regression-14 |
| 5923 | description: |
| 5924 | The command |
| 5925 | $ (foobar) 2> /dev/null |
| 5926 | generates no output under /bin/sh, but pdksh produces the error |
| 5927 | foobar: not found |
| 5928 | Also, the command |
| 5929 | $ foobar 2> /dev/null |
| 5930 | generates an error under /bin/sh and pdksh, but AT&T ksh88 produces |
| 5931 | no error (redirected to /dev/null). |
| 5932 | stdin: |
| 5933 | (you/should/not/see/this/error/1) 2> /dev/null |
| 5934 | you/should/not/see/this/error/2 2> /dev/null |
| 5935 | true |
| 5936 | --- |
| 5937 | name: regression-15 |
| 5938 | description: |
| 5939 | The command |
| 5940 | $ whence foobar |
| 5941 | generates a blank line under pdksh and sets the exit status to 0. |
| 5942 | AT&T ksh88 generates no output and sets the exit status to 1. Also, |
| 5943 | the command |
| 5944 | $ whence foobar cat |
| 5945 | generates no output under AT&T ksh88 (pdksh generates a blank line |
| 5946 | and /bin/cat). |
| 5947 | stdin: |
| 5948 | whence does/not/exist > /dev/null |
| 5949 | echo 1: $? |
| 5950 | echo 2: $(whence does/not/exist | wc -l) |
| 5951 | echo 3: $(whence does/not/exist cat | wc -l) |
| 5952 | expected-stdout: |
| 5953 | 1: 1 |
| 5954 | 2: 0 |
| 5955 | 3: 0 |
| 5956 | --- |
| 5957 | name: regression-16 |
| 5958 | description: |
| 5959 | ${var%%expr} seems to be broken in many places. On the mips |
| 5960 | the commands |
| 5961 | $ read line < /etc/passwd |
| 5962 | $ echo $line |
| 5963 | root:0:1:... |
| 5964 | $ echo ${line%%:*} |
| 5965 | root |
| 5966 | $ echo $line |
| 5967 | root |
| 5968 | $ |
| 5969 | change the value of line. On sun4s & pas, the echo ${line%%:*} doesn't |
| 5970 | work. Haven't checked elsewhere... |
| 5971 | script: |
| 5972 | read x |
| 5973 | y=$x |
| 5974 | echo ${x%%:*} |
| 5975 | echo $x |
| 5976 | stdin: |
| 5977 | root:asdjhasdasjhs:0:1:Root:/:/bin/sh |
| 5978 | expected-stdout: |
| 5979 | root |
| 5980 | root:asdjhasdasjhs:0:1:Root:/:/bin/sh |
| 5981 | --- |
| 5982 | name: regression-17 |
| 5983 | description: |
| 5984 | The command |
| 5985 | . /foo/bar |
| 5986 | should set the exit status to non-zero (sh and AT&T ksh88 do). |
| 5987 | XXX doting a non existent file is a fatal error for a script |
| 5988 | stdin: |
| 5989 | . does/not/exist |
| 5990 | expected-exit: e != 0 |
| 5991 | expected-stderr-pattern: /.?/ |
| 5992 | --- |
| 5993 | name: regression-19 |
| 5994 | description: |
| 5995 | Both of the following echos should produce the same thing, but don't: |
| 5996 | $ x=foo/bar |
| 5997 | $ echo ${x%/*} |
| 5998 | foo |
| 5999 | $ echo "${x%/*}" |
| 6000 | foo/bar |
| 6001 | stdin: |
| 6002 | x=foo/bar |
| 6003 | echo "${x%/*}" |
| 6004 | expected-stdout: |
| 6005 | foo |
| 6006 | --- |
| 6007 | name: regression-21 |
| 6008 | description: |
| 6009 | backslash does not work as expected in case labels: |
| 6010 | $ x='-x' |
| 6011 | $ case $x in |
| 6012 | -\?) echo hi |
| 6013 | esac |
| 6014 | hi |
| 6015 | $ x='-?' |
| 6016 | $ case $x in |
| 6017 | -\\?) echo hi |
| 6018 | esac |
| 6019 | hi |
| 6020 | $ |
| 6021 | stdin: |
| 6022 | case -x in |
| 6023 | -\?) echo fail |
| 6024 | esac |
| 6025 | --- |
| 6026 | name: regression-22 |
| 6027 | description: |
| 6028 | Quoting backquotes inside backquotes doesn't work: |
| 6029 | $ echo `echo hi \`echo there\` folks` |
| 6030 | asks for more info. sh and AT&T ksh88 both echo |
| 6031 | hi there folks |
| 6032 | stdin: |
| 6033 | echo `echo hi \`echo there\` folks` |
| 6034 | expected-stdout: |
| 6035 | hi there folks |
| 6036 | --- |
| 6037 | name: regression-23 |
| 6038 | description: |
| 6039 | )) is not treated `correctly': |
| 6040 | $ (echo hi ; (echo there ; echo folks)) |
| 6041 | missing (( |
| 6042 | $ |
| 6043 | instead of (as sh and ksh.att) |
| 6044 | $ (echo hi ; (echo there ; echo folks)) |
| 6045 | hi |
| 6046 | there |
| 6047 | folks |
| 6048 | $ |
| 6049 | stdin: |
| 6050 | ( : ; ( : ; echo hi)) |
| 6051 | expected-stdout: |
| 6052 | hi |
| 6053 | --- |
| 6054 | name: regression-25 |
| 6055 | description: |
| 6056 | Check reading stdin in a while loop. The read should only read |
| 6057 | a single line, not a whole stdio buffer; the cat should get |
| 6058 | the rest. |
| 6059 | stdin: |
| 6060 | (echo a; echo b) | while read x ; do |
| 6061 | echo $x |
| 6062 | cat > /dev/null |
| 6063 | done |
| 6064 | expected-stdout: |
| 6065 | a |
| 6066 | --- |
| 6067 | name: regression-26 |
| 6068 | description: |
| 6069 | Check reading stdin in a while loop. The read should read both |
| 6070 | lines, not just the first. |
| 6071 | script: |
| 6072 | a= |
| 6073 | while [ "$a" != xxx ] ; do |
| 6074 | last=$x |
| 6075 | read x |
| 6076 | cat /dev/null | sed 's/x/y/' |
| 6077 | a=x$a |
| 6078 | done |
| 6079 | echo $last |
| 6080 | stdin: |
| 6081 | a |
| 6082 | b |
| 6083 | expected-stdout: |
| 6084 | b |
| 6085 | --- |
| 6086 | name: regression-27 |
| 6087 | description: |
| 6088 | The command |
| 6089 | . /does/not/exist |
| 6090 | should cause a script to exit. |
| 6091 | stdin: |
| 6092 | . does/not/exist |
| 6093 | echo hi |
| 6094 | expected-exit: e != 0 |
| 6095 | expected-stderr-pattern: /does\/not\/exist/ |
| 6096 | --- |
| 6097 | name: regression-28 |
| 6098 | description: |
| 6099 | variable assignements not detected well |
| 6100 | stdin: |
| 6101 | a.x=1 echo hi |
| 6102 | expected-exit: e != 0 |
| 6103 | expected-stderr-pattern: /a\.x=1/ |
| 6104 | --- |
| 6105 | name: regression-29 |
| 6106 | description: |
| 6107 | alias expansion different from AT&T ksh88 |
| 6108 | stdin: |
| 6109 | alias a='for ' b='i in' |
| 6110 | a b hi ; do echo $i ; done |
| 6111 | expected-stdout: |
| 6112 | hi |
| 6113 | --- |
| 6114 | name: regression-30 |
| 6115 | description: |
| 6116 | strange characters allowed inside ${...} |
| 6117 | stdin: |
| 6118 | echo ${a{b}} |
| 6119 | expected-exit: e != 0 |
| 6120 | expected-stderr-pattern: /.?/ |
| 6121 | --- |
| 6122 | name: regression-31 |
| 6123 | description: |
| 6124 | Does read handle partial lines correctly |
| 6125 | script: |
| 6126 | a= ret= |
| 6127 | while [ "$a" != xxx ] ; do |
| 6128 | read x y z |
| 6129 | ret=$? |
| 6130 | a=x$a |
| 6131 | done |
| 6132 | echo "[$x]" |
| 6133 | echo $ret |
| 6134 | stdin: ! |
| 6135 | a A aA |
| 6136 | b B Bb |
| 6137 | c |
| 6138 | expected-stdout: |
| 6139 | [c] |
| 6140 | 1 |
| 6141 | --- |
| 6142 | name: regression-32 |
| 6143 | description: |
| 6144 | Does read set variables to null at eof? |
| 6145 | script: |
| 6146 | a= |
| 6147 | while [ "$a" != xxx ] ; do |
| 6148 | read x y z |
| 6149 | a=x$a |
| 6150 | done |
| 6151 | echo 1: ${x-x not set} ${y-y not set} ${z-z not set} |
| 6152 | echo 2: ${x:+x not null} ${y:+y not null} ${z:+z not null} |
| 6153 | stdin: |
| 6154 | a A Aa |
| 6155 | b B Bb |
| 6156 | expected-stdout: |
| 6157 | 1: |
| 6158 | 2: |
| 6159 | --- |
| 6160 | name: regression-33 |
| 6161 | description: |
| 6162 | Does umask print a leading 0 when umask is 3 digits? |
| 6163 | stdin: |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 6164 | # on MiNT, the first umask call seems to fail |
| 6165 | umask 022 |
| 6166 | # now, the test proper |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 6167 | umask 222 |
| 6168 | umask |
| 6169 | expected-stdout: |
| 6170 | 0222 |
| 6171 | --- |
| 6172 | name: regression-35 |
| 6173 | description: |
| 6174 | Tempory files used for here-docs in functions get trashed after |
| 6175 | the function is parsed (before it is executed) |
| 6176 | stdin: |
| 6177 | f1() { |
| 6178 | cat <<- EOF |
| 6179 | F1 |
| 6180 | EOF |
| 6181 | f2() { |
| 6182 | cat <<- EOF |
| 6183 | F2 |
| 6184 | EOF |
| 6185 | } |
| 6186 | } |
| 6187 | f1 |
| 6188 | f2 |
| 6189 | unset -f f1 |
| 6190 | f2 |
| 6191 | expected-stdout: |
| 6192 | F1 |
| 6193 | F2 |
| 6194 | F2 |
| 6195 | --- |
| 6196 | name: regression-36 |
| 6197 | description: |
| 6198 | Command substitution breaks reading in while loop |
| 6199 | (test from <sjg@void.zen.oz.au>) |
| 6200 | stdin: |
| 6201 | (echo abcdef; echo; echo 123) | |
| 6202 | while read line |
| 6203 | do |
| 6204 | # the following line breaks it |
| 6205 | c=`echo $line | wc -c` |
| 6206 | echo $c |
| 6207 | done |
| 6208 | expected-stdout: |
| 6209 | 7 |
| 6210 | 1 |
| 6211 | 4 |
| 6212 | --- |
| 6213 | name: regression-37 |
| 6214 | description: |
| 6215 | Machines with broken times() (reported by <sjg@void.zen.oz.au>) |
| 6216 | time does not report correct real time |
| 6217 | stdin: |
| 6218 | time sleep 1 |
| 6219 | expected-stderr-pattern: !/^\s*0\.0[\s\d]+real|^\s*real[\s]+0+\.0/ |
| 6220 | --- |
| 6221 | name: regression-38 |
| 6222 | description: |
| 6223 | set -e doesn't ignore exit codes for if/while/until/&&/||/!. |
| 6224 | arguments: !-e! |
| 6225 | stdin: |
| 6226 | if false; then echo hi ; fi |
| 6227 | false || true |
| 6228 | false && true |
| 6229 | while false; do echo hi; done |
| 6230 | echo ok |
| 6231 | expected-stdout: |
| 6232 | ok |
| 6233 | --- |
| 6234 | name: regression-39 |
| 6235 | description: |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 6236 | Only posh and oksh(2013-07) say âhiâ below; FreeBSD sh, |
| 6237 | GNU bash in POSIX mode, dash, ksh93, mksh donât. All of |
| 6238 | them exit 0. The POSIX behaviour is needed by BSD make. |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 6239 | stdin: |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 6240 | set -e |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 6241 | echo `false; echo hi` $(<this-file-does-not-exist) |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 6242 | echo $? |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 6243 | expected-stdout: |
| 6244 | |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 6245 | 0 |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 6246 | expected-stderr-pattern: /this-file-does-not-exist/ |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 6247 | --- |
| 6248 | name: regression-40 |
| 6249 | description: |
| 6250 | This used to cause a core dump |
| 6251 | env-setup: !RANDOM=12! |
| 6252 | stdin: |
| 6253 | echo hi |
| 6254 | expected-stdout: |
| 6255 | hi |
| 6256 | --- |
| 6257 | name: regression-41 |
| 6258 | description: |
| 6259 | foo should be set to bar (should not be empty) |
| 6260 | stdin: |
| 6261 | foo=` |
| 6262 | echo bar` |
| 6263 | echo "($foo)" |
| 6264 | expected-stdout: |
| 6265 | (bar) |
| 6266 | --- |
| 6267 | name: regression-42 |
| 6268 | description: |
| 6269 | Can't use command line assignments to assign readonly parameters. |
| 6270 | stdin: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 6271 | print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \ |
| 6272 | 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \ |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 6273 | done >env; chmod +x env; PATH=.$PATHSEP$PATH |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 6274 | foo=bar |
| 6275 | readonly foo |
| 6276 | foo=stuff env | grep '^foo' |
| 6277 | expected-exit: e != 0 |
| 6278 | expected-stderr-pattern: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 6279 | /read-only/ |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 6280 | --- |
| 6281 | name: regression-43 |
| 6282 | description: |
| 6283 | Can subshells be prefixed by redirections (historical shells allow |
| 6284 | this) |
| 6285 | stdin: |
| 6286 | < /dev/null (sed 's/^/X/') |
| 6287 | --- |
| 6288 | name: regression-45 |
| 6289 | description: |
| 6290 | Parameter assignments with [] recognised correctly |
| 6291 | stdin: |
| 6292 | FOO=*[12] |
| 6293 | BAR=abc[ |
| 6294 | MORE=[abc] |
| 6295 | JUNK=a[bc |
| 6296 | echo "<$FOO>" |
| 6297 | echo "<$BAR>" |
| 6298 | echo "<$MORE>" |
| 6299 | echo "<$JUNK>" |
| 6300 | expected-stdout: |
| 6301 | <*[12]> |
| 6302 | <abc[> |
| 6303 | <[abc]> |
| 6304 | <a[bc> |
| 6305 | --- |
| 6306 | name: regression-46 |
| 6307 | description: |
| 6308 | Check that alias expansion works in command substitutions and |
| 6309 | at the end of file. |
| 6310 | stdin: |
| 6311 | alias x='echo hi' |
| 6312 | FOO="`x` " |
| 6313 | echo "[$FOO]" |
| 6314 | x |
| 6315 | expected-stdout: |
| 6316 | [hi ] |
| 6317 | hi |
| 6318 | --- |
| 6319 | name: regression-47 |
| 6320 | description: |
| 6321 | Check that aliases are fully read. |
| 6322 | stdin: |
| 6323 | alias x='echo hi; |
| 6324 | echo there' |
| 6325 | x |
| 6326 | echo done |
| 6327 | expected-stdout: |
| 6328 | hi |
| 6329 | there |
| 6330 | done |
| 6331 | --- |
| 6332 | name: regression-48 |
| 6333 | description: |
| 6334 | Check that (here doc) temp files are not left behind after an exec. |
| 6335 | stdin: |
| 6336 | mkdir foo || exit 1 |
| 6337 | TMPDIR=$PWD/foo "$__progname" <<- 'EOF' |
| 6338 | x() { |
| 6339 | sed 's/^/X /' << E_O_F |
| 6340 | hi |
| 6341 | there |
| 6342 | folks |
| 6343 | E_O_F |
| 6344 | echo "done ($?)" |
| 6345 | } |
| 6346 | echo=echo; [ -x /bin/echo ] && echo=/bin/echo |
| 6347 | exec $echo subtest-1 hi |
| 6348 | EOF |
| 6349 | echo subtest-1 foo/* |
| 6350 | TMPDIR=$PWD/foo "$__progname" <<- 'EOF' |
| 6351 | echo=echo; [ -x /bin/echo ] && echo=/bin/echo |
| 6352 | sed 's/^/X /' << E_O_F; exec $echo subtest-2 hi |
| 6353 | a |
| 6354 | few |
| 6355 | lines |
| 6356 | E_O_F |
| 6357 | EOF |
| 6358 | echo subtest-2 foo/* |
| 6359 | expected-stdout: |
| 6360 | subtest-1 hi |
| 6361 | subtest-1 foo/* |
| 6362 | X a |
| 6363 | X few |
| 6364 | X lines |
| 6365 | subtest-2 hi |
| 6366 | subtest-2 foo/* |
| 6367 | --- |
| 6368 | name: regression-49 |
| 6369 | description: |
| 6370 | Check that unset params with attributes are reported by set, those |
| 6371 | sans attributes are not. |
| 6372 | stdin: |
| 6373 | unset FOO BAR |
| 6374 | echo X$FOO |
| 6375 | export BAR |
| 6376 | typeset -i BLAH |
| 6377 | set | grep FOO |
| 6378 | set | grep BAR |
| 6379 | set | grep BLAH |
| 6380 | expected-stdout: |
| 6381 | X |
| 6382 | BAR |
| 6383 | BLAH |
| 6384 | --- |
| 6385 | name: regression-50 |
| 6386 | description: |
| 6387 | Check that aliases do not use continuation prompt after trailing |
| 6388 | semi-colon. |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 6389 | file-setup: file 644 "envf" |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 6390 | PS1=Y |
| 6391 | PS2=X |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 6392 | env-setup: !ENV=./envf! |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 6393 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 6394 | arguments: !-i! |
| 6395 | stdin: |
| 6396 | alias foo='echo hi ; ' |
| 6397 | foo |
| 6398 | foo echo there |
| 6399 | expected-stdout: |
| 6400 | hi |
| 6401 | hi |
| 6402 | there |
| 6403 | expected-stderr: ! |
| 6404 | YYYY |
| 6405 | --- |
| 6406 | name: regression-51 |
| 6407 | description: |
| 6408 | Check that set allows both +o and -o options on same command line. |
| 6409 | stdin: |
| 6410 | set a b c |
| 6411 | set -o noglob +o allexport |
| 6412 | echo A: $*, * |
| 6413 | expected-stdout: |
| 6414 | A: a b c, * |
| 6415 | --- |
| 6416 | name: regression-52 |
| 6417 | description: |
| 6418 | Check that globbing works in pipelined commands |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 6419 | file-setup: file 644 "envf" |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 6420 | PS1=P |
| 6421 | file-setup: file 644 "abc" |
| 6422 | stuff |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 6423 | env-setup: !ENV=./envf! |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 6424 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 6425 | arguments: !-i! |
| 6426 | stdin: |
| 6427 | sed 's/^/X /' < ab* |
| 6428 | echo mark 1 |
| 6429 | sed 's/^/X /' < ab* | sed 's/^/Y /' |
| 6430 | echo mark 2 |
| 6431 | expected-stdout: |
| 6432 | X stuff |
| 6433 | mark 1 |
| 6434 | Y X stuff |
| 6435 | mark 2 |
| 6436 | expected-stderr: ! |
| 6437 | PPPPP |
| 6438 | --- |
| 6439 | name: regression-53 |
| 6440 | description: |
| 6441 | Check that getopts works in functions |
| 6442 | stdin: |
| 6443 | bfunc() { |
| 6444 | echo bfunc: enter "(args: $*; OPTIND=$OPTIND)" |
| 6445 | while getopts B oc; do |
| 6446 | case $oc in |
| 6447 | (B) |
| 6448 | echo bfunc: B option |
| 6449 | ;; |
| 6450 | (*) |
| 6451 | echo bfunc: odd option "($oc)" |
| 6452 | ;; |
| 6453 | esac |
| 6454 | done |
| 6455 | echo bfunc: leave |
| 6456 | } |
| 6457 | |
| 6458 | function kfunc { |
| 6459 | echo kfunc: enter "(args: $*; OPTIND=$OPTIND)" |
| 6460 | while getopts K oc; do |
| 6461 | case $oc in |
| 6462 | (K) |
| 6463 | echo kfunc: K option |
| 6464 | ;; |
| 6465 | (*) |
| 6466 | echo bfunc: odd option "($oc)" |
| 6467 | ;; |
| 6468 | esac |
| 6469 | done |
| 6470 | echo kfunc: leave |
| 6471 | } |
| 6472 | |
| 6473 | set -- -f -b -k -l |
| 6474 | echo "line 1: OPTIND=$OPTIND" |
| 6475 | getopts kbfl optc |
| 6476 | echo "line 2: ret=$?, optc=$optc, OPTIND=$OPTIND" |
| 6477 | bfunc -BBB blah |
| 6478 | echo "line 3: OPTIND=$OPTIND" |
| 6479 | getopts kbfl optc |
| 6480 | echo "line 4: ret=$?, optc=$optc, OPTIND=$OPTIND" |
| 6481 | kfunc -KKK blah |
| 6482 | echo "line 5: OPTIND=$OPTIND" |
| 6483 | getopts kbfl optc |
| 6484 | echo "line 6: ret=$?, optc=$optc, OPTIND=$OPTIND" |
| 6485 | echo |
| 6486 | |
| 6487 | OPTIND=1 |
| 6488 | set -- -fbkl |
| 6489 | echo "line 10: OPTIND=$OPTIND" |
| 6490 | getopts kbfl optc |
| 6491 | echo "line 20: ret=$?, optc=$optc, OPTIND=$OPTIND" |
| 6492 | bfunc -BBB blah |
| 6493 | echo "line 30: OPTIND=$OPTIND" |
| 6494 | getopts kbfl optc |
| 6495 | echo "line 40: ret=$?, optc=$optc, OPTIND=$OPTIND" |
| 6496 | kfunc -KKK blah |
| 6497 | echo "line 50: OPTIND=$OPTIND" |
| 6498 | getopts kbfl optc |
| 6499 | echo "line 60: ret=$?, optc=$optc, OPTIND=$OPTIND" |
| 6500 | expected-stdout: |
| 6501 | line 1: OPTIND=1 |
| 6502 | line 2: ret=0, optc=f, OPTIND=2 |
| 6503 | bfunc: enter (args: -BBB blah; OPTIND=2) |
| 6504 | bfunc: B option |
| 6505 | bfunc: B option |
| 6506 | bfunc: leave |
| 6507 | line 3: OPTIND=2 |
| 6508 | line 4: ret=0, optc=b, OPTIND=3 |
| 6509 | kfunc: enter (args: -KKK blah; OPTIND=1) |
| 6510 | kfunc: K option |
| 6511 | kfunc: K option |
| 6512 | kfunc: K option |
| 6513 | kfunc: leave |
| 6514 | line 5: OPTIND=3 |
| 6515 | line 6: ret=0, optc=k, OPTIND=4 |
| 6516 | |
| 6517 | line 10: OPTIND=1 |
| 6518 | line 20: ret=0, optc=f, OPTIND=2 |
| 6519 | bfunc: enter (args: -BBB blah; OPTIND=2) |
| 6520 | bfunc: B option |
| 6521 | bfunc: B option |
| 6522 | bfunc: leave |
| 6523 | line 30: OPTIND=2 |
| 6524 | line 40: ret=1, optc=?, OPTIND=2 |
| 6525 | kfunc: enter (args: -KKK blah; OPTIND=1) |
| 6526 | kfunc: K option |
| 6527 | kfunc: K option |
| 6528 | kfunc: K option |
| 6529 | kfunc: leave |
| 6530 | line 50: OPTIND=2 |
| 6531 | line 60: ret=1, optc=?, OPTIND=2 |
| 6532 | --- |
| 6533 | name: regression-54 |
| 6534 | description: |
| 6535 | Check that ; is not required before the then in if (( ... )) then ... |
| 6536 | stdin: |
| 6537 | if (( 1 )) then |
| 6538 | echo ok dparen |
| 6539 | fi |
| 6540 | if [[ -n 1 ]] then |
| 6541 | echo ok dbrackets |
| 6542 | fi |
| 6543 | expected-stdout: |
| 6544 | ok dparen |
| 6545 | ok dbrackets |
| 6546 | --- |
| 6547 | name: regression-55 |
| 6548 | description: |
| 6549 | Check ${foo:%bar} is allowed (ksh88 allows it...) |
| 6550 | stdin: |
| 6551 | x=fooXbarXblah |
| 6552 | echo 1 ${x%X*} |
| 6553 | echo 2 ${x:%X*} |
| 6554 | echo 3 ${x%%X*} |
| 6555 | echo 4 ${x:%%X*} |
| 6556 | echo 5 ${x#*X} |
| 6557 | echo 6 ${x:#*X} |
| 6558 | echo 7 ${x##*X} |
| 6559 | echo 8 ${x:##*X} |
| 6560 | expected-stdout: |
| 6561 | 1 fooXbar |
| 6562 | 2 fooXbar |
| 6563 | 3 foo |
| 6564 | 4 foo |
| 6565 | 5 barXblah |
| 6566 | 6 barXblah |
| 6567 | 7 blah |
| 6568 | 8 blah |
| 6569 | --- |
| 6570 | name: regression-57 |
| 6571 | description: |
| 6572 | Check if typeset output is correct for |
| 6573 | uninitialised array elements. |
| 6574 | stdin: |
| 6575 | typeset -i xxx[4] |
| 6576 | echo A |
| 6577 | typeset -i | grep xxx | sed 's/^/ /' |
| 6578 | echo B |
| 6579 | typeset | grep xxx | sed 's/^/ /' |
| 6580 | |
| 6581 | xxx[1]=2+5 |
| 6582 | echo M |
| 6583 | typeset -i | grep xxx | sed 's/^/ /' |
| 6584 | echo N |
| 6585 | typeset | grep xxx | sed 's/^/ /' |
| 6586 | expected-stdout: |
| 6587 | A |
| 6588 | xxx |
| 6589 | B |
| 6590 | typeset -i xxx |
| 6591 | M |
| 6592 | xxx[1]=7 |
| 6593 | N |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 6594 | set -A xxx |
| 6595 | typeset -i xxx[1] |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 6596 | --- |
| 6597 | name: regression-58 |
| 6598 | description: |
| 6599 | Check if trap exit is ok (exit not mistaken for signal name) |
| 6600 | stdin: |
| 6601 | trap 'echo hi' exit |
| 6602 | trap exit 1 |
| 6603 | expected-stdout: |
| 6604 | hi |
| 6605 | --- |
| 6606 | name: regression-59 |
| 6607 | description: |
| 6608 | Check if ${#array[*]} is calculated correctly. |
| 6609 | stdin: |
| 6610 | a[12]=hi |
| 6611 | a[8]=there |
| 6612 | echo ${#a[*]} |
| 6613 | expected-stdout: |
| 6614 | 2 |
| 6615 | --- |
| 6616 | name: regression-60 |
| 6617 | description: |
| 6618 | Check if default exit status is previous command |
| 6619 | stdin: |
| 6620 | (true; exit) |
| 6621 | echo A $? |
| 6622 | (false; exit) |
| 6623 | echo B $? |
| 6624 | ( (exit 103) ; exit) |
| 6625 | echo C $? |
| 6626 | expected-stdout: |
| 6627 | A 0 |
| 6628 | B 1 |
| 6629 | C 103 |
| 6630 | --- |
| 6631 | name: regression-61 |
| 6632 | description: |
| 6633 | Check if EXIT trap is executed for sub shells. |
| 6634 | stdin: |
| 6635 | trap 'echo parent exit' EXIT |
| 6636 | echo start |
| 6637 | (echo A; echo A last) |
| 6638 | echo B |
| 6639 | (echo C; trap 'echo sub exit' EXIT; echo C last) |
| 6640 | echo parent last |
| 6641 | expected-stdout: |
| 6642 | start |
| 6643 | A |
| 6644 | A last |
| 6645 | B |
| 6646 | C |
| 6647 | C last |
| 6648 | sub exit |
| 6649 | parent last |
| 6650 | parent exit |
| 6651 | --- |
| 6652 | name: regression-62 |
| 6653 | description: |
| 6654 | Check if test -nt/-ot succeeds if second(first) file is missing. |
| 6655 | stdin: |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 6656 | :>a |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 6657 | test a -nt b && echo nt OK || echo nt BAD |
| 6658 | test b -ot a && echo ot OK || echo ot BAD |
| 6659 | expected-stdout: |
| 6660 | nt OK |
| 6661 | ot OK |
| 6662 | --- |
| 6663 | name: regression-63 |
| 6664 | description: |
| 6665 | Check if typeset, export, and readonly work |
| 6666 | stdin: |
| 6667 | { |
| 6668 | echo FNORD-0 |
| 6669 | FNORD_A=1 |
| 6670 | FNORD_B=2 |
| 6671 | FNORD_C=3 |
| 6672 | FNORD_D=4 |
| 6673 | FNORD_E=5 |
| 6674 | FNORD_F=6 |
| 6675 | FNORD_G=7 |
| 6676 | FNORD_H=8 |
| 6677 | integer FNORD_E FNORD_F FNORD_G FNORD_H |
| 6678 | export FNORD_C FNORD_D FNORD_G FNORD_H |
| 6679 | readonly FNORD_B FNORD_D FNORD_F FNORD_H |
| 6680 | echo FNORD-1 |
| 6681 | export |
| 6682 | echo FNORD-2 |
| 6683 | export -p |
| 6684 | echo FNORD-3 |
| 6685 | readonly |
| 6686 | echo FNORD-4 |
| 6687 | readonly -p |
| 6688 | echo FNORD-5 |
| 6689 | typeset |
| 6690 | echo FNORD-6 |
| 6691 | typeset -p |
| 6692 | echo FNORD-7 |
| 6693 | typeset - |
| 6694 | echo FNORD-8 |
| 6695 | } | fgrep FNORD |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 6696 | fnord=(42 23) |
| 6697 | typeset -p fnord |
| 6698 | echo FNORD-9 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 6699 | expected-stdout: |
| 6700 | FNORD-0 |
| 6701 | FNORD-1 |
| 6702 | FNORD_C |
| 6703 | FNORD_D |
| 6704 | FNORD_G |
| 6705 | FNORD_H |
| 6706 | FNORD-2 |
| 6707 | export FNORD_C=3 |
| 6708 | export FNORD_D=4 |
| 6709 | export FNORD_G=7 |
| 6710 | export FNORD_H=8 |
| 6711 | FNORD-3 |
| 6712 | FNORD_B |
| 6713 | FNORD_D |
| 6714 | FNORD_F |
| 6715 | FNORD_H |
| 6716 | FNORD-4 |
| 6717 | readonly FNORD_B=2 |
| 6718 | readonly FNORD_D=4 |
| 6719 | readonly FNORD_F=6 |
| 6720 | readonly FNORD_H=8 |
| 6721 | FNORD-5 |
| 6722 | typeset FNORD_A |
| 6723 | typeset -r FNORD_B |
| 6724 | typeset -x FNORD_C |
| 6725 | typeset -x -r FNORD_D |
| 6726 | typeset -i FNORD_E |
| 6727 | typeset -i -r FNORD_F |
| 6728 | typeset -i -x FNORD_G |
| 6729 | typeset -i -x -r FNORD_H |
| 6730 | FNORD-6 |
| 6731 | typeset FNORD_A=1 |
| 6732 | typeset -r FNORD_B=2 |
| 6733 | typeset -x FNORD_C=3 |
| 6734 | typeset -x -r FNORD_D=4 |
| 6735 | typeset -i FNORD_E=5 |
| 6736 | typeset -i -r FNORD_F=6 |
| 6737 | typeset -i -x FNORD_G=7 |
| 6738 | typeset -i -x -r FNORD_H=8 |
| 6739 | FNORD-7 |
| 6740 | FNORD_A=1 |
| 6741 | FNORD_B=2 |
| 6742 | FNORD_C=3 |
| 6743 | FNORD_D=4 |
| 6744 | FNORD_E=5 |
| 6745 | FNORD_F=6 |
| 6746 | FNORD_G=7 |
| 6747 | FNORD_H=8 |
| 6748 | FNORD-8 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 6749 | set -A fnord |
| 6750 | typeset fnord[0]=42 |
| 6751 | typeset fnord[1]=23 |
| 6752 | FNORD-9 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 6753 | --- |
| 6754 | name: regression-64 |
| 6755 | description: |
| 6756 | Check that we can redefine functions calling time builtin |
| 6757 | stdin: |
| 6758 | t() { |
| 6759 | time >/dev/null |
| 6760 | } |
| 6761 | t 2>/dev/null |
| 6762 | t() { |
| 6763 | time |
| 6764 | } |
| 6765 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 6766 | name: regression-65 |
| 6767 | description: |
| 6768 | check for a regression with sleep builtin and signal mask |
| 6769 | category: !nojsig |
Elliott Hughes | dd4abe0 | 2018-02-05 15:55:19 -0800 | [diff] [blame] | 6770 | time-limit: 5 |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 6771 | stdin: |
| 6772 | sleep 1 |
| 6773 | echo blub |& |
| 6774 | while read -p line; do :; done |
| 6775 | echo ok |
| 6776 | expected-stdout: |
| 6777 | ok |
| 6778 | --- |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 6779 | name: regression-66 |
| 6780 | description: |
| 6781 | Check that quoting is sane |
| 6782 | category: !nojsig |
| 6783 | stdin: |
| 6784 | ac_space=' ' |
| 6785 | ac_newline=' |
| 6786 | ' |
| 6787 | set | grep ^ac_ |& |
| 6788 | set -A lines |
| 6789 | while IFS= read -pr line; do |
| 6790 | if [[ $line = *space* ]]; then |
| 6791 | lines[0]=$line |
| 6792 | else |
| 6793 | lines[1]=$line |
| 6794 | fi |
| 6795 | done |
| 6796 | for line in "${lines[@]}"; do |
| 6797 | print -r -- "$line" |
| 6798 | done |
| 6799 | expected-stdout: |
| 6800 | ac_space=' ' |
| 6801 | ac_newline=$'\n' |
| 6802 | --- |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 6803 | name: regression-67 |
| 6804 | description: |
| 6805 | Check that we can both break and use source on the same line |
| 6806 | stdin: |
| 6807 | for s in s; do break; done; print -s s |
| 6808 | --- |
| 6809 | name: regression-68 |
| 6810 | description: |
| 6811 | Check that all common arithmetic operators work as expected |
| 6812 | stdin: |
| 6813 | echo 1 $(( a = 5 )) . |
| 6814 | echo 2 $(( ++a )) , $(( a++ )) , $(( a )) . |
| 6815 | echo 3 $(( --a )) , $(( a-- )) , $(( a )) . |
| 6816 | echo 4 $(( a == 5 )) , $(( a == 6 )) . |
| 6817 | echo 5 $(( a != 5 )) , $(( a != 6 )) . |
| 6818 | echo 6 $(( a *= 3 )) . |
| 6819 | echo 7 $(( a /= 5 )) . |
| 6820 | echo 8 $(( a %= 2 )) . |
| 6821 | echo 9 $(( a += 9 )) . |
| 6822 | echo 10 $(( a -= 4 )) . |
| 6823 | echo 11 $(( a <<= 1 )) . |
| 6824 | echo 12 $(( a >>= 1 )) . |
| 6825 | echo 13 $(( a &= 4 )) . |
| 6826 | echo 14 $(( a ^= a )) . |
| 6827 | echo 15 $(( a |= 5 )) . |
| 6828 | echo 16 $(( 5 << 1 )) . |
| 6829 | echo 17 $(( 5 >> 1 )) . |
| 6830 | echo 18 $(( 5 <= 6 )) , $(( 5 <= 5 )) , $(( 5 <= 4 )) . |
| 6831 | echo 19 $(( 5 >= 6 )) , $(( 5 >= 5 )) , $(( 5 >= 4 )) . |
| 6832 | echo 20 $(( 5 < 6 )) , $(( 5 < 5 )) , $(( 5 < 4 )) . |
| 6833 | echo 21 $(( 5 > 6 )) , $(( 5 > 5 )) , $(( 5 > 4 )) . |
| 6834 | echo 22 $(( 0 && 0 )) , $(( 0 && 1 )) , $(( 1 && 0 )) , $(( 1 && 1 )) . |
| 6835 | echo 23 $(( 0 || 0 )) , $(( 0 || 1 )) , $(( 1 || 0 )) , $(( 1 || 1 )) . |
| 6836 | echo 24 $(( 5 * 3 )) . |
| 6837 | echo 25 $(( 7 / 2 )) . |
| 6838 | echo 26 $(( 5 % 5 )) , $(( 5 % 4 )) , $(( 5 % 1 )) , $(( 5 % -1 )) , $(( 5 % -2 )) . |
| 6839 | echo 27 $(( 5 + 2 )) , $(( 5 + 0 )) , $(( 5 + -2 )) . |
| 6840 | echo 28 $(( 5 - 2 )) , $(( 5 - 0 )) , $(( 5 - -2 )) . |
| 6841 | echo 29 $(( 6 & 4 )) , $(( 6 & 8 )) . |
| 6842 | echo 30 $(( 4 ^ 2 )) , $(( 4 ^ 4 )) . |
| 6843 | echo 31 $(( 4 | 2 )) , $(( 4 | 4 )) , $(( 4 | 0 )) . |
| 6844 | echo 32 $(( 0 ? 1 : 2 )) , $(( 3 ? 4 : 5 )) . |
| 6845 | echo 33 $(( 5 , 2 , 3 )) . |
| 6846 | echo 34 $(( ~0 )) , $(( ~1 )) , $(( ~~1 )) , $(( ~~2 )) . |
| 6847 | echo 35 $(( !0 )) , $(( !1 )) , $(( !!1 )) , $(( !!2 )) . |
| 6848 | echo 36 $(( (5) )) . |
| 6849 | expected-stdout: |
| 6850 | 1 5 . |
| 6851 | 2 6 , 6 , 7 . |
| 6852 | 3 6 , 6 , 5 . |
| 6853 | 4 1 , 0 . |
| 6854 | 5 0 , 1 . |
| 6855 | 6 15 . |
| 6856 | 7 3 . |
| 6857 | 8 1 . |
| 6858 | 9 10 . |
| 6859 | 10 6 . |
| 6860 | 11 12 . |
| 6861 | 12 6 . |
| 6862 | 13 4 . |
| 6863 | 14 0 . |
| 6864 | 15 5 . |
| 6865 | 16 10 . |
| 6866 | 17 2 . |
| 6867 | 18 1 , 1 , 0 . |
| 6868 | 19 0 , 1 , 1 . |
| 6869 | 20 1 , 0 , 0 . |
| 6870 | 21 0 , 0 , 1 . |
| 6871 | 22 0 , 0 , 0 , 1 . |
| 6872 | 23 0 , 1 , 1 , 1 . |
| 6873 | 24 15 . |
| 6874 | 25 3 . |
| 6875 | 26 0 , 1 , 0 , 0 , 1 . |
| 6876 | 27 7 , 5 , 3 . |
| 6877 | 28 3 , 5 , 7 . |
| 6878 | 29 4 , 0 . |
| 6879 | 30 6 , 0 . |
| 6880 | 31 6 , 4 , 4 . |
| 6881 | 32 2 , 4 . |
| 6882 | 33 3 . |
| 6883 | 34 -1 , -2 , 1 , 2 . |
| 6884 | 35 1 , 0 , 1 , 1 . |
| 6885 | 36 5 . |
| 6886 | --- |
| 6887 | name: regression-69 |
| 6888 | description: |
| 6889 | Check that all non-lksh arithmetic operators work as expected |
| 6890 | category: shell:legacy-no |
| 6891 | stdin: |
| 6892 | a=5 b=0x80000005 |
| 6893 | echo 1 $(( a ^<= 1 )) , $(( b ^<= 1 )) . |
| 6894 | echo 2 $(( a ^>= 2 )) , $(( b ^>= 2 )) . |
| 6895 | echo 3 $(( 5 ^< 1 )) . |
| 6896 | echo 4 $(( 5 ^> 1 )) . |
| 6897 | expected-stdout: |
| 6898 | 1 10 , 11 . |
| 6899 | 2 -2147483646 , -1073741822 . |
| 6900 | 3 10 . |
| 6901 | 4 -2147483646 . |
| 6902 | --- |
Elliott Hughes | 4708626 | 2019-03-26 12:34:31 -0700 | [diff] [blame] | 6903 | name: export-1 |
| 6904 | description: |
| 6905 | Check allexport works, basic |
| 6906 | stdin: |
| 6907 | qa=1 |
| 6908 | set -A qb 2 3 |
| 6909 | set -a |
| 6910 | qc=4 |
| 6911 | set -A qd 5 6 |
| 6912 | export -p | grep '^export q' |
| 6913 | expected-stdout: |
| 6914 | export qc=4 |
| 6915 | export qd[0]=5 |
| 6916 | export qd[1]=6 |
| 6917 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 6918 | name: readonly-0 |
| 6919 | description: |
| 6920 | Ensure readonly is honoured for assignments and unset |
| 6921 | stdin: |
| 6922 | "$__progname" -c 'u=x; echo $? $u .' || echo aborted, $? |
| 6923 | echo = |
| 6924 | "$__progname" -c 'readonly u; u=x; echo $? $u .' || echo aborted, $? |
| 6925 | echo = |
| 6926 | "$__progname" -c 'u=x; readonly u; unset u; echo $? $u .' || echo aborted, $? |
| 6927 | expected-stdout: |
| 6928 | 0 x . |
| 6929 | = |
| 6930 | aborted, 2 |
| 6931 | = |
| 6932 | 1 x . |
| 6933 | expected-stderr-pattern: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 6934 | /read-only/ |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 6935 | --- |
| 6936 | name: readonly-1 |
| 6937 | description: |
| 6938 | http://austingroupbugs.net/view.php?id=367 for export |
| 6939 | stdin: |
| 6940 | "$__progname" -c 'readonly foo; export foo=a; echo $?' || echo aborted, $? |
| 6941 | expected-stdout: |
| 6942 | aborted, 2 |
| 6943 | expected-stderr-pattern: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 6944 | /read-only/ |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 6945 | --- |
| 6946 | name: readonly-2a |
| 6947 | description: |
| 6948 | Check that getopts works as intended, for readonly-2b to be valid |
| 6949 | stdin: |
| 6950 | "$__progname" -c 'set -- -a b; getopts a c; echo $? $c .; getopts a c; echo $? $c .' || echo aborted, $? |
| 6951 | expected-stdout: |
| 6952 | 0 a . |
| 6953 | 1 ? . |
| 6954 | --- |
| 6955 | name: readonly-2b |
| 6956 | description: |
| 6957 | http://austingroupbugs.net/view.php?id=367 for getopts |
| 6958 | stdin: |
| 6959 | "$__progname" -c 'readonly c; set -- -a b; getopts a c; echo $? $c .' || echo aborted, $? |
| 6960 | expected-stdout: |
| 6961 | 2 . |
| 6962 | expected-stderr-pattern: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 6963 | /read-only/ |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 6964 | --- |
| 6965 | name: readonly-3 |
| 6966 | description: |
| 6967 | http://austingroupbugs.net/view.php?id=367 for read |
| 6968 | stdin: |
| 6969 | echo x | "$__progname" -c 'read s; echo $? $s .' || echo aborted, $? |
| 6970 | echo y | "$__progname" -c 'readonly s; read s; echo $? $s .' || echo aborted, $? |
| 6971 | expected-stdout: |
| 6972 | 0 x . |
| 6973 | 2 . |
| 6974 | expected-stderr-pattern: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 6975 | /read-only/ |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 6976 | --- |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 6977 | name: readonly-4 |
| 6978 | description: |
| 6979 | Do not permit bypassing readonly for first array item |
| 6980 | stdin: |
| 6981 | set -A arr -- foo bar |
| 6982 | readonly arr |
| 6983 | arr=baz |
| 6984 | print -r -- "${arr[@]}" |
| 6985 | expected-exit: e != 0 |
| 6986 | expected-stderr-pattern: |
| 6987 | /read[ -]?only/ |
| 6988 | --- |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 6989 | name: readonly-5 |
| 6990 | description: |
| 6991 | Ensure readonly is idempotent |
| 6992 | stdin: |
| 6993 | readonly x=1 |
| 6994 | readonly x |
| 6995 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 6996 | name: syntax-1 |
| 6997 | description: |
| 6998 | Check that lone ampersand is a syntax error |
| 6999 | stdin: |
| 7000 | & |
| 7001 | expected-exit: e != 0 |
| 7002 | expected-stderr-pattern: |
| 7003 | /syntax error/ |
| 7004 | --- |
| 7005 | name: xxx-quoted-newline-1 |
| 7006 | description: |
| 7007 | Check that \<newline> works inside of ${} |
| 7008 | stdin: |
| 7009 | abc=2 |
| 7010 | echo ${ab\ |
| 7011 | c} |
| 7012 | expected-stdout: |
| 7013 | 2 |
| 7014 | --- |
| 7015 | name: xxx-quoted-newline-2 |
| 7016 | description: |
| 7017 | Check that \<newline> works at the start of a here document |
| 7018 | stdin: |
| 7019 | cat << EO\ |
| 7020 | F |
| 7021 | hi |
| 7022 | EOF |
| 7023 | expected-stdout: |
| 7024 | hi |
| 7025 | --- |
| 7026 | name: xxx-quoted-newline-3 |
| 7027 | description: |
| 7028 | Check that \<newline> works at the end of a here document |
| 7029 | stdin: |
| 7030 | cat << EOF |
| 7031 | hi |
| 7032 | EO\ |
| 7033 | F |
| 7034 | expected-stdout: |
| 7035 | hi |
| 7036 | --- |
| 7037 | name: xxx-multi-assignment-cmd |
| 7038 | description: |
| 7039 | Check that assignments in a command affect subsequent assignments |
| 7040 | in the same command |
| 7041 | stdin: |
| 7042 | FOO=abc |
| 7043 | FOO=123 BAR=$FOO |
| 7044 | echo $BAR |
| 7045 | expected-stdout: |
| 7046 | 123 |
| 7047 | --- |
| 7048 | name: xxx-multi-assignment-posix-cmd |
| 7049 | description: |
| 7050 | Check that the behaviour for multiple assignments with a |
| 7051 | command name matches POSIX. See: |
| 7052 | http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925 |
| 7053 | stdin: |
| 7054 | X=a Y=b; X=$Y Y=$X "$__progname" -c 'echo 1 $X $Y .'; echo 2 $X $Y . |
| 7055 | unset X Y Z |
| 7056 | X=a Y=${X=b} Z=$X "$__progname" -c 'echo 3 $Z .' |
| 7057 | unset X Y Z |
| 7058 | X=a Y=${X=b} Z=$X; echo 4 $Z . |
| 7059 | expected-stdout: |
| 7060 | 1 b a . |
| 7061 | 2 a b . |
| 7062 | 3 b . |
| 7063 | 4 a . |
| 7064 | --- |
| 7065 | name: xxx-multi-assignment-posix-nocmd |
| 7066 | description: |
| 7067 | Check that the behaviour for multiple assignments with no |
| 7068 | command name matches POSIX (Debian #334182). See: |
| 7069 | http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925 |
| 7070 | stdin: |
| 7071 | X=a Y=b; X=$Y Y=$X; echo 1 $X $Y . |
| 7072 | expected-stdout: |
| 7073 | 1 b b . |
| 7074 | --- |
| 7075 | name: xxx-multi-assignment-posix-subassign |
| 7076 | description: |
| 7077 | Check that the behaviour for multiple assignments matches POSIX: |
| 7078 | - The assignment words shall be expanded in the current execution |
| 7079 | environment. |
| 7080 | - The assignments happen in the temporary execution environment. |
| 7081 | stdin: |
| 7082 | unset X Y Z |
| 7083 | Z=a Y=${X:=b} sh -c 'echo +$X+ +$Y+ +$Z+' |
| 7084 | echo /$X/ |
| 7085 | # Now for the special case: |
| 7086 | unset X Y Z |
| 7087 | X= Y=${X:=b} sh -c 'echo +$X+ +$Y+' |
| 7088 | echo /$X/ |
| 7089 | expected-stdout: |
| 7090 | ++ +b+ +a+ |
| 7091 | /b/ |
| 7092 | ++ +b+ |
| 7093 | /b/ |
| 7094 | --- |
| 7095 | name: xxx-exec-environment-1 |
| 7096 | description: |
| 7097 | Check to see if exec sets it's environment correctly |
| 7098 | stdin: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 7099 | print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \ |
| 7100 | 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \ |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 7101 | done >env; chmod +x env; PATH=.$PATHSEP$PATH |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7102 | FOO=bar exec env |
| 7103 | expected-stdout-pattern: |
| 7104 | /(^|.*\n)FOO=bar\n/ |
| 7105 | --- |
| 7106 | name: xxx-exec-environment-2 |
| 7107 | description: |
| 7108 | Check to make sure exec doesn't change environment if a program |
| 7109 | isn't exec-ed |
| 7110 | stdin: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 7111 | print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \ |
| 7112 | 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \ |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 7113 | done >env; chmod +x env; PATH=.$PATHSEP$PATH |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 7114 | env >bar1 |
| 7115 | FOO=bar exec; env >bar2 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7116 | cmp -s bar1 bar2 |
| 7117 | --- |
| 7118 | name: exec-function-environment-1 |
| 7119 | description: |
| 7120 | Check assignments in function calls and whether they affect |
| 7121 | the current execution environment (ksh93, SUSv4) |
| 7122 | stdin: |
| 7123 | f() { a=2; }; g() { b=3; echo y$c-; }; a=1 f; b=2; c=1 g |
| 7124 | echo x$a-$b- z$c- |
| 7125 | expected-stdout: |
| 7126 | y1- |
| 7127 | x2-3- z1- |
| 7128 | --- |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 7129 | name: exec-modern-korn-shell |
| 7130 | description: |
| 7131 | Check that exec can execute any command that makes it |
| 7132 | through syntax and parser |
| 7133 | stdin: |
| 7134 | print '#!'"$__progname"'\necho tf' >lq |
| 7135 | chmod +x lq |
| 7136 | PATH=$PWD |
| 7137 | exec 2>&1 |
| 7138 | foo() { print two; } |
| 7139 | print =1 |
| 7140 | (exec print one) |
| 7141 | print =2 |
| 7142 | (exec foo) |
| 7143 | print =3 |
| 7144 | (exec ls) |
| 7145 | print =4 |
| 7146 | (exec lq) |
| 7147 | expected-stdout-pattern: |
Elliott Hughes | 4708626 | 2019-03-26 12:34:31 -0700 | [diff] [blame] | 7148 | /=1\none\n=2\ntwo\n=3\n.*: ls: inaccessible or not found\n=4\ntf\n/ |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 7149 | --- |
| 7150 | name: exec-ksh88 |
| 7151 | description: |
| 7152 | Check that exec only executes after a PATH search |
| 7153 | arguments: !-o!posix! |
| 7154 | stdin: |
| 7155 | print '#!'"$__progname"'\necho tf' >lq |
| 7156 | chmod +x lq |
| 7157 | PATH=$PWD |
| 7158 | exec 2>&1 |
| 7159 | foo() { print two; } |
| 7160 | print =1 |
| 7161 | (exec print one) |
| 7162 | print =2 |
| 7163 | (exec foo) |
| 7164 | print =3 |
| 7165 | (exec ls) |
| 7166 | print =4 |
| 7167 | (exec lq) |
| 7168 | expected-stdout-pattern: |
Elliott Hughes | 4708626 | 2019-03-26 12:34:31 -0700 | [diff] [blame] | 7169 | /=1\n.*: print: inaccessible or not found\n=2\n.*: foo: inaccessible or not found\n=3\n.*: ls: inaccessible or not found\n=4\ntf\n/ |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 7170 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7171 | name: xxx-what-do-you-call-this-1 |
| 7172 | stdin: |
| 7173 | echo "${foo:-"a"}*" |
| 7174 | expected-stdout: |
| 7175 | a* |
| 7176 | --- |
| 7177 | name: xxx-prefix-strip-1 |
| 7178 | stdin: |
| 7179 | foo='a cdef' |
| 7180 | echo ${foo#a c} |
| 7181 | expected-stdout: |
| 7182 | def |
| 7183 | --- |
| 7184 | name: xxx-prefix-strip-2 |
| 7185 | stdin: |
| 7186 | set a c |
| 7187 | x='a cdef' |
| 7188 | echo ${x#$*} |
| 7189 | expected-stdout: |
| 7190 | def |
| 7191 | --- |
| 7192 | name: xxx-variable-syntax-1 |
| 7193 | stdin: |
| 7194 | echo ${:} |
| 7195 | expected-stderr-pattern: |
| 7196 | /bad substitution/ |
| 7197 | expected-exit: 1 |
| 7198 | --- |
| 7199 | name: xxx-variable-syntax-2 |
| 7200 | stdin: |
| 7201 | set 0 |
| 7202 | echo ${*:0} |
| 7203 | expected-stderr-pattern: |
| 7204 | /bad substitution/ |
| 7205 | expected-exit: 1 |
| 7206 | --- |
| 7207 | name: xxx-variable-syntax-3 |
| 7208 | stdin: |
| 7209 | set -A foo 0 |
| 7210 | echo ${foo[*]:0} |
| 7211 | expected-stderr-pattern: |
| 7212 | /bad substitution/ |
| 7213 | expected-exit: 1 |
| 7214 | --- |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 7215 | name: xxx-variable-syntax-4 |
| 7216 | description: |
| 7217 | Not all kinds of trims are currently impossible, check those who do |
| 7218 | stdin: |
| 7219 | foo() { |
| 7220 | echo "<$*> X${*:+ }X" |
| 7221 | } |
| 7222 | foo a b |
| 7223 | foo "" c |
| 7224 | foo "" |
| 7225 | foo "" "" |
| 7226 | IFS=: |
| 7227 | foo a b |
| 7228 | foo "" c |
| 7229 | foo "" |
| 7230 | foo "" "" |
| 7231 | IFS= |
| 7232 | foo a b |
| 7233 | foo "" c |
| 7234 | foo "" |
| 7235 | foo "" "" |
| 7236 | expected-stdout: |
| 7237 | <a b> X X |
| 7238 | < c> X X |
| 7239 | <> XX |
| 7240 | < > X X |
| 7241 | <a:b> X X |
| 7242 | <:c> X X |
| 7243 | <> XX |
| 7244 | <:> X X |
| 7245 | <ab> X X |
| 7246 | <c> X X |
| 7247 | <> XX |
| 7248 | <> XX |
| 7249 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7250 | name: xxx-substitution-eval-order |
| 7251 | description: |
| 7252 | Check order of evaluation of expressions |
| 7253 | stdin: |
| 7254 | i=1 x= y= |
| 7255 | set -A A abc def GHI j G k |
| 7256 | echo ${A[x=(i+=1)]#${A[y=(i+=2)]}} |
| 7257 | echo $x $y |
| 7258 | expected-stdout: |
| 7259 | HI |
| 7260 | 2 4 |
| 7261 | --- |
Elliott Hughes | 4708626 | 2019-03-26 12:34:31 -0700 | [diff] [blame] | 7262 | name: xxx-substitution-eval-order-2 |
| 7263 | description: |
| 7264 | Check some corner cases |
| 7265 | stdin: |
| 7266 | unset var |
| 7267 | i=42 |
| 7268 | : ${var+${q[i=777]}} required to be lazy by POSIX |
| 7269 | echo 1=$i |
| 7270 | var=meow |
| 7271 | i=42 |
| 7272 | : ${var+${q[i=777]}} eval since var is now set |
| 7273 | echo 2=$i |
| 7274 | unset var |
| 7275 | i=42 |
| 7276 | : ${var#${q[i=777]}} pattern is needed even if var is empty |
| 7277 | echo 3=$i |
| 7278 | var=meow |
| 7279 | i=42 |
| 7280 | : ${var#${q[i=777]}} |
| 7281 | echo 4=$i |
| 7282 | expected-stdout: |
| 7283 | 1=42 |
| 7284 | 2=777 |
| 7285 | 3=777 |
| 7286 | 4=777 |
| 7287 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7288 | name: xxx-set-option-1 |
| 7289 | description: |
| 7290 | Check option parsing in set |
| 7291 | stdin: |
| 7292 | set -vsA foo -- A 1 3 2 |
| 7293 | echo ${foo[*]} |
| 7294 | expected-stderr: |
| 7295 | echo ${foo[*]} |
| 7296 | expected-stdout: |
| 7297 | 1 2 3 A |
| 7298 | --- |
| 7299 | name: xxx-exec-1 |
| 7300 | description: |
| 7301 | Check that exec exits for built-ins |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 7302 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7303 | arguments: !-i! |
| 7304 | stdin: |
| 7305 | exec echo hi |
| 7306 | echo still herre |
| 7307 | expected-stdout: |
| 7308 | hi |
| 7309 | expected-stderr-pattern: /.*/ |
| 7310 | --- |
| 7311 | name: xxx-while-1 |
| 7312 | description: |
| 7313 | Check the return value of while loops |
| 7314 | XXX need to do same for for/select/until loops |
| 7315 | stdin: |
| 7316 | i=x |
| 7317 | while [ $i != xxx ] ; do |
| 7318 | i=x$i |
| 7319 | if [ $i = xxx ] ; then |
| 7320 | false |
| 7321 | continue |
| 7322 | fi |
| 7323 | done |
| 7324 | echo loop1=$? |
| 7325 | |
| 7326 | i=x |
| 7327 | while [ $i != xxx ] ; do |
| 7328 | i=x$i |
| 7329 | if [ $i = xxx ] ; then |
| 7330 | false |
| 7331 | break |
| 7332 | fi |
| 7333 | done |
| 7334 | echo loop2=$? |
| 7335 | |
| 7336 | i=x |
| 7337 | while [ $i != xxx ] ; do |
| 7338 | i=x$i |
| 7339 | false |
| 7340 | done |
| 7341 | echo loop3=$? |
| 7342 | expected-stdout: |
| 7343 | loop1=0 |
| 7344 | loop2=0 |
| 7345 | loop3=1 |
| 7346 | --- |
| 7347 | name: xxx-status-1 |
| 7348 | description: |
| 7349 | Check that blank lines don't clear $? |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 7350 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7351 | arguments: !-i! |
| 7352 | stdin: |
| 7353 | (exit 1) |
| 7354 | echo $? |
| 7355 | (exit 1) |
| 7356 | |
| 7357 | echo $? |
| 7358 | true |
| 7359 | expected-stdout: |
| 7360 | 1 |
| 7361 | 1 |
| 7362 | expected-stderr-pattern: /.*/ |
| 7363 | --- |
| 7364 | name: xxx-status-2 |
| 7365 | description: |
| 7366 | Check that $? is preserved in subshells, includes, traps. |
| 7367 | stdin: |
| 7368 | (exit 1) |
| 7369 | |
| 7370 | echo blank: $? |
| 7371 | |
| 7372 | (exit 2) |
| 7373 | (echo subshell: $?) |
| 7374 | |
| 7375 | echo 'echo include: $?' > foo |
| 7376 | (exit 3) |
| 7377 | . ./foo |
| 7378 | |
| 7379 | trap 'echo trap: $?' ERR |
| 7380 | (exit 4) |
| 7381 | echo exit: $? |
| 7382 | expected-stdout: |
| 7383 | blank: 1 |
| 7384 | subshell: 2 |
| 7385 | include: 3 |
| 7386 | trap: 4 |
| 7387 | exit: 4 |
| 7388 | --- |
Elliott Hughes | 4708626 | 2019-03-26 12:34:31 -0700 | [diff] [blame] | 7389 | name: xxx-stat-1 |
| 7390 | description: |
| 7391 | Check that tests on files are consistent |
| 7392 | stdin: |
| 7393 | mkdir a |
| 7394 | echo x >a/b |
| 7395 | test -e a/b; echo 1e $? . |
| 7396 | test -f a/b; echo 1f $? . |
| 7397 | chmod 0 a |
| 7398 | test -e a/b; echo 2e $? . |
| 7399 | test -f a/b; echo 2f $? . |
| 7400 | chmod 700 a |
| 7401 | test -e a/b; echo 3e $? . |
| 7402 | test -f a/b; echo 3f $? . |
| 7403 | expected-stdout: |
| 7404 | 1e 0 . |
| 7405 | 1f 0 . |
| 7406 | 2e 1 . |
| 7407 | 2f 1 . |
| 7408 | 3e 0 . |
| 7409 | 3f 0 . |
| 7410 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7411 | name: xxx-clean-chars-1 |
| 7412 | description: |
| 7413 | Check MAGIC character is stuffed correctly |
| 7414 | stdin: |
| 7415 | echo `echo [£` |
| 7416 | expected-stdout: |
| 7417 | [£ |
| 7418 | --- |
| 7419 | name: xxx-param-subst-qmark-1 |
| 7420 | description: |
| 7421 | Check suppresion of error message with null string. According to |
| 7422 | POSIX, it shouldn't print the error as 'word' isn't ommitted. |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 7423 | ksh88/93, Solaris /bin/sh and /usr/xpg4/bin/sh all print the error. |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7424 | stdin: |
| 7425 | unset foo |
| 7426 | x= |
| 7427 | echo x${foo?$x} |
| 7428 | expected-exit: 1 |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 7429 | expected-stderr-pattern: !/not set/ |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7430 | --- |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 7431 | name: xxx-param-subst-qmark-namespec |
| 7432 | description: |
| 7433 | Check special names are output correctly |
| 7434 | stdin: |
| 7435 | doit() { |
| 7436 | "$__progname" -c "$@" >o1 2>o2 |
| 7437 | rv=$? |
| 7438 | echo RETVAL: $rv |
| 7439 | sed -e "s^${__progname%.exe}\.*e*x*e*: PROG: " -e 's/^/STDOUT: /g' <o1 |
| 7440 | sed -e "s^${__progname%.exe}\.*e*x*e*: PROG: " -e 's/^/STDERR: /g' <o2 |
| 7441 | } |
| 7442 | doit 'echo ${1x}' |
| 7443 | doit 'echo "${1x}"' |
| 7444 | doit 'echo ${1?}' |
| 7445 | doit 'echo ${19?}' |
| 7446 | doit 'echo ${!:?}' |
| 7447 | doit -u 'echo ${*:?}' foo "" |
| 7448 | expected-stdout: |
| 7449 | RETVAL: 1 |
| 7450 | STDERR: PROG: ${1x}: bad substitution |
| 7451 | RETVAL: 1 |
| 7452 | STDERR: PROG: ${1x}: bad substitution |
| 7453 | RETVAL: 1 |
| 7454 | STDERR: PROG: 1: parameter null or not set |
| 7455 | RETVAL: 1 |
| 7456 | STDERR: PROG: 19: parameter null or not set |
| 7457 | RETVAL: 1 |
| 7458 | STDERR: PROG: !: parameter null or not set |
| 7459 | RETVAL: 1 |
| 7460 | STDERR: foo: ${*:?}: bad substitution |
| 7461 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7462 | name: xxx-param-_-1 |
| 7463 | # fails due to weirdness of execv stuff |
| 7464 | category: !os:uwin-nt |
| 7465 | description: |
| 7466 | Check c flag is set. |
| 7467 | arguments: !-c!echo "[$-]"! |
| 7468 | expected-stdout-pattern: /^\[.*c.*\]$/ |
| 7469 | --- |
| 7470 | name: tilde-expand-1 |
| 7471 | description: |
| 7472 | Check tilde expansion after equal signs |
| 7473 | env-setup: !HOME=/sweet! |
| 7474 | stdin: |
| 7475 | echo ${A=a=}~ b=~ c=d~ ~ |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 7476 | export e=~ f=d~ |
| 7477 | command command export g=~ h=d~ |
| 7478 | echo ". $e . $f ." |
| 7479 | echo ". $g . $h ." |
| 7480 | set -o posix |
| 7481 | unset A e f g h |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7482 | echo ${A=a=}~ b=~ c=d~ ~ |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 7483 | export e=~ f=d~ |
| 7484 | command command export g=~ h=d~ |
| 7485 | echo ". $e . $f ." |
| 7486 | echo ". $g . $h ." |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7487 | expected-stdout: |
| 7488 | a=/sweet b=/sweet c=d~ /sweet |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 7489 | . /sweet . d~ . |
| 7490 | . /sweet . d~ . |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7491 | a=~ b=~ c=d~ /sweet |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 7492 | . /sweet . d~ . |
| 7493 | . /sweet . d~ . |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7494 | --- |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 7495 | name: tilde-expand-2 |
| 7496 | description: |
| 7497 | Check tilde expansion works |
| 7498 | env-setup: !HOME=/sweet! |
| 7499 | stdin: |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 7500 | :>'c=a' |
| 7501 | typeset c=[ab] |
| 7502 | :>'d=a' |
| 7503 | x=typeset; $x d=[ab] |
| 7504 | echo "<$c>" "<$d>" |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 7505 | wd=$PWD |
| 7506 | cd / |
| 7507 | plus=$(print -r -- ~+) |
| 7508 | minus=$(print -r -- ~-) |
| 7509 | nix=$(print -r -- ~) |
| 7510 | [[ $plus = / ]]; echo one $? . |
| 7511 | [[ $minus = "$wd" ]]; echo two $? . |
| 7512 | [[ $nix = /sweet ]]; echo nix $? . |
| 7513 | expected-stdout: |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 7514 | <[ab]> <a> |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 7515 | one 0 . |
| 7516 | two 0 . |
| 7517 | nix 0 . |
| 7518 | --- |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 7519 | name: tilde-expand-3 |
| 7520 | description: |
| 7521 | Check mostly Austin 351 stuff |
| 7522 | stdin: |
| 7523 | showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } |
| 7524 | set "1 b=2" "3 d=4" |
| 7525 | export a=$1 \c=$2 |
| 7526 | showargs 1 "$a" "$b" "$c" "$d" |
| 7527 | unset a b c d |
| 7528 | HOME=/tmp |
| 7529 | export \a=~ b=~ |
| 7530 | command export c=~ |
| 7531 | builtin export d=~ |
| 7532 | \\builtin export e=~ |
| 7533 | showargs 2 "$a" "$b" "$c" "$d" "$e" ksh |
| 7534 | unset a b c d e |
| 7535 | set -o posix |
| 7536 | export \a=~ b=~ |
| 7537 | command export c=~ |
| 7538 | builtin export d=~ |
| 7539 | \\builtin export e=~ |
| 7540 | showargs 3 "$a" "$b" "$c" "$d" "$e" posix |
| 7541 | unset a b c d e |
| 7542 | set +o posix |
| 7543 | export a=$1 |
| 7544 | showargs 4 "$a" "$b" ksh |
| 7545 | unset a b |
| 7546 | showargs 5 a=$1 ksh |
| 7547 | export \a=$1 |
| 7548 | showargs 6 "$a" "$b" ksh |
| 7549 | unset a b |
| 7550 | set -o posix |
| 7551 | export a=$1 |
| 7552 | showargs 7 "$a" "$b" posix |
| 7553 | unset a b |
| 7554 | showargs 8 a=$1 posix |
| 7555 | export \a=$1 |
| 7556 | showargs 9 "$a" "$b" posix |
| 7557 | unset a b |
| 7558 | set +o posix |
| 7559 | command echo 10 ksh a=~ |
| 7560 | command command export a=~ |
| 7561 | showargs 11 "$a" |
| 7562 | unset a |
| 7563 | set -o posix |
| 7564 | command echo 12 posix a=~ |
| 7565 | command command export a=~ |
| 7566 | showargs 13 "$a" |
| 7567 | unset a |
| 7568 | # unspecified whether /tmp or ~ |
| 7569 | var=export; command $var a=~ |
| 7570 | showargs 14 "$a" |
| 7571 | echo 'echo "<$foo>"' >bar |
| 7572 | "$__progname" bar |
| 7573 | var=foo |
| 7574 | export $var=1 |
| 7575 | "$__progname" bar |
| 7576 | export $var=~ |
| 7577 | "$__progname" bar |
| 7578 | # unspecified |
| 7579 | command -- export a=~ |
| 7580 | showargs 18 "$a" |
| 7581 | set -A bla |
| 7582 | typeset bla[1]=~:~ |
| 7583 | global gbl=~ g2=$1 |
| 7584 | local lcl=~ l2=$1 |
| 7585 | readonly ro=~ r2=$1 |
| 7586 | showargs 19 "${bla[1]}" a=~ "$gbl" "$lcl" "$ro" "$g2" "$l2" "$r2" |
| 7587 | set +o posix |
| 7588 | echo "20 some arbitrary stuff "=~ |
| 7589 | set -o posix |
| 7590 | echo "21 some arbitrary stuff "=~ |
| 7591 | expected-stdout: |
| 7592 | <1> <1 b=2> <> <3> <4> . |
| 7593 | <2> </tmp> </tmp> </tmp> </tmp> </tmp> <ksh> . |
| 7594 | <3> <~> </tmp> </tmp> <~> </tmp> <posix> . |
| 7595 | <4> <1 b=2> <> <ksh> . |
| 7596 | <5> <a=1> <b=2> <ksh> . |
| 7597 | <6> <1> <2> <ksh> . |
| 7598 | <7> <1 b=2> <> <posix> . |
| 7599 | <8> <a=1> <b=2> <posix> . |
| 7600 | <9> <1> <2> <posix> . |
| 7601 | 10 ksh a=/tmp |
| 7602 | <11> </tmp> . |
| 7603 | 12 posix a=~ |
| 7604 | <13> </tmp> . |
| 7605 | <14> <~> . |
| 7606 | <> |
| 7607 | <1> |
| 7608 | <~> |
| 7609 | <18> <~> . |
| 7610 | <19> </tmp:/tmp> <a=~> </tmp> </tmp> </tmp> <1 b=2> <1 b=2> <1 b=2> . |
| 7611 | 20 some arbitrary stuff =/tmp |
| 7612 | 21 some arbitrary stuff =~ |
| 7613 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7614 | name: exit-err-1 |
| 7615 | description: |
| 7616 | Check some "exit on error" conditions |
| 7617 | stdin: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 7618 | print '#!'"$__progname"'\nexec "$1"' >env |
| 7619 | print '#!'"$__progname"'\nexit 1' >false |
| 7620 | chmod +x env false |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 7621 | PATH=.$PATHSEP$PATH |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7622 | set -ex |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 7623 | env false && echo something |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7624 | echo END |
| 7625 | expected-stdout: |
| 7626 | END |
| 7627 | expected-stderr: |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 7628 | + env false |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7629 | + echo END |
| 7630 | --- |
| 7631 | name: exit-err-2 |
| 7632 | description: |
| 7633 | Check some "exit on error" edge conditions (POSIXly) |
| 7634 | stdin: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 7635 | print '#!'"$__progname"'\nexec "$1"' >env |
| 7636 | print '#!'"$__progname"'\nexit 1' >false |
| 7637 | print '#!'"$__progname"'\nexit 0' >true |
| 7638 | chmod +x env false |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 7639 | PATH=.$PATHSEP$PATH |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7640 | set -ex |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 7641 | if env true; then |
| 7642 | env false && echo something |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7643 | fi |
| 7644 | echo END |
| 7645 | expected-stdout: |
| 7646 | END |
| 7647 | expected-stderr: |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 7648 | + env true |
| 7649 | + env false |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7650 | + echo END |
| 7651 | --- |
| 7652 | name: exit-err-3 |
| 7653 | description: |
| 7654 | pdksh regression which AT&T ksh does right |
| 7655 | TFM says: [set] -e | errexit |
| 7656 | Exit (after executing the ERR trap) ... |
| 7657 | stdin: |
| 7658 | trap 'echo EXIT' EXIT |
| 7659 | trap 'echo ERR' ERR |
| 7660 | set -e |
| 7661 | cd /XXXXX 2>/dev/null |
| 7662 | echo DONE |
| 7663 | exit 0 |
| 7664 | expected-stdout: |
| 7665 | ERR |
| 7666 | EXIT |
| 7667 | expected-exit: e != 0 |
| 7668 | --- |
| 7669 | name: exit-err-4 |
| 7670 | description: |
| 7671 | "set -e" test suite (POSIX) |
| 7672 | stdin: |
| 7673 | set -e |
| 7674 | echo pre |
| 7675 | if true ; then |
| 7676 | false && echo foo |
| 7677 | fi |
| 7678 | echo bar |
| 7679 | expected-stdout: |
| 7680 | pre |
| 7681 | bar |
| 7682 | --- |
| 7683 | name: exit-err-5 |
| 7684 | description: |
| 7685 | "set -e" test suite (POSIX) |
| 7686 | stdin: |
| 7687 | set -e |
| 7688 | foo() { |
| 7689 | while [ "$1" ]; do |
| 7690 | for E in $x; do |
| 7691 | [ "$1" = "$E" ] && { shift ; continue 2 ; } |
| 7692 | done |
| 7693 | x="$x $1" |
| 7694 | shift |
| 7695 | done |
| 7696 | echo $x |
| 7697 | } |
| 7698 | echo pre |
| 7699 | foo a b b c |
| 7700 | echo post |
| 7701 | expected-stdout: |
| 7702 | pre |
| 7703 | a b c |
| 7704 | post |
| 7705 | --- |
| 7706 | name: exit-err-6 |
| 7707 | description: |
| 7708 | "set -e" test suite (BSD make) |
| 7709 | category: os:mirbsd |
| 7710 | stdin: |
| 7711 | mkdir zd zd/a zd/b |
| 7712 | print 'all:\n\t@echo eins\n\t@exit 42\n' >zd/a/Makefile |
| 7713 | print 'all:\n\t@echo zwei\n' >zd/b/Makefile |
| 7714 | wd=$(pwd) |
| 7715 | set -e |
| 7716 | 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" |
| 7717 | expected-stdout: |
| 7718 | ===> a |
| 7719 | eins |
| 7720 | *** Error code 42 |
| 7721 | |
| 7722 | Stop in WD/zd/a (line 2 of Makefile). |
| 7723 | --- |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 7724 | name: exit-err-7 |
| 7725 | description: |
| 7726 | "set -e" regression (LP#1104543) |
| 7727 | stdin: |
| 7728 | set -e |
| 7729 | bla() { |
| 7730 | [ -x $PWD/nonexistant ] && $PWD/nonexistant |
| 7731 | } |
| 7732 | echo x |
| 7733 | bla |
| 7734 | echo y$? |
| 7735 | expected-stdout: |
| 7736 | x |
| 7737 | expected-exit: 1 |
| 7738 | --- |
| 7739 | name: exit-err-8 |
| 7740 | description: |
| 7741 | "set -e" regression (Debian #700526) |
| 7742 | stdin: |
| 7743 | set -e |
| 7744 | _db_cmd() { return $1; } |
| 7745 | db_input() { _db_cmd 30; } |
| 7746 | db_go() { _db_cmd 0; } |
| 7747 | db_input || : |
| 7748 | db_go |
| 7749 | exit 0 |
| 7750 | --- |
Elliott Hughes | 966dd55 | 2016-12-08 15:56:04 -0800 | [diff] [blame] | 7751 | name: exit-err-9 |
| 7752 | description: |
| 7753 | "set -e" versus bang pipelines |
| 7754 | stdin: |
| 7755 | set -e |
| 7756 | ! false | false |
| 7757 | echo 1 ok |
| 7758 | ! false && false |
| 7759 | echo 2 wrong |
| 7760 | expected-stdout: |
| 7761 | 1 ok |
| 7762 | expected-exit: 1 |
| 7763 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7764 | name: exit-enoent-1 |
| 7765 | description: |
| 7766 | SUSv4 says that the shell should exit with 126/127 in some situations |
| 7767 | stdin: |
| 7768 | i=0 |
| 7769 | (echo; echo :) >x |
| 7770 | "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r . |
| 7771 | "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r . |
| 7772 | echo exit 42 >x |
| 7773 | "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r . |
| 7774 | "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r . |
| 7775 | rm -f x |
| 7776 | "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r . |
| 7777 | "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r . |
| 7778 | expected-stdout: |
| 7779 | 0 0 . |
| 7780 | 1 126 . |
| 7781 | 2 42 . |
| 7782 | 3 126 . |
| 7783 | 4 127 . |
| 7784 | 5 127 . |
| 7785 | --- |
| 7786 | name: exit-eval-1 |
| 7787 | description: |
| 7788 | Check eval vs substitution exit codes (ksh93 alike) |
| 7789 | stdin: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 7790 | (exit 12) |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7791 | eval $(false) |
| 7792 | echo A $? |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 7793 | (exit 12) |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7794 | eval ' $(false)' |
| 7795 | echo B $? |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 7796 | (exit 12) |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7797 | eval " $(false)" |
| 7798 | echo C $? |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 7799 | (exit 12) |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7800 | eval "eval $(false)" |
| 7801 | echo D $? |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 7802 | (exit 12) |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7803 | eval 'eval '"$(false)" |
| 7804 | echo E $? |
| 7805 | IFS="$IFS:" |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 7806 | (exit 12) |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7807 | eval $(echo :; false) |
| 7808 | echo F $? |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 7809 | echo -n "G " |
| 7810 | (exit 12) |
| 7811 | eval 'echo $?' |
| 7812 | echo H $? |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7813 | expected-stdout: |
| 7814 | A 0 |
| 7815 | B 1 |
| 7816 | C 0 |
| 7817 | D 0 |
| 7818 | E 0 |
| 7819 | F 0 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 7820 | G 12 |
| 7821 | H 0 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 7822 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 7823 | name: exit-trap-1 |
| 7824 | description: |
| 7825 | Check that "exit" with no arguments behaves SUSv4 conformant. |
| 7826 | stdin: |
| 7827 | trap 'echo hi; exit' EXIT |
| 7828 | exit 9 |
| 7829 | expected-stdout: |
| 7830 | hi |
| 7831 | expected-exit: 9 |
| 7832 | --- |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 7833 | name: exit-trap-2 |
| 7834 | description: |
| 7835 | Check that ERR and EXIT traps are run just like ksh93 does. |
| 7836 | GNU bash does not run ERtrap in ±e eval-undef but runs it |
| 7837 | twice (bug?) in +e eval-false, so does ksh93 (bug?), which |
| 7838 | also has a bug to continue execution (echoing "and out" and |
| 7839 | returning 0) in +e eval-undef. |
| 7840 | file-setup: file 644 "x" |
| 7841 | v=; unset v |
| 7842 | trap 'echo EXtrap' EXIT |
| 7843 | trap 'echo ERtrap' ERR |
| 7844 | set $1 |
| 7845 | echo "and run $2" |
| 7846 | eval $2 |
| 7847 | echo and out |
| 7848 | file-setup: file 644 "xt" |
| 7849 | v=; unset v |
| 7850 | trap 'echo EXtrap' EXIT |
| 7851 | trap 'echo ERtrap' ERR |
| 7852 | set $1 |
| 7853 | echo 'and run true' |
| 7854 | true |
| 7855 | echo and out |
| 7856 | file-setup: file 644 "xf" |
| 7857 | v=; unset v |
| 7858 | trap 'echo EXtrap' EXIT |
| 7859 | trap 'echo ERtrap' ERR |
| 7860 | set $1 |
| 7861 | echo 'and run false' |
| 7862 | false |
| 7863 | echo and out |
| 7864 | file-setup: file 644 "xu" |
| 7865 | v=; unset v |
| 7866 | trap 'echo EXtrap' EXIT |
| 7867 | trap 'echo ERtrap' ERR |
| 7868 | set $1 |
| 7869 | echo 'and run ${v?}' |
| 7870 | ${v?} |
| 7871 | echo and out |
| 7872 | stdin: |
| 7873 | runtest() { |
| 7874 | rm -f rc |
| 7875 | ( |
| 7876 | "$__progname" "$@" |
| 7877 | echo $? >rc |
| 7878 | ) 2>&1 | sed \ |
| 7879 | -e 's/parameter not set/parameter null or not set/' \ |
| 7880 | -e 's/[[]6]//' -e 's/: eval: line 1//' -e 's/: line 6//' \ |
| 7881 | -e "s^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]PROG" |
| 7882 | } |
| 7883 | xe=-e |
| 7884 | echo : $xe |
| 7885 | runtest x $xe true |
| 7886 | echo = eval-true $(<rc) . |
| 7887 | runtest x $xe false |
| 7888 | echo = eval-false $(<rc) . |
| 7889 | runtest x $xe '${v?}' |
| 7890 | echo = eval-undef $(<rc) . |
| 7891 | runtest xt $xe |
| 7892 | echo = noeval-true $(<rc) . |
| 7893 | runtest xf $xe |
| 7894 | echo = noeval-false $(<rc) . |
| 7895 | runtest xu $xe |
| 7896 | echo = noeval-undef $(<rc) . |
| 7897 | xe=+e |
| 7898 | echo : $xe |
| 7899 | runtest x $xe true |
| 7900 | echo = eval-true $(<rc) . |
| 7901 | runtest x $xe false |
| 7902 | echo = eval-false $(<rc) . |
| 7903 | runtest x $xe '${v?}' |
| 7904 | echo = eval-undef $(<rc) . |
| 7905 | runtest xt $xe |
| 7906 | echo = noeval-true $(<rc) . |
| 7907 | runtest xf $xe |
| 7908 | echo = noeval-false $(<rc) . |
| 7909 | runtest xu $xe |
| 7910 | echo = noeval-undef $(<rc) . |
| 7911 | expected-stdout: |
| 7912 | : -e |
| 7913 | and run true |
| 7914 | and out |
| 7915 | EXtrap |
| 7916 | = eval-true 0 . |
| 7917 | and run false |
| 7918 | ERtrap |
| 7919 | EXtrap |
| 7920 | = eval-false 1 . |
| 7921 | and run ${v?} |
| 7922 | x: v: parameter null or not set |
| 7923 | ERtrap |
| 7924 | EXtrap |
| 7925 | = eval-undef 1 . |
| 7926 | and run true |
| 7927 | and out |
| 7928 | EXtrap |
| 7929 | = noeval-true 0 . |
| 7930 | and run false |
| 7931 | ERtrap |
| 7932 | EXtrap |
| 7933 | = noeval-false 1 . |
| 7934 | and run ${v?} |
| 7935 | xu: v: parameter null or not set |
| 7936 | EXtrap |
| 7937 | = noeval-undef 1 . |
| 7938 | : +e |
| 7939 | and run true |
| 7940 | and out |
| 7941 | EXtrap |
| 7942 | = eval-true 0 . |
| 7943 | and run false |
| 7944 | ERtrap |
| 7945 | and out |
| 7946 | EXtrap |
| 7947 | = eval-false 0 . |
| 7948 | and run ${v?} |
| 7949 | x: v: parameter null or not set |
| 7950 | ERtrap |
| 7951 | EXtrap |
| 7952 | = eval-undef 1 . |
| 7953 | and run true |
| 7954 | and out |
| 7955 | EXtrap |
| 7956 | = noeval-true 0 . |
| 7957 | and run false |
| 7958 | ERtrap |
| 7959 | and out |
| 7960 | EXtrap |
| 7961 | = noeval-false 0 . |
| 7962 | and run ${v?} |
| 7963 | xu: v: parameter null or not set |
| 7964 | EXtrap |
| 7965 | = noeval-undef 1 . |
| 7966 | --- |
Elliott Hughes | 4708626 | 2019-03-26 12:34:31 -0700 | [diff] [blame] | 7967 | name: exit-trap-3 |
| 7968 | description: |
| 7969 | Check that the EXIT trap is run in many places, Debian #910276 |
| 7970 | stdin: |
| 7971 | fkt() { |
| 7972 | trap -- "echo $1 >&2" EXIT |
| 7973 | } |
| 7974 | fkt shell_exit |
| 7975 | $(fkt fn_exit) |
| 7976 | $(trap -- "echo comsub_exit >&2" EXIT) |
| 7977 | (trap -- "echo subshell_exit >&2" EXIT) |
| 7978 | expected-stderr: |
| 7979 | fn_exit |
| 7980 | comsub_exit |
| 7981 | subshell_exit |
| 7982 | shell_exit |
| 7983 | --- |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 7984 | name: exit-trap-interactive |
| 7985 | description: |
| 7986 | Check that interactive shell doesn't exit via EXIT trap on syntax error |
| 7987 | arguments: !-i! |
| 7988 | stdin: |
| 7989 | trap -- EXIT |
| 7990 | echo Syntax error < |
| 7991 | echo 'After error 1' |
| 7992 | trap 'echo Exit trap' EXIT |
| 7993 | echo Syntax error < |
| 7994 | echo 'After error 2' |
| 7995 | trap 'echo Exit trap' EXIT |
| 7996 | exit |
| 7997 | echo 'After exit' |
| 7998 | expected-stdout: |
| 7999 | After error 1 |
| 8000 | After error 2 |
| 8001 | Exit trap |
| 8002 | expected-stderr-pattern: |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 8003 | /syntax error: unexpected 'newline'/ |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 8004 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8005 | name: test-stlt-1 |
| 8006 | description: |
| 8007 | Check that test also can handle string1 < string2 etc. |
| 8008 | stdin: |
| 8009 | test 2005/10/08 '<' 2005/08/21 && echo ja || echo nein |
| 8010 | test 2005/08/21 \< 2005/10/08 && echo ja || echo nein |
| 8011 | test 2005/10/08 '>' 2005/08/21 && echo ja || echo nein |
| 8012 | test 2005/08/21 \> 2005/10/08 && echo ja || echo nein |
| 8013 | expected-stdout: |
| 8014 | nein |
| 8015 | ja |
| 8016 | ja |
| 8017 | nein |
| 8018 | expected-stderr-pattern: !/unexpected op/ |
| 8019 | --- |
| 8020 | name: test-precedence-1 |
| 8021 | description: |
| 8022 | Check a weird precedence case (and POSIX echo) |
| 8023 | stdin: |
| 8024 | test \( -f = -f \) |
| 8025 | rv=$? |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 8026 | echo $rv |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8027 | expected-stdout: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 8028 | 0 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8029 | --- |
| 8030 | name: test-option-1 |
| 8031 | description: |
| 8032 | Test the test -o operator |
| 8033 | stdin: |
| 8034 | runtest() { |
| 8035 | test -o $1; echo $? |
| 8036 | [ -o $1 ]; echo $? |
| 8037 | [[ -o $1 ]]; echo $? |
| 8038 | } |
| 8039 | if_test() { |
| 8040 | test -o $1 -o -o !$1; echo $? |
| 8041 | [ -o $1 -o -o !$1 ]; echo $? |
| 8042 | [[ -o $1 || -o !$1 ]]; echo $? |
| 8043 | test -o ?$1; echo $? |
| 8044 | } |
| 8045 | echo 0y $(if_test utf8-mode) = |
| 8046 | echo 0n $(if_test utf8-hack) = |
| 8047 | echo 1= $(runtest utf8-hack) = |
| 8048 | echo 2= $(runtest !utf8-hack) = |
| 8049 | echo 3= $(runtest ?utf8-hack) = |
| 8050 | set +U |
| 8051 | echo 1+ $(runtest utf8-mode) = |
| 8052 | echo 2+ $(runtest !utf8-mode) = |
| 8053 | echo 3+ $(runtest ?utf8-mode) = |
| 8054 | set -U |
| 8055 | echo 1- $(runtest utf8-mode) = |
| 8056 | echo 2- $(runtest !utf8-mode) = |
| 8057 | echo 3- $(runtest ?utf8-mode) = |
| 8058 | echo = short flags = |
| 8059 | echo 0y $(if_test -U) = |
| 8060 | echo 0y $(if_test +U) = |
| 8061 | echo 0n $(if_test -_) = |
| 8062 | echo 0n $(if_test -U-) = |
| 8063 | echo 1= $(runtest -_) = |
| 8064 | echo 2= $(runtest !-_) = |
| 8065 | echo 3= $(runtest ?-_) = |
| 8066 | set +U |
| 8067 | echo 1+ $(runtest -U) = |
| 8068 | echo 2+ $(runtest !-U) = |
| 8069 | echo 3+ $(runtest ?-U) = |
| 8070 | echo 1+ $(runtest +U) = |
| 8071 | echo 2+ $(runtest !+U) = |
| 8072 | echo 3+ $(runtest ?+U) = |
| 8073 | set -U |
| 8074 | echo 1- $(runtest -U) = |
| 8075 | echo 2- $(runtest !-U) = |
| 8076 | echo 3- $(runtest ?-U) = |
| 8077 | echo 1- $(runtest +U) = |
| 8078 | echo 2- $(runtest !+U) = |
| 8079 | echo 3- $(runtest ?+U) = |
| 8080 | expected-stdout: |
| 8081 | 0y 0 0 0 0 = |
| 8082 | 0n 1 1 1 1 = |
| 8083 | 1= 1 1 1 = |
| 8084 | 2= 1 1 1 = |
| 8085 | 3= 1 1 1 = |
| 8086 | 1+ 1 1 1 = |
| 8087 | 2+ 0 0 0 = |
| 8088 | 3+ 0 0 0 = |
| 8089 | 1- 0 0 0 = |
| 8090 | 2- 1 1 1 = |
| 8091 | 3- 0 0 0 = |
| 8092 | = short flags = |
| 8093 | 0y 0 0 0 0 = |
| 8094 | 0y 0 0 0 0 = |
| 8095 | 0n 1 1 1 1 = |
| 8096 | 0n 1 1 1 1 = |
| 8097 | 1= 1 1 1 = |
| 8098 | 2= 1 1 1 = |
| 8099 | 3= 1 1 1 = |
| 8100 | 1+ 1 1 1 = |
| 8101 | 2+ 0 0 0 = |
| 8102 | 3+ 0 0 0 = |
| 8103 | 1+ 1 1 1 = |
| 8104 | 2+ 0 0 0 = |
| 8105 | 3+ 0 0 0 = |
| 8106 | 1- 0 0 0 = |
| 8107 | 2- 1 1 1 = |
| 8108 | 3- 0 0 0 = |
| 8109 | 1- 0 0 0 = |
| 8110 | 2- 1 1 1 = |
| 8111 | 3- 0 0 0 = |
| 8112 | --- |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 8113 | name: test-varset-1 |
| 8114 | description: |
| 8115 | Test the test -v operator |
| 8116 | stdin: |
| 8117 | [[ -v a ]] |
| 8118 | rv=$?; echo $((++i)) $rv |
| 8119 | a= |
| 8120 | [[ -v a ]] |
| 8121 | rv=$?; echo $((++i)) $rv |
| 8122 | unset a |
| 8123 | [[ -v a ]] |
| 8124 | rv=$?; echo $((++i)) $rv |
| 8125 | a=x |
| 8126 | [[ -v a ]] |
| 8127 | rv=$?; echo $((++i)) $rv |
| 8128 | nameref b=a |
| 8129 | [[ -v b ]] |
| 8130 | rv=$?; echo $((++i)) $rv |
| 8131 | unset a |
| 8132 | [[ -v b ]] |
| 8133 | rv=$?; echo $((++i)) $rv |
| 8134 | x[1]=y |
| 8135 | [[ -v x ]] |
| 8136 | rv=$?; echo $((++i)) $rv |
| 8137 | [[ -v x[0] ]] |
| 8138 | rv=$?; echo $((++i)) $rv |
| 8139 | [[ -v x[1] ]] |
| 8140 | rv=$?; echo $((++i)) $rv |
| 8141 | [[ -v x[2] ]] |
| 8142 | rv=$?; echo $((++i)) $rv |
| 8143 | expected-stdout: |
| 8144 | 1 1 |
| 8145 | 2 0 |
| 8146 | 3 1 |
| 8147 | 4 0 |
| 8148 | 5 0 |
| 8149 | 6 1 |
| 8150 | 7 1 |
| 8151 | 8 1 |
| 8152 | 9 0 |
| 8153 | 10 1 |
| 8154 | --- |
| 8155 | name: test-varset-2 |
| 8156 | description: |
| 8157 | test -v works only on scalars |
| 8158 | stdin: |
| 8159 | [[ -v x[*] ]] |
| 8160 | echo ok |
| 8161 | expected-exit: e != 0 |
| 8162 | expected-stderr-pattern: |
| 8163 | /unexpected '\*'/ |
| 8164 | --- |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 8165 | name: test-stnze-1 |
| 8166 | description: |
| 8167 | Check that the short form [ $x ] works |
| 8168 | stdin: |
| 8169 | i=0 |
| 8170 | [ -n $x ] |
| 8171 | rv=$?; echo $((++i)) $rv |
| 8172 | [ $x ] |
| 8173 | rv=$?; echo $((++i)) $rv |
| 8174 | [ -n "$x" ] |
| 8175 | rv=$?; echo $((++i)) $rv |
| 8176 | [ "$x" ] |
| 8177 | rv=$?; echo $((++i)) $rv |
| 8178 | x=0 |
| 8179 | [ -n $x ] |
| 8180 | rv=$?; echo $((++i)) $rv |
| 8181 | [ $x ] |
| 8182 | rv=$?; echo $((++i)) $rv |
| 8183 | [ -n "$x" ] |
| 8184 | rv=$?; echo $((++i)) $rv |
| 8185 | [ "$x" ] |
| 8186 | rv=$?; echo $((++i)) $rv |
| 8187 | x='1 -a 1 = 2' |
| 8188 | [ -n $x ] |
| 8189 | rv=$?; echo $((++i)) $rv |
| 8190 | [ $x ] |
| 8191 | rv=$?; echo $((++i)) $rv |
| 8192 | [ -n "$x" ] |
| 8193 | rv=$?; echo $((++i)) $rv |
| 8194 | [ "$x" ] |
| 8195 | rv=$?; echo $((++i)) $rv |
| 8196 | expected-stdout: |
| 8197 | 1 0 |
| 8198 | 2 1 |
| 8199 | 3 1 |
| 8200 | 4 1 |
| 8201 | 5 0 |
| 8202 | 6 0 |
| 8203 | 7 0 |
| 8204 | 8 0 |
| 8205 | 9 1 |
| 8206 | 10 1 |
| 8207 | 11 0 |
| 8208 | 12 0 |
| 8209 | --- |
| 8210 | name: test-stnze-2 |
| 8211 | description: |
| 8212 | Check that the short form [[ $x ]] works (ksh93 extension) |
| 8213 | stdin: |
| 8214 | i=0 |
| 8215 | [[ -n $x ]] |
| 8216 | rv=$?; echo $((++i)) $rv |
| 8217 | [[ $x ]] |
| 8218 | rv=$?; echo $((++i)) $rv |
| 8219 | [[ -n "$x" ]] |
| 8220 | rv=$?; echo $((++i)) $rv |
| 8221 | [[ "$x" ]] |
| 8222 | rv=$?; echo $((++i)) $rv |
| 8223 | x=0 |
| 8224 | [[ -n $x ]] |
| 8225 | rv=$?; echo $((++i)) $rv |
| 8226 | [[ $x ]] |
| 8227 | rv=$?; echo $((++i)) $rv |
| 8228 | [[ -n "$x" ]] |
| 8229 | rv=$?; echo $((++i)) $rv |
| 8230 | [[ "$x" ]] |
| 8231 | rv=$?; echo $((++i)) $rv |
| 8232 | x='1 -a 1 = 2' |
| 8233 | [[ -n $x ]] |
| 8234 | rv=$?; echo $((++i)) $rv |
| 8235 | [[ $x ]] |
| 8236 | rv=$?; echo $((++i)) $rv |
| 8237 | [[ -n "$x" ]] |
| 8238 | rv=$?; echo $((++i)) $rv |
| 8239 | [[ "$x" ]] |
| 8240 | rv=$?; echo $((++i)) $rv |
| 8241 | expected-stdout: |
| 8242 | 1 1 |
| 8243 | 2 1 |
| 8244 | 3 1 |
| 8245 | 4 1 |
| 8246 | 5 0 |
| 8247 | 6 0 |
| 8248 | 7 0 |
| 8249 | 8 0 |
| 8250 | 9 0 |
| 8251 | 10 0 |
| 8252 | 11 0 |
| 8253 | 12 0 |
| 8254 | --- |
| 8255 | name: test-numeq |
| 8256 | description: |
| 8257 | Check numeric -eq works (R40d regression); spotted by Martijn Dekker |
| 8258 | stdin: |
| 8259 | tst() { |
| 8260 | eval "$2" |
| 8261 | case $? in |
| 8262 | (0) echo yepp 0 \#"$*" ;; |
| 8263 | (1) echo nope 1 \#"$*" ;; |
| 8264 | (2) echo terr 2 \#"$*" ;; |
| 8265 | (*) echo wtf\? $? \#"$*" ;; |
| 8266 | esac |
| 8267 | } |
| 8268 | tst 1 'test 2 -eq 2' |
| 8269 | tst 2 'test 2 -eq 2a' |
| 8270 | tst 3 'test 2 -eq 3' |
| 8271 | tst 4 'test 2 -ne 2' |
| 8272 | tst 5 'test 2 -ne 2a' |
| 8273 | tst 6 'test 2 -ne 3' |
| 8274 | tst 7 'test \! 2 -eq 2' |
| 8275 | tst 8 'test \! 2 -eq 2a' |
| 8276 | tst 9 'test \! 2 -eq 3' |
| 8277 | expected-stdout: |
| 8278 | yepp 0 #1 test 2 -eq 2 |
| 8279 | terr 2 #2 test 2 -eq 2a |
| 8280 | nope 1 #3 test 2 -eq 3 |
| 8281 | nope 1 #4 test 2 -ne 2 |
| 8282 | terr 2 #5 test 2 -ne 2a |
| 8283 | yepp 0 #6 test 2 -ne 3 |
| 8284 | nope 1 #7 test \! 2 -eq 2 |
| 8285 | terr 2 #8 test \! 2 -eq 2a |
| 8286 | yepp 0 #9 test \! 2 -eq 3 |
| 8287 | expected-stderr-pattern: |
| 8288 | /bad number/ |
| 8289 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8290 | name: mkshrc-1 |
| 8291 | description: |
| 8292 | Check that ~/.mkshrc works correctly. |
| 8293 | Part 1: verify user environment is not read (internal) |
| 8294 | stdin: |
| 8295 | echo x $FNORD |
| 8296 | expected-stdout: |
| 8297 | x |
| 8298 | --- |
| 8299 | name: mkshrc-2a |
| 8300 | description: |
| 8301 | Check that ~/.mkshrc works correctly. |
| 8302 | Part 2: verify mkshrc is not read (non-interactive shells) |
| 8303 | file-setup: file 644 ".mkshrc" |
| 8304 | FNORD=42 |
| 8305 | env-setup: !HOME=.!ENV=! |
| 8306 | stdin: |
| 8307 | echo x $FNORD |
| 8308 | expected-stdout: |
| 8309 | x |
| 8310 | --- |
| 8311 | name: mkshrc-2b |
| 8312 | description: |
| 8313 | Check that ~/.mkshrc works correctly. |
| 8314 | Part 2: verify mkshrc can be read (interactive shells) |
| 8315 | file-setup: file 644 ".mkshrc" |
| 8316 | FNORD=42 |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 8317 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8318 | arguments: !-i! |
| 8319 | env-setup: !HOME=.!ENV=!PS1=! |
| 8320 | stdin: |
| 8321 | echo x $FNORD |
| 8322 | expected-stdout: |
| 8323 | x 42 |
| 8324 | expected-stderr-pattern: |
| 8325 | /(# )*/ |
| 8326 | --- |
| 8327 | name: mkshrc-3 |
| 8328 | description: |
| 8329 | Check that ~/.mkshrc works correctly. |
| 8330 | Part 3: verify mkshrc can be turned off |
| 8331 | file-setup: file 644 ".mkshrc" |
| 8332 | FNORD=42 |
| 8333 | env-setup: !HOME=.!ENV=nonexistant! |
| 8334 | stdin: |
| 8335 | echo x $FNORD |
| 8336 | expected-stdout: |
| 8337 | x |
| 8338 | --- |
| 8339 | name: sh-mode-1 |
| 8340 | description: |
| 8341 | Check that sh mode turns braceexpand off |
| 8342 | and that that works correctly |
| 8343 | stdin: |
| 8344 | set -o braceexpand |
| 8345 | set +o sh |
| 8346 | [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh |
| 8347 | [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex |
| 8348 | echo {a,b,c} |
| 8349 | set +o braceexpand |
| 8350 | echo {a,b,c} |
| 8351 | set -o braceexpand |
| 8352 | echo {a,b,c} |
| 8353 | set -o sh |
| 8354 | echo {a,b,c} |
| 8355 | [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh |
| 8356 | [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex |
| 8357 | set -o braceexpand |
| 8358 | echo {a,b,c} |
| 8359 | [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh |
| 8360 | [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex |
| 8361 | expected-stdout: |
| 8362 | nosh |
| 8363 | brex |
| 8364 | a b c |
| 8365 | {a,b,c} |
| 8366 | a b c |
| 8367 | {a,b,c} |
| 8368 | sh |
| 8369 | nobrex |
| 8370 | a b c |
| 8371 | sh |
| 8372 | brex |
| 8373 | --- |
| 8374 | name: sh-mode-2a |
| 8375 | description: |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 8376 | Check that posix or sh mode is *not* automatically turned on |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8377 | category: !binsh |
| 8378 | stdin: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 8379 | ln -s "$__progname" ksh || cp "$__progname" ksh |
| 8380 | ln -s "$__progname" sh || cp "$__progname" sh |
| 8381 | ln -s "$__progname" ./-ksh || cp "$__progname" ./-ksh |
| 8382 | ln -s "$__progname" ./-sh || cp "$__progname" ./-sh |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8383 | for shell in {,-}{,k}sh; do |
| 8384 | print -- $shell $(./$shell +l -c \ |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 8385 | '[[ $(set +o) == *"-o "@(sh|posix)@(| *) ]] && echo sh || echo nosh') |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8386 | done |
| 8387 | expected-stdout: |
| 8388 | sh nosh |
| 8389 | ksh nosh |
| 8390 | -sh nosh |
| 8391 | -ksh nosh |
| 8392 | --- |
| 8393 | name: sh-mode-2b |
| 8394 | description: |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 8395 | Check that posix or sh mode *is* automatically turned on |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8396 | category: binsh |
| 8397 | stdin: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 8398 | ln -s "$__progname" ksh || cp "$__progname" ksh |
| 8399 | ln -s "$__progname" sh || cp "$__progname" sh |
| 8400 | ln -s "$__progname" ./-ksh || cp "$__progname" ./-ksh |
| 8401 | ln -s "$__progname" ./-sh || cp "$__progname" ./-sh |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8402 | for shell in {,-}{,k}sh; do |
| 8403 | print -- $shell $(./$shell +l -c \ |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 8404 | '[[ $(set +o) == *"-o "@(sh|posix)@(| *) ]] && echo sh || echo nosh') |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8405 | done |
| 8406 | expected-stdout: |
| 8407 | sh sh |
| 8408 | ksh nosh |
| 8409 | -sh sh |
| 8410 | -ksh nosh |
| 8411 | --- |
| 8412 | name: pipeline-1 |
| 8413 | description: |
| 8414 | pdksh bug: last command of a pipeline is executed in a |
| 8415 | subshell - make sure it still is, scripts depend on it |
| 8416 | file-setup: file 644 "abcx" |
| 8417 | file-setup: file 644 "abcy" |
| 8418 | stdin: |
| 8419 | echo * |
| 8420 | echo a | while read d; do |
| 8421 | echo $d |
| 8422 | echo $d* |
| 8423 | echo * |
| 8424 | set -o noglob |
| 8425 | echo $d* |
| 8426 | echo * |
| 8427 | done |
| 8428 | echo * |
| 8429 | expected-stdout: |
| 8430 | abcx abcy |
| 8431 | a |
| 8432 | abcx abcy |
| 8433 | abcx abcy |
| 8434 | a* |
| 8435 | * |
| 8436 | abcx abcy |
| 8437 | --- |
| 8438 | name: pipeline-2 |
| 8439 | description: |
| 8440 | check that co-processes work with TCOMs, TPIPEs and TPARENs |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 8441 | category: !nojsig |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8442 | stdin: |
| 8443 | "$__progname" -c 'i=100; echo hi |& while read -p line; do echo "$((i++)) $line"; done' |
| 8444 | "$__progname" -c 'i=200; echo hi | cat |& while read -p line; do echo "$((i++)) $line"; done' |
| 8445 | "$__progname" -c 'i=300; (echo hi | cat) |& while read -p line; do echo "$((i++)) $line"; done' |
| 8446 | expected-stdout: |
| 8447 | 100 hi |
| 8448 | 200 hi |
| 8449 | 300 hi |
| 8450 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 8451 | name: pipeline-3 |
| 8452 | description: |
| 8453 | Check that PIPESTATUS does what it's supposed to |
| 8454 | stdin: |
| 8455 | echo 1 $PIPESTATUS . |
| 8456 | echo 2 ${PIPESTATUS[0]} . |
| 8457 | echo 3 ${PIPESTATUS[1]} . |
| 8458 | (echo x; exit 12) | (cat; exit 23) | (cat; exit 42) |
| 8459 | echo 5 $? , $PIPESTATUS , ${PIPESTATUS[0]} , ${PIPESTATUS[1]} , ${PIPESTATUS[2]} , ${PIPESTATUS[3]} . |
| 8460 | echo 6 ${PIPESTATUS[0]} . |
| 8461 | set | fgrep PIPESTATUS |
| 8462 | echo 8 $(set | fgrep PIPESTATUS) . |
| 8463 | expected-stdout: |
| 8464 | 1 0 . |
| 8465 | 2 0 . |
| 8466 | 3 . |
| 8467 | x |
| 8468 | 5 42 , 12 , 12 , 23 , 42 , . |
| 8469 | 6 0 . |
| 8470 | PIPESTATUS[0]=0 |
| 8471 | 8 PIPESTATUS[0]=0 PIPESTATUS[1]=0 . |
| 8472 | --- |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 8473 | name: pipeline-4 |
| 8474 | description: |
| 8475 | Check that "set -o pipefail" does what it's supposed to |
| 8476 | stdin: |
| 8477 | echo 1 "$("$__progname" -c '(exit 12) | (exit 23) | (exit 42); echo $?')" . |
| 8478 | echo 2 "$("$__progname" -c '! (exit 12) | (exit 23) | (exit 42); echo $?')" . |
| 8479 | echo 3 "$("$__progname" -o pipefail -c '(exit 12) | (exit 23) | (exit 42); echo $?')" . |
| 8480 | echo 4 "$("$__progname" -o pipefail -c '! (exit 12) | (exit 23) | (exit 42); echo $?')" . |
| 8481 | echo 5 "$("$__progname" -c '(exit 23) | (exit 42) | :; echo $?')" . |
| 8482 | echo 6 "$("$__progname" -c '! (exit 23) | (exit 42) | :; echo $?')" . |
| 8483 | echo 7 "$("$__progname" -o pipefail -c '(exit 23) | (exit 42) | :; echo $?')" . |
| 8484 | echo 8 "$("$__progname" -o pipefail -c '! (exit 23) | (exit 42) | :; echo $?')" . |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 8485 | echo 9 "$("$__progname" -o pipefail -c 'x=$( (exit 23) | (exit 42) | :); echo $?')" . |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 8486 | expected-stdout: |
| 8487 | 1 42 . |
| 8488 | 2 0 . |
| 8489 | 3 42 . |
| 8490 | 4 0 . |
| 8491 | 5 0 . |
| 8492 | 6 1 . |
| 8493 | 7 42 . |
| 8494 | 8 0 . |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 8495 | 9 42 . |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 8496 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8497 | name: persist-history-1 |
| 8498 | description: |
| 8499 | Check if persistent history saving works |
| 8500 | category: !no-histfile |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 8501 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8502 | arguments: !-i! |
| 8503 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 8504 | file-setup: file 644 "Env" |
| 8505 | PS1=X |
| 8506 | stdin: |
| 8507 | cat hist.file |
| 8508 | expected-stdout-pattern: |
| 8509 | /cat hist.file/ |
| 8510 | expected-stderr-pattern: |
| 8511 | /^X*$/ |
| 8512 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 8513 | name: typeset-1 |
| 8514 | description: |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 8515 | Check that typeset -g works correctly |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 8516 | stdin: |
| 8517 | set -A arrfoo 65 |
| 8518 | foo() { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 8519 | typeset -g -Uui16 arrfoo[*] |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 8520 | } |
| 8521 | echo before ${arrfoo[0]} . |
| 8522 | foo |
| 8523 | echo after ${arrfoo[0]} . |
| 8524 | set -A arrbar 65 |
| 8525 | bar() { |
| 8526 | echo inside before ${arrbar[0]} . |
| 8527 | arrbar[0]=97 |
| 8528 | echo inside changed ${arrbar[0]} . |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 8529 | typeset -g -Uui16 arrbar[*] |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 8530 | echo inside typeset ${arrbar[0]} . |
| 8531 | arrbar[0]=48 |
| 8532 | echo inside changed ${arrbar[0]} . |
| 8533 | } |
| 8534 | echo before ${arrbar[0]} . |
| 8535 | bar |
| 8536 | echo after ${arrbar[0]} . |
| 8537 | expected-stdout: |
| 8538 | before 65 . |
| 8539 | after 16#41 . |
| 8540 | before 65 . |
| 8541 | inside before 65 . |
| 8542 | inside changed 97 . |
| 8543 | inside typeset 16#61 . |
| 8544 | inside changed 16#30 . |
| 8545 | after 16#30 . |
| 8546 | --- |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 8547 | name: typeset-2 |
| 8548 | description: |
| 8549 | Check that typeset -p on arrays works correctly |
| 8550 | stdin: |
| 8551 | set -A x -- a b c |
| 8552 | echo = |
| 8553 | typeset -p x |
| 8554 | echo = |
| 8555 | typeset -p x[1] |
| 8556 | expected-stdout: |
| 8557 | = |
| 8558 | set -A x |
| 8559 | typeset x[0]=a |
| 8560 | typeset x[1]=b |
| 8561 | typeset x[2]=c |
| 8562 | = |
| 8563 | typeset x[1]=b |
| 8564 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8565 | name: typeset-padding-1 |
| 8566 | description: |
| 8567 | Check if left/right justification works as per TFM |
| 8568 | stdin: |
| 8569 | typeset -L10 ln=0hall0 |
| 8570 | typeset -R10 rn=0hall0 |
| 8571 | typeset -ZL10 lz=0hall0 |
| 8572 | typeset -ZR10 rz=0hall0 |
| 8573 | typeset -Z10 rx=" hallo " |
| 8574 | echo "<$ln> <$rn> <$lz> <$rz> <$rx>" |
| 8575 | expected-stdout: |
| 8576 | <0hall0 > < 0hall0> <hall0 > <00000hall0> <0000 hallo> |
| 8577 | --- |
| 8578 | name: typeset-padding-2 |
| 8579 | description: |
| 8580 | Check if base-!10 integers are padded right |
| 8581 | stdin: |
| 8582 | typeset -Uui16 -L9 ln=16#1 |
| 8583 | typeset -Uui16 -R9 rn=16#1 |
| 8584 | typeset -Uui16 -Z9 zn=16#1 |
| 8585 | typeset -L9 ls=16#1 |
| 8586 | typeset -R9 rs=16#1 |
| 8587 | typeset -Z9 zs=16#1 |
| 8588 | echo "<$ln> <$rn> <$zn> <$ls> <$rs> <$zs>" |
| 8589 | expected-stdout: |
| 8590 | <16#1 > < 16#1> <16#000001> <16#1 > < 16#1> <0000016#1> |
| 8591 | --- |
Elliott Hughes | 4708626 | 2019-03-26 12:34:31 -0700 | [diff] [blame] | 8592 | name: typeset-padding-3 |
| 8593 | description: |
| 8594 | Check for a regression in which UTF-8 wasnât left-padded right |
| 8595 | stdin: |
| 8596 | set -U |
| 8597 | nl=$'\n' |
| 8598 | typeset -L20 x='. ak' |
| 8599 | typeset -R20 y='. ak' |
| 8600 | print -r -- "<$x> (1$nl<12345678910 345678920$nl<$y> 1)" |
| 8601 | typeset -L20 x='. aáº' |
| 8602 | typeset -R20 y='. aáº' |
| 8603 | print -r -- "<$x> (2$nl<12345678910 345678920$nl<$y> 2)" |
| 8604 | expected-stdout: |
| 8605 | <. ak > (1 |
| 8606 | <12345678910 345678920 |
| 8607 | < . ak> 1) |
| 8608 | <. aẠ> (2 |
| 8609 | <12345678910 345678920 |
| 8610 | < . aáº> 2) |
| 8611 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8612 | name: utf8bom-1 |
| 8613 | description: |
| 8614 | Check that the UTF-8 Byte Order Mark is ignored as the first |
| 8615 | multibyte character of the shell input (with -c, from standard |
| 8616 | input, as file, or as eval argument), but nowhere else |
Elliott Hughes | 4708626 | 2019-03-26 12:34:31 -0700 | [diff] [blame] | 8617 | # breaks on Mac OSX (HFS+ non-standard UTF-8 canonical decomposition) |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 8618 | category: !os:darwin,!shell:ebcdic-yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8619 | stdin: |
| 8620 | mkdir foo |
| 8621 | print '#!/bin/sh\necho ohne' >foo/fnord |
| 8622 | print '#!/bin/sh\necho mit' >foo/fnord |
| 8623 | print 'fnord\nfnord\nfnord\nfnord' >foo/bar |
| 8624 | print eval \''fnord\nfnord\nfnord\nfnord'\' >foo/zoo |
| 8625 | set -A anzahl -- foo/* |
| 8626 | echo got ${#anzahl[*]} files |
| 8627 | chmod +x foo/* |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 8628 | export PATH=$(pwd)/foo$PATHSEP$PATH |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8629 | "$__progname" -c 'fnord' |
| 8630 | echo = |
| 8631 | "$__progname" -c 'fnord; fnord; fnord; fnord' |
| 8632 | echo = |
| 8633 | "$__progname" foo/bar |
| 8634 | echo = |
| 8635 | "$__progname" <foo/bar |
| 8636 | echo = |
| 8637 | "$__progname" foo/zoo |
| 8638 | echo = |
| 8639 | "$__progname" -c 'echo : $(fnord)' |
| 8640 | rm -rf foo |
| 8641 | expected-stdout: |
| 8642 | got 4 files |
| 8643 | ohne |
| 8644 | = |
| 8645 | ohne |
| 8646 | ohne |
| 8647 | mit |
| 8648 | ohne |
| 8649 | = |
| 8650 | ohne |
| 8651 | ohne |
| 8652 | mit |
| 8653 | ohne |
| 8654 | = |
| 8655 | ohne |
| 8656 | ohne |
| 8657 | mit |
| 8658 | ohne |
| 8659 | = |
| 8660 | ohne |
| 8661 | ohne |
| 8662 | mit |
| 8663 | ohne |
| 8664 | = |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 8665 | : ohne |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8666 | --- |
| 8667 | name: utf8bom-2 |
| 8668 | description: |
| 8669 | Check that we can execute BOM-shebangs (failures not fatal) |
| 8670 | XXX if the OS can already execute them, we lose |
| 8671 | note: cygwin execve(2) doesn't return to us with ENOEXEC, we lose |
| 8672 | note: Ultrix perl5 t4 returns 65280 (exit-code 255) and no text |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 8673 | XXX fails when LD_PRELOAD is set with -e and Perl chokes it (ASan) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 8674 | need-pass: no |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 8675 | category: !os:cygwin,!os:msys,!os:ultrix,!os:uwin-nt,!smksh |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8676 | env-setup: !FOO=BAR! |
| 8677 | stdin: |
| 8678 | print '#!'"$__progname"'\nprint "1 a=$ENV{FOO}";' >t1 |
| 8679 | print '#!'"$__progname"'\nprint "2 a=$ENV{FOO}";' >t2 |
| 8680 | print '#!'"$__perlname"'\nprint "3 a=$ENV{FOO}\n";' >t3 |
| 8681 | print '#!'"$__perlname"'\nprint "4 a=$ENV{FOO}\n";' >t4 |
| 8682 | chmod +x t? |
| 8683 | ./t1 |
| 8684 | ./t2 |
| 8685 | ./t3 |
| 8686 | ./t4 |
| 8687 | expected-stdout: |
| 8688 | 1 a=/nonexistant{FOO} |
| 8689 | 2 a=/nonexistant{FOO} |
| 8690 | 3 a=BAR |
| 8691 | 4 a=BAR |
| 8692 | expected-stderr-pattern: |
| 8693 | /(Unrecognized character .... ignored at \..t4 line 1)*/ |
| 8694 | --- |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 8695 | name: utf8opt-1 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8696 | description: |
| 8697 | Check that the utf8-mode flag is not set at non-interactive startup |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 8698 | env-setup: !PS1=!PS2=!LC_CTYPE=@utflocale@! |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8699 | stdin: |
| 8700 | if [[ $- = *U* ]]; then |
| 8701 | echo is set |
| 8702 | else |
| 8703 | echo is not set |
| 8704 | fi |
| 8705 | expected-stdout: |
| 8706 | is not set |
| 8707 | --- |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 8708 | name: utf8opt-2 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8709 | description: |
| 8710 | Check that the utf8-mode flag is set at interactive startup. |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 8711 | If your OS is old, try passing HAVE_SETLOCALE_CTYPE=0 to Build.sh |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 8712 | need-pass: no |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 8713 | category: !noutf8 |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 8714 | need-ctty: yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8715 | arguments: !-i! |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 8716 | env-setup: !PS1=!PS2=!LC_CTYPE=@utflocale@! |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8717 | stdin: |
| 8718 | if [[ $- = *U* ]]; then |
| 8719 | echo is set |
| 8720 | else |
| 8721 | echo is not set |
| 8722 | fi |
| 8723 | expected-stdout: |
| 8724 | is set |
| 8725 | expected-stderr-pattern: |
| 8726 | /(# )*/ |
| 8727 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 8728 | name: utf8opt-3a |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8729 | description: |
| 8730 | Ensure ±U on the command line is honoured |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 8731 | (these two tests may pass falsely depending on CPPFLAGS) |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8732 | stdin: |
| 8733 | export i=0 |
| 8734 | code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi' |
| 8735 | let i++; "$__progname" -U -c "$code" |
| 8736 | let i++; "$__progname" +U -c "$code" |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 8737 | echo $((++i)) done |
| 8738 | expected-stdout: |
| 8739 | 1 on |
| 8740 | 2 off |
| 8741 | 3 done |
| 8742 | --- |
| 8743 | name: utf8opt-3b |
| 8744 | description: |
| 8745 | Ensure ±U on the command line is honoured, interactive shells |
| 8746 | need-ctty: yes |
| 8747 | stdin: |
| 8748 | export i=0 |
| 8749 | code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi' |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8750 | let i++; "$__progname" -U -ic "$code" |
| 8751 | let i++; "$__progname" +U -ic "$code" |
| 8752 | echo $((++i)) done |
| 8753 | expected-stdout: |
| 8754 | 1 on |
| 8755 | 2 off |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 8756 | 3 done |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8757 | --- |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 8758 | name: utf8bug-1 |
| 8759 | description: |
| 8760 | Ensure trailing combining characters are not lost |
| 8761 | stdin: |
| 8762 | set -U |
| 8763 | a=a |
| 8764 | b=$'\u0301' |
| 8765 | x=$a$b |
| 8766 | print -r -- "<e$x>" |
| 8767 | x=$a |
| 8768 | x+=$b |
| 8769 | print -r -- "<e$x>" |
| 8770 | b=$'\u0301'b |
| 8771 | x=$a |
| 8772 | x+=$b |
| 8773 | print -r -- "<e$x>" |
| 8774 | expected-stdout: |
| 8775 | <eaÌ> |
| 8776 | <eaÌ> |
| 8777 | <eaÌb> |
| 8778 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8779 | name: aliases-1 |
| 8780 | description: |
| 8781 | Check if built-in shell aliases are okay |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8782 | stdin: |
| 8783 | alias |
| 8784 | typeset -f |
| 8785 | expected-stdout: |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 8786 | autoload='\\builtin typeset -fu' |
| 8787 | functions='\\builtin typeset -f' |
| 8788 | hash='\\builtin alias -t' |
| 8789 | history='\\builtin fc -l' |
| 8790 | integer='\\builtin typeset -i' |
| 8791 | local='\\builtin typeset' |
| 8792 | login='\\builtin exec login' |
| 8793 | nameref='\\builtin typeset -n' |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8794 | nohup='nohup ' |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 8795 | r='\\builtin fc -e -' |
| 8796 | type='\\builtin whence -v' |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8797 | --- |
| 8798 | name: aliases-2b |
| 8799 | description: |
| 8800 | Check if âset -o shâ does not influence built-in aliases |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8801 | arguments: !-o!sh! |
| 8802 | stdin: |
| 8803 | alias |
| 8804 | typeset -f |
| 8805 | expected-stdout: |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 8806 | autoload='\\builtin typeset -fu' |
| 8807 | functions='\\builtin typeset -f' |
| 8808 | hash='\\builtin alias -t' |
| 8809 | history='\\builtin fc -l' |
| 8810 | integer='\\builtin typeset -i' |
| 8811 | local='\\builtin typeset' |
| 8812 | login='\\builtin exec login' |
| 8813 | nameref='\\builtin typeset -n' |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8814 | nohup='nohup ' |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 8815 | r='\\builtin fc -e -' |
| 8816 | type='\\builtin whence -v' |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8817 | --- |
| 8818 | name: aliases-3b |
| 8819 | description: |
| 8820 | Check if running as sh does not influence built-in aliases |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8821 | stdin: |
| 8822 | cp "$__progname" sh |
| 8823 | ./sh -c 'alias; typeset -f' |
| 8824 | rm -f sh |
| 8825 | expected-stdout: |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 8826 | autoload='\\builtin typeset -fu' |
| 8827 | functions='\\builtin typeset -f' |
| 8828 | hash='\\builtin alias -t' |
| 8829 | history='\\builtin fc -l' |
| 8830 | integer='\\builtin typeset -i' |
| 8831 | local='\\builtin typeset' |
| 8832 | login='\\builtin exec login' |
| 8833 | nameref='\\builtin typeset -n' |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8834 | nohup='nohup ' |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 8835 | r='\\builtin fc -e -' |
| 8836 | type='\\builtin whence -v' |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8837 | --- |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 8838 | name: aliases-cmdline |
| 8839 | description: |
| 8840 | Check that aliases work from the command line (Debian #517009) |
| 8841 | Note that due to the nature of the lexing process, defining |
| 8842 | aliases in COMSUBs then immediately using them, and things |
| 8843 | like 'alias foo=bar && foo', still fail. |
| 8844 | stdin: |
| 8845 | "$__progname" -c $'alias a="echo OK"\na' |
| 8846 | expected-stdout: |
| 8847 | OK |
| 8848 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8849 | name: aliases-funcdef-1 |
| 8850 | description: |
| 8851 | Check if POSIX functions take precedences over aliases |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 8852 | stdin: |
| 8853 | alias foo='echo makro' |
| 8854 | foo() { |
| 8855 | echo funktion |
| 8856 | } |
| 8857 | foo |
| 8858 | expected-stdout: |
| 8859 | makro |
| 8860 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8861 | name: aliases-funcdef-2 |
| 8862 | description: |
| 8863 | Check if POSIX functions take precedences over aliases |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 8864 | stdin: |
| 8865 | alias foo='echo makro' |
| 8866 | foo () { |
| 8867 | echo funktion |
| 8868 | } |
| 8869 | foo |
| 8870 | expected-stdout: |
| 8871 | makro |
| 8872 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8873 | name: aliases-funcdef-3 |
| 8874 | description: |
| 8875 | Check if aliases take precedences over Korn functions |
| 8876 | stdin: |
| 8877 | alias foo='echo makro' |
| 8878 | function foo { |
| 8879 | echo funktion |
| 8880 | } |
| 8881 | foo |
| 8882 | expected-stdout: |
| 8883 | makro |
| 8884 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 8885 | name: aliases-funcdef-4 |
| 8886 | description: |
| 8887 | Functions should only take over if actually being defined |
| 8888 | stdin: |
| 8889 | alias local |
| 8890 | :|| local() { :; } |
| 8891 | alias local |
| 8892 | expected-stdout: |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 8893 | local='\\builtin typeset' |
| 8894 | local='\\builtin typeset' |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 8895 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8896 | name: arrays-1 |
| 8897 | description: |
| 8898 | Check if Korn Shell arrays work as expected |
| 8899 | stdin: |
| 8900 | v="c d" |
| 8901 | set -A foo -- a \$v "$v" '$v' b |
| 8902 | echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|" |
| 8903 | expected-stdout: |
| 8904 | 5|a|$v|c d|$v|b| |
| 8905 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 8906 | name: arrays-2a |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8907 | description: |
| 8908 | Check if bash-style arrays work as expected |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8909 | stdin: |
| 8910 | v="c d" |
| 8911 | foo=(a \$v "$v" '$v' b) |
| 8912 | echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|" |
| 8913 | expected-stdout: |
| 8914 | 5|a|$v|c d|$v|b| |
| 8915 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 8916 | name: arrays-2b |
| 8917 | description: |
| 8918 | Check if bash-style arrays work as expected, with newlines |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 8919 | stdin: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 8920 | print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "$x|"; done' >pfp |
| 8921 | chmod +x pfp |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 8922 | test -n "$ZSH_VERSION" && setopt KSH_ARRAYS |
| 8923 | v="e f" |
| 8924 | foo=(a |
| 8925 | bc |
| 8926 | d \$v "$v" '$v' g |
| 8927 | ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 8928 | ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 8929 | foo=(a\ |
| 8930 | bc |
| 8931 | d \$v "$v" '$v' g |
| 8932 | ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 8933 | ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 8934 | foo=(a\ |
| 8935 | bc\\ |
| 8936 | d \$v "$v" '$v' |
| 8937 | g) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 8938 | ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 8939 | expected-stdout: |
| 8940 | 7|a|bc|d|$v|e f|$v|g| |
| 8941 | 7|a|bc|d|$v|e f|$v|g| |
| 8942 | 6|abc\|d|$v|e f|$v|g|| |
| 8943 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8944 | name: arrays-3 |
| 8945 | description: |
| 8946 | Check if array bounds are uint32_t |
| 8947 | stdin: |
| 8948 | set -A foo a b c |
| 8949 | foo[4097]=d |
| 8950 | foo[2147483637]=e |
| 8951 | echo ${foo[*]} |
| 8952 | foo[-1]=f |
| 8953 | echo ${foo[4294967295]} g ${foo[*]} |
| 8954 | expected-stdout: |
| 8955 | a b c d e |
| 8956 | f g a b c d e f |
| 8957 | --- |
| 8958 | name: arrays-4 |
| 8959 | description: |
| 8960 | Check if Korn Shell arrays with specified indices work as expected |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8961 | stdin: |
| 8962 | v="c d" |
| 8963 | set -A foo -- [1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b |
| 8964 | echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|" |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 8965 | # we don't want this at all: |
| 8966 | # 5|a|$v|c d||$v|b| |
| 8967 | set -A arr "[5]=meh" |
| 8968 | echo "<${arr[0]}><${arr[5]}>" |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8969 | expected-stdout: |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 8970 | 5|[1]=$v|[2]=c d|[4]=$v|[0]=a|[5]=b|| |
| 8971 | <[5]=meh><> |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8972 | --- |
| 8973 | name: arrays-5 |
| 8974 | description: |
| 8975 | Check if bash-style arrays with specified indices work as expected |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 8976 | (taken out temporarily to fix arrays-4; see also arrays-9a comment) |
| 8977 | category: disabled |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8978 | stdin: |
| 8979 | v="c d" |
| 8980 | foo=([1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b) |
| 8981 | echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|" |
| 8982 | x=([128]=foo bar baz) |
| 8983 | echo k= ${!x[*]} . |
| 8984 | echo v= ${x[*]} . |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 8985 | # Check that we do not break this by globbing |
| 8986 | :>b=blah |
| 8987 | bleh=5 |
| 8988 | typeset -a arr |
| 8989 | arr+=([bleh]=blah) |
| 8990 | echo "<${arr[0]}><${arr[5]}>" |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8991 | expected-stdout: |
| 8992 | 5|a|$v|c d||$v|b| |
| 8993 | k= 128 129 130 . |
| 8994 | v= foo bar baz . |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 8995 | <><blah> |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 8996 | --- |
| 8997 | name: arrays-6 |
| 8998 | description: |
| 8999 | Check if we can get the array keys (indices) for indexed arrays, |
| 9000 | Korn shell style |
| 9001 | stdin: |
| 9002 | of() { |
| 9003 | i=0 |
| 9004 | for x in "$@"; do |
| 9005 | echo -n "$((i++))<$x>" |
| 9006 | done |
| 9007 | echo |
| 9008 | } |
| 9009 | foo[1]=eins |
| 9010 | set | grep '^foo' |
| 9011 | echo = |
| 9012 | foo[0]=zwei |
| 9013 | foo[4]=drei |
| 9014 | set | grep '^foo' |
| 9015 | echo = |
| 9016 | echo a $(of ${foo[*]}) = $(of ${bar[*]}) a |
| 9017 | echo b $(of "${foo[*]}") = $(of "${bar[*]}") b |
| 9018 | echo c $(of ${foo[@]}) = $(of ${bar[@]}) c |
| 9019 | echo d $(of "${foo[@]}") = $(of "${bar[@]}") d |
| 9020 | echo e $(of ${!foo[*]}) = $(of ${!bar[*]}) e |
| 9021 | echo f $(of "${!foo[*]}") = $(of "${!bar[*]}") f |
| 9022 | echo g $(of ${!foo[@]}) = $(of ${!bar[@]}) g |
| 9023 | echo h $(of "${!foo[@]}") = $(of "${!bar[@]}") h |
| 9024 | expected-stdout: |
| 9025 | foo[1]=eins |
| 9026 | = |
| 9027 | foo[0]=zwei |
| 9028 | foo[1]=eins |
| 9029 | foo[4]=drei |
| 9030 | = |
| 9031 | a 0<zwei>1<eins>2<drei> = a |
| 9032 | b 0<zwei eins drei> = 0<> b |
| 9033 | c 0<zwei>1<eins>2<drei> = c |
| 9034 | d 0<zwei>1<eins>2<drei> = d |
| 9035 | e 0<0>1<1>2<4> = e |
| 9036 | f 0<0 1 4> = 0<> f |
| 9037 | g 0<0>1<1>2<4> = g |
| 9038 | h 0<0>1<1>2<4> = h |
| 9039 | --- |
| 9040 | name: arrays-7 |
| 9041 | description: |
| 9042 | Check if we can get the array keys (indices) for indexed arrays, |
| 9043 | Korn shell style, in some corner cases |
| 9044 | stdin: |
| 9045 | echo !arz: ${!arz} |
| 9046 | echo !arz[0]: ${!arz[0]} |
| 9047 | echo !arz[1]: ${!arz[1]} |
| 9048 | arz=foo |
| 9049 | echo !arz: ${!arz} |
| 9050 | echo !arz[0]: ${!arz[0]} |
| 9051 | echo !arz[1]: ${!arz[1]} |
| 9052 | unset arz |
| 9053 | echo !arz: ${!arz} |
| 9054 | echo !arz[0]: ${!arz[0]} |
| 9055 | echo !arz[1]: ${!arz[1]} |
| 9056 | expected-stdout: |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 9057 | !arz: arz |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 9058 | !arz[0]: arz[0] |
| 9059 | !arz[1]: arz[1] |
| 9060 | !arz: arz |
| 9061 | !arz[0]: arz[0] |
| 9062 | !arz[1]: arz[1] |
| 9063 | !arz: arz |
| 9064 | !arz[0]: arz[0] |
| 9065 | !arz[1]: arz[1] |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 9066 | --- |
| 9067 | name: arrays-8 |
| 9068 | description: |
| 9069 | Check some behavioural rules for arrays. |
| 9070 | stdin: |
| 9071 | fna() { |
| 9072 | set -A aa 9 |
| 9073 | } |
| 9074 | fnb() { |
| 9075 | typeset ab |
| 9076 | set -A ab 9 |
| 9077 | } |
| 9078 | fnc() { |
| 9079 | typeset ac |
| 9080 | set -A ac 91 |
| 9081 | unset ac |
| 9082 | set -A ac 92 |
| 9083 | } |
| 9084 | fnd() { |
| 9085 | set +A ad 9 |
| 9086 | } |
| 9087 | fne() { |
| 9088 | unset ae |
| 9089 | set +A ae 9 |
| 9090 | } |
| 9091 | fnf() { |
| 9092 | unset af[0] |
| 9093 | set +A af 9 |
| 9094 | } |
| 9095 | fng() { |
| 9096 | unset ag[*] |
| 9097 | set +A ag 9 |
| 9098 | } |
| 9099 | set -A aa 1 2 |
| 9100 | set -A ab 1 2 |
| 9101 | set -A ac 1 2 |
| 9102 | set -A ad 1 2 |
| 9103 | set -A ae 1 2 |
| 9104 | set -A af 1 2 |
| 9105 | set -A ag 1 2 |
| 9106 | set -A ah 1 2 |
| 9107 | typeset -Z3 aa ab ac ad ae af ag |
| 9108 | print 1a ${aa[*]} . |
| 9109 | print 1b ${ab[*]} . |
| 9110 | print 1c ${ac[*]} . |
| 9111 | print 1d ${ad[*]} . |
| 9112 | print 1e ${ae[*]} . |
| 9113 | print 1f ${af[*]} . |
| 9114 | print 1g ${ag[*]} . |
| 9115 | print 1h ${ah[*]} . |
| 9116 | fna |
| 9117 | fnb |
| 9118 | fnc |
| 9119 | fnd |
| 9120 | fne |
| 9121 | fnf |
| 9122 | fng |
| 9123 | typeset -Z5 ah[*] |
| 9124 | print 2a ${aa[*]} . |
| 9125 | print 2b ${ab[*]} . |
| 9126 | print 2c ${ac[*]} . |
| 9127 | print 2d ${ad[*]} . |
| 9128 | print 2e ${ae[*]} . |
| 9129 | print 2f ${af[*]} . |
| 9130 | print 2g ${ag[*]} . |
| 9131 | print 2h ${ah[*]} . |
| 9132 | expected-stdout: |
| 9133 | 1a 001 002 . |
| 9134 | 1b 001 002 . |
| 9135 | 1c 001 002 . |
| 9136 | 1d 001 002 . |
| 9137 | 1e 001 002 . |
| 9138 | 1f 001 002 . |
| 9139 | 1g 001 002 . |
| 9140 | 1h 1 2 . |
| 9141 | 2a 9 . |
| 9142 | 2b 001 002 . |
| 9143 | 2c 92 . |
| 9144 | 2d 009 002 . |
| 9145 | 2e 9 . |
| 9146 | 2f 9 002 . |
| 9147 | 2g 009 . |
| 9148 | 2h 00001 00002 . |
| 9149 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 9150 | name: arrays-9a |
| 9151 | description: |
| 9152 | Check that we can concatenate arrays |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 9153 | stdin: |
| 9154 | unset foo; foo=(bar); foo+=(baz); echo 1 ${!foo[*]} : ${foo[*]} . |
| 9155 | unset foo; foo=(foo bar); foo+=(baz); echo 2 ${!foo[*]} : ${foo[*]} . |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 9156 | # unset foo; foo=([2]=foo [0]=bar); foo+=(baz [5]=quux); echo 3 ${!foo[*]} : ${foo[*]} . |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 9157 | expected-stdout: |
| 9158 | 1 0 1 : bar baz . |
| 9159 | 2 0 1 2 : foo bar baz . |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 9160 | # 3 0 2 3 5 : bar foo baz quux . |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 9161 | --- |
| 9162 | name: arrays-9b |
| 9163 | description: |
| 9164 | Check that we can concatenate parameters too |
| 9165 | stdin: |
| 9166 | unset foo; foo=bar; foo+=baz; echo 1 $foo . |
| 9167 | unset foo; typeset -i16 foo=10; foo+=20; echo 2 $foo . |
| 9168 | expected-stdout: |
| 9169 | 1 barbaz . |
| 9170 | 2 16#a20 . |
| 9171 | --- |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 9172 | name: arrassign-basic |
| 9173 | description: |
| 9174 | Check basic whitespace conserving properties of wdarrassign |
| 9175 | stdin: |
| 9176 | a=($(echo a b)) |
| 9177 | b=($(echo "a b")) |
| 9178 | c=("$(echo "a b")") |
| 9179 | d=("$(echo a b)") |
| 9180 | a+=($(echo c d)) |
| 9181 | b+=($(echo "c d")) |
| 9182 | c+=("$(echo "c d")") |
| 9183 | d+=("$(echo c d)") |
| 9184 | echo ".a:${a[0]}.${a[1]}.${a[2]}.${a[3]}:" |
| 9185 | echo ".b:${b[0]}.${b[1]}.${b[2]}.${b[3]}:" |
| 9186 | echo ".c:${c[0]}.${c[1]}.${c[2]}.${c[3]}:" |
| 9187 | echo ".d:${d[0]}.${d[1]}.${d[2]}.${d[3]}:" |
| 9188 | expected-stdout: |
| 9189 | .a:a.b.c.d: |
| 9190 | .b:a.b.c.d: |
| 9191 | .c:a b.c d..: |
| 9192 | .d:a b.c d..: |
| 9193 | --- |
Elliott Hughes | dd4abe0 | 2018-02-05 15:55:19 -0800 | [diff] [blame] | 9194 | name: arrassign-eol |
| 9195 | description: |
| 9196 | Commands after array assignments are not permitted |
| 9197 | stdin: |
| 9198 | foo=(a b) env |
| 9199 | expected-exit: e != 0 |
| 9200 | expected-stderr-pattern: |
| 9201 | /syntax error: unexpected 'env'/ |
| 9202 | --- |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 9203 | name: arrassign-fnc-none |
| 9204 | description: |
| 9205 | Check locality of array access inside a function |
| 9206 | stdin: |
| 9207 | function fn { |
| 9208 | x+=(f) |
| 9209 | echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:" |
| 9210 | } |
| 9211 | function rfn { |
| 9212 | if [[ -n $BASH_VERSION ]]; then |
| 9213 | y=() |
| 9214 | else |
| 9215 | set -A y |
| 9216 | fi |
| 9217 | y+=(f) |
| 9218 | echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:" |
| 9219 | } |
| 9220 | x=(m m) |
| 9221 | y=(m m) |
| 9222 | echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:" |
| 9223 | fn |
| 9224 | echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:" |
| 9225 | fn |
| 9226 | echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:" |
| 9227 | echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:" |
| 9228 | rfn |
| 9229 | echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:" |
| 9230 | rfn |
| 9231 | echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:" |
| 9232 | expected-stdout: |
| 9233 | .f0:m.m..: |
| 9234 | .fn:m.m.f.: |
| 9235 | .f1:m.m.f.: |
| 9236 | .fn:m.m.f.f: |
| 9237 | .f2:m.m.f.f: |
| 9238 | .rf0:m.m..: |
| 9239 | .rfn:f...: |
| 9240 | .rf1:f...: |
| 9241 | .rfn:f...: |
| 9242 | .rf2:f...: |
| 9243 | --- |
| 9244 | name: arrassign-fnc-local |
| 9245 | description: |
| 9246 | Check locality of array access inside a function |
| 9247 | with the bash/mksh/ksh93 local/typeset keyword |
| 9248 | (note: ksh93 has no local; typeset works only in FKSH) |
| 9249 | stdin: |
| 9250 | function fn { |
| 9251 | typeset x |
| 9252 | x+=(f) |
| 9253 | echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:" |
| 9254 | } |
| 9255 | function rfn { |
| 9256 | if [[ -n $BASH_VERSION ]]; then |
| 9257 | y=() |
| 9258 | else |
| 9259 | set -A y |
| 9260 | fi |
| 9261 | typeset y |
| 9262 | y+=(f) |
| 9263 | echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:" |
| 9264 | } |
| 9265 | function fnr { |
| 9266 | typeset z |
| 9267 | if [[ -n $BASH_VERSION ]]; then |
| 9268 | z=() |
| 9269 | else |
| 9270 | set -A z |
| 9271 | fi |
| 9272 | z+=(f) |
| 9273 | echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:" |
| 9274 | } |
| 9275 | x=(m m) |
| 9276 | y=(m m) |
| 9277 | z=(m m) |
| 9278 | echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:" |
| 9279 | fn |
| 9280 | echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:" |
| 9281 | fn |
| 9282 | echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:" |
| 9283 | echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:" |
| 9284 | rfn |
| 9285 | echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:" |
| 9286 | rfn |
| 9287 | echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:" |
| 9288 | echo ".f0r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:" |
| 9289 | fnr |
| 9290 | echo ".f1r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:" |
| 9291 | fnr |
| 9292 | echo ".f2r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:" |
| 9293 | expected-stdout: |
| 9294 | .f0:m.m..: |
| 9295 | .fn:f...: |
| 9296 | .f1:m.m..: |
| 9297 | .fn:f...: |
| 9298 | .f2:m.m..: |
| 9299 | .rf0:m.m..: |
| 9300 | .rfn:f...: |
| 9301 | .rf1:...: |
| 9302 | .rfn:f...: |
| 9303 | .rf2:...: |
| 9304 | .f0r:m.m..: |
| 9305 | .fnr:f...: |
| 9306 | .f1r:m.m..: |
| 9307 | .fnr:f...: |
| 9308 | .f2r:m.m..: |
| 9309 | --- |
| 9310 | name: arrassign-fnc-global |
| 9311 | description: |
| 9312 | Check locality of array access inside a function |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 9313 | with the bash4/mksh/yash/zsh typeset -g keyword |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 9314 | stdin: |
| 9315 | function fn { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 9316 | typeset -g x |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 9317 | x+=(f) |
| 9318 | echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:" |
| 9319 | } |
| 9320 | function rfn { |
| 9321 | set -A y |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 9322 | typeset -g y |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 9323 | y+=(f) |
| 9324 | echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:" |
| 9325 | } |
| 9326 | function fnr { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 9327 | typeset -g z |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 9328 | set -A z |
| 9329 | z+=(f) |
| 9330 | echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:" |
| 9331 | } |
| 9332 | x=(m m) |
| 9333 | y=(m m) |
| 9334 | z=(m m) |
| 9335 | echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:" |
| 9336 | fn |
| 9337 | echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:" |
| 9338 | fn |
| 9339 | echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:" |
| 9340 | echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:" |
| 9341 | rfn |
| 9342 | echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:" |
| 9343 | rfn |
| 9344 | echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:" |
| 9345 | echo ".f0r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:" |
| 9346 | fnr |
| 9347 | echo ".f1r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:" |
| 9348 | fnr |
| 9349 | echo ".f2r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:" |
| 9350 | expected-stdout: |
| 9351 | .f0:m.m..: |
| 9352 | .fn:m.m.f.: |
| 9353 | .f1:m.m.f.: |
| 9354 | .fn:m.m.f.f: |
| 9355 | .f2:m.m.f.f: |
| 9356 | .rf0:m.m..: |
| 9357 | .rfn:f...: |
| 9358 | .rf1:f...: |
| 9359 | .rfn:f...: |
| 9360 | .rf2:f...: |
| 9361 | .f0r:m.m..: |
| 9362 | .fnr:f...: |
| 9363 | .f1r:f...: |
| 9364 | .fnr:f...: |
| 9365 | .f2r:f...: |
| 9366 | --- |
| 9367 | name: strassign-fnc-none |
| 9368 | description: |
| 9369 | Check locality of string access inside a function |
| 9370 | stdin: |
| 9371 | function fn { |
| 9372 | x+=f |
| 9373 | echo ".fn:$x:" |
| 9374 | } |
| 9375 | function rfn { |
| 9376 | y= |
| 9377 | y+=f |
| 9378 | echo ".rfn:$y:" |
| 9379 | } |
| 9380 | x=m |
| 9381 | y=m |
| 9382 | echo ".f0:$x:" |
| 9383 | fn |
| 9384 | echo ".f1:$x:" |
| 9385 | fn |
| 9386 | echo ".f2:$x:" |
| 9387 | echo ".rf0:$y:" |
| 9388 | rfn |
| 9389 | echo ".rf1:$y:" |
| 9390 | rfn |
| 9391 | echo ".rf2:$y:" |
| 9392 | expected-stdout: |
| 9393 | .f0:m: |
| 9394 | .fn:mf: |
| 9395 | .f1:mf: |
| 9396 | .fn:mff: |
| 9397 | .f2:mff: |
| 9398 | .rf0:m: |
| 9399 | .rfn:f: |
| 9400 | .rf1:f: |
| 9401 | .rfn:f: |
| 9402 | .rf2:f: |
| 9403 | --- |
| 9404 | name: strassign-fnc-local |
| 9405 | description: |
| 9406 | Check locality of string access inside a function |
| 9407 | with the bash/mksh/ksh93 local/typeset keyword |
| 9408 | (note: ksh93 has no local; typeset works only in FKSH) |
| 9409 | stdin: |
| 9410 | function fn { |
| 9411 | typeset x |
| 9412 | x+=f |
| 9413 | echo ".fn:$x:" |
| 9414 | } |
| 9415 | function rfn { |
| 9416 | y= |
| 9417 | typeset y |
| 9418 | y+=f |
| 9419 | echo ".rfn:$y:" |
| 9420 | } |
| 9421 | function fnr { |
| 9422 | typeset z |
| 9423 | z= |
| 9424 | z+=f |
| 9425 | echo ".fnr:$z:" |
| 9426 | } |
| 9427 | x=m |
| 9428 | y=m |
| 9429 | z=m |
| 9430 | echo ".f0:$x:" |
| 9431 | fn |
| 9432 | echo ".f1:$x:" |
| 9433 | fn |
| 9434 | echo ".f2:$x:" |
| 9435 | echo ".rf0:$y:" |
| 9436 | rfn |
| 9437 | echo ".rf1:$y:" |
| 9438 | rfn |
| 9439 | echo ".rf2:$y:" |
| 9440 | echo ".f0r:$z:" |
| 9441 | fnr |
| 9442 | echo ".f1r:$z:" |
| 9443 | fnr |
| 9444 | echo ".f2r:$z:" |
| 9445 | expected-stdout: |
| 9446 | .f0:m: |
| 9447 | .fn:f: |
| 9448 | .f1:m: |
| 9449 | .fn:f: |
| 9450 | .f2:m: |
| 9451 | .rf0:m: |
| 9452 | .rfn:f: |
| 9453 | .rf1:: |
| 9454 | .rfn:f: |
| 9455 | .rf2:: |
| 9456 | .f0r:m: |
| 9457 | .fnr:f: |
| 9458 | .f1r:m: |
| 9459 | .fnr:f: |
| 9460 | .f2r:m: |
| 9461 | --- |
| 9462 | name: strassign-fnc-global |
| 9463 | description: |
| 9464 | Check locality of string access inside a function |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 9465 | with the bash4/mksh/yash/zsh typeset -g keyword |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 9466 | stdin: |
| 9467 | function fn { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 9468 | typeset -g x |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 9469 | x+=f |
| 9470 | echo ".fn:$x:" |
| 9471 | } |
| 9472 | function rfn { |
| 9473 | y= |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 9474 | typeset -g y |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 9475 | y+=f |
| 9476 | echo ".rfn:$y:" |
| 9477 | } |
| 9478 | function fnr { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 9479 | typeset -g z |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 9480 | z= |
| 9481 | z+=f |
| 9482 | echo ".fnr:$z:" |
| 9483 | } |
| 9484 | x=m |
| 9485 | y=m |
| 9486 | z=m |
| 9487 | echo ".f0:$x:" |
| 9488 | fn |
| 9489 | echo ".f1:$x:" |
| 9490 | fn |
| 9491 | echo ".f2:$x:" |
| 9492 | echo ".rf0:$y:" |
| 9493 | rfn |
| 9494 | echo ".rf1:$y:" |
| 9495 | rfn |
| 9496 | echo ".rf2:$y:" |
| 9497 | echo ".f0r:$z:" |
| 9498 | fnr |
| 9499 | echo ".f1r:$z:" |
| 9500 | fnr |
| 9501 | echo ".f2r:$z:" |
| 9502 | expected-stdout: |
| 9503 | .f0:m: |
| 9504 | .fn:mf: |
| 9505 | .f1:mf: |
| 9506 | .fn:mff: |
| 9507 | .f2:mff: |
| 9508 | .rf0:m: |
| 9509 | .rfn:f: |
| 9510 | .rf1:f: |
| 9511 | .rfn:f: |
| 9512 | .rf2:f: |
| 9513 | .f0r:m: |
| 9514 | .fnr:f: |
| 9515 | .f1r:f: |
| 9516 | .fnr:f: |
| 9517 | .f2r:f: |
| 9518 | --- |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 9519 | name: unset-fnc-local-ksh |
| 9520 | description: |
| 9521 | Check that âunsetâ removes a previous âlocalâ |
| 9522 | (ksh93 syntax compatible version); apparently, |
| 9523 | there are shells which fail this? |
| 9524 | stdin: |
| 9525 | function f { |
| 9526 | echo f0: $x |
| 9527 | typeset x |
| 9528 | echo f1: $x |
| 9529 | x=fa |
| 9530 | echo f2: $x |
| 9531 | unset x |
| 9532 | echo f3: $x |
| 9533 | x=fb |
| 9534 | echo f4: $x |
| 9535 | } |
| 9536 | x=o |
| 9537 | echo before: $x |
| 9538 | f |
| 9539 | echo after: $x |
| 9540 | expected-stdout: |
| 9541 | before: o |
| 9542 | f0: o |
| 9543 | f1: |
| 9544 | f2: fa |
| 9545 | f3: o |
| 9546 | f4: fb |
| 9547 | after: fb |
| 9548 | --- |
| 9549 | name: unset-fnc-local-sh |
| 9550 | description: |
| 9551 | Check that âunsetâ removes a previous âlocalâ |
| 9552 | (Debian Policy §10.4 sh version); apparently, |
| 9553 | there are shells which fail this? |
| 9554 | stdin: |
| 9555 | f() { |
| 9556 | echo f0: $x |
| 9557 | local x |
| 9558 | echo f1: $x |
| 9559 | x=fa |
| 9560 | echo f2: $x |
| 9561 | unset x |
| 9562 | echo f3: $x |
| 9563 | x=fb |
| 9564 | echo f4: $x |
| 9565 | } |
| 9566 | x=o |
| 9567 | echo before: $x |
| 9568 | f |
| 9569 | echo after: $x |
| 9570 | expected-stdout: |
| 9571 | before: o |
| 9572 | f0: o |
| 9573 | f1: |
| 9574 | f2: fa |
| 9575 | f3: o |
| 9576 | f4: fb |
| 9577 | after: fb |
| 9578 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 9579 | name: varexpand-substr-1 |
| 9580 | description: |
| 9581 | Check if bash-style substring expansion works |
| 9582 | when using positive numerics |
| 9583 | stdin: |
| 9584 | x=abcdefghi |
| 9585 | typeset -i y=123456789 |
| 9586 | typeset -i 16 z=123456789 # 16#75bcd15 |
| 9587 | echo a t${x:2:2} ${y:2:3} ${z:2:3} a |
| 9588 | echo b ${x::3} ${y::3} ${z::3} b |
| 9589 | echo c ${x:2:} ${y:2:} ${z:2:} c |
| 9590 | echo d ${x:2} ${y:2} ${z:2} d |
| 9591 | echo e ${x:2:6} ${y:2:6} ${z:2:7} e |
| 9592 | echo f ${x:2:7} ${y:2:7} ${z:2:8} f |
| 9593 | echo g ${x:2:8} ${y:2:8} ${z:2:9} g |
| 9594 | expected-stdout: |
| 9595 | a tcd 345 #75 a |
| 9596 | b abc 123 16# b |
| 9597 | c c |
| 9598 | d cdefghi 3456789 #75bcd15 d |
| 9599 | e cdefgh 345678 #75bcd1 e |
| 9600 | f cdefghi 3456789 #75bcd15 f |
| 9601 | g cdefghi 3456789 #75bcd15 g |
| 9602 | --- |
| 9603 | name: varexpand-substr-2 |
| 9604 | description: |
| 9605 | Check if bash-style substring expansion works |
| 9606 | when using negative numerics or expressions |
| 9607 | stdin: |
| 9608 | x=abcdefghi |
| 9609 | typeset -i y=123456789 |
| 9610 | typeset -i 16 z=123456789 # 16#75bcd15 |
| 9611 | n=2 |
| 9612 | echo a ${x:$n:3} ${y:$n:3} ${z:$n:3} a |
| 9613 | echo b ${x:(n):3} ${y:(n):3} ${z:(n):3} b |
| 9614 | echo c ${x:(-2):1} ${y:(-2):1} ${z:(-2):1} c |
| 9615 | echo d t${x: n:2} ${y: n:3} ${z: n:3} d |
| 9616 | expected-stdout: |
| 9617 | a cde 345 #75 a |
| 9618 | b cde 345 #75 b |
| 9619 | c h 8 1 c |
| 9620 | d tcd 345 #75 d |
| 9621 | --- |
| 9622 | name: varexpand-substr-3 |
| 9623 | description: |
| 9624 | Check that some things that work in bash fail. |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 9625 | This is by design. Oh and vice versa, nowadays. |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 9626 | stdin: |
| 9627 | export x=abcdefghi n=2 |
| 9628 | "$__progname" -c 'echo v${x:(n)}x' |
| 9629 | "$__progname" -c 'echo w${x: n}x' |
| 9630 | "$__progname" -c 'echo x${x:n}x' |
| 9631 | "$__progname" -c 'echo y${x:}x' |
| 9632 | "$__progname" -c 'echo z${x}x' |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 9633 | # next fails only in bash |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 9634 | "$__progname" -c 'x=abcdef;y=123;echo ${x:${y:2:1}:2}' >/dev/null 2>&1; echo $? |
| 9635 | expected-stdout: |
| 9636 | vcdefghix |
| 9637 | wcdefghix |
| 9638 | zabcdefghix |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 9639 | 0 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 9640 | expected-stderr-pattern: |
| 9641 | /x:n.*bad substitution.*\n.*bad substitution/ |
| 9642 | --- |
| 9643 | name: varexpand-substr-4 |
| 9644 | description: |
| 9645 | Check corner cases for substring expansion |
| 9646 | stdin: |
| 9647 | x=abcdefghi |
| 9648 | integer y=2 |
| 9649 | echo a ${x:(y == 1 ? 2 : 3):4} a |
| 9650 | expected-stdout: |
| 9651 | a defg a |
| 9652 | --- |
| 9653 | name: varexpand-substr-5A |
| 9654 | description: |
| 9655 | Check that substring expansions work on characters |
| 9656 | stdin: |
| 9657 | set +U |
| 9658 | x=mäh |
| 9659 | echo a ${x::1} ${x: -1} a |
| 9660 | echo b ${x::3} ${x: -3} b |
| 9661 | echo c ${x:1:2} ${x: -3:2} c |
| 9662 | echo d ${#x} d |
| 9663 | expected-stdout: |
| 9664 | a m h a |
| 9665 | b mä äh b |
| 9666 | c ä ä c |
| 9667 | d 4 d |
| 9668 | --- |
| 9669 | name: varexpand-substr-5W |
| 9670 | description: |
| 9671 | Check that substring expansions work on characters |
| 9672 | stdin: |
| 9673 | set -U |
| 9674 | x=mäh |
| 9675 | echo a ${x::1} ${x: -1} a |
| 9676 | echo b ${x::2} ${x: -2} b |
| 9677 | echo c ${x:1:1} ${x: -2:1} c |
| 9678 | echo d ${#x} d |
| 9679 | expected-stdout: |
| 9680 | a m h a |
| 9681 | b mä äh b |
| 9682 | c ä ä c |
| 9683 | d 3 d |
| 9684 | --- |
| 9685 | name: varexpand-substr-6 |
| 9686 | description: |
| 9687 | Check that string substitution works correctly |
| 9688 | stdin: |
| 9689 | foo=1 |
| 9690 | bar=2 |
| 9691 | baz=qwertyuiop |
| 9692 | echo a ${baz: foo: bar} |
| 9693 | echo b ${baz: foo: $bar} |
| 9694 | echo c ${baz: $foo: bar} |
| 9695 | echo d ${baz: $foo: $bar} |
| 9696 | expected-stdout: |
| 9697 | a we |
| 9698 | b we |
| 9699 | c we |
| 9700 | d we |
| 9701 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 9702 | name: varexpand-special-hash |
| 9703 | description: |
| 9704 | Check special ${var@x} expansion for x=hash |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 9705 | category: !shell:ebcdic-yes |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 9706 | stdin: |
| 9707 | typeset -i8 foo=10 |
| 9708 | bar=baz |
| 9709 | unset baz |
| 9710 | print ${foo@#} ${bar@#} ${baz@#} . |
| 9711 | expected-stdout: |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 9712 | 9B15FBFB CFBDD32B 00000000 . |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 9713 | --- |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 9714 | name: varexpand-special-hash-ebcdic |
| 9715 | description: |
| 9716 | Check special ${var@x} expansion for x=hash |
| 9717 | category: !shell:ebcdic-no |
| 9718 | stdin: |
| 9719 | typeset -i8 foo=10 |
| 9720 | bar=baz |
| 9721 | unset baz |
| 9722 | print ${foo@#} ${bar@#} ${baz@#} . |
| 9723 | expected-stdout: |
| 9724 | 016AE33D 9769C4AF 00000000 . |
| 9725 | --- |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 9726 | name: varexpand-special-quote |
| 9727 | description: |
| 9728 | Check special ${var@Q} expansion for quoted strings |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 9729 | category: !shell:faux-ebcdic |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 9730 | stdin: |
| 9731 | set +U |
| 9732 | i=x |
| 9733 | j=a\ b |
| 9734 | k=$'c |
| 9735 | d\xA0''eâ¬f' |
| 9736 | print -r -- "<i=$i j=$j k=$k>" |
| 9737 | s="u=${i@Q} v=${j@Q} w=${k@Q}" |
| 9738 | print -r -- "s=\"$s\"" |
| 9739 | eval "$s" |
| 9740 | typeset -p u v w |
| 9741 | expected-stdout: |
| 9742 | <i=x j=a b k=c |
| 9743 | d eâ¬f> |
| 9744 | s="u=x v='a b' w=$'c\nd\240e\u20ACf'" |
| 9745 | typeset u=x |
| 9746 | typeset v='a b' |
| 9747 | typeset w=$'c\nd\240e\u20ACf' |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 9748 | --- |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 9749 | name: varexpand-special-quote-faux-EBCDIC |
| 9750 | description: |
| 9751 | Check special ${var@Q} expansion for quoted strings |
| 9752 | category: shell:faux-ebcdic |
| 9753 | stdin: |
| 9754 | set +U |
| 9755 | i=x |
| 9756 | j=a\ b |
| 9757 | k=$'c |
| 9758 | d\xA0''eâ¬f' |
| 9759 | print -r -- "<i=$i j=$j k=$k>" |
| 9760 | s="u=${i@Q} v=${j@Q} w=${k@Q}" |
| 9761 | print -r -- "s=\"$s\"" |
| 9762 | eval "$s" |
| 9763 | typeset -p u v w |
| 9764 | expected-stdout: |
| 9765 | <i=x j=a b k=c |
| 9766 | d eâ¬f> |
| 9767 | s="u=x v='a b' w=$'c\nd e\u20ACf'" |
| 9768 | typeset u=x |
| 9769 | typeset v='a b' |
| 9770 | typeset w=$'c\nd e\u20ACf' |
| 9771 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 9772 | name: varexpand-null-1 |
| 9773 | description: |
| 9774 | Ensure empty strings expand emptily |
| 9775 | stdin: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 9776 | print s ${a} . ${b} S |
| 9777 | print t ${a#?} . ${b%?} T |
| 9778 | print r ${a=} . ${b/c/d} R |
| 9779 | print q |
| 9780 | print s "${a}" . "${b}" S |
| 9781 | print t "${a#?}" . "${b%?}" T |
| 9782 | print r "${a=}" . "${b/c/d}" R |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 9783 | expected-stdout: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 9784 | s . S |
| 9785 | t . T |
| 9786 | r . R |
| 9787 | q |
| 9788 | s . S |
| 9789 | t . T |
| 9790 | r . R |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 9791 | --- |
| 9792 | name: varexpand-null-2 |
| 9793 | description: |
| 9794 | Ensure empty strings, when quoted, are expanded as empty strings |
| 9795 | stdin: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 9796 | print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "<$x> "; done' >pfs |
| 9797 | chmod +x pfs |
| 9798 | ./pfs 1 "${a}" 2 "${a#?}" + "${b%?}" 3 "${a=}" + "${b/c/d}" |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 9799 | echo . |
| 9800 | expected-stdout: |
| 9801 | <1> <> <2> <> <+> <> <3> <> <+> <> . |
| 9802 | --- |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 9803 | name: varexpand-null-3 |
| 9804 | description: |
| 9805 | Ensure concatenating behaviour matches other shells |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 9806 | stdin: |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 9807 | showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 9808 | showargs 0 ""$@ |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 9809 | x=; showargs 1 "$x"$@ |
| 9810 | set A; showargs 2 "${@:+}" |
| 9811 | n() { echo "$#"; } |
| 9812 | unset e |
| 9813 | set -- a b |
| 9814 | n """$@" |
| 9815 | n "$@" |
| 9816 | n "$@""" |
| 9817 | n "$e""$@" |
| 9818 | n "$@" |
| 9819 | n "$@""$e" |
| 9820 | set -- |
| 9821 | n """$@" |
| 9822 | n "$@" |
| 9823 | n "$@""" |
| 9824 | n "$e""$@" |
| 9825 | n "$@" |
| 9826 | n "$@""$e" |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 9827 | expected-stdout: |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 9828 | <0> <> . |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 9829 | <1> <> . |
| 9830 | <2> <> . |
| 9831 | 2 |
| 9832 | 2 |
| 9833 | 2 |
| 9834 | 2 |
| 9835 | 2 |
| 9836 | 2 |
| 9837 | 1 |
| 9838 | 0 |
| 9839 | 1 |
| 9840 | 1 |
| 9841 | 0 |
| 9842 | 1 |
Elliott Hughes | 56b517d | 2014-10-06 11:30:44 -0700 | [diff] [blame] | 9843 | --- |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 9844 | name: varexpand-funny-chars |
| 9845 | description: |
| 9846 | Check some characters |
| 9847 | XXX \uEF80 is asymmetric, possibly buggy so we donât check this |
| 9848 | stdin: |
| 9849 | x=$'<\x00>'; typeset -p x |
| 9850 | x=$'<\x01>'; typeset -p x |
| 9851 | x=$'<\u0000>'; typeset -p x |
| 9852 | x=$'<\u0001>'; typeset -p x |
| 9853 | expected-stdout: |
| 9854 | typeset x='<' |
| 9855 | typeset x=$'<\001>' |
| 9856 | typeset x='<' |
| 9857 | typeset x=$'<\001>' |
| 9858 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 9859 | name: print-funny-chars |
| 9860 | description: |
| 9861 | Check print builtin's capability to output designated characters |
| 9862 | stdin: |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 9863 | { |
| 9864 | print '<\0144\0344\xDB\u00DB\u20AC\uDB\x40>' |
| 9865 | print '<\x00>' |
| 9866 | print '<\x01>' |
| 9867 | print '<\u0000>' |
| 9868 | print '<\u0001>' |
| 9869 | } | { |
| 9870 | # integer-base-one-3Ar |
| 9871 | typeset -Uui16 -Z11 pos=0 |
| 9872 | typeset -Uui16 -Z5 hv=2147483647 |
| 9873 | dasc= |
| 9874 | if read -arN -1 line; then |
| 9875 | typeset -i1 line |
| 9876 | i=0 |
| 9877 | while (( i < ${#line[*]} )); do |
| 9878 | hv=${line[i++]} |
| 9879 | if (( (pos & 15) == 0 )); then |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 9880 | (( pos )) && print -r -- "$dasc|" |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 9881 | print -n "${pos#16#} " |
| 9882 | dasc=' |' |
| 9883 | fi |
| 9884 | print -n "${hv#16#} " |
| 9885 | if (( (hv < 32) || (hv > 126) )); then |
| 9886 | dasc=$dasc. |
| 9887 | else |
| 9888 | dasc=$dasc${line[i-1]#1#} |
| 9889 | fi |
| 9890 | (( (pos++ & 15) == 7 )) && print -n -- '- ' |
| 9891 | done |
| 9892 | fi |
| 9893 | while (( pos & 15 )); do |
| 9894 | print -n ' ' |
| 9895 | (( (pos++ & 15) == 7 )) && print -n -- '- ' |
| 9896 | done |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 9897 | (( hv == 2147483647 )) || print -r -- "$dasc|" |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 9898 | } |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 9899 | expected-stdout: |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 9900 | 00000000 3C 64 E4 DB C3 9B E2 82 - AC C3 9B 40 3E 0A 3C 00 |<d.........@>.<.| |
| 9901 | 00000010 3E 0A 3C 01 3E 0A 3C 00 - 3E 0A 3C 01 3E 0A |>.<.>.<.>.<.>.| |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 9902 | --- |
| 9903 | name: print-bksl-c |
| 9904 | description: |
| 9905 | Check print builtin's \c escape |
| 9906 | stdin: |
| 9907 | print '\ca'; print b |
| 9908 | expected-stdout: |
| 9909 | ab |
| 9910 | --- |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 9911 | name: print-cr |
| 9912 | description: |
| 9913 | Check that CR+LF is not collapsed into LF as some MSYS shells wrongly do |
| 9914 | stdin: |
| 9915 | echo '#!'"$__progname" >foo |
| 9916 | cat >>foo <<-'EOF' |
| 9917 | print -n -- '220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT\r\n220->> Bitte keine Werbung einwerfen! <<\r\r\n220 Who do you wanna pretend to be today' |
| 9918 | print \?
|
| 9919 | EOF |
| 9920 | chmod +x foo |
| 9921 | echo "[$(./foo)]" |
| 9922 | ./foo | while IFS= read -r line; do |
| 9923 | print -r -- "{$line}" |
| 9924 | done |
| 9925 | expected-stdout: |
| 9926 | [220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT
|
| 9927 | 220->> Bitte keine Werbung einwerfen! <<
|
| 9928 | 220 Who do you wanna pretend to be today?
] |
| 9929 | {220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT
} |
| 9930 | {220->> Bitte keine Werbung einwerfen! <<
} |
| 9931 | {220 Who do you wanna pretend to be today?
} |
| 9932 | --- |
Elliott Hughes | b27ce95 | 2015-04-21 13:39:18 -0700 | [diff] [blame] | 9933 | name: print-crlf |
| 9934 | description: |
| 9935 | Check that CR+LF is shown and read as-is |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 9936 | category: shell:textmode-no |
Elliott Hughes | b27ce95 | 2015-04-21 13:39:18 -0700 | [diff] [blame] | 9937 | stdin: |
| 9938 | cat >foo <<-'EOF' |
| 9939 | x='bar
|
| 9940 | ' #
|
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 9941 | echo .${#x} #
|
Elliott Hughes | b27ce95 | 2015-04-21 13:39:18 -0700 | [diff] [blame] | 9942 | if test x"$KSH_VERSION" = x""; then #
|
| 9943 | printf '<%s>' "$x" #
|
| 9944 | else #
|
| 9945 | print -nr -- "<$x>" #
|
| 9946 | fi #
|
| 9947 | EOF |
| 9948 | echo "[$("$__progname" foo)]" |
| 9949 | "$__progname" foo | while IFS= read -r line; do |
| 9950 | print -r -- "{$line}" |
| 9951 | done |
| 9952 | expected-stdout: |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 9953 | [.5 |
| 9954 | <bar
|
Elliott Hughes | b27ce95 | 2015-04-21 13:39:18 -0700 | [diff] [blame] | 9955 | >] |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 9956 | {.5} |
Elliott Hughes | b27ce95 | 2015-04-21 13:39:18 -0700 | [diff] [blame] | 9957 | {<bar
} |
| 9958 | --- |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 9959 | name: print-crlf-textmode |
| 9960 | description: |
| 9961 | Check that CR+LF is treated as newline |
| 9962 | category: shell:textmode-yes |
| 9963 | stdin: |
| 9964 | cat >foo <<-'EOF' |
| 9965 | x='bar
|
| 9966 | ' #
|
| 9967 | echo .${#x} #
|
| 9968 | if test x"$KSH_VERSION" = x""; then #
|
| 9969 | printf '<%s>' "$x" #
|
| 9970 | else #
|
| 9971 | print -nr -- "<$x>" #
|
| 9972 | fi #
|
| 9973 | EOF |
| 9974 | echo "[$("$__progname" foo)]" |
| 9975 | "$__progname" foo | while IFS= read -r line; do |
| 9976 | print -r -- "{$line}" |
| 9977 | done |
| 9978 | expected-stdout: |
| 9979 | [.4 |
| 9980 | <bar |
| 9981 | >] |
| 9982 | {.4} |
| 9983 | {<bar} |
| 9984 | --- |
Elliott Hughes | b27ce95 | 2015-04-21 13:39:18 -0700 | [diff] [blame] | 9985 | name: print-lf |
| 9986 | description: |
| 9987 | Check that LF-only is shown and read as-is |
| 9988 | stdin: |
| 9989 | cat >foo <<-'EOF' |
| 9990 | x='bar |
| 9991 | ' # |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 9992 | echo .${#x} # |
Elliott Hughes | b27ce95 | 2015-04-21 13:39:18 -0700 | [diff] [blame] | 9993 | if test x"$KSH_VERSION" = x""; then # |
| 9994 | printf '<%s>' "$x" # |
| 9995 | else # |
| 9996 | print -nr -- "<$x>" # |
| 9997 | fi # |
| 9998 | EOF |
| 9999 | echo "[$("$__progname" foo)]" |
| 10000 | "$__progname" foo | while IFS= read -r line; do |
| 10001 | print -r -- "{$line}" |
| 10002 | done |
| 10003 | expected-stdout: |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 10004 | [.4 |
| 10005 | <bar |
Elliott Hughes | b27ce95 | 2015-04-21 13:39:18 -0700 | [diff] [blame] | 10006 | >] |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 10007 | {.4} |
Elliott Hughes | b27ce95 | 2015-04-21 13:39:18 -0700 | [diff] [blame] | 10008 | {<bar} |
| 10009 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10010 | name: print-nul-chars |
| 10011 | description: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 10012 | Check handling of NUL characters for print and COMSUB |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10013 | stdin: |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10014 | x=$(print '<\0>') |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 10015 | print $(($(print '<\0>' | wc -c))) $(($(print "$x" | wc -c))) \ |
| 10016 | ${#x} "$x" '<\0>' |
| 10017 | expected-stdout-pattern: |
| 10018 | /^4 3 2 <> <\0>$/ |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10019 | --- |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 10020 | name: print-array |
| 10021 | description: |
| 10022 | Check that print -A works as expected |
| 10023 | stdin: |
| 10024 | print -An 0x20AC 0xC3 0xBC 8#101 |
| 10025 | set -U |
| 10026 | print -A 0x20AC 0xC3 0xBC 8#102 |
| 10027 | expected-stdout: |
| 10028 | ¬Ã¼Aâ¬Ã¼B |
| 10029 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10030 | name: print-escapes |
| 10031 | description: |
| 10032 | Check backslash expansion by the print builtin |
| 10033 | stdin: |
| 10034 | print '\ \!\"\#\$\%\&'\\\''\(\)\*\+\,\-\.\/\0\1\2\3\4\5\6\7\8' \ |
| 10035 | '\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T' \ |
| 10036 | '\U\V\W\X\Y\Z\[\\\]\^\_\`\a\b \d\e\f\g\h\i\j\k\l\m\n\o\p' \ |
| 10037 | '\q\r\s\t\u\v\w\x\y\z\{\|\}\~' '\u20acd' '\U20acd' '\x123' \ |
| 10038 | '\0x' '\0123' '\01234' | { |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10039 | # integer-base-one-3As |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10040 | typeset -Uui16 -Z11 pos=0 |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10041 | typeset -Uui16 -Z5 hv=2147483647 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10042 | typeset -i1 wc=0x0A |
| 10043 | dasc= |
| 10044 | nl=${wc#1#} |
| 10045 | while IFS= read -r line; do |
| 10046 | line=$line$nl |
| 10047 | while [[ -n $line ]]; do |
| 10048 | hv=1#${line::1} |
| 10049 | if (( (pos & 15) == 0 )); then |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 10050 | (( pos )) && print -r -- "$dasc|" |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10051 | print -n "${pos#16#} " |
| 10052 | dasc=' |' |
| 10053 | fi |
| 10054 | print -n "${hv#16#} " |
| 10055 | if (( (hv < 32) || (hv > 126) )); then |
| 10056 | dasc=$dasc. |
| 10057 | else |
| 10058 | dasc=$dasc${line::1} |
| 10059 | fi |
| 10060 | (( (pos++ & 15) == 7 )) && print -n -- '- ' |
| 10061 | line=${line:1} |
| 10062 | done |
| 10063 | done |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10064 | while (( pos & 15 )); do |
| 10065 | print -n ' ' |
| 10066 | (( (pos++ & 15) == 7 )) && print -n -- '- ' |
| 10067 | done |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 10068 | (( hv == 2147483647 )) || print -r -- "$dasc|" |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10069 | } |
| 10070 | expected-stdout: |
| 10071 | 00000000 5C 20 5C 21 5C 22 5C 23 - 5C 24 5C 25 5C 26 5C 27 |\ \!\"\#\$\%\&\'| |
| 10072 | 00000010 5C 28 5C 29 5C 2A 5C 2B - 5C 2C 5C 2D 5C 2E 5C 2F |\(\)\*\+\,\-\.\/| |
| 10073 | 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| |
| 10074 | 00000030 20 5C 39 5C 3A 5C 3B 5C - 3C 5C 3D 5C 3E 5C 3F 5C | \9\:\;\<\=\>\?\| |
| 10075 | 00000040 40 5C 41 5C 42 5C 43 5C - 44 1B 5C 46 5C 47 5C 48 |@\A\B\C\D.\F\G\H| |
| 10076 | 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| |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 10077 | 00000060 5C 51 5C 52 5C 53 5C 54 - 20 5C 55 5C 56 5C 57 5C |\Q\R\S\T \U\V\W\| |
| 10078 | 00000070 58 5C 59 5C 5A 5C 5B 5C - 5C 5D 5C 5E 5C 5F 5C 60 |X\Y\Z\[\\]\^\_\`| |
| 10079 | 00000080 07 08 20 20 5C 64 1B 0C - 5C 67 5C 68 5C 69 5C 6A |.. \d..\g\h\i\j| |
| 10080 | 00000090 5C 6B 5C 6C 5C 6D 0A 5C - 6F 5C 70 20 5C 71 0D 5C |\k\l\m.\o\p \q.\| |
| 10081 | 000000A0 73 09 5C 75 0B 5C 77 5C - 78 5C 79 5C 7A 5C 7B 5C |s.\u.\w\x\y\z\{\| |
| 10082 | 000000B0 7C 5C 7D 5C 7E 20 E2 82 - AC 64 20 EF BF BD 20 12 ||\}\~ ...d ... .| |
| 10083 | 000000C0 33 20 78 20 53 20 53 34 - 0A |3 x S S4.| |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10084 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10085 | name: dollar-doublequoted-strings |
| 10086 | description: |
| 10087 | Check that a $ preceding "â¦" is ignored |
| 10088 | stdin: |
| 10089 | echo $"Localise me!" |
| 10090 | cat <<<$"Me too!" |
| 10091 | V=X |
| 10092 | aol=aol |
| 10093 | cat <<-$"aol" |
| 10094 | I do not take a $V for a V! |
| 10095 | aol |
| 10096 | expected-stdout: |
| 10097 | Localise me! |
| 10098 | Me too! |
| 10099 | I do not take a $V for a V! |
| 10100 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10101 | name: dollar-quoted-strings |
| 10102 | description: |
| 10103 | Check backslash expansion by $'â¦' strings |
| 10104 | stdin: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 10105 | print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn |
| 10106 | chmod +x pfn |
| 10107 | ./pfn $'\ \!\"\#\$\%\&\'\(\)\*\+\,\-\.\/ \1\2\3\4\5\6' \ |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10108 | $'a\0b' $'a\01b' $'\7\8\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I' \ |
| 10109 | $'\J\K\L\M\N\O\P\Q\R\S\T\U1\V\W\X\Y\Z\[\\\]\^\_\`\a\b\d\e' \ |
| 10110 | $'\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u1\v\w\x1\y\z\{\|\}\~ $x' \ |
| 10111 | $'\u20acd' $'\U20acd' $'\x123' $'fn\x0rd' $'\0234' $'\234' \ |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 10112 | $'\2345' $'\ca' $'\c!' $'\c?' $'\câ¦' $'a\ |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10113 | b' | { |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10114 | # integer-base-one-3As |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10115 | typeset -Uui16 -Z11 pos=0 |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10116 | typeset -Uui16 -Z5 hv=2147483647 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10117 | typeset -i1 wc=0x0A |
| 10118 | dasc= |
| 10119 | nl=${wc#1#} |
| 10120 | while IFS= read -r line; do |
| 10121 | line=$line$nl |
| 10122 | while [[ -n $line ]]; do |
| 10123 | hv=1#${line::1} |
| 10124 | if (( (pos & 15) == 0 )); then |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 10125 | (( pos )) && print -r -- "$dasc|" |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10126 | print -n "${pos#16#} " |
| 10127 | dasc=' |' |
| 10128 | fi |
| 10129 | print -n "${hv#16#} " |
| 10130 | if (( (hv < 32) || (hv > 126) )); then |
| 10131 | dasc=$dasc. |
| 10132 | else |
| 10133 | dasc=$dasc${line::1} |
| 10134 | fi |
| 10135 | (( (pos++ & 15) == 7 )) && print -n -- '- ' |
| 10136 | line=${line:1} |
| 10137 | done |
| 10138 | done |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10139 | while (( pos & 15 )); do |
| 10140 | print -n ' ' |
| 10141 | (( (pos++ & 15) == 7 )) && print -n -- '- ' |
| 10142 | done |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 10143 | (( hv == 2147483647 )) || print -r -- "$dasc|" |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10144 | } |
| 10145 | expected-stdout: |
| 10146 | 00000000 20 21 22 23 24 25 26 27 - 28 29 2A 2B 2C 2D 2E 2F | !"#$%&'()*+,-./| |
| 10147 | 00000010 20 01 02 03 04 05 06 0A - 61 0A 61 01 62 0A 07 38 | .......a.a.b..8| |
| 10148 | 00000020 39 3A 3B 3C 3D 3E 3F 40 - 41 42 43 44 1B 46 47 48 |9:;<=>?@ABCD.FGH| |
| 10149 | 00000030 49 0A 4A 4B 4C 4D 4E 4F - 50 51 52 53 54 01 56 57 |I.JKLMNOPQRST.VW| |
| 10150 | 00000040 58 59 5A 5B 5C 5D 5E 5F - 60 07 08 64 1B 0A 0C 67 |XYZ[\]^_`..d...g| |
| 10151 | 00000050 68 69 6A 6B 6C 6D 0A 6F - 70 71 0D 73 09 01 0B 77 |hijklm.opq.s...w| |
| 10152 | 00000060 01 79 7A 7B 7C 7D 7E 20 - 24 78 0A E2 82 AC 64 0A |.yz{|}~ $x....d.| |
| 10153 | 00000070 EF BF BD 0A C4 A3 0A 66 - 6E 0A 13 34 0A 9C 0A 9C |.......fn..4....| |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 10154 | 00000080 35 0A 01 0A 01 0A 7F 0A - 82 80 A6 0A 61 0A 62 0A |5...........a.b.| |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10155 | --- |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 10156 | name: dollar-quotes-in-heredocs-strings |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10157 | description: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 10158 | They are, however, not parsed in here documents, here strings |
| 10159 | (outside of string delimiters) or regular strings, but in |
| 10160 | parameter substitutions. |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10161 | stdin: |
| 10162 | cat <<EOF |
| 10163 | dollar = strchr(s, '$'); /* ' */ |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 10164 | foo " bar \" baz |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10165 | EOF |
| 10166 | cat <<$'a\tb' |
| 10167 | a\tb |
| 10168 | a b |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10169 | cat <<<"dollar = strchr(s, '$'); /* ' */" |
| 10170 | cat <<<'dollar = strchr(s, '\''$'\''); /* '\'' */' |
| 10171 | x="dollar = strchr(s, '$'); /* ' */" |
| 10172 | cat <<<"$x" |
| 10173 | cat <<<$'a\E[0m\tb' |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 10174 | unset nl; print -r -- "x${nl:=$'\n'}y" |
| 10175 | echo "1 foo\"bar" |
| 10176 | # cf & HEREDOC |
| 10177 | cat <<EOF |
| 10178 | 2 foo\"bar |
| 10179 | EOF |
| 10180 | # probably never reached for here strings? |
| 10181 | cat <<<"3 foo\"bar" |
| 10182 | cat <<<"4 foo\\\"bar" |
| 10183 | cat <<<'5 foo\"bar' |
| 10184 | # old scripts use this (e.g. ncurses) |
| 10185 | echo "^$" |
| 10186 | # make sure this works, outside of quotes |
| 10187 | cat <<<'7'$'\t''.' |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10188 | expected-stdout: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 10189 | dollar = strchr(s, '$'); /* ' */ |
| 10190 | foo " bar \" baz |
| 10191 | a\tb |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10192 | dollar = strchr(s, '$'); /* ' */ |
| 10193 | dollar = strchr(s, '$'); /* ' */ |
| 10194 | dollar = strchr(s, '$'); /* ' */ |
| 10195 | a[0m b |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 10196 | x |
| 10197 | y |
| 10198 | 1 foo"bar |
| 10199 | 2 foo\"bar |
| 10200 | 3 foo"bar |
| 10201 | 4 foo\"bar |
| 10202 | 5 foo\"bar |
| 10203 | ^$ |
| 10204 | 7 . |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10205 | --- |
| 10206 | name: dot-needs-argument |
| 10207 | description: |
| 10208 | check Debian #415167 solution: '.' without arguments should fail |
| 10209 | stdin: |
| 10210 | "$__progname" -c . |
| 10211 | "$__progname" -c source |
| 10212 | expected-exit: e != 0 |
| 10213 | expected-stderr-pattern: |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 10214 | /\.: missing argument.*\n.*source: missing argument/ |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10215 | --- |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 10216 | name: dot-errorlevel |
| 10217 | description: |
| 10218 | Ensure dot resets $? |
| 10219 | stdin: |
| 10220 | :>dotfile |
| 10221 | (exit 42) |
| 10222 | . ./dotfile |
| 10223 | echo 1 $? . |
| 10224 | expected-stdout: |
| 10225 | 1 0 . |
| 10226 | --- |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 10227 | name: alias-function-no-conflict |
| 10228 | description: |
| 10229 | make aliases not conflict with function definitions |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 10230 | stdin: |
| 10231 | # POSIX function can be defined, but alias overrides it |
| 10232 | alias foo='echo bar' |
| 10233 | foo |
| 10234 | foo() { |
| 10235 | echo baz |
| 10236 | } |
| 10237 | foo |
| 10238 | unset -f foo |
| 10239 | foo 2>/dev/null || echo rab |
| 10240 | # alias overrides ksh function |
| 10241 | alias korn='echo bar' |
| 10242 | korn |
| 10243 | function korn { |
| 10244 | echo baz |
| 10245 | } |
| 10246 | korn |
| 10247 | # alias temporarily overrides POSIX function |
| 10248 | bla() { |
| 10249 | echo bfn |
| 10250 | } |
| 10251 | bla |
| 10252 | alias bla='echo bal' |
| 10253 | bla |
| 10254 | unalias bla |
| 10255 | bla |
| 10256 | expected-stdout: |
| 10257 | bar |
| 10258 | bar |
| 10259 | bar |
| 10260 | bar |
| 10261 | bar |
| 10262 | bfn |
| 10263 | bal |
| 10264 | bfn |
| 10265 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10266 | name: bash-function-parens |
| 10267 | description: |
| 10268 | ensure the keyword function is ignored when preceding |
| 10269 | POSIX style function declarations (bashism) |
| 10270 | stdin: |
| 10271 | mk() { |
| 10272 | echo '#!'"$__progname" |
| 10273 | echo "$1 {" |
| 10274 | echo ' echo "bar='\''$0'\'\" |
| 10275 | echo '}' |
Elliott Hughes | b27ce95 | 2015-04-21 13:39:18 -0700 | [diff] [blame] | 10276 | print -r -- "${2:-foo}" |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10277 | } |
| 10278 | mk 'function foo' >f-korn |
| 10279 | mk 'foo ()' >f-dash |
| 10280 | mk 'function foo ()' >f-bash |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 10281 | print '#!'"$__progname"'\nprint -r -- "${0%/f-argh}"' >f-argh |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10282 | chmod +x f-* |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 10283 | u=$(./f-argh) |
| 10284 | x="korn: $(./f-korn)"; echo "${x/@("$u")/.}" |
| 10285 | x="dash: $(./f-dash)"; echo "${x/@("$u")/.}" |
| 10286 | x="bash: $(./f-bash)"; echo "${x/@("$u")/.}" |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10287 | expected-stdout: |
| 10288 | korn: bar='foo' |
| 10289 | dash: bar='./f-dash' |
| 10290 | bash: bar='./f-bash' |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10291 | --- |
| 10292 | name: integer-base-one-1 |
| 10293 | description: |
| 10294 | check if the use of fake integer base 1 works |
| 10295 | stdin: |
| 10296 | set -U |
| 10297 | typeset -Uui16 i0=1#ï i1=1#⬠|
| 10298 | typeset -i1 o0a=64 |
| 10299 | typeset -i1 o1a=0x263A |
| 10300 | typeset -Uui1 o0b=0x7E |
| 10301 | typeset -Uui1 o1b=0xFDD0 |
| 10302 | integer px=0xCAFE 'p0=1# ' p1=1#⦠pl=1#f |
| 10303 | echo "in <$i0> <$i1>" |
| 10304 | echo "out <${o0a#1#}|${o0b#1#}> <${o1a#1#}|${o1b#1#}>" |
| 10305 | typeset -Uui1 i0 i1 |
| 10306 | echo "pass <$px> <$p0> <$p1> <$pl> <${i0#1#}|${i1#1#}>" |
| 10307 | typeset -Uui16 tv1=1#~ tv2=1# tv3=1# tv4=1# tv5=1#À tv6=1#Á tv7=1#Â tv8=1#Â |
| 10308 | echo "specX <${tv1#16#}> <${tv2#16#}> <${tv3#16#}> <${tv4#16#}> <${tv5#16#}> <${tv6#16#}> <${tv7#16#}> <${tv8#16#}>" |
| 10309 | typeset -i1 tv1 tv2 tv3 tv4 tv5 tv6 tv7 tv8 |
| 10310 | echo "specW <${tv1#1#}> <${tv2#1#}> <${tv3#1#}> <${tv4#1#}> <${tv5#1#}> <${tv6#1#}> <${tv7#1#}> <${tv8#1#}>" |
| 10311 | typeset -i1 xs1=0xEF7F xs2=0xEF80 xs3=0xFDD0 |
| 10312 | echo "specU <${xs1#1#}> <${xs2#1#}> <${xs3#1#}>" |
| 10313 | expected-stdout: |
| 10314 | in <16#EFEF> <16#20AC> |
| 10315 | out <@|~> <âº|ï·> |
| 10316 | pass <16#cafe> <1# > <1#â¦> <1#f> <ï|â¬> |
| 10317 | specX <7E> <7F> <EF80> <EF81> <EFC0> <EFC1> <A0> <80> |
| 10318 | specW <~> <> <> <> <À> <Á> <Â > <Â> |
| 10319 | specU <> <> <ï·> |
| 10320 | --- |
| 10321 | name: integer-base-one-2a |
| 10322 | description: |
| 10323 | check if the use of fake integer base 1 stops at correct characters |
| 10324 | stdin: |
| 10325 | set -U |
| 10326 | integer x=1#foo |
| 10327 | echo /$x/ |
| 10328 | expected-stderr-pattern: |
| 10329 | /1#foo: unexpected 'oo'/ |
| 10330 | expected-exit: e != 0 |
| 10331 | --- |
| 10332 | name: integer-base-one-2b |
| 10333 | description: |
| 10334 | check if the use of fake integer base 1 stops at correct characters |
| 10335 | stdin: |
| 10336 | set -U |
| 10337 | integer x=1#À |
| 10338 | echo /$x/ |
| 10339 | expected-stderr-pattern: |
| 10340 | /1#À: unexpected ''/ |
| 10341 | expected-exit: e != 0 |
| 10342 | --- |
| 10343 | name: integer-base-one-2c1 |
| 10344 | description: |
| 10345 | check if the use of fake integer base 1 stops at correct characters |
| 10346 | stdin: |
| 10347 | set -U |
| 10348 | integer x=1#⦠|
| 10349 | echo /$x/ |
| 10350 | expected-stdout: |
| 10351 | /1#â¦/ |
| 10352 | --- |
| 10353 | name: integer-base-one-2c2 |
| 10354 | description: |
| 10355 | check if the use of fake integer base 1 stops at correct characters |
| 10356 | stdin: |
| 10357 | set +U |
| 10358 | integer x=1#⦠|
| 10359 | echo /$x/ |
| 10360 | expected-stderr-pattern: |
| 10361 | /1#â¦: unexpected ''/ |
| 10362 | expected-exit: e != 0 |
| 10363 | --- |
| 10364 | name: integer-base-one-2d1 |
| 10365 | description: |
| 10366 | check if the use of fake integer base 1 handles octets okay |
| 10367 | stdin: |
| 10368 | set -U |
| 10369 | typeset -i16 x=1#ÿ |
| 10370 | echo /$x/ # invalid utf-8 |
| 10371 | expected-stdout: |
| 10372 | /16#efff/ |
| 10373 | --- |
| 10374 | name: integer-base-one-2d2 |
| 10375 | description: |
| 10376 | check if the use of fake integer base 1 handles octets |
| 10377 | stdin: |
| 10378 | set -U |
| 10379 | typeset -i16 x=1#Â |
| 10380 | echo /$x/ # invalid 2-byte |
| 10381 | expected-stdout: |
| 10382 | /16#efc2/ |
| 10383 | --- |
| 10384 | name: integer-base-one-2d3 |
| 10385 | description: |
| 10386 | check if the use of fake integer base 1 handles octets |
| 10387 | stdin: |
| 10388 | set -U |
| 10389 | typeset -i16 x=1#ï |
| 10390 | echo /$x/ # invalid 2-byte |
| 10391 | expected-stdout: |
| 10392 | /16#efef/ |
| 10393 | --- |
| 10394 | name: integer-base-one-2d4 |
| 10395 | description: |
| 10396 | check if the use of fake integer base 1 stops at invalid input |
| 10397 | stdin: |
| 10398 | set -U |
| 10399 | typeset -i16 x=1#ï¿À |
| 10400 | echo /$x/ # invalid 3-byte |
| 10401 | expected-stderr-pattern: |
| 10402 | /1#ï¿À: unexpected '¿'/ |
| 10403 | expected-exit: e != 0 |
| 10404 | --- |
| 10405 | name: integer-base-one-2d5 |
| 10406 | description: |
| 10407 | check if the use of fake integer base 1 stops at invalid input |
| 10408 | stdin: |
| 10409 | set -U |
| 10410 | typeset -i16 x=1#À |
| 10411 | echo /$x/ # non-minimalistic |
| 10412 | expected-stderr-pattern: |
| 10413 | /1#À: unexpected ''/ |
| 10414 | expected-exit: e != 0 |
| 10415 | --- |
| 10416 | name: integer-base-one-2d6 |
| 10417 | description: |
| 10418 | check if the use of fake integer base 1 stops at invalid input |
| 10419 | stdin: |
| 10420 | set -U |
| 10421 | typeset -i16 x=1#à |
| 10422 | echo /$x/ # non-minimalistic |
| 10423 | expected-stderr-pattern: |
| 10424 | /1#à: unexpected ''/ |
| 10425 | expected-exit: e != 0 |
| 10426 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10427 | name: integer-base-one-3As |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10428 | description: |
| 10429 | some sample code for hexdumping |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10430 | not NUL safe; input lines must be NL terminated |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10431 | stdin: |
| 10432 | { |
| 10433 | print 'Hello, World!\\\nããã«ã¡ã¯ï¼' |
| 10434 | typeset -Uui16 i=0x100 |
| 10435 | # change that to 0xFF once we can handle embedded |
| 10436 | # NUL characters in strings / here documents |
| 10437 | while (( i++ < 0x1FF )); do |
| 10438 | print -n "\x${i#16#1}" |
| 10439 | done |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10440 | print '\0z' |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10441 | } | { |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10442 | # integer-base-one-3As |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10443 | typeset -Uui16 -Z11 pos=0 |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10444 | typeset -Uui16 -Z5 hv=2147483647 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10445 | typeset -i1 wc=0x0A |
| 10446 | dasc= |
| 10447 | nl=${wc#1#} |
| 10448 | while IFS= read -r line; do |
| 10449 | line=$line$nl |
| 10450 | while [[ -n $line ]]; do |
| 10451 | hv=1#${line::1} |
| 10452 | if (( (pos & 15) == 0 )); then |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 10453 | (( pos )) && print -r -- "$dasc|" |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10454 | print -n "${pos#16#} " |
| 10455 | dasc=' |' |
| 10456 | fi |
| 10457 | print -n "${hv#16#} " |
| 10458 | if (( (hv < 32) || (hv > 126) )); then |
| 10459 | dasc=$dasc. |
| 10460 | else |
| 10461 | dasc=$dasc${line::1} |
| 10462 | fi |
| 10463 | (( (pos++ & 15) == 7 )) && print -n -- '- ' |
| 10464 | line=${line:1} |
| 10465 | done |
| 10466 | done |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10467 | while (( pos & 15 )); do |
| 10468 | print -n ' ' |
| 10469 | (( (pos++ & 15) == 7 )) && print -n -- '- ' |
| 10470 | done |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 10471 | (( hv == 2147483647 )) || print -r -- "$dasc|" |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10472 | } |
| 10473 | expected-stdout: |
| 10474 | 00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..| |
| 10475 | 00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................| |
| 10476 | 00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................| |
| 10477 | 00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................| |
| 10478 | 00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.| |
| 10479 | 00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>| |
| 10480 | 00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN| |
| 10481 | 00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^| |
| 10482 | 00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn| |
| 10483 | 00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~| |
| 10484 | 000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................| |
| 10485 | 000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................| |
| 10486 | 000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................| |
| 10487 | 000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................| |
| 10488 | 000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................| |
| 10489 | 000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................| |
| 10490 | 00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................| |
| 10491 | 00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................| |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10492 | 00000120 FF 7A 0A - |.z.| |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10493 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10494 | name: integer-base-one-3Ws |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10495 | description: |
Elliott Hughes | 4708626 | 2019-03-26 12:34:31 -0700 | [diff] [blame] | 10496 | some sample code for hexdumping UCS-2 |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10497 | not NUL safe; input lines must be NL terminated |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10498 | stdin: |
| 10499 | set -U |
| 10500 | { |
| 10501 | print 'Hello, World!\\\nããã«ã¡ã¯ï¼' |
| 10502 | typeset -Uui16 i=0x100 |
| 10503 | # change that to 0xFF once we can handle embedded |
| 10504 | # NUL characters in strings / here documents |
| 10505 | while (( i++ < 0x1FF )); do |
| 10506 | print -n "\u${i#16#1}" |
| 10507 | done |
| 10508 | print |
| 10509 | print \\xff # invalid utf-8 |
| 10510 | print \\xc2 # invalid 2-byte |
| 10511 | print \\xef\\xbf\\xc0 # invalid 3-byte |
| 10512 | print \\xc0\\x80 # non-minimalistic |
| 10513 | print \\xe0\\x80\\x80 # non-minimalistic |
| 10514 | print '�￾￿' # end of range |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10515 | print '\0z' # embedded NUL |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10516 | } | { |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10517 | # integer-base-one-3Ws |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10518 | typeset -Uui16 -Z11 pos=0 |
| 10519 | typeset -Uui16 -Z7 hv |
| 10520 | typeset -i1 wc=0x0A |
| 10521 | typeset -i lpos |
| 10522 | dasc= |
| 10523 | nl=${wc#1#} |
| 10524 | while IFS= read -r line; do |
| 10525 | line=$line$nl |
| 10526 | lpos=0 |
| 10527 | while (( lpos < ${#line} )); do |
| 10528 | wc=1#${line:(lpos++):1} |
| 10529 | if (( (wc < 32) || \ |
| 10530 | ((wc > 126) && (wc < 160)) )); then |
| 10531 | dch=. |
| 10532 | elif (( (wc & 0xFF80) == 0xEF80 )); then |
| 10533 | dch=� |
| 10534 | else |
| 10535 | dch=${wc#1#} |
| 10536 | fi |
| 10537 | if (( (pos & 7) == 7 )); then |
| 10538 | dasc=$dasc$dch |
| 10539 | dch= |
| 10540 | elif (( (pos & 7) == 0 )); then |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 10541 | (( pos )) && print -r -- "$dasc|" |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10542 | print -n "${pos#16#} " |
| 10543 | dasc=' |' |
| 10544 | fi |
| 10545 | let hv=wc |
| 10546 | print -n "${hv#16#} " |
| 10547 | (( (pos++ & 7) == 3 )) && \ |
| 10548 | print -n -- '- ' |
| 10549 | dasc=$dasc$dch |
| 10550 | done |
| 10551 | done |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10552 | while (( pos & 7 )); do |
| 10553 | print -n ' ' |
| 10554 | (( (pos++ & 7) == 3 )) && print -n -- '- ' |
| 10555 | done |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 10556 | (( hv == 2147483647 )) || print -r -- "$dasc|" |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10557 | } |
| 10558 | expected-stdout: |
| 10559 | 00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W| |
| 10560 | 00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.ã| |
| 10561 | 00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |ãã«ã¡ã¯ï¼...| |
| 10562 | 00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........| |
| 10563 | 00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........| |
| 10564 | 00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........| |
| 10565 | 00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"| |
| 10566 | 00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*| |
| 10567 | 00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012| |
| 10568 | 00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:| |
| 10569 | 00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB| |
| 10570 | 00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ| |
| 10571 | 00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR| |
| 10572 | 00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ| |
| 10573 | 00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab| |
| 10574 | 00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij| |
| 10575 | 00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr| |
| 10576 | 00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz| |
| 10577 | 00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....| |
| 10578 | 00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........| |
| 10579 | 000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........| |
| 10580 | 000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........| |
| 10581 | 000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |..... ¡¢| |
| 10582 | 000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA |£¤¥¦§¨©ª| |
| 10583 | 000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 |«¬Â®¯°±²| |
| 10584 | 000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA |³´µ¶·¸¹º| |
| 10585 | 000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 |»¼½¾¿ÃÃÃ| |
| 10586 | 000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA |ÃÃÃ
ÃÃÃÃÃ| |
| 10587 | 000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 |ÃÃÃÃÃÃÃÃ| |
| 10588 | 000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA |ÃÃÃÃÃÃÃÃ| |
| 10589 | 000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 |ÃÃÃÃÃà áâ| |
| 10590 | 000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA |ãäåæçèéê| |
| 10591 | 00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 |ëìÃîïðñò| |
| 10592 | 00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA |óôõö÷øùú| |
| 10593 | 00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |ûüýþÿ.�.| |
| 10594 | 00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |�.���.��| |
| 10595 | 00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |.���.���| |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10596 | 00000128 EFBE EFEF EFBF EFBF - 000A 007A 000A |����.z.| |
| 10597 | --- |
| 10598 | name: integer-base-one-3Ar |
| 10599 | description: |
| 10600 | some sample code for hexdumping; NUL and binary safe |
| 10601 | stdin: |
| 10602 | { |
| 10603 | print 'Hello, World!\\\nããã«ã¡ã¯ï¼' |
| 10604 | typeset -Uui16 i=0x100 |
| 10605 | # change that to 0xFF once we can handle embedded |
| 10606 | # NUL characters in strings / here documents |
| 10607 | while (( i++ < 0x1FF )); do |
| 10608 | print -n "\x${i#16#1}" |
| 10609 | done |
| 10610 | print '\0z' |
| 10611 | } | { |
| 10612 | # integer-base-one-3Ar |
| 10613 | typeset -Uui16 -Z11 pos=0 |
| 10614 | typeset -Uui16 -Z5 hv=2147483647 |
| 10615 | dasc= |
| 10616 | if read -arN -1 line; then |
| 10617 | typeset -i1 line |
| 10618 | i=0 |
| 10619 | while (( i < ${#line[*]} )); do |
| 10620 | hv=${line[i++]} |
| 10621 | if (( (pos & 15) == 0 )); then |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 10622 | (( pos )) && print -r -- "$dasc|" |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10623 | print -n "${pos#16#} " |
| 10624 | dasc=' |' |
| 10625 | fi |
| 10626 | print -n "${hv#16#} " |
| 10627 | if (( (hv < 32) || (hv > 126) )); then |
| 10628 | dasc=$dasc. |
| 10629 | else |
| 10630 | dasc=$dasc${line[i-1]#1#} |
| 10631 | fi |
| 10632 | (( (pos++ & 15) == 7 )) && print -n -- '- ' |
| 10633 | done |
| 10634 | fi |
| 10635 | while (( pos & 15 )); do |
| 10636 | print -n ' ' |
| 10637 | (( (pos++ & 15) == 7 )) && print -n -- '- ' |
| 10638 | done |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 10639 | (( hv == 2147483647 )) || print -r -- "$dasc|" |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10640 | } |
| 10641 | expected-stdout: |
| 10642 | 00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..| |
| 10643 | 00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................| |
| 10644 | 00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................| |
| 10645 | 00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................| |
| 10646 | 00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.| |
| 10647 | 00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>| |
| 10648 | 00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN| |
| 10649 | 00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^| |
| 10650 | 00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn| |
| 10651 | 00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~| |
| 10652 | 000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................| |
| 10653 | 000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................| |
| 10654 | 000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................| |
| 10655 | 000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................| |
| 10656 | 000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................| |
| 10657 | 000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................| |
| 10658 | 00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................| |
| 10659 | 00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................| |
| 10660 | 00000120 FF 00 7A 0A - |..z.| |
| 10661 | --- |
| 10662 | name: integer-base-one-3Wr |
| 10663 | description: |
Elliott Hughes | 4708626 | 2019-03-26 12:34:31 -0700 | [diff] [blame] | 10664 | some sample code for hexdumping UCS-2; NUL and binary safe |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10665 | stdin: |
| 10666 | set -U |
| 10667 | { |
| 10668 | print 'Hello, World!\\\nããã«ã¡ã¯ï¼' |
| 10669 | typeset -Uui16 i=0x100 |
| 10670 | # change that to 0xFF once we can handle embedded |
| 10671 | # NUL characters in strings / here documents |
| 10672 | while (( i++ < 0x1FF )); do |
| 10673 | print -n "\u${i#16#1}" |
| 10674 | done |
| 10675 | print |
| 10676 | print \\xff # invalid utf-8 |
| 10677 | print \\xc2 # invalid 2-byte |
| 10678 | print \\xef\\xbf\\xc0 # invalid 3-byte |
| 10679 | print \\xc0\\x80 # non-minimalistic |
| 10680 | print \\xe0\\x80\\x80 # non-minimalistic |
| 10681 | print '�￾￿' # end of range |
| 10682 | print '\0z' # embedded NUL |
| 10683 | } | { |
| 10684 | # integer-base-one-3Wr |
| 10685 | typeset -Uui16 -Z11 pos=0 |
| 10686 | typeset -Uui16 -Z7 hv=2147483647 |
| 10687 | dasc= |
| 10688 | if read -arN -1 line; then |
| 10689 | typeset -i1 line |
| 10690 | i=0 |
| 10691 | while (( i < ${#line[*]} )); do |
| 10692 | hv=${line[i++]} |
| 10693 | if (( (hv < 32) || \ |
| 10694 | ((hv > 126) && (hv < 160)) )); then |
| 10695 | dch=. |
| 10696 | elif (( (hv & 0xFF80) == 0xEF80 )); then |
| 10697 | dch=� |
| 10698 | else |
| 10699 | dch=${line[i-1]#1#} |
| 10700 | fi |
| 10701 | if (( (pos & 7) == 7 )); then |
| 10702 | dasc=$dasc$dch |
| 10703 | dch= |
| 10704 | elif (( (pos & 7) == 0 )); then |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 10705 | (( pos )) && print -r -- "$dasc|" |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10706 | print -n "${pos#16#} " |
| 10707 | dasc=' |' |
| 10708 | fi |
| 10709 | print -n "${hv#16#} " |
| 10710 | (( (pos++ & 7) == 3 )) && \ |
| 10711 | print -n -- '- ' |
| 10712 | dasc=$dasc$dch |
| 10713 | done |
| 10714 | fi |
| 10715 | while (( pos & 7 )); do |
| 10716 | print -n ' ' |
| 10717 | (( (pos++ & 7) == 3 )) && print -n -- '- ' |
| 10718 | done |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 10719 | (( hv == 2147483647 )) || print -r -- "$dasc|" |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10720 | } |
| 10721 | expected-stdout: |
| 10722 | 00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W| |
| 10723 | 00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.ã| |
| 10724 | 00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |ãã«ã¡ã¯ï¼...| |
| 10725 | 00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........| |
| 10726 | 00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........| |
| 10727 | 00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........| |
| 10728 | 00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"| |
| 10729 | 00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*| |
| 10730 | 00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012| |
| 10731 | 00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:| |
| 10732 | 00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB| |
| 10733 | 00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ| |
| 10734 | 00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR| |
| 10735 | 00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ| |
| 10736 | 00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab| |
| 10737 | 00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij| |
| 10738 | 00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr| |
| 10739 | 00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz| |
| 10740 | 00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....| |
| 10741 | 00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........| |
| 10742 | 000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........| |
| 10743 | 000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........| |
| 10744 | 000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |..... ¡¢| |
| 10745 | 000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA |£¤¥¦§¨©ª| |
| 10746 | 000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 |«¬Â®¯°±²| |
| 10747 | 000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA |³´µ¶·¸¹º| |
| 10748 | 000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 |»¼½¾¿ÃÃÃ| |
| 10749 | 000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA |ÃÃÃ
ÃÃÃÃÃ| |
| 10750 | 000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 |ÃÃÃÃÃÃÃÃ| |
| 10751 | 000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA |ÃÃÃÃÃÃÃÃ| |
| 10752 | 000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 |ÃÃÃÃÃà áâ| |
| 10753 | 000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA |ãäåæçèéê| |
| 10754 | 00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 |ëìÃîïðñò| |
| 10755 | 00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA |óôõö÷øùú| |
| 10756 | 00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |ûüýþÿ.�.| |
| 10757 | 00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |�.���.��| |
| 10758 | 00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |.���.���| |
| 10759 | 00000128 EFBE EFEF EFBF EFBF - 000A 0000 007A 000A |����..z.| |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10760 | --- |
| 10761 | name: integer-base-one-4 |
| 10762 | description: |
| 10763 | Check if ksh93-style base-one integers work |
| 10764 | category: !smksh |
| 10765 | stdin: |
| 10766 | set -U |
| 10767 | echo 1 $(('a')) |
| 10768 | (echo 2f $(('aa'))) 2>&1 | sed "s/^[^']*'/2p '/" |
| 10769 | echo 3 $(('â¦')) |
| 10770 | x="'a'" |
| 10771 | echo "4 <$x>" |
| 10772 | echo 5 $(($x)) |
| 10773 | echo 6 $((x)) |
| 10774 | expected-stdout: |
| 10775 | 1 97 |
| 10776 | 2p 'aa': multi-character character constant |
| 10777 | 3 8230 |
| 10778 | 4 <'a'> |
| 10779 | 5 97 |
| 10780 | 6 97 |
| 10781 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10782 | name: integer-base-one-5A |
| 10783 | description: |
Elliott Hughes | 4708626 | 2019-03-26 12:34:31 -0700 | [diff] [blame] | 10784 | Check to see that weâre NUL and UCS safe |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 10785 | category: !shell:ebcdic-yes |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10786 | stdin: |
| 10787 | set +U |
| 10788 | print 'a\0b\xfdz' >x |
| 10789 | read -a y <x |
| 10790 | set -U |
| 10791 | typeset -Uui16 y |
| 10792 | print ${y[*]} . |
| 10793 | expected-stdout: |
| 10794 | 16#61 16#0 16#62 16#FD 16#7A . |
| 10795 | --- |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 10796 | name: integer-base-one-5E |
| 10797 | description: |
Elliott Hughes | 4708626 | 2019-03-26 12:34:31 -0700 | [diff] [blame] | 10798 | Check to see that weâre NUL and UCS safe |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 10799 | category: !shell:ebcdic-no |
| 10800 | stdin: |
| 10801 | set +U |
| 10802 | print 'a\0b\xfdz' >x |
| 10803 | read -a y <x |
| 10804 | set -U |
| 10805 | typeset -Uui16 y |
| 10806 | print ${y[*]} . |
| 10807 | expected-stdout: |
| 10808 | 16#81 16#0 16#82 16#FD 16#A9 . |
| 10809 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10810 | name: integer-base-one-5W |
| 10811 | description: |
Elliott Hughes | 4708626 | 2019-03-26 12:34:31 -0700 | [diff] [blame] | 10812 | Check to see that weâre NUL and UCS safe |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10813 | stdin: |
| 10814 | set -U |
| 10815 | print 'a\0bâ¬c' >x |
| 10816 | read -a y <x |
| 10817 | set +U |
| 10818 | typeset -Uui16 y |
| 10819 | print ${y[*]} . |
| 10820 | expected-stdout: |
| 10821 | 16#61 16#0 16#62 16#20AC 16#63 . |
| 10822 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10823 | name: ulimit-1 |
| 10824 | description: |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 10825 | Check that ulimit as used in dot.mksh works or is stubbed |
| 10826 | stdin: |
| 10827 | ulimit -c 0 |
| 10828 | --- |
| 10829 | name: ulimit-2 |
| 10830 | description: |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10831 | Check if we can use a specific syntax idiom for ulimit |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 10832 | XXX Haiku works, but only for -n and -V |
| 10833 | category: !os:haiku,!os:syllable |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10834 | stdin: |
| 10835 | if ! x=$(ulimit -d) || [[ $x = unknown ]]; then |
| 10836 | #echo expected to fail on this OS |
| 10837 | echo okay |
| 10838 | else |
| 10839 | ulimit -dS $x && echo okay |
| 10840 | fi |
| 10841 | expected-stdout: |
| 10842 | okay |
| 10843 | --- |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 10844 | name: redir-1 |
| 10845 | description: |
| 10846 | Check some of the most basic invariants of I/O redirection |
| 10847 | stdin: |
| 10848 | i=0 |
| 10849 | function d { |
| 10850 | print o$i. |
| 10851 | print -u2 e$((i++)). |
| 10852 | } |
| 10853 | d >a 2>b |
| 10854 | echo =1= |
| 10855 | cat a |
| 10856 | echo =2= |
| 10857 | cat b |
| 10858 | echo =3= |
| 10859 | d 2>&1 >c |
| 10860 | echo =4= |
| 10861 | cat c |
| 10862 | echo =5= |
| 10863 | expected-stdout: |
| 10864 | =1= |
| 10865 | o0. |
| 10866 | =2= |
| 10867 | e0. |
| 10868 | =3= |
| 10869 | e1. |
| 10870 | =4= |
| 10871 | o1. |
| 10872 | =5= |
| 10873 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10874 | name: bashiop-1 |
| 10875 | description: |
| 10876 | Check if GNU bash-like I/O redirection works |
| 10877 | Part 1: this is also supported by GNU bash |
| 10878 | stdin: |
| 10879 | exec 3>&1 |
| 10880 | function threeout { |
| 10881 | echo ras |
| 10882 | echo dwa >&2 |
| 10883 | echo tri >&3 |
| 10884 | } |
| 10885 | threeout &>foo |
| 10886 | echo === |
| 10887 | cat foo |
| 10888 | expected-stdout: |
| 10889 | tri |
| 10890 | === |
| 10891 | ras |
| 10892 | dwa |
| 10893 | --- |
| 10894 | name: bashiop-2a |
| 10895 | description: |
| 10896 | Check if GNU bash-like I/O redirection works |
| 10897 | Part 2: this is *not* supported by GNU bash |
| 10898 | stdin: |
| 10899 | exec 3>&1 |
| 10900 | function threeout { |
| 10901 | echo ras |
| 10902 | echo dwa >&2 |
| 10903 | echo tri >&3 |
| 10904 | } |
| 10905 | threeout 3&>foo |
| 10906 | echo === |
| 10907 | cat foo |
| 10908 | expected-stdout: |
| 10909 | ras |
| 10910 | === |
| 10911 | dwa |
| 10912 | tri |
| 10913 | --- |
| 10914 | name: bashiop-2b |
| 10915 | description: |
| 10916 | Check if GNU bash-like I/O redirection works |
| 10917 | Part 2: this is *not* supported by GNU bash |
| 10918 | stdin: |
| 10919 | exec 3>&1 |
| 10920 | function threeout { |
| 10921 | echo ras |
| 10922 | echo dwa >&2 |
| 10923 | echo tri >&3 |
| 10924 | } |
| 10925 | threeout 3>foo &>&3 |
| 10926 | echo === |
| 10927 | cat foo |
| 10928 | expected-stdout: |
| 10929 | === |
| 10930 | ras |
| 10931 | dwa |
| 10932 | tri |
| 10933 | --- |
| 10934 | name: bashiop-2c |
| 10935 | description: |
| 10936 | Check if GNU bash-like I/O redirection works |
| 10937 | Part 2: this is supported by GNU bash 4 only |
| 10938 | stdin: |
| 10939 | echo mir >foo |
| 10940 | set -o noclobber |
| 10941 | exec 3>&1 |
| 10942 | function threeout { |
| 10943 | echo ras |
| 10944 | echo dwa >&2 |
| 10945 | echo tri >&3 |
| 10946 | } |
| 10947 | threeout &>>foo |
| 10948 | echo === |
| 10949 | cat foo |
| 10950 | expected-stdout: |
| 10951 | tri |
| 10952 | === |
| 10953 | mir |
| 10954 | ras |
| 10955 | dwa |
| 10956 | --- |
| 10957 | name: bashiop-3a |
| 10958 | description: |
| 10959 | Check if GNU bash-like I/O redirection fails correctly |
| 10960 | Part 1: this is also supported by GNU bash |
| 10961 | stdin: |
| 10962 | echo mir >foo |
| 10963 | set -o noclobber |
| 10964 | exec 3>&1 |
| 10965 | function threeout { |
| 10966 | echo ras |
| 10967 | echo dwa >&2 |
| 10968 | echo tri >&3 |
| 10969 | } |
| 10970 | threeout &>foo |
| 10971 | echo === |
| 10972 | cat foo |
| 10973 | expected-stdout: |
| 10974 | === |
| 10975 | mir |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 10976 | expected-stderr-pattern: /.*: can't (create|overwrite) .*/ |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 10977 | --- |
| 10978 | name: bashiop-3b |
| 10979 | description: |
| 10980 | Check if GNU bash-like I/O redirection fails correctly |
| 10981 | Part 2: this is *not* supported by GNU bash |
| 10982 | stdin: |
| 10983 | echo mir >foo |
| 10984 | set -o noclobber |
| 10985 | exec 3>&1 |
| 10986 | function threeout { |
| 10987 | echo ras |
| 10988 | echo dwa >&2 |
| 10989 | echo tri >&3 |
| 10990 | } |
| 10991 | threeout &>|foo |
| 10992 | echo === |
| 10993 | cat foo |
| 10994 | expected-stdout: |
| 10995 | tri |
| 10996 | === |
| 10997 | ras |
| 10998 | dwa |
| 10999 | --- |
| 11000 | name: bashiop-4 |
| 11001 | description: |
| 11002 | Check if GNU bash-like I/O redirection works |
| 11003 | Part 4: this is also supported by GNU bash, |
| 11004 | but failed in some mksh versions |
| 11005 | stdin: |
| 11006 | exec 3>&1 |
| 11007 | function threeout { |
| 11008 | echo ras |
| 11009 | echo dwa >&2 |
| 11010 | echo tri >&3 |
| 11011 | } |
| 11012 | function blubb { |
| 11013 | [[ -e bar ]] && threeout "$bf" &>foo |
| 11014 | } |
| 11015 | blubb |
| 11016 | echo -n >bar |
| 11017 | blubb |
| 11018 | echo === |
| 11019 | cat foo |
| 11020 | expected-stdout: |
| 11021 | tri |
| 11022 | === |
| 11023 | ras |
| 11024 | dwa |
| 11025 | --- |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11026 | name: bashiop-5 |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 11027 | description: |
| 11028 | Check if GNU bash-like I/O redirection is only supported |
| 11029 | in !POSIX !sh mode as it breaks existing scripts' syntax |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 11030 | stdin: |
| 11031 | :>x; echo 1 "$("$__progname" -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" . |
| 11032 | :>x; echo 2 "$("$__progname" -o posix -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" . |
| 11033 | :>x; echo 3 "$("$__progname" -o sh -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" . |
| 11034 | expected-stdout: |
| 11035 | 1 = foo echo bar . |
| 11036 | 2 = bar . |
| 11037 | 3 = bar . |
| 11038 | --- |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 11039 | name: oksh-eval |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 11040 | description: |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 11041 | Check expansions. |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 11042 | stdin: |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 11043 | a= |
| 11044 | for n in ${a#*=}; do echo 1hu ${n} .; done |
| 11045 | for n in "${a#*=}"; do echo 1hq ${n} .; done |
| 11046 | for n in ${a##*=}; do echo 2hu ${n} .; done |
| 11047 | for n in "${a##*=}"; do echo 2hq ${n} .; done |
| 11048 | for n in ${a%=*}; do echo 1pu ${n} .; done |
| 11049 | for n in "${a%=*}"; do echo 1pq ${n} .; done |
| 11050 | for n in ${a%%=*}; do echo 2pu ${n} .; done |
| 11051 | for n in "${a%%=*}"; do echo 2pq ${n} .; done |
| 11052 | expected-stdout: |
| 11053 | 1hq . |
| 11054 | 2hq . |
| 11055 | 1pq . |
| 11056 | 2pq . |
| 11057 | --- |
| 11058 | name: oksh-and-list-error-1 |
| 11059 | description: |
| 11060 | Test exit status of rightmost element in 2 element && list in -e mode |
| 11061 | stdin: |
| 11062 | true && false |
| 11063 | echo "should not print" |
| 11064 | arguments: !-e! |
| 11065 | expected-exit: e != 0 |
| 11066 | --- |
| 11067 | name: oksh-and-list-error-2 |
| 11068 | description: |
| 11069 | Test exit status of rightmost element in 3 element && list in -e mode |
| 11070 | stdin: |
| 11071 | true && true && false |
| 11072 | echo "should not print" |
| 11073 | arguments: !-e! |
| 11074 | expected-exit: e != 0 |
| 11075 | --- |
| 11076 | name: oksh-or-list-error-1 |
| 11077 | description: |
| 11078 | Test exit status of || list in -e mode |
| 11079 | stdin: |
| 11080 | false || false |
| 11081 | echo "should not print" |
| 11082 | arguments: !-e! |
| 11083 | expected-exit: e != 0 |
| 11084 | --- |
| 11085 | name: oksh-longline-crash |
| 11086 | description: |
| 11087 | This used to cause a core dump |
| 11088 | stdin: |
| 11089 | ulimit -c 0 |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 11090 | 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" |
| 11091 | 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" |
| 11092 | for deplib in $deplibs; do |
| 11093 | case $deplib in |
| 11094 | -L*) |
| 11095 | new_libs="$deplib $new_libs" |
| 11096 | ;; |
| 11097 | *) |
| 11098 | case " $specialdeplibs " in |
| 11099 | *" $deplib "*) |
| 11100 | new_libs="$deplib $new_libs";; |
| 11101 | esac |
| 11102 | ;; |
| 11103 | esac |
| 11104 | done |
| 11105 | --- |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 11106 | name: oksh-seterror-1 |
| 11107 | description: |
| 11108 | The -e flag should be ignored when executing a compound list |
| 11109 | followed by an if statement. |
| 11110 | stdin: |
| 11111 | if true; then false && false; fi |
| 11112 | true |
| 11113 | arguments: !-e! |
| 11114 | expected-exit: e == 0 |
| 11115 | --- |
| 11116 | name: oksh-seterror-2 |
| 11117 | description: |
| 11118 | The -e flag should be ignored when executing a compound list |
| 11119 | followed by an if statement. |
| 11120 | stdin: |
| 11121 | if true; then if true; then false && false; fi; fi |
| 11122 | true |
| 11123 | arguments: !-e! |
| 11124 | expected-exit: e == 0 |
| 11125 | --- |
| 11126 | name: oksh-seterror-3 |
| 11127 | description: |
| 11128 | The -e flag should be ignored when executing a compound list |
| 11129 | followed by an elif statement. |
| 11130 | stdin: |
| 11131 | if true; then :; elif true; then false && false; fi |
| 11132 | arguments: !-e! |
| 11133 | expected-exit: e == 0 |
| 11134 | --- |
| 11135 | name: oksh-seterror-4 |
| 11136 | description: |
| 11137 | The -e flag should be ignored when executing a pipeline |
| 11138 | beginning with '!' |
| 11139 | stdin: |
| 11140 | for i in 1 2 3 |
| 11141 | do |
| 11142 | false && false |
| 11143 | true || false |
| 11144 | done |
| 11145 | arguments: !-e! |
| 11146 | expected-exit: e == 0 |
| 11147 | --- |
| 11148 | name: oksh-seterror-5 |
| 11149 | description: |
| 11150 | The -e flag should be ignored when executing a pipeline |
| 11151 | beginning with '!' |
| 11152 | stdin: |
| 11153 | ! true | false |
| 11154 | true |
| 11155 | arguments: !-e! |
| 11156 | expected-exit: e == 0 |
| 11157 | --- |
| 11158 | name: oksh-seterror-6 |
| 11159 | description: |
| 11160 | When trapping ERR and EXIT, both traps should run in -e mode |
| 11161 | when an error occurs. |
| 11162 | stdin: |
| 11163 | trap 'echo EXIT' EXIT |
| 11164 | trap 'echo ERR' ERR |
| 11165 | set -e |
| 11166 | false |
| 11167 | echo DONE |
| 11168 | exit 0 |
| 11169 | arguments: !-e! |
| 11170 | expected-exit: e != 0 |
| 11171 | expected-stdout: |
| 11172 | ERR |
| 11173 | EXIT |
| 11174 | --- |
| 11175 | name: oksh-seterror-7 |
| 11176 | description: |
| 11177 | The -e flag within a command substitution should be honored |
| 11178 | stdin: |
| 11179 | echo $( set -e; false; echo foo ) |
| 11180 | arguments: !-e! |
| 11181 | expected-stdout: |
| 11182 | |
| 11183 | --- |
| 11184 | name: oksh-input-comsub |
| 11185 | description: |
| 11186 | A command substitution using input redirection should exit with |
| 11187 | failure if the input file does not exist. |
| 11188 | stdin: |
| 11189 | var=$(< non-existent) |
| 11190 | expected-exit: e != 0 |
| 11191 | expected-stderr-pattern: /non-existent/ |
| 11192 | --- |
| 11193 | name: oksh-empty-for-list |
| 11194 | description: |
| 11195 | A for list which expands to zero items should not execute the body. |
| 11196 | stdin: |
| 11197 | set foo bar baz ; for out in ; do echo $out ; done |
| 11198 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 11199 | name: oksh-varfunction-mod1 |
| 11200 | description: |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 11201 | (Inspired by PR 2450 on OpenBSD.) Calling |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 11202 | FOO=bar f |
| 11203 | where f is a ksh style function, should not set FOO in the current |
| 11204 | env. If f is a Bourne style function, FOO should be set. Furthermore, |
| 11205 | the function should receive a correct value of FOO. However, differing |
| 11206 | from oksh, setting FOO in the function itself must change the value in |
| 11207 | setting FOO in the function itself should not change the value in |
| 11208 | global environment. |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 11209 | stdin: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 11210 | print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \ |
| 11211 | 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \ |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 11212 | done >env; chmod +x env; PATH=.$PATHSEP$PATH |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 11213 | function k { |
| 11214 | if [ x$FOO != xbar ]; then |
| 11215 | echo 1 |
| 11216 | return 1 |
| 11217 | fi |
| 11218 | x=$(env | grep FOO) |
| 11219 | if [ "x$x" != "xFOO=bar" ]; then |
| 11220 | echo 2 |
| 11221 | return 1; |
| 11222 | fi |
| 11223 | FOO=foo |
| 11224 | return 0 |
| 11225 | } |
| 11226 | b () { |
| 11227 | if [ x$FOO != xbar ]; then |
| 11228 | echo 3 |
| 11229 | return 1 |
| 11230 | fi |
| 11231 | x=$(env | grep FOO) |
| 11232 | if [ "x$x" != "xFOO=bar" ]; then |
| 11233 | echo 4 |
| 11234 | return 1; |
| 11235 | fi |
| 11236 | FOO=foo |
| 11237 | return 0 |
| 11238 | } |
| 11239 | FOO=bar k |
| 11240 | if [ $? != 0 ]; then |
| 11241 | exit 1 |
| 11242 | fi |
| 11243 | if [ x$FOO != x ]; then |
| 11244 | exit 1 |
| 11245 | fi |
| 11246 | FOO=bar b |
| 11247 | if [ $? != 0 ]; then |
| 11248 | exit 1 |
| 11249 | fi |
| 11250 | if [ x$FOO != xfoo ]; then |
| 11251 | exit 1 |
| 11252 | fi |
| 11253 | FOO=barbar |
| 11254 | FOO=bar k |
| 11255 | if [ $? != 0 ]; then |
| 11256 | exit 1 |
| 11257 | fi |
| 11258 | if [ x$FOO != xbarbar ]; then |
| 11259 | exit 1 |
| 11260 | fi |
| 11261 | FOO=bar b |
| 11262 | if [ $? != 0 ]; then |
| 11263 | exit 1 |
| 11264 | fi |
| 11265 | if [ x$FOO != xfoo ]; then |
| 11266 | exit 1 |
| 11267 | fi |
| 11268 | --- |
| 11269 | name: fd-cloexec-1 |
| 11270 | description: |
| 11271 | Verify that file descriptors > 2 are private for Korn shells |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11272 | AT&T ksh93 does this still, which means we must keep it as well |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 11273 | XXX fails on some old Perl installations |
| 11274 | need-pass: no |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 11275 | stdin: |
Elliott Hughes | b27ce95 | 2015-04-21 13:39:18 -0700 | [diff] [blame] | 11276 | cat >cld <<-EOF |
| 11277 | #!$__perlname |
| 11278 | open(my \$fh, ">&", 9) or die "E: open \$!"; |
| 11279 | syswrite(\$fh, "Fowl\\n", 5) or die "E: write \$!"; |
| 11280 | EOF |
| 11281 | chmod +x cld |
| 11282 | exec 9>&1 |
| 11283 | ./cld |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 11284 | expected-exit: e != 0 |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11285 | expected-stderr-pattern: |
Elliott Hughes | b27ce95 | 2015-04-21 13:39:18 -0700 | [diff] [blame] | 11286 | /E: open / |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 11287 | --- |
| 11288 | name: fd-cloexec-2 |
| 11289 | description: |
| 11290 | Verify that file descriptors > 2 are not private for POSIX shells |
| 11291 | See Debian Bug #154540, Closes: #499139 |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 11292 | XXX fails on some old Perl installations |
| 11293 | need-pass: no |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 11294 | stdin: |
Elliott Hughes | b27ce95 | 2015-04-21 13:39:18 -0700 | [diff] [blame] | 11295 | cat >cld <<-EOF |
| 11296 | #!$__perlname |
| 11297 | open(my \$fh, ">&", 9) or die "E: open \$!"; |
| 11298 | syswrite(\$fh, "Fowl\\n", 5) or die "E: write \$!"; |
| 11299 | EOF |
| 11300 | chmod +x cld |
| 11301 | test -n "$POSH_VERSION" || set -o posix |
| 11302 | exec 9>&1 |
| 11303 | ./cld |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 11304 | expected-stdout: |
| 11305 | Fowl |
| 11306 | --- |
Elliott Hughes | 4708626 | 2019-03-26 12:34:31 -0700 | [diff] [blame] | 11307 | name: fd-cloexec-3 |
| 11308 | description: |
| 11309 | Another check for close-on-exec |
| 11310 | stdin: |
| 11311 | print '#!'"$__progname" >ts |
| 11312 | cat >>ts <<'EOF' |
| 11313 | s=ERR |
| 11314 | read -rN-1 -u$1 s 2>/dev/null; e=$? |
| 11315 | print -r -- "($1, $((!e)), $s)" |
| 11316 | EOF |
| 11317 | chmod +x ts |
| 11318 | print foo >tx |
| 11319 | runtest() { |
| 11320 | s=$1; shift |
| 11321 | print -r -- $("$__progname" "$@" -c "$s") "$@" . |
| 11322 | } |
| 11323 | runtest 'exec 3<tx; ./ts 3 3<&3; ./ts 3' |
| 11324 | runtest 'exec 3<tx; ./ts 3 3<&3; ./ts 3' -o posix |
| 11325 | runtest 'exec 3<tx; ./ts 3 3<&3; ./ts 3' -o sh |
| 11326 | runtest 'exec 3<tx; ./ts 4 4<&3; ./ts 4 4<&3' |
| 11327 | runtest 'exec 3<tx; ./ts 3 3<&3; ./ts 3 3<&3' |
| 11328 | expected-stdout: |
| 11329 | (3, 1, foo) (3, 0, ERR) . |
| 11330 | (3, 1, foo) (3, 1, ) -o posix . |
| 11331 | (3, 1, foo) (3, 1, ) -o sh . |
| 11332 | (4, 1, foo) (4, 1, ) . |
| 11333 | (3, 1, foo) (3, 1, ) . |
| 11334 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11335 | name: comsub-1a |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 11336 | description: |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11337 | COMSUB are now parsed recursively, so this works |
| 11338 | see also regression-6: matching parenthesÄs bug |
| 11339 | Fails on: pdksh bash2 bash3 zsh |
| 11340 | Passes on: bash4 ksh93 mksh(20110313+) |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 11341 | stdin: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 11342 | echo 1 $(case 1 in (1) echo yes;; (2) echo no;; esac) . |
| 11343 | echo 2 $(case 1 in 1) echo yes;; 2) echo no;; esac) . |
| 11344 | TEST=1234; echo 3 ${TEST: $(case 1 in (1) echo 1;; (*) echo 2;; esac)} . |
| 11345 | TEST=5678; echo 4 ${TEST: $(case 1 in 1) echo 1;; *) echo 2;; esac)} . |
| 11346 | a=($(case 1 in (1) echo 1;; (*) echo 2;; esac)); echo 5 ${a[0]} . |
| 11347 | a=($(case 1 in 1) echo 1;; *) echo 2;; esac)); echo 6 ${a[0]} . |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 11348 | expected-stdout: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 11349 | 1 yes . |
| 11350 | 2 yes . |
| 11351 | 3 234 . |
| 11352 | 4 678 . |
| 11353 | 5 1 . |
| 11354 | 6 1 . |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11355 | --- |
| 11356 | name: comsub-1b |
| 11357 | description: |
| 11358 | COMSUB are now parsed recursively, so this works |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 11359 | Fails on: pdksh bash2 bash3 bash4 zsh |
| 11360 | Passes on: ksh93 mksh(20110313+) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11361 | stdin: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 11362 | echo 1 $(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10)) . |
| 11363 | echo 2 $(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20)) . |
| 11364 | (( a = $(case 1 in (1) echo 1;; (*) echo 2;; esac) )); echo 3 $a . |
| 11365 | (( a = $(case 1 in 1) echo 1;; *) echo 2;; esac) )); echo 4 $a . |
| 11366 | a=($(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10))); echo 5 ${a[0]} . |
| 11367 | a=($(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20))); echo 6 ${a[0]} . |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11368 | expected-stdout: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 11369 | 1 11 . |
| 11370 | 2 21 . |
| 11371 | 3 1 . |
| 11372 | 4 1 . |
| 11373 | 5 11 . |
| 11374 | 6 21 . |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 11375 | --- |
| 11376 | name: comsub-2 |
| 11377 | description: |
| 11378 | RedHat BZ#496791 â another case of missing recursion |
| 11379 | in parsing COMSUB expressions |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11380 | Fails on: pdksh bash2 bash3¹ bash4¹ zsh |
| 11381 | Passes on: ksh93 mksh(20110305+) |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 11382 | â bash[34] seem to choke on comment ending with backslash-newline |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 11383 | stdin: |
| 11384 | # a comment with " ' \ |
| 11385 | x=$( |
| 11386 | echo yes |
| 11387 | # a comment with " ' \ |
| 11388 | ) |
| 11389 | echo $x |
| 11390 | expected-stdout: |
| 11391 | yes |
| 11392 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11393 | name: comsub-3 |
| 11394 | description: |
| 11395 | Extended test for COMSUB explaining why a recursive parser |
| 11396 | is a must (a non-recursive parser cannot pass all three of |
| 11397 | these test cases, especially the â#â is difficult) |
| 11398 | stdin: |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 11399 | print '#!'"$__progname"'\necho 1234' >id; chmod +x id; PATH=.$PATHSEP$PATH |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11400 | echo $(typeset -i10 x=16#20; echo $x) |
| 11401 | echo $(typeset -Uui16 x=16#$(id -u) |
| 11402 | ) . |
| 11403 | echo $(c=1; d=1 |
| 11404 | typeset -Uui16 a=36#foo; c=2 |
| 11405 | typeset -Uui16 b=36 #foo; d=2 |
| 11406 | echo $a $b $c $d) |
| 11407 | expected-stdout: |
| 11408 | 32 |
| 11409 | . |
| 11410 | 16#4F68 16#24 2 1 |
| 11411 | --- |
| 11412 | name: comsub-4 |
| 11413 | description: |
| 11414 | Check the tree dump functions for !MKSH_SMALL functionality |
| 11415 | category: !smksh |
| 11416 | stdin: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 11417 | x() { case $1 in u) echo x ;;& *) echo $1 ;; esac; } |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11418 | typeset -f x |
| 11419 | expected-stdout: |
| 11420 | x() { |
| 11421 | case $1 in |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 11422 | (u) |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11423 | \echo x |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11424 | ;| |
| 11425 | (*) |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11426 | \echo $1 |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11427 | ;; |
| 11428 | esac |
| 11429 | } |
| 11430 | --- |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 11431 | name: comsub-5 |
| 11432 | description: |
| 11433 | Check COMSUB works with aliases (does not expand them twice) |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11434 | and reentrancy safety |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 11435 | stdin: |
| 11436 | print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn |
| 11437 | chmod +x pfn |
| 11438 | alias echo='echo a' |
| 11439 | foo() { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11440 | echo moo |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 11441 | ./pfn "$(echo foo)" |
| 11442 | } |
| 11443 | ./pfn "$(echo b)" |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11444 | typeset -f foo >x |
| 11445 | cat x |
| 11446 | foo |
| 11447 | . ./x |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 11448 | typeset -f foo |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11449 | foo |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 11450 | expected-stdout: |
| 11451 | a b |
| 11452 | foo() { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11453 | \echo a moo |
| 11454 | ./pfn "$(\echo a foo )" |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 11455 | } |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11456 | a moo |
| 11457 | a foo |
| 11458 | foo() { |
| 11459 | \echo a moo |
| 11460 | ./pfn "$(\echo a foo )" |
| 11461 | } |
| 11462 | a moo |
| 11463 | a foo |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 11464 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11465 | name: comsub-torture |
| 11466 | description: |
| 11467 | Check the tree dump functions work correctly |
| 11468 | stdin: |
| 11469 | if [[ -z $__progname ]]; then echo >&2 call me with __progname; exit 1; fi |
| 11470 | while IFS= read -r line; do |
| 11471 | if [[ $line = '#1' ]]; then |
| 11472 | lastf=0 |
| 11473 | continue |
| 11474 | elif [[ $line = EOFN* ]]; then |
| 11475 | fbody=$fbody$'\n'$line |
| 11476 | continue |
| 11477 | elif [[ $line != '#'* ]]; then |
| 11478 | fbody=$fbody$'\n\t'$line |
| 11479 | continue |
| 11480 | fi |
| 11481 | if (( lastf )); then |
| 11482 | x="inline_${nextf}() {"$fbody$'\n}\n' |
| 11483 | print -nr -- "$x" |
| 11484 | print -r -- "${x}typeset -f inline_$nextf" | "$__progname" |
| 11485 | x="function comsub_$nextf { x=\$("$fbody$'\n); }\n' |
| 11486 | print -nr -- "$x" |
| 11487 | print -r -- "${x}typeset -f comsub_$nextf" | "$__progname" |
| 11488 | x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n' |
| 11489 | print -nr -- "$x" |
| 11490 | print -r -- "${x}typeset -f reread_$nextf" | "$__progname" |
| 11491 | fi |
| 11492 | lastf=1 |
| 11493 | fbody= |
| 11494 | nextf=${line#?} |
| 11495 | done <<'EOD' |
| 11496 | #1 |
| 11497 | #TCOM |
| 11498 | vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" |
| 11499 | #TPAREN_TPIPE_TLIST |
| 11500 | (echo $foo | tr -dc 0-9; echo) |
| 11501 | #TAND_TOR |
| 11502 | cmd && echo ja || echo nein |
| 11503 | #TSELECT |
| 11504 | select file in *; do echo "<$file>" ; break ; done |
| 11505 | #TFOR_TTIME |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 11506 | time for i in {1,2,3} ; do echo $i ; done |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11507 | #TCASE |
| 11508 | case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac |
| 11509 | #TIF_TBANG_TDBRACKET_TELIF |
| 11510 | if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi |
| 11511 | #TWHILE |
| 11512 | i=1; while (( i < 10 )); do echo $i; let ++i; done |
| 11513 | #TUNTIL |
| 11514 | i=10; until (( !--i )) ; do echo $i; done |
| 11515 | #TCOPROC |
| 11516 | cat * |& ls |
| 11517 | #TFUNCT_TBRACE_TASYNC |
| 11518 | function korn { echo eins; echo zwei ; } |
| 11519 | bourne () { logger * & } |
| 11520 | #IOREAD_IOCAT |
| 11521 | tr x u 0<foo >>bar |
| 11522 | #IOWRITE_IOCLOB_IOHERE_noIOSKIP |
| 11523 | cat >|bar <<'EOFN' |
| 11524 | foo |
| 11525 | EOFN |
| 11526 | #IOWRITE_noIOCLOB_IOHERE_IOSKIP |
| 11527 | cat 1>bar <<-EOFI |
| 11528 | foo |
| 11529 | EOFI |
| 11530 | #IORDWR_IODUP |
| 11531 | sh 1<>/dev/console 0<&1 2>&1 |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 11532 | #COMSUB_EXPRSUB_FUNSUB_VALSUB |
| 11533 | echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;} |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11534 | #QCHAR_OQUOTE_CQUOTE |
| 11535 | echo fo\ob\"a\`r\'b\$az |
| 11536 | echo "fo\ob\"a\`r\'b\$az" |
| 11537 | echo 'fo\ob\"a\`r'\''b\$az' |
| 11538 | #OSUBST_CSUBST_OPAT_SPAT_CPAT |
| 11539 | [[ ${foo#bl\(u\)b} = @(bar|baz) ]] |
| 11540 | #heredoc_closed |
| 11541 | x=$(cat <<EOFN |
| 11542 | note there must be no space between EOFN and ) |
| 11543 | EOFN); echo $x |
| 11544 | #heredoc_space |
| 11545 | x=$(cat <<EOFN\ |
| 11546 | note the space between EOFN and ) is actually part of the here document marker |
| 11547 | EOFN ); echo $x |
| 11548 | #patch_motd |
| 11549 | x=$(sysctl -n kern.version | sed 1q) |
| 11550 | [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \ |
| 11551 | ed -s /etc/motd 2>&1 <<-EOF |
| 11552 | 1,/^\$/d |
| 11553 | 0a |
| 11554 | $x |
| 11555 | |
| 11556 | . |
| 11557 | wq |
| 11558 | EOF)" = @(?) ]] && rm -f /etc/motd |
| 11559 | if [[ ! -s /etc/motd ]]; then |
| 11560 | install -c -o root -g wheel -m 664 /dev/null /etc/motd |
| 11561 | print -- "$x\n" >/etc/motd |
| 11562 | fi |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 11563 | #wdarrassign |
| 11564 | case x in |
| 11565 | x) a+=b; c+=(d e) |
| 11566 | esac |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11567 | #0 |
| 11568 | EOD |
| 11569 | expected-stdout: |
| 11570 | inline_TCOM() { |
| 11571 | vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" |
| 11572 | } |
| 11573 | inline_TCOM() { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11574 | vara=1 varb="2 3" \cmd arg1 $arg2 "$arg3 4" |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11575 | } |
| 11576 | function comsub_TCOM { x=$( |
| 11577 | vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" |
| 11578 | ); } |
| 11579 | function comsub_TCOM { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11580 | x=$(vara=1 varb="2 3" \cmd arg1 $arg2 "$arg3 4" ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11581 | } |
| 11582 | function reread_TCOM { x=$(( |
| 11583 | vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" |
| 11584 | )|tr u x); } |
| 11585 | function reread_TCOM { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11586 | x=$( ( vara=1 varb="2 3" \cmd arg1 $arg2 "$arg3 4" ) | \tr u x ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11587 | } |
| 11588 | inline_TPAREN_TPIPE_TLIST() { |
| 11589 | (echo $foo | tr -dc 0-9; echo) |
| 11590 | } |
| 11591 | inline_TPAREN_TPIPE_TLIST() { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11592 | ( \echo $foo | \tr -dc 0-9 |
| 11593 | \echo ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11594 | } |
| 11595 | function comsub_TPAREN_TPIPE_TLIST { x=$( |
| 11596 | (echo $foo | tr -dc 0-9; echo) |
| 11597 | ); } |
| 11598 | function comsub_TPAREN_TPIPE_TLIST { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11599 | x=$( ( \echo $foo | \tr -dc 0-9 ; \echo ) ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11600 | } |
| 11601 | function reread_TPAREN_TPIPE_TLIST { x=$(( |
| 11602 | (echo $foo | tr -dc 0-9; echo) |
| 11603 | )|tr u x); } |
| 11604 | function reread_TPAREN_TPIPE_TLIST { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11605 | x=$( ( ( \echo $foo | \tr -dc 0-9 ; \echo ) ) | \tr u x ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11606 | } |
| 11607 | inline_TAND_TOR() { |
| 11608 | cmd && echo ja || echo nein |
| 11609 | } |
| 11610 | inline_TAND_TOR() { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11611 | \cmd && \echo ja || \echo nein |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11612 | } |
| 11613 | function comsub_TAND_TOR { x=$( |
| 11614 | cmd && echo ja || echo nein |
| 11615 | ); } |
| 11616 | function comsub_TAND_TOR { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11617 | x=$(\cmd && \echo ja || \echo nein ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11618 | } |
| 11619 | function reread_TAND_TOR { x=$(( |
| 11620 | cmd && echo ja || echo nein |
| 11621 | )|tr u x); } |
| 11622 | function reread_TAND_TOR { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11623 | x=$( ( \cmd && \echo ja || \echo nein ) | \tr u x ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11624 | } |
| 11625 | inline_TSELECT() { |
| 11626 | select file in *; do echo "<$file>" ; break ; done |
| 11627 | } |
| 11628 | inline_TSELECT() { |
| 11629 | select file in * |
| 11630 | do |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11631 | \echo "<$file>" |
| 11632 | \break |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11633 | done |
| 11634 | } |
| 11635 | function comsub_TSELECT { x=$( |
| 11636 | select file in *; do echo "<$file>" ; break ; done |
| 11637 | ); } |
| 11638 | function comsub_TSELECT { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11639 | x=$(select file in * ; do \echo "<$file>" ; \break ; done ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11640 | } |
| 11641 | function reread_TSELECT { x=$(( |
| 11642 | select file in *; do echo "<$file>" ; break ; done |
| 11643 | )|tr u x); } |
| 11644 | function reread_TSELECT { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11645 | x=$( ( select file in * ; do \echo "<$file>" ; \break ; done ) | \tr u x ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11646 | } |
| 11647 | inline_TFOR_TTIME() { |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 11648 | time for i in {1,2,3} ; do echo $i ; done |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11649 | } |
| 11650 | inline_TFOR_TTIME() { |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 11651 | time for i in {1,2,3} |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11652 | do |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11653 | \echo $i |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11654 | done |
| 11655 | } |
| 11656 | function comsub_TFOR_TTIME { x=$( |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 11657 | time for i in {1,2,3} ; do echo $i ; done |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11658 | ); } |
| 11659 | function comsub_TFOR_TTIME { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11660 | x=$(time for i in {1,2,3} ; do \echo $i ; done ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11661 | } |
| 11662 | function reread_TFOR_TTIME { x=$(( |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 11663 | time for i in {1,2,3} ; do echo $i ; done |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11664 | )|tr u x); } |
| 11665 | function reread_TFOR_TTIME { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11666 | x=$( ( time for i in {1,2,3} ; do \echo $i ; done ) | \tr u x ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11667 | } |
| 11668 | inline_TCASE() { |
| 11669 | case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac |
| 11670 | } |
| 11671 | inline_TCASE() { |
| 11672 | case $foo in |
| 11673 | (1) |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11674 | \echo eins |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11675 | ;& |
| 11676 | (2) |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11677 | \echo zwei |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11678 | ;| |
| 11679 | (*) |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11680 | \echo kann net bis drei zählen |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11681 | ;; |
| 11682 | esac |
| 11683 | } |
| 11684 | function comsub_TCASE { x=$( |
| 11685 | case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac |
| 11686 | ); } |
| 11687 | function comsub_TCASE { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11688 | x=$(case $foo in (1) \echo eins ;& (2) \echo zwei ;| (*) \echo kann net bis drei zählen ;; esac ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11689 | } |
| 11690 | function reread_TCASE { x=$(( |
| 11691 | case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zählen;; esac |
| 11692 | )|tr u x); } |
| 11693 | function reread_TCASE { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11694 | x=$( ( case $foo in (1) \echo eins ;& (2) \echo zwei ;| (*) \echo kann net bis drei zählen ;; esac ) | \tr u x ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11695 | } |
| 11696 | inline_TIF_TBANG_TDBRACKET_TELIF() { |
| 11697 | if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi |
| 11698 | } |
| 11699 | inline_TIF_TBANG_TDBRACKET_TELIF() { |
| 11700 | if ! [[ 1 = 1 ]] |
| 11701 | then |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11702 | \echo eins |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11703 | elif [[ 1 = 2 ]] |
| 11704 | then |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11705 | \echo zwei |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11706 | else |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11707 | \echo drei |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11708 | fi |
| 11709 | } |
| 11710 | function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$( |
| 11711 | if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi |
| 11712 | ); } |
| 11713 | function comsub_TIF_TBANG_TDBRACKET_TELIF { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11714 | x=$(if ! [[ 1 = 1 ]] ; then \echo eins ; elif [[ 1 = 2 ]] ; then \echo zwei ; else \echo drei ; fi ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11715 | } |
| 11716 | function reread_TIF_TBANG_TDBRACKET_TELIF { x=$(( |
| 11717 | if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi |
| 11718 | )|tr u x); } |
| 11719 | function reread_TIF_TBANG_TDBRACKET_TELIF { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11720 | x=$( ( if ! [[ 1 = 1 ]] ; then \echo eins ; elif [[ 1 = 2 ]] ; then \echo zwei ; else \echo drei ; fi ) | \tr u x ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11721 | } |
| 11722 | inline_TWHILE() { |
| 11723 | i=1; while (( i < 10 )); do echo $i; let ++i; done |
| 11724 | } |
| 11725 | inline_TWHILE() { |
| 11726 | i=1 |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 11727 | while { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11728 | \\builtin let " i < 10 " |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 11729 | } |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11730 | do |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11731 | \echo $i |
| 11732 | \let ++i |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11733 | done |
| 11734 | } |
| 11735 | function comsub_TWHILE { x=$( |
| 11736 | i=1; while (( i < 10 )); do echo $i; let ++i; done |
| 11737 | ); } |
| 11738 | function comsub_TWHILE { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11739 | x=$(i=1 ; while { \\builtin let " i < 10 " ; } ; do \echo $i ; \let ++i ; done ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11740 | } |
| 11741 | function reread_TWHILE { x=$(( |
| 11742 | i=1; while (( i < 10 )); do echo $i; let ++i; done |
| 11743 | )|tr u x); } |
| 11744 | function reread_TWHILE { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11745 | x=$( ( i=1 ; while { \\builtin let " i < 10 " ; } ; do \echo $i ; \let ++i ; done ) | \tr u x ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11746 | } |
| 11747 | inline_TUNTIL() { |
| 11748 | i=10; until (( !--i )) ; do echo $i; done |
| 11749 | } |
| 11750 | inline_TUNTIL() { |
| 11751 | i=10 |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 11752 | until { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11753 | \\builtin let " !--i " |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 11754 | } |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11755 | do |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11756 | \echo $i |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11757 | done |
| 11758 | } |
| 11759 | function comsub_TUNTIL { x=$( |
| 11760 | i=10; until (( !--i )) ; do echo $i; done |
| 11761 | ); } |
| 11762 | function comsub_TUNTIL { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11763 | x=$(i=10 ; until { \\builtin let " !--i " ; } ; do \echo $i ; done ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11764 | } |
| 11765 | function reread_TUNTIL { x=$(( |
| 11766 | i=10; until (( !--i )) ; do echo $i; done |
| 11767 | )|tr u x); } |
| 11768 | function reread_TUNTIL { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11769 | x=$( ( i=10 ; until { \\builtin let " !--i " ; } ; do \echo $i ; done ) | \tr u x ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11770 | } |
| 11771 | inline_TCOPROC() { |
| 11772 | cat * |& ls |
| 11773 | } |
| 11774 | inline_TCOPROC() { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11775 | \cat * |& |
| 11776 | \ls |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11777 | } |
| 11778 | function comsub_TCOPROC { x=$( |
| 11779 | cat * |& ls |
| 11780 | ); } |
| 11781 | function comsub_TCOPROC { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11782 | x=$(\cat * |& \ls ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11783 | } |
| 11784 | function reread_TCOPROC { x=$(( |
| 11785 | cat * |& ls |
| 11786 | )|tr u x); } |
| 11787 | function reread_TCOPROC { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11788 | x=$( ( \cat * |& \ls ) | \tr u x ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11789 | } |
| 11790 | inline_TFUNCT_TBRACE_TASYNC() { |
| 11791 | function korn { echo eins; echo zwei ; } |
| 11792 | bourne () { logger * & } |
| 11793 | } |
| 11794 | inline_TFUNCT_TBRACE_TASYNC() { |
| 11795 | function korn { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11796 | \echo eins |
| 11797 | \echo zwei |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11798 | } |
| 11799 | bourne() { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11800 | \logger * & |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11801 | } |
| 11802 | } |
| 11803 | function comsub_TFUNCT_TBRACE_TASYNC { x=$( |
| 11804 | function korn { echo eins; echo zwei ; } |
| 11805 | bourne () { logger * & } |
| 11806 | ); } |
| 11807 | function comsub_TFUNCT_TBRACE_TASYNC { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11808 | x=$(function korn { \echo eins ; \echo zwei ; } ; bourne() { \logger * & } ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11809 | } |
| 11810 | function reread_TFUNCT_TBRACE_TASYNC { x=$(( |
| 11811 | function korn { echo eins; echo zwei ; } |
| 11812 | bourne () { logger * & } |
| 11813 | )|tr u x); } |
| 11814 | function reread_TFUNCT_TBRACE_TASYNC { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11815 | x=$( ( function korn { \echo eins ; \echo zwei ; } ; bourne() { \logger * & } ) | \tr u x ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11816 | } |
| 11817 | inline_IOREAD_IOCAT() { |
| 11818 | tr x u 0<foo >>bar |
| 11819 | } |
| 11820 | inline_IOREAD_IOCAT() { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11821 | \tr x u <foo >>bar |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11822 | } |
| 11823 | function comsub_IOREAD_IOCAT { x=$( |
| 11824 | tr x u 0<foo >>bar |
| 11825 | ); } |
| 11826 | function comsub_IOREAD_IOCAT { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11827 | x=$(\tr x u <foo >>bar ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11828 | } |
| 11829 | function reread_IOREAD_IOCAT { x=$(( |
| 11830 | tr x u 0<foo >>bar |
| 11831 | )|tr u x); } |
| 11832 | function reread_IOREAD_IOCAT { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11833 | x=$( ( \tr x u <foo >>bar ) | \tr u x ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11834 | } |
| 11835 | inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() { |
| 11836 | cat >|bar <<'EOFN' |
| 11837 | foo |
| 11838 | EOFN |
| 11839 | } |
| 11840 | inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11841 | \cat >|bar <<"EOFN" |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11842 | foo |
| 11843 | EOFN |
| 11844 | |
| 11845 | } |
| 11846 | function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$( |
| 11847 | cat >|bar <<'EOFN' |
| 11848 | foo |
| 11849 | EOFN |
| 11850 | ); } |
| 11851 | function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11852 | x=$(\cat >|bar <<"EOFN" |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11853 | foo |
| 11854 | EOFN |
| 11855 | ) |
| 11856 | } |
| 11857 | function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$(( |
| 11858 | cat >|bar <<'EOFN' |
| 11859 | foo |
| 11860 | EOFN |
| 11861 | )|tr u x); } |
| 11862 | function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11863 | x=$( ( \cat >|bar <<"EOFN" |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11864 | foo |
| 11865 | EOFN |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11866 | ) | \tr u x ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11867 | } |
| 11868 | inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() { |
| 11869 | cat 1>bar <<-EOFI |
| 11870 | foo |
| 11871 | EOFI |
| 11872 | } |
| 11873 | inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11874 | \cat >bar <<-EOFI |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11875 | foo |
| 11876 | EOFI |
| 11877 | |
| 11878 | } |
| 11879 | function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$( |
| 11880 | cat 1>bar <<-EOFI |
| 11881 | foo |
| 11882 | EOFI |
| 11883 | ); } |
| 11884 | function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11885 | x=$(\cat >bar <<-EOFI |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11886 | foo |
| 11887 | EOFI |
| 11888 | ) |
| 11889 | } |
| 11890 | function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$(( |
| 11891 | cat 1>bar <<-EOFI |
| 11892 | foo |
| 11893 | EOFI |
| 11894 | )|tr u x); } |
| 11895 | function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11896 | x=$( ( \cat >bar <<-EOFI |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11897 | foo |
| 11898 | EOFI |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11899 | ) | \tr u x ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11900 | } |
| 11901 | inline_IORDWR_IODUP() { |
| 11902 | sh 1<>/dev/console 0<&1 2>&1 |
| 11903 | } |
| 11904 | inline_IORDWR_IODUP() { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11905 | \sh 1<>/dev/console <&1 2>&1 |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11906 | } |
| 11907 | function comsub_IORDWR_IODUP { x=$( |
| 11908 | sh 1<>/dev/console 0<&1 2>&1 |
| 11909 | ); } |
| 11910 | function comsub_IORDWR_IODUP { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11911 | x=$(\sh 1<>/dev/console <&1 2>&1 ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11912 | } |
| 11913 | function reread_IORDWR_IODUP { x=$(( |
| 11914 | sh 1<>/dev/console 0<&1 2>&1 |
| 11915 | )|tr u x); } |
| 11916 | function reread_IORDWR_IODUP { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11917 | x=$( ( \sh 1<>/dev/console <&1 2>&1 ) | \tr u x ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11918 | } |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 11919 | inline_COMSUB_EXPRSUB_FUNSUB_VALSUB() { |
| 11920 | echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;} |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11921 | } |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 11922 | inline_COMSUB_EXPRSUB_FUNSUB_VALSUB() { |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 11923 | \echo $(\true ) $((1+ 2)) ${ \: ;} ${|REPLY=x ;} |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11924 | } |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 11925 | function comsub_COMSUB_EXPRSUB_FUNSUB_VALSUB { x=$( |
| 11926 | echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;} |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11927 | ); } |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 11928 | function comsub_COMSUB_EXPRSUB_FUNSUB_VALSUB { |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 11929 | x=$(\echo $(\true ) $((1+ 2)) ${ \: ;} ${|REPLY=x ;} ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11930 | } |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 11931 | function reread_COMSUB_EXPRSUB_FUNSUB_VALSUB { x=$(( |
| 11932 | echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;} |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11933 | )|tr u x); } |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 11934 | function reread_COMSUB_EXPRSUB_FUNSUB_VALSUB { |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 11935 | x=$( ( \echo $(\true ) $((1+ 2)) ${ \: ;} ${|REPLY=x ;} ) | \tr u x ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11936 | } |
| 11937 | inline_QCHAR_OQUOTE_CQUOTE() { |
| 11938 | echo fo\ob\"a\`r\'b\$az |
| 11939 | echo "fo\ob\"a\`r\'b\$az" |
| 11940 | echo 'fo\ob\"a\`r'\''b\$az' |
| 11941 | } |
| 11942 | inline_QCHAR_OQUOTE_CQUOTE() { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11943 | \echo fo\ob\"a\`r\'b\$az |
| 11944 | \echo "fo\ob\"a\`r\'b\$az" |
| 11945 | \echo "fo\\ob\\\"a\\\`r"\'"b\\\$az" |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11946 | } |
| 11947 | function comsub_QCHAR_OQUOTE_CQUOTE { x=$( |
| 11948 | echo fo\ob\"a\`r\'b\$az |
| 11949 | echo "fo\ob\"a\`r\'b\$az" |
| 11950 | echo 'fo\ob\"a\`r'\''b\$az' |
| 11951 | ); } |
| 11952 | function comsub_QCHAR_OQUOTE_CQUOTE { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11953 | x=$(\echo fo\ob\"a\`r\'b\$az ; \echo "fo\ob\"a\`r\'b\$az" ; \echo "fo\\ob\\\"a\\\`r"\'"b\\\$az" ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11954 | } |
| 11955 | function reread_QCHAR_OQUOTE_CQUOTE { x=$(( |
| 11956 | echo fo\ob\"a\`r\'b\$az |
| 11957 | echo "fo\ob\"a\`r\'b\$az" |
| 11958 | echo 'fo\ob\"a\`r'\''b\$az' |
| 11959 | )|tr u x); } |
| 11960 | function reread_QCHAR_OQUOTE_CQUOTE { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11961 | 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 ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11962 | } |
| 11963 | inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() { |
| 11964 | [[ ${foo#bl\(u\)b} = @(bar|baz) ]] |
| 11965 | } |
| 11966 | inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() { |
| 11967 | [[ ${foo#bl\(u\)b} = @(bar|baz) ]] |
| 11968 | } |
| 11969 | function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$( |
| 11970 | [[ ${foo#bl\(u\)b} = @(bar|baz) ]] |
| 11971 | ); } |
| 11972 | function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT { |
| 11973 | x=$([[ ${foo#bl\(u\)b} = @(bar|baz) ]] ) |
| 11974 | } |
| 11975 | function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$(( |
| 11976 | [[ ${foo#bl\(u\)b} = @(bar|baz) ]] |
| 11977 | )|tr u x); } |
| 11978 | function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11979 | x=$( ( [[ ${foo#bl\(u\)b} = @(bar|baz) ]] ) | \tr u x ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11980 | } |
| 11981 | inline_heredoc_closed() { |
| 11982 | x=$(cat <<EOFN |
| 11983 | note there must be no space between EOFN and ) |
| 11984 | EOFN); echo $x |
| 11985 | } |
| 11986 | inline_heredoc_closed() { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11987 | x=$(\cat <<EOFN |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11988 | note there must be no space between EOFN and ) |
| 11989 | EOFN |
| 11990 | ) |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11991 | \echo $x |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 11992 | } |
| 11993 | function comsub_heredoc_closed { x=$( |
| 11994 | x=$(cat <<EOFN |
| 11995 | note there must be no space between EOFN and ) |
| 11996 | EOFN); echo $x |
| 11997 | ); } |
| 11998 | function comsub_heredoc_closed { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 11999 | x=$(x=$(\cat <<EOFN |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12000 | note there must be no space between EOFN and ) |
| 12001 | EOFN |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12002 | ) ; \echo $x ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12003 | } |
| 12004 | function reread_heredoc_closed { x=$(( |
| 12005 | x=$(cat <<EOFN |
| 12006 | note there must be no space between EOFN and ) |
| 12007 | EOFN); echo $x |
| 12008 | )|tr u x); } |
| 12009 | function reread_heredoc_closed { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12010 | x=$( ( x=$(\cat <<EOFN |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12011 | note there must be no space between EOFN and ) |
| 12012 | EOFN |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12013 | ) ; \echo $x ) | \tr u x ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12014 | } |
| 12015 | inline_heredoc_space() { |
| 12016 | x=$(cat <<EOFN\ |
| 12017 | note the space between EOFN and ) is actually part of the here document marker |
| 12018 | EOFN ); echo $x |
| 12019 | } |
| 12020 | inline_heredoc_space() { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12021 | x=$(\cat <<EOFN\ |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12022 | note the space between EOFN and ) is actually part of the here document marker |
| 12023 | EOFN |
| 12024 | ) |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12025 | \echo $x |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12026 | } |
| 12027 | function comsub_heredoc_space { x=$( |
| 12028 | x=$(cat <<EOFN\ |
| 12029 | note the space between EOFN and ) is actually part of the here document marker |
| 12030 | EOFN ); echo $x |
| 12031 | ); } |
| 12032 | function comsub_heredoc_space { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12033 | x=$(x=$(\cat <<EOFN\ |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12034 | note the space between EOFN and ) is actually part of the here document marker |
| 12035 | EOFN |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12036 | ) ; \echo $x ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12037 | } |
| 12038 | function reread_heredoc_space { x=$(( |
| 12039 | x=$(cat <<EOFN\ |
| 12040 | note the space between EOFN and ) is actually part of the here document marker |
| 12041 | EOFN ); echo $x |
| 12042 | )|tr u x); } |
| 12043 | function reread_heredoc_space { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12044 | x=$( ( x=$(\cat <<EOFN\ |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12045 | note the space between EOFN and ) is actually part of the here document marker |
| 12046 | EOFN |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12047 | ) ; \echo $x ) | \tr u x ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12048 | } |
| 12049 | inline_patch_motd() { |
| 12050 | x=$(sysctl -n kern.version | sed 1q) |
| 12051 | [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \ |
| 12052 | ed -s /etc/motd 2>&1 <<-EOF |
| 12053 | 1,/^\$/d |
| 12054 | 0a |
| 12055 | $x |
| 12056 | |
| 12057 | . |
| 12058 | wq |
| 12059 | EOF)" = @(?) ]] && rm -f /etc/motd |
| 12060 | if [[ ! -s /etc/motd ]]; then |
| 12061 | install -c -o root -g wheel -m 664 /dev/null /etc/motd |
| 12062 | print -- "$x\n" >/etc/motd |
| 12063 | fi |
| 12064 | } |
| 12065 | inline_patch_motd() { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12066 | x=$(\sysctl -n kern.version | \sed 1q ) |
| 12067 | [[ -s /etc/motd && "$([[ "$(\head -1 /etc/motd )" != $x ]] && \ed -s /etc/motd 2>&1 <<-EOF |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12068 | 1,/^\$/d |
| 12069 | 0a |
| 12070 | $x |
| 12071 | |
| 12072 | . |
| 12073 | wq |
| 12074 | EOF |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12075 | )" = @(?) ]] && \rm -f /etc/motd |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12076 | if [[ ! -s /etc/motd ]] |
| 12077 | then |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12078 | \install -c -o root -g wheel -m 664 /dev/null /etc/motd |
| 12079 | \print -- "$x\n" >/etc/motd |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12080 | fi |
| 12081 | } |
| 12082 | function comsub_patch_motd { x=$( |
| 12083 | x=$(sysctl -n kern.version | sed 1q) |
| 12084 | [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \ |
| 12085 | ed -s /etc/motd 2>&1 <<-EOF |
| 12086 | 1,/^\$/d |
| 12087 | 0a |
| 12088 | $x |
| 12089 | |
| 12090 | . |
| 12091 | wq |
| 12092 | EOF)" = @(?) ]] && rm -f /etc/motd |
| 12093 | if [[ ! -s /etc/motd ]]; then |
| 12094 | install -c -o root -g wheel -m 664 /dev/null /etc/motd |
| 12095 | print -- "$x\n" >/etc/motd |
| 12096 | fi |
| 12097 | ); } |
| 12098 | function comsub_patch_motd { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12099 | x=$(x=$(\sysctl -n kern.version | \sed 1q ) ; [[ -s /etc/motd && "$([[ "$(\head -1 /etc/motd )" != $x ]] && \ed -s /etc/motd 2>&1 <<-EOF |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12100 | 1,/^\$/d |
| 12101 | 0a |
| 12102 | $x |
| 12103 | |
| 12104 | . |
| 12105 | wq |
| 12106 | EOF |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12107 | )" = @(?) ]] && \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 ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12108 | } |
| 12109 | function reread_patch_motd { x=$(( |
| 12110 | x=$(sysctl -n kern.version | sed 1q) |
| 12111 | [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \ |
| 12112 | ed -s /etc/motd 2>&1 <<-EOF |
| 12113 | 1,/^\$/d |
| 12114 | 0a |
| 12115 | $x |
| 12116 | |
| 12117 | . |
| 12118 | wq |
| 12119 | EOF)" = @(?) ]] && rm -f /etc/motd |
| 12120 | if [[ ! -s /etc/motd ]]; then |
| 12121 | install -c -o root -g wheel -m 664 /dev/null /etc/motd |
| 12122 | print -- "$x\n" >/etc/motd |
| 12123 | fi |
| 12124 | )|tr u x); } |
| 12125 | function reread_patch_motd { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12126 | x=$( ( x=$(\sysctl -n kern.version | \sed 1q ) ; [[ -s /etc/motd && "$([[ "$(\head -1 /etc/motd )" != $x ]] && \ed -s /etc/motd 2>&1 <<-EOF |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12127 | 1,/^\$/d |
| 12128 | 0a |
| 12129 | $x |
| 12130 | |
| 12131 | . |
| 12132 | wq |
| 12133 | EOF |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12134 | )" = @(?) ]] && \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 ) |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12135 | } |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12136 | inline_wdarrassign() { |
| 12137 | case x in |
| 12138 | x) a+=b; c+=(d e) |
| 12139 | esac |
| 12140 | } |
| 12141 | inline_wdarrassign() { |
| 12142 | case x in |
| 12143 | (x) |
| 12144 | a+=b |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12145 | \\builtin set -A c+ -- d e |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12146 | ;; |
| 12147 | esac |
| 12148 | } |
| 12149 | function comsub_wdarrassign { x=$( |
| 12150 | case x in |
| 12151 | x) a+=b; c+=(d e) |
| 12152 | esac |
| 12153 | ); } |
| 12154 | function comsub_wdarrassign { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12155 | x=$(case x in (x) a+=b ; \\builtin set -A c+ -- d e ;; esac ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12156 | } |
| 12157 | function reread_wdarrassign { x=$(( |
| 12158 | case x in |
| 12159 | x) a+=b; c+=(d e) |
| 12160 | esac |
| 12161 | )|tr u x); } |
| 12162 | function reread_wdarrassign { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12163 | x=$( ( case x in (x) a+=b ; \\builtin set -A c+ -- d e ;; esac ) | \tr u x ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12164 | } |
| 12165 | --- |
| 12166 | name: comsub-torture-io |
| 12167 | description: |
| 12168 | Check the tree dump functions work correctly with I/O redirection |
| 12169 | stdin: |
| 12170 | if [[ -z $__progname ]]; then echo >&2 call me with __progname; exit 1; fi |
| 12171 | while IFS= read -r line; do |
| 12172 | if [[ $line = '#1' ]]; then |
| 12173 | lastf=0 |
| 12174 | continue |
| 12175 | elif [[ $line = EOFN* ]]; then |
| 12176 | fbody=$fbody$'\n'$line |
| 12177 | continue |
| 12178 | elif [[ $line != '#'* ]]; then |
| 12179 | fbody=$fbody$'\n\t'$line |
| 12180 | continue |
| 12181 | fi |
| 12182 | if (( lastf )); then |
| 12183 | x="inline_${nextf}() {"$fbody$'\n}\n' |
| 12184 | print -nr -- "$x" |
| 12185 | print -r -- "${x}typeset -f inline_$nextf" | "$__progname" |
| 12186 | x="function comsub_$nextf { x=\$("$fbody$'\n); }\n' |
| 12187 | print -nr -- "$x" |
| 12188 | print -r -- "${x}typeset -f comsub_$nextf" | "$__progname" |
| 12189 | x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n' |
| 12190 | print -nr -- "$x" |
| 12191 | print -r -- "${x}typeset -f reread_$nextf" | "$__progname" |
| 12192 | fi |
| 12193 | lastf=1 |
| 12194 | fbody= |
| 12195 | nextf=${line#?} |
| 12196 | done <<'EOD' |
| 12197 | #1 |
| 12198 | #TCOM |
| 12199 | vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3 |
| 12200 | #TPAREN_TPIPE_TLIST |
| 12201 | (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3 |
| 12202 | #TAND_TOR |
| 12203 | cmd >&3 && >&3 echo ja || echo >&3 nein |
| 12204 | #TSELECT |
| 12205 | select file in *; do echo "<$file>" ; break >&3 ; done >&3 |
| 12206 | #TFOR_TTIME |
| 12207 | for i in {1,2,3} ; do time >&3 echo $i ; done >&3 |
| 12208 | #TCASE |
| 12209 | case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3 |
| 12210 | #TIF_TBANG_TDBRACKET_TELIF |
| 12211 | if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3 |
| 12212 | #TWHILE |
| 12213 | i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3 |
| 12214 | #TUNTIL |
| 12215 | i=10; until (( !--i )) >&3 ; do echo $i; done >&3 |
| 12216 | #TCOPROC |
| 12217 | cat * >&3 |& >&3 ls |
| 12218 | #TFUNCT_TBRACE_TASYNC |
| 12219 | function korn { echo eins; echo >&3 zwei ; } |
| 12220 | bourne () { logger * >&3 & } |
| 12221 | #COMSUB_EXPRSUB |
| 12222 | echo $(true >&3) $((1+ 2)) |
| 12223 | #0 |
| 12224 | EOD |
| 12225 | expected-stdout: |
| 12226 | inline_TCOM() { |
| 12227 | vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3 |
| 12228 | } |
| 12229 | inline_TCOM() { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12230 | vara=1 varb="2 3" \cmd arg1 $arg2 "$arg3 4" >&3 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12231 | } |
| 12232 | function comsub_TCOM { x=$( |
| 12233 | vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3 |
| 12234 | ); } |
| 12235 | function comsub_TCOM { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12236 | x=$(vara=1 varb="2 3" \cmd arg1 $arg2 "$arg3 4" >&3 ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12237 | } |
| 12238 | function reread_TCOM { x=$(( |
| 12239 | vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3 |
| 12240 | )|tr u x); } |
| 12241 | function reread_TCOM { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12242 | x=$( ( vara=1 varb="2 3" \cmd arg1 $arg2 "$arg3 4" >&3 ) | \tr u x ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12243 | } |
| 12244 | inline_TPAREN_TPIPE_TLIST() { |
| 12245 | (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3 |
| 12246 | } |
| 12247 | inline_TPAREN_TPIPE_TLIST() { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12248 | ( \echo $foo | \tr -dc 0-9 >&3 |
| 12249 | \echo >&3 ) >&3 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12250 | } |
| 12251 | function comsub_TPAREN_TPIPE_TLIST { x=$( |
| 12252 | (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3 |
| 12253 | ); } |
| 12254 | function comsub_TPAREN_TPIPE_TLIST { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12255 | x=$( ( \echo $foo | \tr -dc 0-9 >&3 ; \echo >&3 ) >&3 ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12256 | } |
| 12257 | function reread_TPAREN_TPIPE_TLIST { x=$(( |
| 12258 | (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3 |
| 12259 | )|tr u x); } |
| 12260 | function reread_TPAREN_TPIPE_TLIST { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12261 | x=$( ( ( \echo $foo | \tr -dc 0-9 >&3 ; \echo >&3 ) >&3 ) | \tr u x ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12262 | } |
| 12263 | inline_TAND_TOR() { |
| 12264 | cmd >&3 && >&3 echo ja || echo >&3 nein |
| 12265 | } |
| 12266 | inline_TAND_TOR() { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12267 | \cmd >&3 && \echo ja >&3 || \echo nein >&3 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12268 | } |
| 12269 | function comsub_TAND_TOR { x=$( |
| 12270 | cmd >&3 && >&3 echo ja || echo >&3 nein |
| 12271 | ); } |
| 12272 | function comsub_TAND_TOR { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12273 | x=$(\cmd >&3 && \echo ja >&3 || \echo nein >&3 ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12274 | } |
| 12275 | function reread_TAND_TOR { x=$(( |
| 12276 | cmd >&3 && >&3 echo ja || echo >&3 nein |
| 12277 | )|tr u x); } |
| 12278 | function reread_TAND_TOR { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12279 | x=$( ( \cmd >&3 && \echo ja >&3 || \echo nein >&3 ) | \tr u x ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12280 | } |
| 12281 | inline_TSELECT() { |
| 12282 | select file in *; do echo "<$file>" ; break >&3 ; done >&3 |
| 12283 | } |
| 12284 | inline_TSELECT() { |
| 12285 | select file in * |
| 12286 | do |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12287 | \echo "<$file>" |
| 12288 | \break >&3 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12289 | done >&3 |
| 12290 | } |
| 12291 | function comsub_TSELECT { x=$( |
| 12292 | select file in *; do echo "<$file>" ; break >&3 ; done >&3 |
| 12293 | ); } |
| 12294 | function comsub_TSELECT { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12295 | x=$(select file in * ; do \echo "<$file>" ; \break >&3 ; done >&3 ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12296 | } |
| 12297 | function reread_TSELECT { x=$(( |
| 12298 | select file in *; do echo "<$file>" ; break >&3 ; done >&3 |
| 12299 | )|tr u x); } |
| 12300 | function reread_TSELECT { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12301 | x=$( ( select file in * ; do \echo "<$file>" ; \break >&3 ; done >&3 ) | \tr u x ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12302 | } |
| 12303 | inline_TFOR_TTIME() { |
| 12304 | for i in {1,2,3} ; do time >&3 echo $i ; done >&3 |
| 12305 | } |
| 12306 | inline_TFOR_TTIME() { |
| 12307 | for i in {1,2,3} |
| 12308 | do |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12309 | time \echo $i >&3 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12310 | done >&3 |
| 12311 | } |
| 12312 | function comsub_TFOR_TTIME { x=$( |
| 12313 | for i in {1,2,3} ; do time >&3 echo $i ; done >&3 |
| 12314 | ); } |
| 12315 | function comsub_TFOR_TTIME { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12316 | x=$(for i in {1,2,3} ; do time \echo $i >&3 ; done >&3 ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12317 | } |
| 12318 | function reread_TFOR_TTIME { x=$(( |
| 12319 | for i in {1,2,3} ; do time >&3 echo $i ; done >&3 |
| 12320 | )|tr u x); } |
| 12321 | function reread_TFOR_TTIME { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12322 | x=$( ( for i in {1,2,3} ; do time \echo $i >&3 ; done >&3 ) | \tr u x ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12323 | } |
| 12324 | inline_TCASE() { |
| 12325 | case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3 |
| 12326 | } |
| 12327 | inline_TCASE() { |
| 12328 | case $foo in |
| 12329 | (1) |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12330 | \echo eins >&3 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12331 | ;& |
| 12332 | (2) |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12333 | \echo zwei >&3 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12334 | ;| |
| 12335 | (*) |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12336 | \echo kann net bis drei zählen >&3 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12337 | ;; |
| 12338 | esac >&3 |
| 12339 | } |
| 12340 | function comsub_TCASE { x=$( |
| 12341 | case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3 |
| 12342 | ); } |
| 12343 | function comsub_TCASE { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12344 | x=$(case $foo in (1) \echo eins >&3 ;& (2) \echo zwei >&3 ;| (*) \echo kann net bis drei zählen >&3 ;; esac >&3 ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12345 | } |
| 12346 | function reread_TCASE { x=$(( |
| 12347 | case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zählen >&3;; esac >&3 |
| 12348 | )|tr u x); } |
| 12349 | function reread_TCASE { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12350 | x=$( ( case $foo in (1) \echo eins >&3 ;& (2) \echo zwei >&3 ;| (*) \echo kann net bis drei zählen >&3 ;; esac >&3 ) | \tr u x ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12351 | } |
| 12352 | inline_TIF_TBANG_TDBRACKET_TELIF() { |
| 12353 | if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3 |
| 12354 | } |
| 12355 | inline_TIF_TBANG_TDBRACKET_TELIF() { |
| 12356 | if ! [[ 1 = 1 ]] >&3 |
| 12357 | then |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12358 | \echo eins |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12359 | elif [[ 1 = 2 ]] >&3 |
| 12360 | then |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12361 | \echo zwei |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12362 | else |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12363 | \echo drei |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12364 | fi >&3 |
| 12365 | } |
| 12366 | function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$( |
| 12367 | if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3 |
| 12368 | ); } |
| 12369 | function comsub_TIF_TBANG_TDBRACKET_TELIF { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12370 | x=$(if ! [[ 1 = 1 ]] >&3 ; then \echo eins ; elif [[ 1 = 2 ]] >&3 ; then \echo zwei ; else \echo drei ; fi >&3 ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12371 | } |
| 12372 | function reread_TIF_TBANG_TDBRACKET_TELIF { x=$(( |
| 12373 | if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3 |
| 12374 | )|tr u x); } |
| 12375 | function reread_TIF_TBANG_TDBRACKET_TELIF { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12376 | x=$( ( if ! [[ 1 = 1 ]] >&3 ; then \echo eins ; elif [[ 1 = 2 ]] >&3 ; then \echo zwei ; else \echo drei ; fi >&3 ) | \tr u x ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12377 | } |
| 12378 | inline_TWHILE() { |
| 12379 | i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3 |
| 12380 | } |
| 12381 | inline_TWHILE() { |
| 12382 | i=1 |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 12383 | while { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12384 | \\builtin let " i < 10 " |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 12385 | } >&3 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12386 | do |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12387 | \echo $i |
| 12388 | \let ++i |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12389 | done >&3 |
| 12390 | } |
| 12391 | function comsub_TWHILE { x=$( |
| 12392 | i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3 |
| 12393 | ); } |
| 12394 | function comsub_TWHILE { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12395 | x=$(i=1 ; while { \\builtin let " i < 10 " ; } >&3 ; do \echo $i ; \let ++i ; done >&3 ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12396 | } |
| 12397 | function reread_TWHILE { x=$(( |
| 12398 | i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3 |
| 12399 | )|tr u x); } |
| 12400 | function reread_TWHILE { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12401 | x=$( ( i=1 ; while { \\builtin let " i < 10 " ; } >&3 ; do \echo $i ; \let ++i ; done >&3 ) | \tr u x ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12402 | } |
| 12403 | inline_TUNTIL() { |
| 12404 | i=10; until (( !--i )) >&3 ; do echo $i; done >&3 |
| 12405 | } |
| 12406 | inline_TUNTIL() { |
| 12407 | i=10 |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 12408 | until { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12409 | \\builtin let " !--i " |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 12410 | } >&3 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12411 | do |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12412 | \echo $i |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12413 | done >&3 |
| 12414 | } |
| 12415 | function comsub_TUNTIL { x=$( |
| 12416 | i=10; until (( !--i )) >&3 ; do echo $i; done >&3 |
| 12417 | ); } |
| 12418 | function comsub_TUNTIL { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12419 | x=$(i=10 ; until { \\builtin let " !--i " ; } >&3 ; do \echo $i ; done >&3 ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12420 | } |
| 12421 | function reread_TUNTIL { x=$(( |
| 12422 | i=10; until (( !--i )) >&3 ; do echo $i; done >&3 |
| 12423 | )|tr u x); } |
| 12424 | function reread_TUNTIL { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12425 | x=$( ( i=10 ; until { \\builtin let " !--i " ; } >&3 ; do \echo $i ; done >&3 ) | \tr u x ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12426 | } |
| 12427 | inline_TCOPROC() { |
| 12428 | cat * >&3 |& >&3 ls |
| 12429 | } |
| 12430 | inline_TCOPROC() { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12431 | \cat * >&3 |& |
| 12432 | \ls >&3 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12433 | } |
| 12434 | function comsub_TCOPROC { x=$( |
| 12435 | cat * >&3 |& >&3 ls |
| 12436 | ); } |
| 12437 | function comsub_TCOPROC { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12438 | x=$(\cat * >&3 |& \ls >&3 ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12439 | } |
| 12440 | function reread_TCOPROC { x=$(( |
| 12441 | cat * >&3 |& >&3 ls |
| 12442 | )|tr u x); } |
| 12443 | function reread_TCOPROC { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12444 | x=$( ( \cat * >&3 |& \ls >&3 ) | \tr u x ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12445 | } |
| 12446 | inline_TFUNCT_TBRACE_TASYNC() { |
| 12447 | function korn { echo eins; echo >&3 zwei ; } |
| 12448 | bourne () { logger * >&3 & } |
| 12449 | } |
| 12450 | inline_TFUNCT_TBRACE_TASYNC() { |
| 12451 | function korn { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12452 | \echo eins |
| 12453 | \echo zwei >&3 |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12454 | } |
| 12455 | bourne() { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12456 | \logger * >&3 & |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12457 | } |
| 12458 | } |
| 12459 | function comsub_TFUNCT_TBRACE_TASYNC { x=$( |
| 12460 | function korn { echo eins; echo >&3 zwei ; } |
| 12461 | bourne () { logger * >&3 & } |
| 12462 | ); } |
| 12463 | function comsub_TFUNCT_TBRACE_TASYNC { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12464 | x=$(function korn { \echo eins ; \echo zwei >&3 ; } ; bourne() { \logger * >&3 & } ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12465 | } |
| 12466 | function reread_TFUNCT_TBRACE_TASYNC { x=$(( |
| 12467 | function korn { echo eins; echo >&3 zwei ; } |
| 12468 | bourne () { logger * >&3 & } |
| 12469 | )|tr u x); } |
| 12470 | function reread_TFUNCT_TBRACE_TASYNC { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12471 | x=$( ( function korn { \echo eins ; \echo zwei >&3 ; } ; bourne() { \logger * >&3 & } ) | \tr u x ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12472 | } |
| 12473 | inline_COMSUB_EXPRSUB() { |
| 12474 | echo $(true >&3) $((1+ 2)) |
| 12475 | } |
| 12476 | inline_COMSUB_EXPRSUB() { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12477 | \echo $(\true >&3 ) $((1+ 2)) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12478 | } |
| 12479 | function comsub_COMSUB_EXPRSUB { x=$( |
| 12480 | echo $(true >&3) $((1+ 2)) |
| 12481 | ); } |
| 12482 | function comsub_COMSUB_EXPRSUB { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12483 | x=$(\echo $(\true >&3 ) $((1+ 2)) ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12484 | } |
| 12485 | function reread_COMSUB_EXPRSUB { x=$(( |
| 12486 | echo $(true >&3) $((1+ 2)) |
| 12487 | )|tr u x); } |
| 12488 | function reread_COMSUB_EXPRSUB { |
Elliott Hughes | a3c3f96 | 2017-04-12 16:52:30 -0700 | [diff] [blame] | 12489 | x=$( ( \echo $(\true >&3 ) $((1+ 2)) ) | \tr u x ) |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12490 | } |
| 12491 | --- |
| 12492 | name: funsub-1 |
| 12493 | description: |
| 12494 | Check that non-subenvironment command substitution works |
| 12495 | stdin: |
| 12496 | set -e |
| 12497 | foo=bar |
| 12498 | echo "ob $foo ." |
| 12499 | echo "${ |
| 12500 | echo "ib $foo :" |
| 12501 | foo=baz |
| 12502 | echo "ia $foo :" |
| 12503 | false |
| 12504 | }" . |
| 12505 | echo "oa $foo ." |
| 12506 | expected-stdout: |
| 12507 | ob bar . |
| 12508 | ib bar : |
| 12509 | ia baz : . |
| 12510 | oa baz . |
| 12511 | --- |
| 12512 | name: funsub-2 |
| 12513 | description: |
| 12514 | You can now reliably use local and return in funsubs |
| 12515 | (not exit though) |
| 12516 | stdin: |
| 12517 | x=q; e=1; x=${ echo a; e=2; echo x$e;}; echo 1:y$x,$e,$?. |
| 12518 | x=q; e=1; x=${ echo a; typeset e=2; echo x$e;}; echo 2:y$x,$e,$?. |
| 12519 | x=q; e=1; x=${ echo a; typeset e=2; return 3; echo x$e;}; echo 3:y$x,$e,$?. |
| 12520 | expected-stdout: |
| 12521 | 1:ya x2,2,0. |
| 12522 | 2:ya x2,1,0. |
| 12523 | 3:ya,1,3. |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12524 | --- |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 12525 | name: valsub-1 |
| 12526 | description: |
| 12527 | Check that "value substitutions" work as advertised |
| 12528 | stdin: |
| 12529 | x=1 |
| 12530 | y=2 |
| 12531 | z=3 |
| 12532 | REPLY=4 |
| 12533 | echo "before: x<$x> y<$y> z<$z> R<$REPLY>" |
| 12534 | x=${| |
| 12535 | local y |
Elliott Hughes | 966dd55 | 2016-12-08 15:56:04 -0800 | [diff] [blame] | 12536 | echo "start: x<$x> y<$y> z<$z> R<$REPLY>" |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 12537 | x=5 |
| 12538 | y=6 |
| 12539 | z=7 |
| 12540 | REPLY=8 |
| 12541 | echo "end: x<$x> y<$y> z<$z> R<$REPLY>" |
| 12542 | } |
| 12543 | echo "after: x<$x> y<$y> z<$z> R<$REPLY>" |
| 12544 | # ensure trailing newlines are kept |
| 12545 | t=${|REPLY=$'foo\n\n';} |
| 12546 | typeset -p t |
| 12547 | echo -n this used to segfault |
| 12548 | echo ${|true;}$(true). |
| 12549 | expected-stdout: |
| 12550 | before: x<1> y<2> z<3> R<4> |
Elliott Hughes | 966dd55 | 2016-12-08 15:56:04 -0800 | [diff] [blame] | 12551 | start: x<1> y<> z<3> R<> |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 12552 | end: x<5> y<6> z<7> R<8> |
| 12553 | after: x<8> y<2> z<7> R<4> |
| 12554 | typeset t=$'foo\n\n' |
| 12555 | this used to segfault. |
| 12556 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 12557 | name: event-subst-3 |
| 12558 | description: |
| 12559 | Check that '!' substitution in noninteractive mode is ignored |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 12560 | file-setup: file 755 "falsetto" |
| 12561 | #! /bin/sh |
| 12562 | echo molto bene |
| 12563 | exit 42 |
| 12564 | file-setup: file 755 "!false" |
| 12565 | #! /bin/sh |
| 12566 | echo si |
| 12567 | stdin: |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 12568 | export PATH=.$PATHSEP$PATH |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 12569 | falsetto |
| 12570 | echo yeap |
| 12571 | !false |
| 12572 | echo meow |
| 12573 | ! false |
| 12574 | echo = $? |
| 12575 | if |
| 12576 | ! false; then echo foo; else echo bar; fi |
| 12577 | expected-stdout: |
| 12578 | molto bene |
| 12579 | yeap |
| 12580 | si |
| 12581 | meow |
| 12582 | = 0 |
| 12583 | foo |
| 12584 | --- |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12585 | name: event-subst-0 |
| 12586 | description: |
| 12587 | Check that '!' substitution in interactive mode is ignored |
| 12588 | need-ctty: yes |
| 12589 | arguments: !-i! |
| 12590 | file-setup: file 755 "falsetto" |
| 12591 | #! /bin/sh |
| 12592 | echo molto bene |
| 12593 | exit 42 |
| 12594 | file-setup: file 755 "!false" |
| 12595 | #! /bin/sh |
| 12596 | echo si |
| 12597 | stdin: |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 12598 | export PATH=.$PATHSEP$PATH |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12599 | falsetto |
| 12600 | echo yeap |
| 12601 | !false |
| 12602 | echo meow |
| 12603 | ! false |
| 12604 | echo = $? |
| 12605 | if |
| 12606 | ! false; then echo foo; else echo bar; fi |
| 12607 | expected-stdout: |
| 12608 | molto bene |
| 12609 | yeap |
| 12610 | si |
| 12611 | meow |
| 12612 | = 0 |
| 12613 | foo |
| 12614 | expected-stderr-pattern: |
| 12615 | /.*/ |
| 12616 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 12617 | name: nounset-1 |
| 12618 | description: |
| 12619 | Check that "set -u" matches (future) SUSv4 requirement |
| 12620 | stdin: |
| 12621 | (set -u |
| 12622 | try() { |
| 12623 | local v |
| 12624 | eval v=\$$1 |
| 12625 | if [[ -n $v ]]; then |
| 12626 | echo $1=nz |
| 12627 | else |
| 12628 | echo $1=zf |
| 12629 | fi |
| 12630 | } |
| 12631 | x=y |
| 12632 | (echo $x) |
| 12633 | echo =1 |
| 12634 | (echo $y) |
| 12635 | echo =2 |
| 12636 | (try x) |
| 12637 | echo =3 |
| 12638 | (try y) |
| 12639 | echo =4 |
| 12640 | (try 0) |
| 12641 | echo =5 |
| 12642 | (try 2) |
| 12643 | echo =6 |
| 12644 | (try) |
| 12645 | echo =7 |
| 12646 | (echo at=$@) |
| 12647 | echo =8 |
| 12648 | (echo asterisk=$*) |
| 12649 | echo =9 |
| 12650 | (echo $?) |
| 12651 | echo =10 |
| 12652 | (echo $!) |
| 12653 | echo =11 |
| 12654 | (echo $-) |
| 12655 | echo =12 |
| 12656 | #(echo $_) |
| 12657 | #echo =13 |
| 12658 | (echo $#) |
| 12659 | echo =14 |
| 12660 | (mypid=$$; try mypid) |
| 12661 | echo =15 |
| 12662 | ) 2>&1 | sed -e 's/^[^]]*]//' -e 's/^[^:]*: *//' |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 12663 | exit ${PIPESTATUS[0]} |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 12664 | expected-stdout: |
| 12665 | y |
| 12666 | =1 |
| 12667 | y: parameter not set |
| 12668 | =2 |
| 12669 | x=nz |
| 12670 | =3 |
| 12671 | y: parameter not set |
| 12672 | =4 |
| 12673 | 0=nz |
| 12674 | =5 |
| 12675 | 2: parameter not set |
| 12676 | =6 |
| 12677 | 1: parameter not set |
| 12678 | =7 |
| 12679 | at= |
| 12680 | =8 |
| 12681 | asterisk= |
| 12682 | =9 |
| 12683 | 0 |
| 12684 | =10 |
| 12685 | !: parameter not set |
| 12686 | =11 |
| 12687 | ush |
| 12688 | =12 |
| 12689 | 0 |
| 12690 | =14 |
| 12691 | mypid=nz |
| 12692 | =15 |
| 12693 | --- |
| 12694 | name: nameref-1 |
| 12695 | description: |
| 12696 | Testsuite for nameref (bound variables) |
| 12697 | stdin: |
| 12698 | bar=global |
| 12699 | typeset -n ir2=bar |
| 12700 | typeset -n ind=ir2 |
| 12701 | echo !ind: ${!ind} |
| 12702 | echo ind: $ind |
| 12703 | echo !ir2: ${!ir2} |
| 12704 | echo ir2: $ir2 |
| 12705 | typeset +n ind |
| 12706 | echo !ind: ${!ind} |
| 12707 | echo ind: $ind |
| 12708 | typeset -n ir2=ind |
| 12709 | echo !ir2: ${!ir2} |
| 12710 | echo ir2: $ir2 |
| 12711 | set|grep ^ir2|sed 's/^/s1: /' |
| 12712 | typeset|grep ' ir2'|sed -e 's/^/s2: /' -e 's/nameref/typeset -n/' |
| 12713 | set -A blub -- e1 e2 e3 |
| 12714 | typeset -n ind=blub |
| 12715 | typeset -n ir2=blub[2] |
| 12716 | echo !ind[1]: ${!ind[1]} |
| 12717 | echo !ir2: $!ir2 |
| 12718 | echo ind[1]: ${ind[1]} |
| 12719 | echo ir2: $ir2 |
| 12720 | expected-stdout: |
| 12721 | !ind: bar |
| 12722 | ind: global |
| 12723 | !ir2: bar |
| 12724 | ir2: global |
| 12725 | !ind: ind |
| 12726 | ind: ir2 |
| 12727 | !ir2: ind |
| 12728 | ir2: ir2 |
| 12729 | s1: ir2=ind |
| 12730 | s2: typeset -n ir2 |
Elliott Hughes | 737fdce | 2014-08-07 12:59:26 -0700 | [diff] [blame] | 12731 | !ind[1]: blub[1] |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 12732 | !ir2: ir2 |
| 12733 | ind[1]: e2 |
| 12734 | ir2: e3 |
| 12735 | --- |
| 12736 | name: nameref-2da |
| 12737 | description: |
| 12738 | Testsuite for nameref (bound variables) |
| 12739 | Functions, argument given directly, after local |
| 12740 | stdin: |
| 12741 | function foo { |
| 12742 | typeset bar=lokal baz=auch |
| 12743 | typeset -n v=bar |
| 12744 | echo entering |
| 12745 | echo !v: ${!v} |
| 12746 | echo !bar: ${!bar} |
| 12747 | echo !baz: ${!baz} |
| 12748 | echo bar: $bar |
| 12749 | echo v: $v |
| 12750 | v=123 |
| 12751 | echo bar: $bar |
| 12752 | echo v: $v |
| 12753 | echo exiting |
| 12754 | } |
| 12755 | bar=global |
| 12756 | echo bar: $bar |
| 12757 | foo bar |
| 12758 | echo bar: $bar |
| 12759 | expected-stdout: |
| 12760 | bar: global |
| 12761 | entering |
| 12762 | !v: bar |
| 12763 | !bar: bar |
| 12764 | !baz: baz |
| 12765 | bar: lokal |
| 12766 | v: lokal |
| 12767 | bar: 123 |
| 12768 | v: 123 |
| 12769 | exiting |
| 12770 | bar: global |
| 12771 | --- |
| 12772 | name: nameref-3 |
| 12773 | description: |
| 12774 | Advanced testsuite for bound variables (ksh93 fails this) |
| 12775 | stdin: |
| 12776 | typeset -n foo=bar[i] |
| 12777 | set -A bar -- b c a |
| 12778 | for i in 0 1 2 3; do |
| 12779 | print $i $foo . |
| 12780 | done |
| 12781 | expected-stdout: |
| 12782 | 0 b . |
| 12783 | 1 c . |
| 12784 | 2 a . |
| 12785 | 3 . |
| 12786 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12787 | name: nameref-4 |
| 12788 | description: |
| 12789 | Ensure we don't run in an infinite loop |
| 12790 | time-limit: 3 |
| 12791 | stdin: |
| 12792 | baz() { |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 12793 | typeset -n foo=fnord fnord=foo |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12794 | foo[0]=bar |
| 12795 | } |
| 12796 | set -A foo bad |
| 12797 | echo sind $foo . |
| 12798 | baz |
| 12799 | echo blah $foo . |
| 12800 | expected-stdout: |
| 12801 | sind bad . |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 12802 | blah bad . |
| 12803 | expected-stderr-pattern: |
| 12804 | /fnord: expression recurses on parameter/ |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12805 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 12806 | name: better-parens-1a |
| 12807 | description: |
| 12808 | Check support for ((â¦)) and $((â¦)) vs (â¦) and $(â¦) |
| 12809 | stdin: |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12810 | if ( (echo fubar)|tr u x); then |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 12811 | echo ja |
| 12812 | else |
| 12813 | echo nein |
| 12814 | fi |
| 12815 | expected-stdout: |
| 12816 | fxbar |
| 12817 | ja |
| 12818 | --- |
| 12819 | name: better-parens-1b |
| 12820 | description: |
| 12821 | Check support for ((â¦)) and $((â¦)) vs (â¦) and $(â¦) |
| 12822 | stdin: |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12823 | echo $( (echo fubar)|tr u x) $? |
| 12824 | expected-stdout: |
| 12825 | fxbar 0 |
| 12826 | --- |
| 12827 | name: better-parens-1c |
| 12828 | description: |
| 12829 | Check support for ((â¦)) and $((â¦)) vs (â¦) and $(â¦) |
| 12830 | stdin: |
| 12831 | x=$( (echo fubar)|tr u x); echo $x $? |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 12832 | expected-stdout: |
| 12833 | fxbar 0 |
| 12834 | --- |
| 12835 | name: better-parens-2a |
| 12836 | description: |
| 12837 | Check support for ((â¦)) and $((â¦)) vs (â¦) and $(â¦) |
| 12838 | stdin: |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12839 | if ((echo fubar)|tr u x); then |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 12840 | echo ja |
| 12841 | else |
| 12842 | echo nein |
| 12843 | fi |
| 12844 | expected-stdout: |
| 12845 | fxbar |
| 12846 | ja |
| 12847 | --- |
| 12848 | name: better-parens-2b |
| 12849 | description: |
| 12850 | Check support for ((â¦)) and $((â¦)) vs (â¦) and $(â¦) |
| 12851 | stdin: |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12852 | echo $((echo fubar)|tr u x) $? |
| 12853 | expected-stdout: |
| 12854 | fxbar 0 |
| 12855 | --- |
| 12856 | name: better-parens-2c |
| 12857 | description: |
| 12858 | Check support for ((â¦)) and $((â¦)) vs (â¦) and $(â¦) |
| 12859 | stdin: |
| 12860 | x=$((echo fubar)|tr u x); echo $x $? |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 12861 | expected-stdout: |
| 12862 | fxbar 0 |
| 12863 | --- |
| 12864 | name: better-parens-3a |
| 12865 | description: |
| 12866 | Check support for ((â¦)) and $((â¦)) vs (â¦) and $(â¦) |
| 12867 | stdin: |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12868 | if ( (echo fubar)|(tr u x)); then |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 12869 | echo ja |
| 12870 | else |
| 12871 | echo nein |
| 12872 | fi |
| 12873 | expected-stdout: |
| 12874 | fxbar |
| 12875 | ja |
| 12876 | --- |
| 12877 | name: better-parens-3b |
| 12878 | description: |
| 12879 | Check support for ((â¦)) and $((â¦)) vs (â¦) and $(â¦) |
| 12880 | stdin: |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12881 | echo $( (echo fubar)|(tr u x)) $? |
| 12882 | expected-stdout: |
| 12883 | fxbar 0 |
| 12884 | --- |
| 12885 | name: better-parens-3c |
| 12886 | description: |
| 12887 | Check support for ((â¦)) and $((â¦)) vs (â¦) and $(â¦) |
| 12888 | stdin: |
| 12889 | x=$( (echo fubar)|(tr u x)); echo $x $? |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 12890 | expected-stdout: |
| 12891 | fxbar 0 |
| 12892 | --- |
| 12893 | name: better-parens-4a |
| 12894 | description: |
| 12895 | Check support for ((â¦)) and $((â¦)) vs (â¦) and $(â¦) |
| 12896 | stdin: |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12897 | if ((echo fubar)|(tr u x)); then |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 12898 | echo ja |
| 12899 | else |
| 12900 | echo nein |
| 12901 | fi |
| 12902 | expected-stdout: |
| 12903 | fxbar |
| 12904 | ja |
| 12905 | --- |
| 12906 | name: better-parens-4b |
| 12907 | description: |
| 12908 | Check support for ((â¦)) and $((â¦)) vs (â¦) and $(â¦) |
| 12909 | stdin: |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 12910 | echo $((echo fubar)|(tr u x)) $? |
| 12911 | expected-stdout: |
| 12912 | fxbar 0 |
| 12913 | --- |
| 12914 | name: better-parens-4c |
| 12915 | description: |
| 12916 | Check support for ((â¦)) and $((â¦)) vs (â¦) and $(â¦) |
| 12917 | stdin: |
| 12918 | x=$((echo fubar)|(tr u x)); echo $x $? |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 12919 | expected-stdout: |
| 12920 | fxbar 0 |
| 12921 | --- |
Elliott Hughes | fc0307d | 2016-02-02 15:26:47 -0800 | [diff] [blame] | 12922 | name: better-parens-5 |
| 12923 | description: |
| 12924 | Another corner case |
| 12925 | stdin: |
| 12926 | ( (echo 'fo o$bar' "baz\$bla\"" m\$eh) | tr a A) |
| 12927 | ((echo 'fo o$bar' "baz\$bla\"" m\$eh) | tr a A) |
| 12928 | expected-stdout: |
| 12929 | fo o$bAr bAz$blA" m$eh |
| 12930 | fo o$bAr bAz$blA" m$eh |
| 12931 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 12932 | name: echo-test-1 |
| 12933 | description: |
| 12934 | Test what the echo builtin does (mksh) |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 12935 | category: !shell:ebcdic-yes |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 12936 | stdin: |
| 12937 | echo -n 'foo\x40bar' |
| 12938 | echo -e '\tbaz' |
| 12939 | expected-stdout: |
| 12940 | foo@bar baz |
| 12941 | --- |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 12942 | name: echo-test-1-ebcdic |
| 12943 | description: |
| 12944 | Test what the echo builtin does (mksh) |
| 12945 | category: !shell:ebcdic-no |
| 12946 | stdin: |
| 12947 | echo -n 'foo\x7Cbar' |
| 12948 | echo -e '\tbaz' |
| 12949 | expected-stdout: |
| 12950 | foo@bar baz |
| 12951 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 12952 | name: echo-test-2 |
| 12953 | description: |
| 12954 | Test what the echo builtin does (POSIX) |
| 12955 | Note: this follows Debian Policy 10.4 which mandates |
| 12956 | that -n shall be treated as an option, not XSI which |
| 12957 | mandates it shall be treated as string but escapes |
| 12958 | shall be expanded. |
| 12959 | stdin: |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12960 | test -n "$POSH_VERSION" || set -o posix |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 12961 | echo -n 'foo\x40bar' |
| 12962 | echo -e '\tbaz' |
| 12963 | expected-stdout: |
| 12964 | foo\x40bar-e \tbaz |
| 12965 | --- |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12966 | name: echo-test-3-mnbsd |
| 12967 | description: |
| 12968 | Test what the echo builtin does, and test a compatibility flag. |
| 12969 | category: mnbsdash |
| 12970 | stdin: |
| 12971 | "$__progname" -c 'echo -n 1=\\x40$1; echo -e \\x2E' -- foo bar |
| 12972 | "$__progname" -o posix -c 'echo -n 2=\\x40$1; echo -e \\x2E' -- foo bar |
| 12973 | "$__progname" -o sh -c 'echo -n 3=\\x40$1; echo -e \\x2E' -- foo bar |
| 12974 | expected-stdout: |
| 12975 | 1=@foo. |
| 12976 | 2=\x40foo-e \x2E |
| 12977 | 3=\x40bar. |
| 12978 | --- |
| 12979 | name: echo-test-3-normal |
| 12980 | description: |
| 12981 | Test what the echo builtin does, and test a compatibility flag. |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 12982 | category: !mnbsdash,!shell:ebcdic-yes |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 12983 | stdin: |
| 12984 | "$__progname" -c 'echo -n 1=\\x40$1; echo -e \\x2E' -- foo bar |
| 12985 | "$__progname" -o posix -c 'echo -n 2=\\x40$1; echo -e \\x2E' -- foo bar |
| 12986 | "$__progname" -o sh -c 'echo -n 3=\\x40$1; echo -e \\x2E' -- foo bar |
| 12987 | expected-stdout: |
| 12988 | 1=@foo. |
| 12989 | 2=\x40foo-e \x2E |
| 12990 | 3=\x40foo-e \x2E |
| 12991 | --- |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 12992 | name: echo-test-3-ebcdic |
| 12993 | description: |
| 12994 | Test what the echo builtin does, and test a compatibility flag. |
| 12995 | category: !mnbsdash,!shell:ebcdic-no |
| 12996 | stdin: |
| 12997 | "$__progname" -c 'echo -n 1=\\x7C$1; echo -e \\x4B' -- foo bar |
| 12998 | "$__progname" -o posix -c 'echo -n 2=\\x7C$1; echo -e \\x4B' -- foo bar |
| 12999 | "$__progname" -o sh -c 'echo -n 3=\\x7C$1; echo -e \\x4B' -- foo bar |
| 13000 | expected-stdout: |
| 13001 | 1=@foo. |
| 13002 | 2=\x7Cfoo-e \x4B |
| 13003 | 3=\x7Cfoo-e \x4B |
| 13004 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 13005 | name: utilities-getopts-1 |
| 13006 | description: |
| 13007 | getopts sets OPTIND correctly for unparsed option |
| 13008 | stdin: |
| 13009 | set -- -a -a -x |
| 13010 | while getopts :a optc; do |
| 13011 | echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc." |
| 13012 | done |
| 13013 | echo done |
| 13014 | expected-stdout: |
| 13015 | OPTARG=, OPTIND=2, optc=a. |
| 13016 | OPTARG=, OPTIND=3, optc=a. |
| 13017 | OPTARG=x, OPTIND=4, optc=?. |
| 13018 | done |
| 13019 | --- |
| 13020 | name: utilities-getopts-2 |
| 13021 | description: |
| 13022 | Check OPTARG |
| 13023 | stdin: |
| 13024 | set -- -a Mary -x |
| 13025 | while getopts a: optc; do |
| 13026 | echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc." |
| 13027 | done |
| 13028 | echo done |
| 13029 | expected-stdout: |
| 13030 | OPTARG=Mary, OPTIND=3, optc=a. |
| 13031 | OPTARG=, OPTIND=4, optc=?. |
| 13032 | done |
| 13033 | expected-stderr-pattern: /.*-x.*option/ |
| 13034 | --- |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 13035 | name: utilities-getopts-3 |
| 13036 | description: |
| 13037 | Check unsetting OPTARG |
| 13038 | stdin: |
| 13039 | set -- -x arg -y |
| 13040 | getopts x:y opt && echo "${OPTARG-unset}" |
| 13041 | getopts x:y opt && echo "${OPTARG-unset}" |
| 13042 | expected-stdout: |
| 13043 | arg |
| 13044 | unset |
| 13045 | --- |
Jean-Baptiste Queru | 5155f1c | 2011-06-16 10:05:28 -0700 | [diff] [blame] | 13046 | name: wcswidth-1 |
| 13047 | description: |
| 13048 | Check the new wcswidth feature |
| 13049 | stdin: |
| 13050 | s=ä½ |
| 13051 | set +U |
| 13052 | print octets: ${#s} . |
| 13053 | print 8-bit width: ${%s} . |
| 13054 | set -U |
| 13055 | print characters: ${#s} . |
| 13056 | print columns: ${%s} . |
| 13057 | s=� |
| 13058 | set +U |
| 13059 | print octets: ${#s} . |
| 13060 | print 8-bit width: ${%s} . |
| 13061 | set -U |
| 13062 | print characters: ${#s} . |
| 13063 | print columns: ${%s} . |
| 13064 | expected-stdout: |
| 13065 | octets: 3 . |
| 13066 | 8-bit width: -1 . |
| 13067 | characters: 1 . |
| 13068 | columns: 2 . |
| 13069 | octets: 3 . |
| 13070 | 8-bit width: 3 . |
| 13071 | characters: 1 . |
| 13072 | columns: 1 . |
| 13073 | --- |
| 13074 | name: wcswidth-2 |
| 13075 | description: |
| 13076 | Check some corner cases |
| 13077 | stdin: |
| 13078 | print % $% . |
| 13079 | set -U |
| 13080 | x='a b' |
| 13081 | print c ${%x} . |
| 13082 | set +U |
| 13083 | x='a b' |
| 13084 | print d ${%x} . |
| 13085 | expected-stdout: |
| 13086 | % $% . |
| 13087 | c -1 . |
| 13088 | d -1 . |
| 13089 | --- |
| 13090 | name: wcswidth-3 |
| 13091 | description: |
| 13092 | Check some corner cases |
| 13093 | stdin: |
| 13094 | print ${%} . |
| 13095 | expected-stderr-pattern: |
| 13096 | /bad substitution/ |
| 13097 | expected-exit: 1 |
| 13098 | --- |
| 13099 | name: wcswidth-4a |
| 13100 | description: |
| 13101 | Check some corner cases |
| 13102 | stdin: |
| 13103 | print ${%*} . |
| 13104 | expected-stderr-pattern: |
| 13105 | /bad substitution/ |
| 13106 | expected-exit: 1 |
| 13107 | --- |
| 13108 | name: wcswidth-4b |
| 13109 | description: |
| 13110 | Check some corner cases |
| 13111 | stdin: |
| 13112 | print ${%@} . |
| 13113 | expected-stderr-pattern: |
| 13114 | /bad substitution/ |
| 13115 | expected-exit: 1 |
| 13116 | --- |
| 13117 | name: wcswidth-4c |
| 13118 | description: |
| 13119 | Check some corner cases |
| 13120 | stdin: |
| 13121 | : |
| 13122 | print ${%?} . |
| 13123 | expected-stdout: |
| 13124 | 1 . |
| 13125 | --- |
| 13126 | name: realpath-1 |
| 13127 | description: |
| 13128 | Check proper return values for realpath |
| 13129 | category: os:mirbsd |
| 13130 | stdin: |
| 13131 | wd=$(realpath .) |
| 13132 | mkdir dir |
| 13133 | :>file |
| 13134 | :>dir/file |
| 13135 | ln -s dir lndir |
| 13136 | ln -s file lnfile |
| 13137 | ln -s nix lnnix |
| 13138 | ln -s . lnself |
| 13139 | i=0 |
| 13140 | chk() { |
| 13141 | typeset x y |
| 13142 | x=$(realpath "$wd/$1" 2>&1); y=$? |
| 13143 | print $((++i)) "?$1" =${x##*$wd/} !$y |
| 13144 | } |
| 13145 | chk dir |
| 13146 | chk dir/ |
| 13147 | chk dir/file |
| 13148 | chk dir/nix |
| 13149 | chk file |
| 13150 | chk file/ |
| 13151 | chk file/file |
| 13152 | chk file/nix |
| 13153 | chk nix |
| 13154 | chk nix/ |
| 13155 | chk nix/file |
| 13156 | chk nix/nix |
| 13157 | chk lndir |
| 13158 | chk lndir/ |
| 13159 | chk lndir/file |
| 13160 | chk lndir/nix |
| 13161 | chk lnfile |
| 13162 | chk lnfile/ |
| 13163 | chk lnfile/file |
| 13164 | chk lnfile/nix |
| 13165 | chk lnnix |
| 13166 | chk lnnix/ |
| 13167 | chk lnnix/file |
| 13168 | chk lnnix/nix |
| 13169 | 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 |
| 13170 | rm lnself |
| 13171 | expected-stdout: |
| 13172 | 1 ?dir =dir !0 |
| 13173 | 2 ?dir/ =dir !0 |
| 13174 | 3 ?dir/file =dir/file !0 |
| 13175 | 4 ?dir/nix =dir/nix !0 |
| 13176 | 5 ?file =file !0 |
| 13177 | 6 ?file/ =file/: Not a directory !20 |
| 13178 | 7 ?file/file =file/file: Not a directory !20 |
| 13179 | 8 ?file/nix =file/nix: Not a directory !20 |
| 13180 | 9 ?nix =nix !0 |
| 13181 | 10 ?nix/ =nix !0 |
| 13182 | 11 ?nix/file =nix/file: No such file or directory !2 |
| 13183 | 12 ?nix/nix =nix/nix: No such file or directory !2 |
| 13184 | 13 ?lndir =dir !0 |
| 13185 | 14 ?lndir/ =dir !0 |
| 13186 | 15 ?lndir/file =dir/file !0 |
| 13187 | 16 ?lndir/nix =dir/nix !0 |
| 13188 | 17 ?lnfile =file !0 |
| 13189 | 18 ?lnfile/ =lnfile/: Not a directory !20 |
| 13190 | 19 ?lnfile/file =lnfile/file: Not a directory !20 |
| 13191 | 20 ?lnfile/nix =lnfile/nix: Not a directory !20 |
| 13192 | 21 ?lnnix =nix !0 |
| 13193 | 22 ?lnnix/ =nix !0 |
| 13194 | 23 ?lnnix/file =lnnix/file: No such file or directory !2 |
| 13195 | 24 ?lnnix/nix =lnnix/nix: No such file or directory !2 |
| 13196 | 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 |
| 13197 | --- |
Geremy Condra | 03ebf06 | 2011-10-12 18:17:24 -0700 | [diff] [blame] | 13198 | name: realpath-2 |
| 13199 | description: |
| 13200 | Ensure that exactly two leading slashes are not collapsed |
| 13201 | POSIX guarantees this exception, e.g. for UNC paths on Cygwin |
| 13202 | category: os:mirbsd |
| 13203 | stdin: |
| 13204 | ln -s /bin t1 |
| 13205 | ln -s //bin t2 |
| 13206 | ln -s ///bin t3 |
| 13207 | realpath /bin |
| 13208 | realpath //bin |
| 13209 | realpath ///bin |
| 13210 | realpath /usr/bin |
| 13211 | realpath /usr//bin |
| 13212 | realpath /usr///bin |
| 13213 | realpath t1 |
| 13214 | realpath t2 |
| 13215 | realpath t3 |
| 13216 | rm -f t1 t2 t3 |
| 13217 | cd //usr/bin |
| 13218 | pwd |
| 13219 | cd ../lib |
| 13220 | pwd |
| 13221 | realpath //usr/include/../bin |
| 13222 | expected-stdout: |
| 13223 | /bin |
| 13224 | //bin |
| 13225 | /bin |
| 13226 | /usr/bin |
| 13227 | /usr/bin |
| 13228 | /usr/bin |
| 13229 | /bin |
| 13230 | //bin |
| 13231 | /bin |
| 13232 | //usr/bin |
| 13233 | //usr/lib |
| 13234 | //usr/bin |
| 13235 | --- |
| 13236 | name: crash-1 |
| 13237 | description: |
| 13238 | Crashed during March 2011, fixed on vernal equinÅx ⺠|
| 13239 | category: os:mirbsd,os:openbsd |
| 13240 | stdin: |
| 13241 | export MALLOC_OPTIONS=FGJPRSX |
| 13242 | "$__progname" -c 'x=$(tr z r <<<baz); echo $x' |
| 13243 | expected-stdout: |
| 13244 | bar |
| 13245 | --- |
| 13246 | name: debian-117-1 |
| 13247 | description: |
| 13248 | Check test - bug#465250 |
| 13249 | stdin: |
| 13250 | test \( ! -e \) ; echo $? |
| 13251 | expected-stdout: |
| 13252 | 1 |
| 13253 | --- |
| 13254 | name: debian-117-2 |
| 13255 | description: |
| 13256 | Check test - bug#465250 |
| 13257 | stdin: |
| 13258 | test \( -e \) ; echo $? |
| 13259 | expected-stdout: |
| 13260 | 0 |
| 13261 | --- |
| 13262 | name: debian-117-3 |
| 13263 | description: |
| 13264 | Check test - bug#465250 |
| 13265 | stdin: |
| 13266 | test ! -e ; echo $? |
| 13267 | expected-stdout: |
| 13268 | 1 |
| 13269 | --- |
| 13270 | name: debian-117-4 |
| 13271 | description: |
| 13272 | Check test - bug#465250 |
| 13273 | stdin: |
| 13274 | test -e ; echo $? |
| 13275 | expected-stdout: |
| 13276 | 0 |
| 13277 | --- |
| 13278 | name: case-zsh |
| 13279 | description: |
| 13280 | Check that zsh case variants work |
| 13281 | stdin: |
| 13282 | case 'b' in |
| 13283 | a) echo a ;; |
| 13284 | b) echo b ;; |
| 13285 | c) echo c ;; |
| 13286 | *) echo x ;; |
| 13287 | esac |
| 13288 | echo = |
| 13289 | case 'b' in |
| 13290 | a) echo a ;& |
| 13291 | b) echo b ;& |
| 13292 | c) echo c ;& |
| 13293 | *) echo x ;& |
| 13294 | esac |
| 13295 | echo = |
| 13296 | case 'b' in |
| 13297 | a) echo a ;| |
| 13298 | b) echo b ;| |
| 13299 | c) echo c ;| |
| 13300 | *) echo x ;| |
| 13301 | esac |
| 13302 | expected-stdout: |
| 13303 | b |
| 13304 | = |
| 13305 | b |
| 13306 | c |
| 13307 | x |
| 13308 | = |
| 13309 | b |
| 13310 | x |
| 13311 | --- |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 13312 | name: case-braces |
| 13313 | description: |
| 13314 | Check that case end tokens are not mixed up (Debian #220272) |
| 13315 | stdin: |
| 13316 | i=0 |
| 13317 | for value in 'x' '}' 'esac'; do |
| 13318 | print -n "$((++i))($value)bourne " |
| 13319 | case $value in |
| 13320 | }) echo brace ;; |
| 13321 | *) echo no ;; |
| 13322 | esac |
| 13323 | print -n "$((++i))($value)korn " |
| 13324 | case $value { |
| 13325 | esac) echo esac ;; |
| 13326 | *) echo no ;; |
| 13327 | } |
| 13328 | done |
| 13329 | expected-stdout: |
| 13330 | 1(x)bourne no |
| 13331 | 2(x)korn no |
| 13332 | 3(})bourne brace |
| 13333 | 4(})korn no |
| 13334 | 5(esac)bourne no |
| 13335 | 6(esac)korn esac |
| 13336 | --- |
| 13337 | name: command-shift |
| 13338 | description: |
| 13339 | Check that 'command shift' works |
| 13340 | stdin: |
| 13341 | function snc { |
| 13342 | echo "before 0='$0' 1='$1' 2='$2'" |
| 13343 | shift |
| 13344 | echo "after 0='$0' 1='$1' 2='$2'" |
| 13345 | } |
| 13346 | function swc { |
| 13347 | echo "before 0='$0' 1='$1' 2='$2'" |
| 13348 | command shift |
| 13349 | echo "after 0='$0' 1='$1' 2='$2'" |
| 13350 | } |
| 13351 | echo = without command |
| 13352 | snc ä¸ äº |
| 13353 | echo = with command |
| 13354 | swc ä¸ äº |
| 13355 | echo = done |
| 13356 | expected-stdout: |
| 13357 | = without command |
| 13358 | before 0='snc' 1='ä¸' 2='äº' |
| 13359 | after 0='snc' 1='äº' 2='' |
| 13360 | = with command |
| 13361 | before 0='swc' 1='ä¸' 2='äº' |
| 13362 | after 0='swc' 1='äº' 2='' |
| 13363 | = done |
| 13364 | --- |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 13365 | name: command-pvV-posix-priorities |
| 13366 | description: |
| 13367 | For POSIX compatibility, command -v should find aliases and reserved |
| 13368 | words, and command -p[vV] should find aliases, reserved words, and |
| 13369 | builtins over external commands. |
| 13370 | stdin: |
| 13371 | PATH=/bin:/usr/bin |
| 13372 | alias foo="bar baz" |
| 13373 | bar() { :; } |
| 13374 | for word in 'if' 'foo' 'bar' 'set' 'true'; do |
| 13375 | command -v "$word" |
| 13376 | command -pv "$word" |
| 13377 | command -V "$word" |
| 13378 | command -pV "$word" |
| 13379 | done |
| 13380 | expected-stdout: |
| 13381 | if |
| 13382 | if |
| 13383 | if is a reserved word |
| 13384 | if is a reserved word |
| 13385 | alias foo='bar baz' |
| 13386 | alias foo='bar baz' |
| 13387 | foo is an alias for 'bar baz' |
| 13388 | foo is an alias for 'bar baz' |
| 13389 | bar |
| 13390 | bar |
| 13391 | bar is a function |
| 13392 | bar is a function |
| 13393 | set |
| 13394 | set |
| 13395 | set is a special shell builtin |
| 13396 | set is a special shell builtin |
| 13397 | true |
| 13398 | true |
| 13399 | true is a shell builtin |
| 13400 | true is a shell builtin |
| 13401 | --- |
| 13402 | name: whence-preserve-tradition |
| 13403 | description: |
| 13404 | This regression test is to ensure that the POSIX compatibility |
| 13405 | changes for 'command' (see previous test) do not affect traditional |
| 13406 | 'whence' behaviour. |
| 13407 | category: os:mirbsd |
| 13408 | stdin: |
| 13409 | PATH=/bin:/usr/bin |
| 13410 | alias foo="bar baz" |
| 13411 | bar() { :; } |
| 13412 | for word in 'if' 'foo' 'bar' 'set' 'true'; do |
| 13413 | whence "$word" |
| 13414 | whence -p "$word" |
| 13415 | whence -v "$word" |
| 13416 | whence -pv "$word" |
| 13417 | done |
| 13418 | expected-stdout: |
| 13419 | if |
| 13420 | if is a reserved word |
| 13421 | if not found |
| 13422 | 'bar baz' |
| 13423 | foo is an alias for 'bar baz' |
| 13424 | foo not found |
| 13425 | bar |
| 13426 | bar is a function |
| 13427 | bar not found |
| 13428 | set |
| 13429 | set is a special shell builtin |
| 13430 | set not found |
| 13431 | true |
| 13432 | /bin/true |
| 13433 | true is a shell builtin |
| 13434 | true is a tracked alias for /bin/true |
| 13435 | --- |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 13436 | name: duffs-device |
| 13437 | description: |
| 13438 | Check that the compiler did not optimise-break them |
| 13439 | (lex.c has got a similar one in SHEREDELIM) |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 13440 | category: !shell:faux-ebcdic,!shell:ebcdic-yes |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 13441 | stdin: |
| 13442 | set +U |
| 13443 | s= |
| 13444 | typeset -i1 i=0 |
| 13445 | while (( ++i < 256 )); do |
| 13446 | s+=${i#1#} |
| 13447 | done |
| 13448 | s+=$'\xC2\xA0\xE2\x82\xAC\xEF\xBF\xBD\xEF\xBF\xBE\xEF\xBF\xBF\xF0\x90\x80\x80.' |
| 13449 | typeset -p s |
| 13450 | expected-stdout: |
| 13451 | typeset s=$'\001\002\003\004\005\006\a\b\t\n\v\f\r\016\017\020\021\022\023\024\025\026\027\030\031\032\E\034\035\036\037 !"#$%&\047()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\u00A0\u20AC\uFFFD\357\277\276\357\277\277\360\220\200\200.' |
| 13452 | --- |
Elliott Hughes | 23925bb | 2017-09-22 16:04:20 -0700 | [diff] [blame] | 13453 | name: duffs-device-ebcdic |
| 13454 | description: |
| 13455 | Check that the compiler did not optimise-break them |
| 13456 | category: !shell:ebcdic-no |
| 13457 | stdin: |
| 13458 | set +U |
| 13459 | s= |
| 13460 | typeset -i1 i=0 |
| 13461 | while (( ++i < 256 )); do |
| 13462 | s+=${i#1#} |
| 13463 | done |
| 13464 | #s+=$'\xC2\xA0\xE2\x82\xAC\xEF\xBF\xBD\xEF\xBF\xBE\xEF\xBF\xBF\xF0\x90\x80\x80.' #XXX |
| 13465 | typeset -p s |
| 13466 | expected-stdout: |
| 13467 | typeset s=$'\001\002\003\004\t\006\007\010\011\012\v\f\r\016\017\020\021\022\023\024\n\b\027\030\031\032\033\034\035\036\037\040\041\042\043\044\045\046\E\050\051\052\053\054\055\056\a\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077 âäàáãåçñ¢.<(+|&éêëèíîïìß!$*);^-/ÂÄÀÁÃÅÇѦ,%_>?øÉÊËÈÍÎÏÌ`:#@\175="Øabcdefghi«»ðýþ±°jklmnopqrªºæ¸Æ¤µ~stuvwxyz¡¿Ð[Þ®¬£¥·©§¶¼½¾Ý¨¯]´×{ABCDEFGHIôöòóõ}JKLMNOPQR¹ûüùúÿ\\÷STUVWXYZ²ÔÖÒÓÕ0123456789³ÛÜÙÚ\377' |
| 13468 | --- |
| 13469 | name: duffs-device-faux-EBCDIC |
| 13470 | description: |
| 13471 | Check that the compiler did not optimise-break them |
| 13472 | category: shell:faux-ebcdic |
| 13473 | stdin: |
| 13474 | set +U |
| 13475 | s= |
| 13476 | typeset -i1 i=0 |
| 13477 | while (( ++i < 256 )); do |
| 13478 | s+=${i#1#} |
| 13479 | done |
| 13480 | s+=$'\xC2\xA0\xE2\x82\xAC\xEF\xBF\xBD\xEF\xBF\xBE\xEF\xBF\xBF\xF0\x90\x80\x80.' |
| 13481 | typeset -p s |
| 13482 | expected-stdout: |
| 13483 | typeset s=$'\001\002\003\004\005\006\a\b\t\n\v\f\r\016\017\020\021\022\023\024\025\026\027\030\031\032\E\034\035\036\037 !"#$%&\047()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237 ¡¢£¤¥¦§¨©ª«¬®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖרÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ\u00A0\u20AC\uFFFD￾￿ð\220\200\200.' |
| 13484 | --- |
Thorsten Glaser | c2dc5de | 2013-02-18 23:02:51 +0000 | [diff] [blame] | 13485 | name: stateptr-underflow |
| 13486 | description: |
| 13487 | This check overflows an Xrestpos stored in a short in R40 |
| 13488 | category: fastbox |
| 13489 | stdin: |
| 13490 | function Lb64decode { |
| 13491 | [[ -o utf8-mode ]]; local u=$? |
| 13492 | set +U |
| 13493 | local c s="$*" t= |
| 13494 | [[ -n $s ]] || { s=$(cat;print x); s=${s%x}; } |
| 13495 | local -i i=0 n=${#s} p=0 v x |
| 13496 | local -i16 o |
| 13497 | |
| 13498 | while (( i < n )); do |
| 13499 | c=${s:(i++):1} |
| 13500 | case $c { |
| 13501 | (=) break ;; |
| 13502 | ([A-Z]) (( v = 1#$c - 65 )) ;; |
| 13503 | ([a-z]) (( v = 1#$c - 71 )) ;; |
| 13504 | ([0-9]) (( v = 1#$c + 4 )) ;; |
| 13505 | (+) v=62 ;; |
| 13506 | (/) v=63 ;; |
| 13507 | (*) continue ;; |
| 13508 | } |
| 13509 | (( x = (x << 6) | v )) |
| 13510 | case $((p++)) { |
| 13511 | (0) continue ;; |
| 13512 | (1) (( o = (x >> 4) & 255 )) ;; |
| 13513 | (2) (( o = (x >> 2) & 255 )) ;; |
| 13514 | (3) (( o = x & 255 )) |
| 13515 | p=0 |
| 13516 | ;; |
| 13517 | } |
| 13518 | t=$t\\x${o#16#} |
| 13519 | done |
| 13520 | print -n $t |
| 13521 | (( u )) || set -U |
| 13522 | } |
| 13523 | |
| 13524 | i=-1 |
| 13525 | s= |
| 13526 | while (( ++i < 12120 )); do |
| 13527 | s+=a |
| 13528 | done |
| 13529 | Lb64decode $s >/dev/null |
| 13530 | --- |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 13531 | name: xtrace-1 |
| 13532 | description: |
| 13533 | Check that "set -x" doesn't redirect too quickly |
| 13534 | stdin: |
| 13535 | print '#!'"$__progname" >bash |
| 13536 | cat >>bash <<'EOF' |
| 13537 | echo 'GNU bash, version 2.05b.0(1)-release (i386-ecce-mirbsd10) |
| 13538 | Copyright (C) 2002 Free Software Foundation, Inc.' |
| 13539 | EOF |
| 13540 | chmod +x bash |
Elliott Hughes | 77740fc | 2016-08-12 15:06:53 -0700 | [diff] [blame] | 13541 | "$__progname" -xc 'foo=$(./bash --version 2>&1 | sed q); echo "=$foo="' |
Thorsten Glaser | 811a575 | 2013-07-25 14:24:45 +0000 | [diff] [blame] | 13542 | expected-stdout: |
| 13543 | =GNU bash, version 2.05b.0(1)-release (i386-ecce-mirbsd10)= |
| 13544 | expected-stderr-pattern: |
| 13545 | /.*/ |
| 13546 | --- |
Elliott Hughes | 5001206 | 2015-03-10 22:22:24 -0700 | [diff] [blame] | 13547 | name: xtrace-2 |
| 13548 | description: |
| 13549 | Check that "set -x" is off during PS4 expansion |
| 13550 | stdin: |
| 13551 | f() { |
| 13552 | print -n "(f1:$-)" |
| 13553 | set -x |
| 13554 | print -n "(f2:$-)" |
| 13555 | } |
| 13556 | PS4='[(p:$-)$(f)] ' |
| 13557 | print "(o0:$-)" |
| 13558 | set -x -o inherit-xtrace |
| 13559 | print "(o1:$-)" |
| 13560 | set +x |
| 13561 | print "(o2:$-)" |
| 13562 | expected-stdout: |
| 13563 | (o0:sh) |
| 13564 | (o1:shx) |
| 13565 | (o2:sh) |
| 13566 | expected-stderr: |
| 13567 | [(p:sh)(f1:sh)(f2:sh)] print '(o1:shx)' |
| 13568 | [(p:sh)(f1:sh)(f2:sh)] set +x |
| 13569 | --- |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 13570 | name: fksh-flags |
| 13571 | description: |
| 13572 | Check that FKSH functions have their own shell flags |
| 13573 | category: shell:legacy-no |
| 13574 | stdin: |
| 13575 | [[ $KSH_VERSION = Version* ]] && set +B |
| 13576 | function foo { |
| 13577 | set +f |
| 13578 | set -e |
| 13579 | echo 2 "${-/s}" . |
| 13580 | } |
| 13581 | set -fh |
| 13582 | echo 1 "${-/s}" . |
| 13583 | foo |
| 13584 | echo 3 "${-/s}" . |
| 13585 | expected-stdout: |
| 13586 | 1 fh . |
| 13587 | 2 eh . |
| 13588 | 3 fh . |
| 13589 | --- |
Elliott Hughes | b27ce95 | 2015-04-21 13:39:18 -0700 | [diff] [blame] | 13590 | name: fksh-flags-legacy |
| 13591 | description: |
| 13592 | Check that even FKSH functions share the shell flags |
Elliott Hughes | 96b4363 | 2015-07-17 11:39:41 -0700 | [diff] [blame] | 13593 | category: shell:legacy-yes |
Elliott Hughes | b27ce95 | 2015-04-21 13:39:18 -0700 | [diff] [blame] | 13594 | stdin: |
| 13595 | [[ $KSH_VERSION = Version* ]] && set +B |
| 13596 | foo() { |
| 13597 | set +f |
| 13598 | set -e |
| 13599 | echo 2 "${-/s}" . |
| 13600 | } |
| 13601 | set -fh |
| 13602 | echo 1 "${-/s}" . |
| 13603 | foo |
| 13604 | echo 3 "${-/s}" . |
| 13605 | expected-stdout: |
| 13606 | 1 fh . |
| 13607 | 2 eh . |
| 13608 | 3 eh . |
| 13609 | --- |
| 13610 | name: fsh-flags |
| 13611 | description: |
| 13612 | Check that !FKSH functions share the shell flags |
| 13613 | stdin: |
| 13614 | [[ $KSH_VERSION = Version* ]] && set +B |
| 13615 | foo() { |
| 13616 | set +f |
| 13617 | set -e |
| 13618 | echo 2 "${-/s}" . |
| 13619 | } |
| 13620 | set -fh |
| 13621 | echo 1 "${-/s}" . |
| 13622 | foo |
| 13623 | echo 3 "${-/s}" . |
| 13624 | expected-stdout: |
| 13625 | 1 fh . |
| 13626 | 2 eh . |
| 13627 | 3 eh . |
| 13628 | --- |