Thorsten Glaser | ba2627c | 2010-08-24 18:21:37 +0200 | [diff] [blame] | 1 | # $MirOS: src/bin/mksh/check.t,v 1.388 2010/08/24 15:47:44 tg Exp $ |
| 2 | # $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $ |
| 3 | # $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $ |
| 4 | # $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $ |
| 5 | #- |
| 6 | # Copyright © 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 |
| 7 | # Thorsten Glaser <tg@mirbsd.org> |
| 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 |
| 26 | |
| 27 | expected-stdout: |
| 28 | @(#)MIRBSD KSH R39 2010/08/24 |
| 29 | description: |
| 30 | Check version of shell. |
| 31 | stdin: |
| 32 | echo $KSH_VERSION |
| 33 | name: KSH_VERSION |
| 34 | --- |
| 35 | name: selftest-1 |
| 36 | description: |
| 37 | Regression test self-testing |
| 38 | stdin: |
| 39 | echo ${foo:-baz} |
| 40 | expected-stdout: |
| 41 | baz |
| 42 | --- |
| 43 | name: selftest-2 |
| 44 | description: |
| 45 | Regression test self-testing |
| 46 | env-setup: !foo=bar! |
| 47 | stdin: |
| 48 | echo ${foo:-baz} |
| 49 | expected-stdout: |
| 50 | bar |
| 51 | --- |
| 52 | name: selftest-3 |
| 53 | description: |
| 54 | Regression test self-testing |
| 55 | env-setup: !ENV=fnord! |
| 56 | stdin: |
| 57 | echo "<$ENV>" |
| 58 | expected-stdout: |
| 59 | <fnord> |
| 60 | --- |
| 61 | name: selftest-env |
| 62 | description: |
| 63 | Just output the environment variables set (always fails) |
| 64 | category: disabled |
| 65 | stdin: |
| 66 | set |
| 67 | --- |
| 68 | name: alias-1 |
| 69 | description: |
| 70 | Check that recursion is detected/avoided in aliases. |
| 71 | stdin: |
| 72 | alias fooBar=fooBar |
| 73 | fooBar |
| 74 | exit 0 |
| 75 | expected-stderr-pattern: |
| 76 | /fooBar.*not found.*/ |
| 77 | --- |
| 78 | name: alias-2 |
| 79 | description: |
| 80 | Check that recursion is detected/avoided in aliases. |
| 81 | stdin: |
| 82 | alias fooBar=barFoo |
| 83 | alias barFoo=fooBar |
| 84 | fooBar |
| 85 | barFoo |
| 86 | exit 0 |
| 87 | expected-stderr-pattern: |
| 88 | /fooBar.*not found.*\n.*barFoo.*not found/ |
| 89 | --- |
| 90 | name: alias-3 |
| 91 | description: |
| 92 | Check that recursion is detected/avoided in aliases. |
| 93 | stdin: |
| 94 | alias Echo='echo ' |
| 95 | alias fooBar=barFoo |
| 96 | alias barFoo=fooBar |
| 97 | Echo fooBar |
| 98 | unalias barFoo |
| 99 | Echo fooBar |
| 100 | expected-stdout: |
| 101 | fooBar |
| 102 | barFoo |
| 103 | --- |
| 104 | name: alias-4 |
| 105 | description: |
| 106 | Check that alias expansion isn't done on keywords (in keyword |
| 107 | postitions). |
| 108 | stdin: |
| 109 | alias Echo='echo ' |
| 110 | alias while=While |
| 111 | while false; do echo hi ; done |
| 112 | Echo while |
| 113 | expected-stdout: |
| 114 | While |
| 115 | --- |
| 116 | name: alias-5 |
| 117 | description: |
| 118 | Check that alias expansion done after alias with trailing space. |
| 119 | stdin: |
| 120 | alias Echo='echo ' |
| 121 | alias foo='bar stuff ' |
| 122 | alias bar='Bar1 Bar2 ' |
| 123 | alias stuff='Stuff' |
| 124 | alias blah='Blah' |
| 125 | Echo foo blah |
| 126 | expected-stdout: |
| 127 | Bar1 Bar2 Stuff Blah |
| 128 | --- |
| 129 | name: alias-6 |
| 130 | description: |
| 131 | Check that alias expansion done after alias with trailing space. |
| 132 | stdin: |
| 133 | alias Echo='echo ' |
| 134 | alias foo='bar bar' |
| 135 | alias bar='Bar ' |
| 136 | alias blah=Blah |
| 137 | Echo foo blah |
| 138 | expected-stdout: |
| 139 | Bar Bar Blah |
| 140 | --- |
| 141 | name: alias-7 |
| 142 | description: |
| 143 | Check that alias expansion done after alias with trailing space |
| 144 | after a keyword. |
| 145 | stdin: |
| 146 | alias X='case ' |
| 147 | alias Y=Z |
| 148 | X Y in 'Y') echo is y ;; Z) echo is z ; esac |
| 149 | expected-stdout: |
| 150 | is z |
| 151 | --- |
| 152 | name: alias-8 |
| 153 | description: |
| 154 | Check that newlines in an alias don't cause the command to be lost. |
| 155 | stdin: |
| 156 | alias foo=' |
| 157 | |
| 158 | |
| 159 | echo hi |
| 160 | |
| 161 | |
| 162 | |
| 163 | echo there |
| 164 | |
| 165 | |
| 166 | ' |
| 167 | foo |
| 168 | expected-stdout: |
| 169 | hi |
| 170 | there |
| 171 | --- |
| 172 | name: alias-9 |
| 173 | description: |
| 174 | Check that recursion is detected/avoided in aliases. |
| 175 | This check fails for slow machines or Cygwin, raise |
| 176 | the time-limit clause (e.g. to 7) if this occurs. |
| 177 | time-limit: 3 |
| 178 | stdin: |
| 179 | echo -n >tf |
| 180 | alias ls=ls |
| 181 | ls |
| 182 | echo $(ls) |
| 183 | exit 0 |
| 184 | expected-stdout: |
| 185 | tf |
| 186 | tf |
| 187 | --- |
| 188 | name: alias-10 |
| 189 | description: |
| 190 | Check that recursion is detected/avoided in aliases. |
| 191 | Regression, introduced during an old bugfix. |
| 192 | stdin: |
| 193 | alias foo='print hello ' |
| 194 | alias bar='foo world' |
| 195 | echo $(bar) |
| 196 | expected-stdout: |
| 197 | hello world |
| 198 | --- |
| 199 | name: arith-lazy-1 |
| 200 | description: |
| 201 | Check that only one side of ternary operator is evaluated |
| 202 | stdin: |
| 203 | x=i+=2 |
| 204 | y=j+=2 |
| 205 | typeset -i i=1 j=1 |
| 206 | echo $((1 ? 20 : (x+=2))) |
| 207 | echo $i,$x |
| 208 | echo $((0 ? (y+=2) : 30)) |
| 209 | echo $j,$y |
| 210 | expected-stdout: |
| 211 | 20 |
| 212 | 1,i+=2 |
| 213 | 30 |
| 214 | 1,j+=2 |
| 215 | --- |
| 216 | name: arith-lazy-2 |
| 217 | description: |
| 218 | Check that assignments not done on non-evaluated side of ternary |
| 219 | operator |
| 220 | stdin: |
| 221 | x=i+=2 |
| 222 | y=j+=2 |
| 223 | typeset -i i=1 j=1 |
| 224 | echo $((1 ? 20 : (x+=2))) |
| 225 | echo $i,$x |
| 226 | echo $((0 ? (y+=2) : 30)) |
| 227 | echo $i,$y |
| 228 | expected-stdout: |
| 229 | 20 |
| 230 | 1,i+=2 |
| 231 | 30 |
| 232 | 1,j+=2 |
| 233 | --- |
| 234 | name: arith-lazy-3 |
| 235 | description: |
| 236 | Check that assignments not done on non-evaluated side of ternary |
| 237 | operator and this construct is parsed correctly (Debian #445651) |
| 238 | stdin: |
| 239 | x=4 |
| 240 | y=$((0 ? x=1 : 2)) |
| 241 | echo = $x $y = |
| 242 | expected-stdout: |
| 243 | = 4 2 = |
| 244 | --- |
| 245 | name: arith-ternary-prec-1 |
| 246 | description: |
| 247 | Check precedence of ternary operator vs assignment |
| 248 | stdin: |
| 249 | typeset -i x=2 |
| 250 | y=$((1 ? 20 : x+=2)) |
| 251 | expected-exit: e != 0 |
| 252 | expected-stderr-pattern: |
| 253 | /.*:.*1 \? 20 : x\+=2.*lvalue.*\n$/ |
| 254 | --- |
| 255 | name: arith-ternary-prec-2 |
| 256 | description: |
| 257 | Check precedence of ternary operator vs assignment |
| 258 | stdin: |
| 259 | typeset -i x=2 |
| 260 | echo $((0 ? x+=2 : 20)) |
| 261 | expected-stdout: |
| 262 | 20 |
| 263 | --- |
| 264 | name: arith-div-assoc-1 |
| 265 | description: |
| 266 | Check associativity of division operator |
| 267 | stdin: |
| 268 | echo $((20 / 2 / 2)) |
| 269 | expected-stdout: |
| 270 | 5 |
| 271 | --- |
| 272 | name: arith-assop-assoc-1 |
| 273 | description: |
| 274 | Check associativity of assignment-operator operator |
| 275 | stdin: |
| 276 | typeset -i i=1 j=2 k=3 |
| 277 | echo $((i += j += k)) |
| 278 | echo $i,$j,$k |
| 279 | expected-stdout: |
| 280 | 6 |
| 281 | 6,5,3 |
| 282 | --- |
| 283 | name: arith-unsigned-1 |
| 284 | description: |
| 285 | Check if unsigned arithmetics work |
| 286 | stdin: |
| 287 | # signed vs unsigned |
| 288 | echo x1 $((-1)) $((#-1)) |
| 289 | # calculating |
| 290 | typeset -i vs |
| 291 | typeset -Ui vu |
| 292 | vs=4123456789; vu=4123456789 |
| 293 | echo x2 $vs $vu |
| 294 | (( vs %= 2147483647 )) |
| 295 | (( vu %= 2147483647 )) |
| 296 | echo x3 $vs $vu |
| 297 | vs=4123456789; vu=4123456789 |
| 298 | (( # vs %= 2147483647 )) |
| 299 | (( # vu %= 2147483647 )) |
| 300 | echo x4 $vs $vu |
| 301 | # make sure the calculation does not change unsigned flag |
| 302 | vs=4123456789; vu=4123456789 |
| 303 | echo x5 $vs $vu |
| 304 | # short form |
| 305 | echo x6 $((# vs % 2147483647)) $((# vu % 2147483647)) |
| 306 | # array refs |
| 307 | set -A va |
| 308 | va[1975973142]=right |
| 309 | va[4123456789]=wrong |
| 310 | echo x7 ${va[#4123456789%2147483647]} |
| 311 | expected-stdout: |
| 312 | x1 -1 4294967295 |
| 313 | x2 -171510507 4123456789 |
| 314 | x3 -171510507 4123456789 |
| 315 | x4 1975973142 1975973142 |
| 316 | x5 -171510507 4123456789 |
| 317 | x6 1975973142 1975973142 |
| 318 | x7 right |
| 319 | --- |
| 320 | name: arith-limit32-1 |
| 321 | description: |
| 322 | Check if arithmetics are 32 bit |
| 323 | stdin: |
| 324 | # signed vs unsigned |
| 325 | echo x1 $((-1)) $((#-1)) |
| 326 | # calculating |
| 327 | typeset -i vs |
| 328 | typeset -Ui vu |
| 329 | vs=2147483647; vu=2147483647 |
| 330 | echo x2 $vs $vu |
| 331 | let vs++ vu++ |
| 332 | echo x3 $vs $vu |
| 333 | vs=4294967295; vu=4294967295 |
| 334 | echo x4 $vs $vu |
| 335 | let vs++ vu++ |
| 336 | echo x5 $vs $vu |
| 337 | let vs++ vu++ |
| 338 | echo x6 $vs $vu |
| 339 | expected-stdout: |
| 340 | x1 -1 4294967295 |
| 341 | x2 2147483647 2147483647 |
| 342 | x3 -2147483648 2147483648 |
| 343 | x4 -1 4294967295 |
| 344 | x5 0 0 |
| 345 | x6 1 1 |
| 346 | --- |
| 347 | name: bksl-nl-ign-1 |
| 348 | description: |
| 349 | Check that \newline is not collasped after # |
| 350 | stdin: |
| 351 | echo hi #there \ |
| 352 | echo folks |
| 353 | expected-stdout: |
| 354 | hi |
| 355 | folks |
| 356 | --- |
| 357 | name: bksl-nl-ign-2 |
| 358 | description: |
| 359 | Check that \newline is not collasped inside single quotes |
| 360 | stdin: |
| 361 | echo 'hi \ |
| 362 | there' |
| 363 | echo folks |
| 364 | expected-stdout: |
| 365 | hi \ |
| 366 | there |
| 367 | folks |
| 368 | --- |
| 369 | name: bksl-nl-ign-3 |
| 370 | description: |
| 371 | Check that \newline is not collasped inside single quotes |
| 372 | stdin: |
| 373 | cat << \EOF |
| 374 | hi \ |
| 375 | there |
| 376 | EOF |
| 377 | expected-stdout: |
| 378 | hi \ |
| 379 | there |
| 380 | --- |
| 381 | name: bksl-nl-ign-4 |
| 382 | description: |
| 383 | Check interaction of aliases, single quotes and here-documents |
| 384 | with backslash-newline |
| 385 | (don't know what POSIX has to say about this) |
| 386 | stdin: |
| 387 | a=2 |
| 388 | alias x='echo hi |
| 389 | cat << "EOF" |
| 390 | foo\ |
| 391 | bar |
| 392 | some' |
| 393 | x |
| 394 | more\ |
| 395 | stuff$a |
| 396 | EOF |
| 397 | expected-stdout: |
| 398 | hi |
| 399 | foo\ |
| 400 | bar |
| 401 | some |
| 402 | more\ |
| 403 | stuff$a |
| 404 | --- |
| 405 | name: bksl-nl-ign-5 |
| 406 | description: |
| 407 | Check what happens with backslash at end of input |
| 408 | (the old Bourne shell trashes them; so do we) |
| 409 | stdin: ! |
| 410 | echo `echo foo\\`bar |
| 411 | echo hi\ |
| 412 | expected-stdout: |
| 413 | foobar |
| 414 | hi |
| 415 | --- |
| 416 | # |
| 417 | # Places \newline should be collapsed |
| 418 | # |
| 419 | name: bksl-nl-1 |
| 420 | description: |
| 421 | Check that \newline is collasped before, in the middle of, and |
| 422 | after words |
| 423 | stdin: |
| 424 | \ |
| 425 | echo hi\ |
| 426 | There, \ |
| 427 | folks |
| 428 | expected-stdout: |
| 429 | hiThere, folks |
| 430 | --- |
| 431 | name: bksl-nl-2 |
| 432 | description: |
| 433 | Check that \newline is collasped in $ sequences |
| 434 | (ksh93 fails this) |
| 435 | stdin: |
| 436 | a=12 |
| 437 | ab=19 |
| 438 | echo $\ |
| 439 | a |
| 440 | echo $a\ |
| 441 | b |
| 442 | echo $\ |
| 443 | {a} |
| 444 | echo ${a\ |
| 445 | b} |
| 446 | echo ${ab\ |
| 447 | } |
| 448 | expected-stdout: |
| 449 | 12 |
| 450 | 19 |
| 451 | 12 |
| 452 | 19 |
| 453 | 19 |
| 454 | --- |
| 455 | name: bksl-nl-3 |
| 456 | description: |
| 457 | Check that \newline is collasped in $(..) and `...` sequences |
| 458 | (ksh93 fails this) |
| 459 | stdin: |
| 460 | echo $\ |
| 461 | (echo foobar1) |
| 462 | echo $(\ |
| 463 | echo foobar2) |
| 464 | echo $(echo foo\ |
| 465 | bar3) |
| 466 | echo $(echo foobar4\ |
| 467 | ) |
| 468 | echo ` |
| 469 | echo stuff1` |
| 470 | echo `echo st\ |
| 471 | uff2` |
| 472 | expected-stdout: |
| 473 | foobar1 |
| 474 | foobar2 |
| 475 | foobar3 |
| 476 | foobar4 |
| 477 | stuff1 |
| 478 | stuff2 |
| 479 | --- |
| 480 | name: bksl-nl-4 |
| 481 | description: |
| 482 | Check that \newline is collasped in $((..)) sequences |
| 483 | (ksh93 fails this) |
| 484 | stdin: |
| 485 | echo $\ |
| 486 | ((1+2)) |
| 487 | echo $(\ |
| 488 | (1+2+3)) |
| 489 | echo $((\ |
| 490 | 1+2+3+4)) |
| 491 | echo $((1+\ |
| 492 | 2+3+4+5)) |
| 493 | echo $((1+2+3+4+5+6)\ |
| 494 | ) |
| 495 | expected-stdout: |
| 496 | 3 |
| 497 | 6 |
| 498 | 10 |
| 499 | 15 |
| 500 | 21 |
| 501 | --- |
| 502 | name: bksl-nl-5 |
| 503 | description: |
| 504 | Check that \newline is collasped in double quoted strings |
| 505 | stdin: |
| 506 | echo "\ |
| 507 | hi" |
| 508 | echo "foo\ |
| 509 | bar" |
| 510 | echo "folks\ |
| 511 | " |
| 512 | expected-stdout: |
| 513 | hi |
| 514 | foobar |
| 515 | folks |
| 516 | --- |
| 517 | name: bksl-nl-6 |
| 518 | description: |
| 519 | Check that \newline is collasped in here document delimiters |
| 520 | (ksh93 fails second part of this) |
| 521 | stdin: |
| 522 | a=12 |
| 523 | cat << EO\ |
| 524 | F |
| 525 | a=$a |
| 526 | foo\ |
| 527 | bar |
| 528 | EOF |
| 529 | cat << E_O_F |
| 530 | foo |
| 531 | E_O_\ |
| 532 | F |
| 533 | echo done |
| 534 | expected-stdout: |
| 535 | a=12 |
| 536 | foobar |
| 537 | foo |
| 538 | done |
| 539 | --- |
| 540 | name: bksl-nl-7 |
| 541 | description: |
| 542 | Check that \newline is collasped in double-quoted here-document |
| 543 | delimiter. |
| 544 | stdin: |
| 545 | a=12 |
| 546 | cat << "EO\ |
| 547 | F" |
| 548 | a=$a |
| 549 | foo\ |
| 550 | bar |
| 551 | EOF |
| 552 | echo done |
| 553 | expected-stdout: |
| 554 | a=$a |
| 555 | foo\ |
| 556 | bar |
| 557 | done |
| 558 | --- |
| 559 | name: bksl-nl-8 |
| 560 | description: |
| 561 | Check that \newline is collasped in various 2+ character tokens |
| 562 | delimiter. |
| 563 | (ksh93 fails this) |
| 564 | stdin: |
| 565 | echo hi &\ |
| 566 | & echo there |
| 567 | echo foo |\ |
| 568 | | echo bar |
| 569 | cat <\ |
| 570 | < EOF |
| 571 | stuff |
| 572 | EOF |
| 573 | cat <\ |
| 574 | <\ |
| 575 | - EOF |
| 576 | more stuff |
| 577 | EOF |
| 578 | cat <<\ |
| 579 | EOF |
| 580 | abcdef |
| 581 | EOF |
| 582 | echo hi >\ |
| 583 | > /dev/null |
| 584 | echo $? |
| 585 | i=1 |
| 586 | case $i in |
| 587 | (\ |
| 588 | x|\ |
| 589 | 1\ |
| 590 | ) echo hi;\ |
| 591 | ; |
| 592 | (*) echo oops |
| 593 | esac |
| 594 | expected-stdout: |
| 595 | hi |
| 596 | there |
| 597 | foo |
| 598 | stuff |
| 599 | more stuff |
| 600 | abcdef |
| 601 | 0 |
| 602 | hi |
| 603 | --- |
| 604 | name: bksl-nl-9 |
| 605 | description: |
| 606 | Check that \ at the end of an alias is collapsed when followed |
| 607 | by a newline |
| 608 | (don't know what POSIX has to say about this) |
| 609 | stdin: |
| 610 | alias x='echo hi\' |
| 611 | x |
| 612 | echo there |
| 613 | expected-stdout: |
| 614 | hiecho there |
| 615 | --- |
| 616 | name: bksl-nl-10 |
| 617 | description: |
| 618 | Check that \newline in a keyword is collapsed |
| 619 | stdin: |
| 620 | i\ |
| 621 | f true; then\ |
| 622 | echo pass; el\ |
| 623 | se echo fail; fi |
| 624 | expected-stdout: |
| 625 | pass |
| 626 | --- |
| 627 | # |
| 628 | # Places \newline should be collapsed (ksh extensions) |
| 629 | # |
| 630 | name: bksl-nl-ksh-1 |
| 631 | description: |
| 632 | Check that \newline is collapsed in extended globbing |
| 633 | (ksh93 fails this) |
| 634 | stdin: |
| 635 | xxx=foo |
| 636 | case $xxx in |
| 637 | (f*\ |
| 638 | (\ |
| 639 | o\ |
| 640 | )\ |
| 641 | ) echo ok ;; |
| 642 | *) echo bad |
| 643 | esac |
| 644 | expected-stdout: |
| 645 | ok |
| 646 | --- |
| 647 | name: bksl-nl-ksh-2 |
| 648 | description: |
| 649 | Check that \newline is collapsed in ((...)) expressions |
| 650 | (ksh93 fails this) |
| 651 | stdin: |
| 652 | i=1 |
| 653 | (\ |
| 654 | (\ |
| 655 | i=i+2\ |
| 656 | )\ |
| 657 | ) |
| 658 | echo $i |
| 659 | expected-stdout: |
| 660 | 3 |
| 661 | --- |
| 662 | name: break-1 |
| 663 | description: |
| 664 | See if break breaks out of loops |
| 665 | stdin: |
| 666 | for i in a b c; do echo $i; break; echo bad-$i; done |
| 667 | echo end-1 |
| 668 | for i in a b c; do echo $i; break 1; echo bad-$i; done |
| 669 | echo end-2 |
| 670 | for i in a b c; do |
| 671 | for j in x y z; do |
| 672 | echo $i:$j |
| 673 | break |
| 674 | echo bad-$i |
| 675 | done |
| 676 | echo end-$i |
| 677 | done |
| 678 | echo end-3 |
| 679 | expected-stdout: |
| 680 | a |
| 681 | end-1 |
| 682 | a |
| 683 | end-2 |
| 684 | a:x |
| 685 | end-a |
| 686 | b:x |
| 687 | end-b |
| 688 | c:x |
| 689 | end-c |
| 690 | end-3 |
| 691 | --- |
| 692 | name: break-2 |
| 693 | description: |
| 694 | See if break breaks out of nested loops |
| 695 | stdin: |
| 696 | for i in a b c; do |
| 697 | for j in x y z; do |
| 698 | echo $i:$j |
| 699 | break 2 |
| 700 | echo bad-$i |
| 701 | done |
| 702 | echo end-$i |
| 703 | done |
| 704 | echo end |
| 705 | expected-stdout: |
| 706 | a:x |
| 707 | end |
| 708 | --- |
| 709 | name: break-3 |
| 710 | description: |
| 711 | What if break used outside of any loops |
| 712 | (ksh88,ksh93 don't print error messages here) |
| 713 | stdin: |
| 714 | break |
| 715 | expected-stderr-pattern: |
| 716 | /.*break.*/ |
| 717 | --- |
| 718 | name: break-4 |
| 719 | description: |
| 720 | What if break N used when only N-1 loops |
| 721 | (ksh88,ksh93 don't print error messages here) |
| 722 | stdin: |
| 723 | for i in a b c; do echo $i; break 2; echo bad-$i; done |
| 724 | echo end |
| 725 | expected-stdout: |
| 726 | a |
| 727 | end |
| 728 | expected-stderr-pattern: |
| 729 | /.*break.*/ |
| 730 | --- |
| 731 | name: break-5 |
| 732 | description: |
| 733 | Error if break argument isn't a number |
| 734 | stdin: |
| 735 | for i in a b c; do echo $i; break abc; echo more-$i; done |
| 736 | echo end |
| 737 | expected-stdout: |
| 738 | a |
| 739 | expected-exit: e != 0 |
| 740 | expected-stderr-pattern: |
| 741 | /.*break.*/ |
| 742 | --- |
| 743 | name: continue-1 |
| 744 | description: |
| 745 | See if continue continues loops |
| 746 | stdin: |
| 747 | for i in a b c; do echo $i; continue; echo bad-$i ; done |
| 748 | echo end-1 |
| 749 | for i in a b c; do echo $i; continue 1; echo bad-$i; done |
| 750 | echo end-2 |
| 751 | for i in a b c; do |
| 752 | for j in x y z; do |
| 753 | echo $i:$j |
| 754 | continue |
| 755 | echo bad-$i-$j |
| 756 | done |
| 757 | echo end-$i |
| 758 | done |
| 759 | echo end-3 |
| 760 | expected-stdout: |
| 761 | a |
| 762 | b |
| 763 | c |
| 764 | end-1 |
| 765 | a |
| 766 | b |
| 767 | c |
| 768 | end-2 |
| 769 | a:x |
| 770 | a:y |
| 771 | a:z |
| 772 | end-a |
| 773 | b:x |
| 774 | b:y |
| 775 | b:z |
| 776 | end-b |
| 777 | c:x |
| 778 | c:y |
| 779 | c:z |
| 780 | end-c |
| 781 | end-3 |
| 782 | --- |
| 783 | name: continue-2 |
| 784 | description: |
| 785 | See if continue breaks out of nested loops |
| 786 | stdin: |
| 787 | for i in a b c; do |
| 788 | for j in x y z; do |
| 789 | echo $i:$j |
| 790 | continue 2 |
| 791 | echo bad-$i-$j |
| 792 | done |
| 793 | echo end-$i |
| 794 | done |
| 795 | echo end |
| 796 | expected-stdout: |
| 797 | a:x |
| 798 | b:x |
| 799 | c:x |
| 800 | end |
| 801 | --- |
| 802 | name: continue-3 |
| 803 | description: |
| 804 | What if continue used outside of any loops |
| 805 | (ksh88,ksh93 don't print error messages here) |
| 806 | stdin: |
| 807 | continue |
| 808 | expected-stderr-pattern: |
| 809 | /.*continue.*/ |
| 810 | --- |
| 811 | name: continue-4 |
| 812 | description: |
| 813 | What if continue N used when only N-1 loops |
| 814 | (ksh88,ksh93 don't print error messages here) |
| 815 | stdin: |
| 816 | for i in a b c; do echo $i; continue 2; echo bad-$i; done |
| 817 | echo end |
| 818 | expected-stdout: |
| 819 | a |
| 820 | b |
| 821 | c |
| 822 | end |
| 823 | expected-stderr-pattern: |
| 824 | /.*continue.*/ |
| 825 | --- |
| 826 | name: continue-5 |
| 827 | description: |
| 828 | Error if continue argument isn't a number |
| 829 | stdin: |
| 830 | for i in a b c; do echo $i; continue abc; echo more-$i; done |
| 831 | echo end |
| 832 | expected-stdout: |
| 833 | a |
| 834 | expected-exit: e != 0 |
| 835 | expected-stderr-pattern: |
| 836 | /.*continue.*/ |
| 837 | --- |
| 838 | name: cd-history |
| 839 | description: |
| 840 | Test someone's CD history package (uses arrays) |
| 841 | stdin: |
| 842 | # go to known place before doing anything |
| 843 | cd / |
| 844 | |
| 845 | alias cd=_cd |
| 846 | function _cd |
| 847 | { |
| 848 | typeset -i cdlen i |
| 849 | typeset t |
| 850 | |
| 851 | if [ $# -eq 0 ] |
| 852 | then |
| 853 | set -- $HOME |
| 854 | fi |
| 855 | |
| 856 | if [ "$CDHISTFILE" -a -r "$CDHISTFILE" ] # if directory history exists |
| 857 | then |
| 858 | typeset CDHIST |
| 859 | i=-1 |
| 860 | while read -r t # read directory history file |
| 861 | do |
| 862 | CDHIST[i=i+1]=$t |
| 863 | done <$CDHISTFILE |
| 864 | fi |
| 865 | |
| 866 | if [ "${CDHIST[0]}" != "$PWD" -a "$PWD" != "" ] |
| 867 | then |
| 868 | _cdins # insert $PWD into cd history |
| 869 | fi |
| 870 | |
| 871 | cdlen=${#CDHIST[*]} # number of elements in history |
| 872 | |
| 873 | case "$@" in |
| 874 | -) # cd to new dir |
| 875 | if [ "$OLDPWD" = "" ] && ((cdlen>1)) |
| 876 | then |
| 877 | 'print' ${CDHIST[1]} |
| 878 | 'cd' ${CDHIST[1]} |
| 879 | _pwd |
| 880 | else |
| 881 | 'cd' $@ |
| 882 | _pwd |
| 883 | fi |
| 884 | ;; |
| 885 | -l) # print directory list |
| 886 | typeset -R3 num |
| 887 | ((i=cdlen)) |
| 888 | while (((i=i-1)>=0)) |
| 889 | do |
| 890 | num=$i |
| 891 | 'print' "$num ${CDHIST[i]}" |
| 892 | done |
| 893 | return |
| 894 | ;; |
| 895 | -[0-9]|-[0-9][0-9]) # cd to dir in list |
| 896 | if (((i=${1#-})<cdlen)) |
| 897 | then |
| 898 | 'print' ${CDHIST[i]} |
| 899 | 'cd' ${CDHIST[i]} |
| 900 | _pwd |
| 901 | else |
| 902 | 'cd' $@ |
| 903 | _pwd |
| 904 | fi |
| 905 | ;; |
| 906 | -*) # cd to matched dir in list |
| 907 | t=${1#-} |
| 908 | i=1 |
| 909 | while ((i<cdlen)) |
| 910 | do |
| 911 | case ${CDHIST[i]} in |
| 912 | *$t*) |
| 913 | 'print' ${CDHIST[i]} |
| 914 | 'cd' ${CDHIST[i]} |
| 915 | _pwd |
| 916 | break |
| 917 | ;; |
| 918 | esac |
| 919 | ((i=i+1)) |
| 920 | done |
| 921 | if ((i>=cdlen)) |
| 922 | then |
| 923 | 'cd' $@ |
| 924 | _pwd |
| 925 | fi |
| 926 | ;; |
| 927 | *) # cd to new dir |
| 928 | 'cd' $@ |
| 929 | _pwd |
| 930 | ;; |
| 931 | esac |
| 932 | |
| 933 | _cdins # insert $PWD into cd history |
| 934 | |
| 935 | if [ "$CDHISTFILE" ] |
| 936 | then |
| 937 | cdlen=${#CDHIST[*]} # number of elements in history |
| 938 | |
| 939 | i=0 |
| 940 | while ((i<cdlen)) |
| 941 | do |
| 942 | 'print' -r ${CDHIST[i]} # update directory history |
| 943 | ((i=i+1)) |
| 944 | done >$CDHISTFILE |
| 945 | fi |
| 946 | } |
| 947 | |
| 948 | function _cdins # insert $PWD into cd history |
| 949 | { # meant to be called only by _cd |
| 950 | typeset -i i |
| 951 | |
| 952 | ((i=0)) |
| 953 | while ((i<${#CDHIST[*]})) # see if dir is already in list |
| 954 | do |
| 955 | if [ "${CDHIST[$i]}" = "$PWD" ] |
| 956 | then |
| 957 | break |
| 958 | fi |
| 959 | ((i=i+1)) |
| 960 | done |
| 961 | |
| 962 | if ((i>22)) # limit max size of list |
| 963 | then |
| 964 | i=22 |
| 965 | fi |
| 966 | |
| 967 | while (((i=i-1)>=0)) # bump old dirs in list |
| 968 | do |
| 969 | CDHIST[i+1]=${CDHIST[i]} |
| 970 | done |
| 971 | |
| 972 | CDHIST[0]=$PWD # insert new directory in list |
| 973 | } |
| 974 | |
| 975 | |
| 976 | function _pwd |
| 977 | { |
| 978 | if [ -n "$ECD" ] |
| 979 | then |
| 980 | pwd 1>&6 |
| 981 | fi |
| 982 | } |
| 983 | # Start of test |
| 984 | cd /tmp |
| 985 | cd /bin |
| 986 | cd /etc |
| 987 | cd - |
| 988 | cd -2 |
| 989 | cd -l |
| 990 | expected-stdout: |
| 991 | /bin |
| 992 | /tmp |
| 993 | 3 / |
| 994 | 2 /etc |
| 995 | 1 /bin |
| 996 | 0 /tmp |
| 997 | --- |
| 998 | name: env-prompt |
| 999 | description: |
| 1000 | Check that prompt not printed when processing ENV |
| 1001 | env-setup: !ENV=./foo! |
| 1002 | file-setup: file 644 "foo" |
| 1003 | XXX=_ |
| 1004 | PS1=X |
| 1005 | false && echo hmmm |
| 1006 | arguments: !-i! |
| 1007 | stdin: |
| 1008 | echo hi${XXX}there |
| 1009 | expected-stdout: |
| 1010 | hi_there |
| 1011 | expected-stderr: ! |
| 1012 | XX |
| 1013 | --- |
| 1014 | name: expand-ugly |
| 1015 | description: |
| 1016 | Check that weird ${foo+bar} constructs are parsed correctly |
| 1017 | stdin: |
| 1018 | (echo 1 ${IFS+'}'z}) 2>&- || echo failed in 1 |
| 1019 | (echo 2 "${IFS+'}'z}") 2>&- || echo failed in 2 |
| 1020 | (echo 3 "foo ${IFS+'bar} baz") 2>&- || echo failed in 3 |
| 1021 | (echo -n '4 '; printf '%s\n' "foo ${IFS+"b c"} baz") 2>&- || echo failed in 4 |
| 1022 | (echo -n '5 '; printf '%s\n' "foo ${IFS+b c} baz") 2>&- || echo failed in 5 |
| 1023 | (echo 6 ${IFS+"}"z}) 2>&- || echo failed in 6 |
| 1024 | (echo 7 "${IFS+"}"z}") 2>&- || echo failed in 7 |
| 1025 | (echo 8 "${IFS+\"}\"z}") 2>&- || echo failed in 8 |
| 1026 | (echo 9 "${IFS+\"\}\"z}") 2>&- || echo failed in 9 |
| 1027 | (echo 10 foo ${IFS+'bar} baz'}) 2>&- || echo failed in 10 |
| 1028 | (echo 11 "$(echo "${IFS+'}'z}")") 2>&- || echo failed in 11 |
| 1029 | (echo 12 "$(echo ${IFS+'}'z})") 2>&- || echo failed in 12 |
| 1030 | (echo 13 ${IFS+\}z}) 2>&- || echo failed in 13 |
| 1031 | (echo 14 "${IFS+\}z}") 2>&- || echo failed in 14 |
| 1032 | u=x; (echo -n '15 '; printf '<%s> ' "foo ${IFS+a"b$u{ {"{{\}b} c ${IFS+d{}} bar" ${IFS-e{}} baz; echo .) 2>&- || echo failed in 15 |
| 1033 | l=t; (echo 16 ${IFS+h`echo -n i ${IFS+$l}h`ere}) 2>&- || echo failed in 16 |
| 1034 | l=t; (echo 17 ${IFS+h$(echo -n i ${IFS+$l}h)ere}) 2>&- || echo failed in 17 |
| 1035 | l=t; (echo 18 "${IFS+h`echo -n i ${IFS+$l}h`ere}") 2>&- || echo failed in 18 |
| 1036 | l=t; (echo 19 "${IFS+h$(echo -n i ${IFS+$l}h)ere}") 2>&- || echo failed in 19 |
| 1037 | l=t; (echo 20 ${IFS+h`echo -n i "${IFS+$l}"h`ere}) 2>&- || echo failed in 20 |
| 1038 | l=t; (echo 21 ${IFS+h$(echo -n i "${IFS+$l}"h)ere}) 2>&- || echo failed in 21 |
| 1039 | l=t; (echo 22 "${IFS+h`echo -n i "${IFS+$l}"h`ere}") 2>&- || echo failed in 22 |
| 1040 | l=t; (echo 23 "${IFS+h$(echo -n i "${IFS+$l}"h)ere}") 2>&- || echo failed in 23 |
| 1041 | key=value; (echo -n '24 '; printf '%s\n' "${IFS+'$key'}") 2>&- || echo failed in 24 |
| 1042 | key=value; (echo -n '25 '; printf '%s\n' "${IFS+"'$key'"}") 2>&- || echo failed in 25 # ksh93: â'$key'â |
| 1043 | key=value; (echo -n '26 '; printf '%s\n' ${IFS+'$key'}) 2>&- || echo failed in 26 |
| 1044 | key=value; (echo -n '27 '; printf '%s\n' ${IFS+"'$key'"}) 2>&- || echo failed in 27 |
| 1045 | (echo -n '28 '; printf '%s\n' "${IFS+"'"x ~ x'}'x"'}"x}" #') 2>&- || echo failed in 28 |
| 1046 | u=x; (echo -n '29 '; printf '<%s> ' foo ${IFS+a"b$u{ {"{ {\}b} c ${IFS+d{}} bar ${IFS-e{}} baz; echo .) 2>&- || echo failed in 29 |
| 1047 | (echo -n '30 '; printf '<%s> ' ${IFS+foo 'b\ |
| 1048 | ar' baz}; echo .) 2>&- || (echo failed in 30; echo failed in 31) |
| 1049 | (echo -n '32 '; printf '<%s> ' ${IFS+foo "b\ |
| 1050 | ar" baz}; echo .) 2>&- || echo failed in 32 |
| 1051 | (echo -n '33 '; printf '<%s> ' "${IFS+foo 'b\ |
| 1052 | ar' baz}"; echo .) 2>&- || echo failed in 33 |
| 1053 | (echo -n '34 '; printf '<%s> ' "${IFS+foo "b\ |
| 1054 | ar" baz}"; echo .) 2>&- || echo failed in 34 |
| 1055 | (echo -n '35 '; printf '<%s> ' ${v=a\ b} x ${v=c\ d}; echo .) 2>&- || echo failed in 35 |
| 1056 | (echo -n '36 '; printf '<%s> ' "${v=a\ b}" x "${v=c\ d}"; echo .) 2>&- || echo failed in 36 |
| 1057 | (echo -n '37 '; printf '<%s> ' ${v-a\ b} x ${v-c\ d}; echo .) 2>&- || echo failed in 37 |
| 1058 | (echo 38 ${IFS+x'a'y} / "${IFS+x'a'y}" .) 2>&- || echo failed in 38 |
| 1059 | foo="x'a'y"; (echo 39 ${foo%*'a'*} / "${foo%*'a'*}" .) 2>&- || echo failed in 39 |
| 1060 | foo="a b c"; (echo -n '40 '; printf '<%s> ' "${foo#a}"; echo .) 2>&- || echo failed in 40 |
| 1061 | expected-stdout: |
| 1062 | 1 }z |
| 1063 | 2 ''z} |
| 1064 | 3 foo 'bar baz |
| 1065 | 4 foo b c baz |
| 1066 | 5 foo b c baz |
| 1067 | 6 }z |
| 1068 | 7 }z |
| 1069 | 8 ""z} |
| 1070 | 9 "}"z |
| 1071 | 10 foo bar} baz |
| 1072 | 11 ''z} |
| 1073 | 12 }z |
| 1074 | 13 }z |
| 1075 | 14 }z |
| 1076 | 15 <foo abx{ {{{}b c d{} bar> <}> <baz> . |
| 1077 | 16 hi there |
| 1078 | 17 hi there |
| 1079 | 18 hi there |
| 1080 | 19 hi there |
| 1081 | 20 hi there |
| 1082 | 21 hi there |
| 1083 | 22 hi there |
| 1084 | 23 hi there |
| 1085 | 24 'value' |
| 1086 | 25 'value' |
| 1087 | 26 $key |
| 1088 | 27 'value' |
| 1089 | 28 'x ~ x''x}"x}" # |
| 1090 | 29 <foo> <abx{ {{> <{}b> <c> <d{}> <bar> <}> <baz> . |
| 1091 | 30 <foo> <b\ |
| 1092 | ar> <baz> . |
| 1093 | 32 <foo> <bar> <baz> . |
| 1094 | 33 <foo 'bar' baz> . |
| 1095 | 34 <foo bar baz> . |
| 1096 | 35 <a> <b> <x> <a> <b> . |
| 1097 | 36 <a\ b> <x> <a\ b> . |
| 1098 | 37 <a b> <x> <c d> . |
| 1099 | 38 xay / x'a'y . |
| 1100 | 39 x' / x' . |
| 1101 | 40 < b c> . |
| 1102 | --- |
| 1103 | name: expand-unglob-dblq |
| 1104 | description: |
| 1105 | Check that regular "${foo+bar}" constructs are parsed correctly |
| 1106 | stdin: |
| 1107 | u=x |
| 1108 | tl_norm() { |
| 1109 | v=$2 |
| 1110 | test x"$v" = x"-" && unset v |
| 1111 | (echo "$1 plus norm foo ${v+'bar'} baz") |
| 1112 | (echo "$1 dash norm foo ${v-'bar'} baz") |
| 1113 | (echo "$1 eqal norm foo ${v='bar'} baz") |
| 1114 | (echo "$1 qstn norm foo ${v?'bar'} baz") 2>&- || \ |
| 1115 | echo "$1 qstn norm -> error" |
| 1116 | (echo "$1 PLUS norm foo ${v:+'bar'} baz") |
| 1117 | (echo "$1 DASH norm foo ${v:-'bar'} baz") |
| 1118 | (echo "$1 EQAL norm foo ${v:='bar'} baz") |
| 1119 | (echo "$1 QSTN norm foo ${v:?'bar'} baz") 2>&- || \ |
| 1120 | echo "$1 QSTN norm -> error" |
| 1121 | } |
| 1122 | tl_paren() { |
| 1123 | v=$2 |
| 1124 | test x"$v" = x"-" && unset v |
| 1125 | (echo "$1 plus parn foo ${v+(bar)} baz") |
| 1126 | (echo "$1 dash parn foo ${v-(bar)} baz") |
| 1127 | (echo "$1 eqal parn foo ${v=(bar)} baz") |
| 1128 | (echo "$1 qstn parn foo ${v?(bar)} baz") 2>&- || \ |
| 1129 | echo "$1 qstn parn -> error" |
| 1130 | (echo "$1 PLUS parn foo ${v:+(bar)} baz") |
| 1131 | (echo "$1 DASH parn foo ${v:-(bar)} baz") |
| 1132 | (echo "$1 EQAL parn foo ${v:=(bar)} baz") |
| 1133 | (echo "$1 QSTN parn foo ${v:?(bar)} baz") 2>&- || \ |
| 1134 | echo "$1 QSTN parn -> error" |
| 1135 | } |
| 1136 | tl_brace() { |
| 1137 | v=$2 |
| 1138 | test x"$v" = x"-" && unset v |
| 1139 | (echo "$1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz") |
| 1140 | (echo "$1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz") |
| 1141 | (echo "$1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz") |
| 1142 | (echo "$1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz") 2>&- || \ |
| 1143 | echo "$1 qstn brac -> error" |
| 1144 | (echo "$1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz") |
| 1145 | (echo "$1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz") |
| 1146 | (echo "$1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz") |
| 1147 | (echo "$1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz") 2>&- || \ |
| 1148 | echo "$1 QSTN brac -> error" |
| 1149 | } |
| 1150 | tl_norm 1 - |
| 1151 | tl_norm 2 '' |
| 1152 | tl_norm 3 x |
| 1153 | tl_paren 4 - |
| 1154 | tl_paren 5 '' |
| 1155 | tl_paren 6 x |
| 1156 | tl_brace 7 - |
| 1157 | tl_brace 8 '' |
| 1158 | tl_brace 9 x |
| 1159 | expected-stdout: |
| 1160 | 1 plus norm foo baz |
| 1161 | 1 dash norm foo 'bar' baz |
| 1162 | 1 eqal norm foo 'bar' baz |
| 1163 | 1 qstn norm -> error |
| 1164 | 1 PLUS norm foo baz |
| 1165 | 1 DASH norm foo 'bar' baz |
| 1166 | 1 EQAL norm foo 'bar' baz |
| 1167 | 1 QSTN norm -> error |
| 1168 | 2 plus norm foo 'bar' baz |
| 1169 | 2 dash norm foo baz |
| 1170 | 2 eqal norm foo baz |
| 1171 | 2 qstn norm foo baz |
| 1172 | 2 PLUS norm foo baz |
| 1173 | 2 DASH norm foo 'bar' baz |
| 1174 | 2 EQAL norm foo 'bar' baz |
| 1175 | 2 QSTN norm -> error |
| 1176 | 3 plus norm foo 'bar' baz |
| 1177 | 3 dash norm foo x baz |
| 1178 | 3 eqal norm foo x baz |
| 1179 | 3 qstn norm foo x baz |
| 1180 | 3 PLUS norm foo 'bar' baz |
| 1181 | 3 DASH norm foo x baz |
| 1182 | 3 EQAL norm foo x baz |
| 1183 | 3 QSTN norm foo x baz |
| 1184 | 4 plus parn foo baz |
| 1185 | 4 dash parn foo (bar) baz |
| 1186 | 4 eqal parn foo (bar) baz |
| 1187 | 4 qstn parn -> error |
| 1188 | 4 PLUS parn foo baz |
| 1189 | 4 DASH parn foo (bar) baz |
| 1190 | 4 EQAL parn foo (bar) baz |
| 1191 | 4 QSTN parn -> error |
| 1192 | 5 plus parn foo (bar) baz |
| 1193 | 5 dash parn foo baz |
| 1194 | 5 eqal parn foo baz |
| 1195 | 5 qstn parn foo baz |
| 1196 | 5 PLUS parn foo baz |
| 1197 | 5 DASH parn foo (bar) baz |
| 1198 | 5 EQAL parn foo (bar) baz |
| 1199 | 5 QSTN parn -> error |
| 1200 | 6 plus parn foo (bar) baz |
| 1201 | 6 dash parn foo x baz |
| 1202 | 6 eqal parn foo x baz |
| 1203 | 6 qstn parn foo x baz |
| 1204 | 6 PLUS parn foo (bar) baz |
| 1205 | 6 DASH parn foo x baz |
| 1206 | 6 EQAL parn foo x baz |
| 1207 | 6 QSTN parn foo x baz |
| 1208 | 7 plus brac foo c } baz |
| 1209 | 7 dash brac foo ax{{{}b c d{} baz |
| 1210 | 7 eqal brac foo ax{{{}b c ax{{{}b} baz |
| 1211 | 7 qstn brac -> error |
| 1212 | 7 PLUS brac foo c } baz |
| 1213 | 7 DASH brac foo ax{{{}b c d{} baz |
| 1214 | 7 EQAL brac foo ax{{{}b c ax{{{}b} baz |
| 1215 | 7 QSTN brac -> error |
| 1216 | 8 plus brac foo ax{{{}b c d{} baz |
| 1217 | 8 dash brac foo c } baz |
| 1218 | 8 eqal brac foo c } baz |
| 1219 | 8 qstn brac foo c } baz |
| 1220 | 8 PLUS brac foo c } baz |
| 1221 | 8 DASH brac foo ax{{{}b c d{} baz |
| 1222 | 8 EQAL brac foo ax{{{}b c ax{{{}b} baz |
| 1223 | 8 QSTN brac -> error |
| 1224 | 9 plus brac foo ax{{{}b c d{} baz |
| 1225 | 9 dash brac foo x c x} baz |
| 1226 | 9 eqal brac foo x c x} baz |
| 1227 | 9 qstn brac foo x c x} baz |
| 1228 | 9 PLUS brac foo ax{{{}b c d{} baz |
| 1229 | 9 DASH brac foo x c x} baz |
| 1230 | 9 EQAL brac foo x c x} baz |
| 1231 | 9 QSTN brac foo x c x} baz |
| 1232 | --- |
| 1233 | name: expand-unglob-unq |
| 1234 | description: |
| 1235 | Check that regular ${foo+bar} constructs are parsed correctly |
| 1236 | stdin: |
| 1237 | u=x |
| 1238 | tl_norm() { |
| 1239 | v=$2 |
| 1240 | test x"$v" = x"-" && unset v |
| 1241 | (echo $1 plus norm foo ${v+'bar'} baz) |
| 1242 | (echo $1 dash norm foo ${v-'bar'} baz) |
| 1243 | (echo $1 eqal norm foo ${v='bar'} baz) |
| 1244 | (echo $1 qstn norm foo ${v?'bar'} baz) 2>&- || \ |
| 1245 | echo "$1 qstn norm -> error" |
| 1246 | (echo $1 PLUS norm foo ${v:+'bar'} baz) |
| 1247 | (echo $1 DASH norm foo ${v:-'bar'} baz) |
| 1248 | (echo $1 EQAL norm foo ${v:='bar'} baz) |
| 1249 | (echo $1 QSTN norm foo ${v:?'bar'} baz) 2>&- || \ |
| 1250 | echo "$1 QSTN norm -> error" |
| 1251 | } |
| 1252 | tl_paren() { |
| 1253 | v=$2 |
| 1254 | test x"$v" = x"-" && unset v |
| 1255 | (echo $1 plus parn foo ${v+\(bar')'} baz) |
| 1256 | (echo $1 dash parn foo ${v-\(bar')'} baz) |
| 1257 | (echo $1 eqal parn foo ${v=\(bar')'} baz) |
| 1258 | (echo $1 qstn parn foo ${v?\(bar')'} baz) 2>&- || \ |
| 1259 | echo "$1 qstn parn -> error" |
| 1260 | (echo $1 PLUS parn foo ${v:+\(bar')'} baz) |
| 1261 | (echo $1 DASH parn foo ${v:-\(bar')'} baz) |
| 1262 | (echo $1 EQAL parn foo ${v:=\(bar')'} baz) |
| 1263 | (echo $1 QSTN parn foo ${v:?\(bar')'} baz) 2>&- || \ |
| 1264 | echo "$1 QSTN parn -> error" |
| 1265 | } |
| 1266 | tl_brace() { |
| 1267 | v=$2 |
| 1268 | test x"$v" = x"-" && unset v |
| 1269 | (echo $1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz) |
| 1270 | (echo $1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz) |
| 1271 | (echo $1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz) |
| 1272 | (echo $1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz) 2>&- || \ |
| 1273 | echo "$1 qstn brac -> error" |
| 1274 | (echo $1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz) |
| 1275 | (echo $1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz) |
| 1276 | (echo $1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz) |
| 1277 | (echo $1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz) 2>&- || \ |
| 1278 | echo "$1 QSTN brac -> error" |
| 1279 | } |
| 1280 | tl_norm 1 - |
| 1281 | tl_norm 2 '' |
| 1282 | tl_norm 3 x |
| 1283 | tl_paren 4 - |
| 1284 | tl_paren 5 '' |
| 1285 | tl_paren 6 x |
| 1286 | tl_brace 7 - |
| 1287 | tl_brace 8 '' |
| 1288 | tl_brace 9 x |
| 1289 | expected-stdout: |
| 1290 | 1 plus norm foo baz |
| 1291 | 1 dash norm foo bar baz |
| 1292 | 1 eqal norm foo bar baz |
| 1293 | 1 qstn norm -> error |
| 1294 | 1 PLUS norm foo baz |
| 1295 | 1 DASH norm foo bar baz |
| 1296 | 1 EQAL norm foo bar baz |
| 1297 | 1 QSTN norm -> error |
| 1298 | 2 plus norm foo bar baz |
| 1299 | 2 dash norm foo baz |
| 1300 | 2 eqal norm foo baz |
| 1301 | 2 qstn norm foo baz |
| 1302 | 2 PLUS norm foo baz |
| 1303 | 2 DASH norm foo bar baz |
| 1304 | 2 EQAL norm foo bar baz |
| 1305 | 2 QSTN norm -> error |
| 1306 | 3 plus norm foo bar baz |
| 1307 | 3 dash norm foo x baz |
| 1308 | 3 eqal norm foo x baz |
| 1309 | 3 qstn norm foo x baz |
| 1310 | 3 PLUS norm foo bar baz |
| 1311 | 3 DASH norm foo x baz |
| 1312 | 3 EQAL norm foo x baz |
| 1313 | 3 QSTN norm foo x baz |
| 1314 | 4 plus parn foo baz |
| 1315 | 4 dash parn foo (bar) baz |
| 1316 | 4 eqal parn foo (bar) baz |
| 1317 | 4 qstn parn -> error |
| 1318 | 4 PLUS parn foo baz |
| 1319 | 4 DASH parn foo (bar) baz |
| 1320 | 4 EQAL parn foo (bar) baz |
| 1321 | 4 QSTN parn -> error |
| 1322 | 5 plus parn foo (bar) baz |
| 1323 | 5 dash parn foo baz |
| 1324 | 5 eqal parn foo baz |
| 1325 | 5 qstn parn foo baz |
| 1326 | 5 PLUS parn foo baz |
| 1327 | 5 DASH parn foo (bar) baz |
| 1328 | 5 EQAL parn foo (bar) baz |
| 1329 | 5 QSTN parn -> error |
| 1330 | 6 plus parn foo (bar) baz |
| 1331 | 6 dash parn foo x baz |
| 1332 | 6 eqal parn foo x baz |
| 1333 | 6 qstn parn foo x baz |
| 1334 | 6 PLUS parn foo (bar) baz |
| 1335 | 6 DASH parn foo x baz |
| 1336 | 6 EQAL parn foo x baz |
| 1337 | 6 QSTN parn foo x baz |
| 1338 | 7 plus brac foo c } baz |
| 1339 | 7 dash brac foo ax{{{}b c d{} baz |
| 1340 | 7 eqal brac foo ax{{{}b c ax{{{}b} baz |
| 1341 | 7 qstn brac -> error |
| 1342 | 7 PLUS brac foo c } baz |
| 1343 | 7 DASH brac foo ax{{{}b c d{} baz |
| 1344 | 7 EQAL brac foo ax{{{}b c ax{{{}b} baz |
| 1345 | 7 QSTN brac -> error |
| 1346 | 8 plus brac foo ax{{{}b c d{} baz |
| 1347 | 8 dash brac foo c } baz |
| 1348 | 8 eqal brac foo c } baz |
| 1349 | 8 qstn brac foo c } baz |
| 1350 | 8 PLUS brac foo c } baz |
| 1351 | 8 DASH brac foo ax{{{}b c d{} baz |
| 1352 | 8 EQAL brac foo ax{{{}b c ax{{{}b} baz |
| 1353 | 8 QSTN brac -> error |
| 1354 | 9 plus brac foo ax{{{}b c d{} baz |
| 1355 | 9 dash brac foo x c x} baz |
| 1356 | 9 eqal brac foo x c x} baz |
| 1357 | 9 qstn brac foo x c x} baz |
| 1358 | 9 PLUS brac foo ax{{{}b c d{} baz |
| 1359 | 9 DASH brac foo x c x} baz |
| 1360 | 9 EQAL brac foo x c x} baz |
| 1361 | 9 QSTN brac foo x c x} baz |
| 1362 | --- |
| 1363 | name: eglob-bad-1 |
| 1364 | description: |
| 1365 | Check that globbing isn't done when glob has syntax error |
| 1366 | file-setup: file 644 "abcx" |
| 1367 | file-setup: file 644 "abcz" |
| 1368 | file-setup: file 644 "bbc" |
| 1369 | stdin: |
| 1370 | echo !([*)* |
| 1371 | echo +(a|b[)* |
| 1372 | expected-stdout: |
| 1373 | !([*)* |
| 1374 | +(a|b[)* |
| 1375 | --- |
| 1376 | name: eglob-bad-2 |
| 1377 | description: |
| 1378 | Check that globbing isn't done when glob has syntax error |
| 1379 | (AT&T ksh fails this test) |
| 1380 | file-setup: file 644 "abcx" |
| 1381 | file-setup: file 644 "abcz" |
| 1382 | file-setup: file 644 "bbc" |
| 1383 | stdin: |
| 1384 | echo [a*(]*)z |
| 1385 | expected-stdout: |
| 1386 | [a*(]*)z |
| 1387 | --- |
| 1388 | name: eglob-infinite-plus |
| 1389 | description: |
| 1390 | Check that shell doesn't go into infinite loop expanding +(...) |
| 1391 | expressions. |
| 1392 | file-setup: file 644 "abc" |
| 1393 | time-limit: 3 |
| 1394 | stdin: |
| 1395 | echo +()c |
| 1396 | echo +()x |
| 1397 | echo +(*)c |
| 1398 | echo +(*)x |
| 1399 | expected-stdout: |
| 1400 | +()c |
| 1401 | +()x |
| 1402 | abc |
| 1403 | +(*)x |
| 1404 | --- |
| 1405 | name: eglob-subst-1 |
| 1406 | description: |
| 1407 | Check that eglobbing isn't done on substitution results |
| 1408 | file-setup: file 644 "abc" |
| 1409 | stdin: |
| 1410 | x='@(*)' |
| 1411 | echo $x |
| 1412 | expected-stdout: |
| 1413 | @(*) |
| 1414 | --- |
| 1415 | name: eglob-nomatch-1 |
| 1416 | description: |
| 1417 | Check that the pattern doesn't match |
| 1418 | stdin: |
| 1419 | echo 1: no-file+(a|b)stuff |
| 1420 | echo 2: no-file+(a*(c)|b)stuff |
| 1421 | echo 3: no-file+((((c)))|b)stuff |
| 1422 | expected-stdout: |
| 1423 | 1: no-file+(a|b)stuff |
| 1424 | 2: no-file+(a*(c)|b)stuff |
| 1425 | 3: no-file+((((c)))|b)stuff |
| 1426 | --- |
| 1427 | name: eglob-match-1 |
| 1428 | description: |
| 1429 | Check that the pattern matches correctly |
| 1430 | file-setup: file 644 "abd" |
| 1431 | file-setup: file 644 "acd" |
| 1432 | file-setup: file 644 "abac" |
| 1433 | stdin: |
| 1434 | echo 1: a+(b|c)d |
| 1435 | echo 2: a!(@(b|B))d |
| 1436 | echo 3: *(a(b|c)) # (...|...) can be used within X(..) |
| 1437 | echo 4: a[b*(foo|bar)]d # patterns not special inside [...] |
| 1438 | expected-stdout: |
| 1439 | 1: abd acd |
| 1440 | 2: acd |
| 1441 | 3: abac |
| 1442 | 4: abd |
| 1443 | --- |
| 1444 | name: eglob-case-1 |
| 1445 | description: |
| 1446 | Simple negation tests |
| 1447 | stdin: |
| 1448 | case foo in !(foo|bar)) echo yes;; *) echo no;; esac |
| 1449 | case bar in !(foo|bar)) echo yes;; *) echo no;; esac |
| 1450 | expected-stdout: |
| 1451 | no |
| 1452 | no |
| 1453 | --- |
| 1454 | name: eglob-case-2 |
| 1455 | description: |
| 1456 | Simple kleene tests |
| 1457 | stdin: |
| 1458 | case foo in *(a|b[)) echo yes;; *) echo no;; esac |
| 1459 | case foo in *(a|b[)|f*) echo yes;; *) echo no;; esac |
| 1460 | case '*(a|b[)' in *(a|b[)) echo yes;; *) echo no;; esac |
| 1461 | expected-stdout: |
| 1462 | no |
| 1463 | yes |
| 1464 | yes |
| 1465 | --- |
| 1466 | name: eglob-trim-1 |
| 1467 | description: |
| 1468 | Eglobbing in trim expressions... |
| 1469 | (AT&T ksh fails this - docs say # matches shortest string, ## matches |
| 1470 | longest...) |
| 1471 | stdin: |
| 1472 | x=abcdef |
| 1473 | echo 1: ${x#a|abc} |
| 1474 | echo 2: ${x##a|abc} |
| 1475 | echo 3: ${x%def|f} |
| 1476 | echo 4: ${x%%f|def} |
| 1477 | expected-stdout: |
| 1478 | 1: bcdef |
| 1479 | 2: def |
| 1480 | 3: abcde |
| 1481 | 4: abc |
| 1482 | --- |
| 1483 | name: eglob-trim-2 |
| 1484 | description: |
| 1485 | Check eglobbing works in trims... |
| 1486 | stdin: |
| 1487 | x=abcdef |
| 1488 | echo 1: ${x#*(a|b)cd} |
| 1489 | echo 2: "${x#*(a|b)cd}" |
| 1490 | echo 3: ${x#"*(a|b)cd"} |
| 1491 | echo 4: ${x#a(b|c)} |
| 1492 | expected-stdout: |
| 1493 | 1: ef |
| 1494 | 2: ef |
| 1495 | 3: abcdef |
| 1496 | 4: cdef |
| 1497 | --- |
| 1498 | name: eglob-substrpl-1 |
| 1499 | description: |
| 1500 | Check eglobbing works in substs... and they work at all |
| 1501 | stdin: |
| 1502 | [[ -n $BASH_VERSION ]] && shopt -s extglob |
| 1503 | x=1222321_ab/cde_b/c_1221 |
| 1504 | y=xyz |
| 1505 | echo 1: ${x/2} |
| 1506 | echo 2: ${x//2} |
| 1507 | echo 3: ${x/+(2)} |
| 1508 | echo 4: ${x//+(2)} |
| 1509 | echo 5: ${x/2/4} |
| 1510 | echo 6: ${x//2/4} |
| 1511 | echo 7: ${x/+(2)/4} |
| 1512 | echo 8: ${x//+(2)/4} |
| 1513 | echo 9: ${x/b/c/e/f} |
| 1514 | echo 10: ${x/b\/c/e/f} |
| 1515 | echo 11: ${x/b\/c/e\/f} |
| 1516 | echo 12: ${x/b\/c/e\\/f} |
| 1517 | echo 13: ${x/b\\/c/e\\/f} |
| 1518 | echo 14: ${x//b/c/e/f} |
| 1519 | echo 15: ${x//b\/c/e/f} |
| 1520 | echo 16: ${x//b\/c/e\/f} |
| 1521 | echo 17: ${x//b\/c/e\\/f} |
| 1522 | echo 18: ${x//b\\/c/e\\/f} |
| 1523 | echo 19: ${x/b\/*\/c/x} |
| 1524 | echo 20: ${x/\//.} |
| 1525 | echo 21: ${x//\//.} |
| 1526 | echo 22: ${x///.} |
| 1527 | echo 23: ${x//#1/9} |
| 1528 | echo 24: ${x//%1/9} |
| 1529 | echo 25: ${x//\%1/9} |
| 1530 | echo 26: ${x//\\%1/9} |
| 1531 | echo 27: ${x//\a/9} |
| 1532 | echo 28: ${x//\\a/9} |
| 1533 | echo 29: ${x/2/$y} |
| 1534 | expected-stdout: |
| 1535 | 1: 122321_ab/cde_b/c_1221 |
| 1536 | 2: 131_ab/cde_b/c_11 |
| 1537 | 3: 1321_ab/cde_b/c_1221 |
| 1538 | 4: 131_ab/cde_b/c_11 |
| 1539 | 5: 1422321_ab/cde_b/c_1221 |
| 1540 | 6: 1444341_ab/cde_b/c_1441 |
| 1541 | 7: 14321_ab/cde_b/c_1221 |
| 1542 | 8: 14341_ab/cde_b/c_141 |
| 1543 | 9: 1222321_ac/e/f/cde_b/c_1221 |
| 1544 | 10: 1222321_ae/fde_b/c_1221 |
| 1545 | 11: 1222321_ae/fde_b/c_1221 |
| 1546 | 12: 1222321_ae\/fde_b/c_1221 |
| 1547 | 13: 1222321_ab/cde_b/c_1221 |
| 1548 | 14: 1222321_ac/e/f/cde_c/e/f/c_1221 |
| 1549 | 15: 1222321_ae/fde_e/f_1221 |
| 1550 | 16: 1222321_ae/fde_e/f_1221 |
| 1551 | 17: 1222321_ae\/fde_e\/f_1221 |
| 1552 | 18: 1222321_ab/cde_b/c_1221 |
| 1553 | 19: 1222321_ax_1221 |
| 1554 | 20: 1222321_ab.cde_b/c_1221 |
| 1555 | 21: 1222321_ab.cde_b.c_1221 |
| 1556 | 22: 1222321_ab/cde_b/c_1221 |
| 1557 | 23: 9222321_ab/cde_b/c_1221 |
| 1558 | 24: 1222321_ab/cde_b/c_1229 |
| 1559 | 25: 1222321_ab/cde_b/c_1229 |
| 1560 | 26: 1222321_ab/cde_b/c_1221 |
| 1561 | 27: 1222321_9b/cde_b/c_1221 |
| 1562 | 28: 1222321_9b/cde_b/c_1221 |
| 1563 | 29: 1xyz22321_ab/cde_b/c_1221 |
| 1564 | --- |
| 1565 | name: eglob-substrpl-2 |
| 1566 | description: |
| 1567 | Check anchored substring replacement works, corner cases |
| 1568 | stdin: |
| 1569 | foo=123 |
| 1570 | echo 1: ${foo/#/x} |
| 1571 | echo 2: ${foo/%/x} |
| 1572 | echo 3: ${foo/#/} |
| 1573 | echo 4: ${foo/#} |
| 1574 | echo 5: ${foo/%/} |
| 1575 | echo 6: ${foo/%} |
| 1576 | expected-stdout: |
| 1577 | 1: x123 |
| 1578 | 2: 123x |
| 1579 | 3: 123 |
| 1580 | 4: 123 |
| 1581 | 5: 123 |
| 1582 | 6: 123 |
| 1583 | --- |
| 1584 | name: eglob-substrpl-3a |
| 1585 | description: |
| 1586 | Check substring replacement works with variables and slashes, too |
| 1587 | stdin: |
| 1588 | pfx=/home/user |
| 1589 | wd=/home/user/tmp |
| 1590 | echo "${wd/#$pfx/~}" |
| 1591 | echo "${wd/#\$pfx/~}" |
| 1592 | echo "${wd/#"$pfx"/~}" |
| 1593 | echo "${wd/#'$pfx'/~}" |
| 1594 | echo "${wd/#"\$pfx"/~}" |
| 1595 | echo "${wd/#'\$pfx'/~}" |
| 1596 | expected-stdout: |
| 1597 | ~/tmp |
| 1598 | /home/user/tmp |
| 1599 | ~/tmp |
| 1600 | /home/user/tmp |
| 1601 | /home/user/tmp |
| 1602 | /home/user/tmp |
| 1603 | --- |
| 1604 | name: eglob-substrpl-3b |
| 1605 | description: |
| 1606 | More of this, bash fails it (bash4 passes) |
| 1607 | stdin: |
| 1608 | pfx=/home/user |
| 1609 | wd=/home/user/tmp |
| 1610 | echo "${wd/#$(echo /home/user)/~}" |
| 1611 | echo "${wd/#"$(echo /home/user)"/~}" |
| 1612 | echo "${wd/#'$(echo /home/user)'/~}" |
| 1613 | expected-stdout: |
| 1614 | ~/tmp |
| 1615 | ~/tmp |
| 1616 | /home/user/tmp |
| 1617 | --- |
| 1618 | name: eglob-substrpl-3c |
| 1619 | description: |
| 1620 | Even more weird cases |
| 1621 | stdin: |
| 1622 | pfx=/home/user |
| 1623 | wd='$pfx/tmp' |
| 1624 | echo 1: ${wd/#$pfx/~} |
| 1625 | echo 2: ${wd/#\$pfx/~} |
| 1626 | echo 3: ${wd/#"$pfx"/~} |
| 1627 | echo 4: ${wd/#'$pfx'/~} |
| 1628 | echo 5: ${wd/#"\$pfx"/~} |
| 1629 | echo 6: ${wd/#'\$pfx'/~} |
| 1630 | ts='a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)' |
| 1631 | tp=a/b |
| 1632 | tr=c/d |
| 1633 | [[ -n $BASH_VERSION ]] && shopt -s extglob |
| 1634 | echo 7: ${ts/a\/b/$tr} |
| 1635 | echo 8: ${ts/a\/b/\$tr} |
| 1636 | echo 9: ${ts/$tp/$tr} |
| 1637 | echo 10: ${ts/\$tp/$tr} |
| 1638 | echo 11: ${ts/\\$tp/$tr} |
| 1639 | echo 12: ${ts/$tp/c/d} |
| 1640 | echo 13: ${ts/$tp/c\/d} |
| 1641 | echo 14: ${ts/$tp/c\\/d} |
| 1642 | echo 15: ${ts/+(a\/b)/$tr} |
| 1643 | echo 16: ${ts/+(a\/b)/\$tr} |
| 1644 | echo 17: ${ts/+($tp)/$tr} |
| 1645 | echo 18: ${ts/+($tp)/c/d} |
| 1646 | echo 19: ${ts/+($tp)/c\/d} |
| 1647 | echo 25: ${ts//a\/b/$tr} |
| 1648 | echo 26: ${ts//a\/b/\$tr} |
| 1649 | echo 27: ${ts//$tp/$tr} |
| 1650 | echo 28: ${ts//$tp/c/d} |
| 1651 | echo 29: ${ts//$tp/c\/d} |
| 1652 | echo 30: ${ts//+(a\/b)/$tr} |
| 1653 | echo 31: ${ts//+(a\/b)/\$tr} |
| 1654 | echo 32: ${ts//+($tp)/$tr} |
| 1655 | echo 33: ${ts//+($tp)/c/d} |
| 1656 | echo 34: ${ts//+($tp)/c\/d} |
| 1657 | tp="+($tp)" |
| 1658 | echo 40: ${ts/$tp/$tr} |
| 1659 | echo 41: ${ts//$tp/$tr} |
| 1660 | expected-stdout: |
| 1661 | 1: $pfx/tmp |
| 1662 | 2: ~/tmp |
| 1663 | 3: $pfx/tmp |
| 1664 | 4: ~/tmp |
| 1665 | 5: ~/tmp |
| 1666 | 6: ~/tmp |
| 1667 | 7: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 1668 | 8: $tra/b$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 1669 | 9: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 1670 | 10: a/ba/bc/d$tp_a/b$tp_*(a/b)_*($tp) |
| 1671 | 11: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 1672 | 12: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 1673 | 13: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 1674 | 14: c\/da/b$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 1675 | 15: c/d$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 1676 | 16: $tr$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 1677 | 17: c/d$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 1678 | 18: c/d$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 1679 | 19: c/d$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 1680 | 25: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp) |
| 1681 | 26: $tr$tr$tp$tp_$tr$tp_*($tr)_*($tp) |
| 1682 | 27: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp) |
| 1683 | 28: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp) |
| 1684 | 29: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp) |
| 1685 | 30: c/d$tp$tp_c/d$tp_*(c/d)_*($tp) |
| 1686 | 31: $tr$tp$tp_$tr$tp_*($tr)_*($tp) |
| 1687 | 32: c/d$tp$tp_c/d$tp_*(c/d)_*($tp) |
| 1688 | 33: c/d$tp$tp_c/d$tp_*(c/d)_*($tp) |
| 1689 | 34: c/d$tp$tp_c/d$tp_*(c/d)_*($tp) |
| 1690 | 40: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 1691 | 41: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 1692 | # This is what GNU bash does: |
| 1693 | # 40: c/d$tp$tp_a/b$tp_*(a/b)_*($tp) |
| 1694 | # 41: c/d$tp$tp_c/d$tp_*(c/d)_*($tp) |
| 1695 | --- |
| 1696 | name: eglob-utf8-1 |
| 1697 | description: |
| 1698 | UTF-8 mode differences for eglobbing |
| 1699 | stdin: |
| 1700 | s=blöd |
| 1701 | set +U |
| 1702 | print 1: ${s%???} . |
| 1703 | print 2: ${s/b???d/x} . |
| 1704 | set -U |
| 1705 | print 3: ${s%???} . |
| 1706 | print 4: ${s/b??d/x} . |
| 1707 | x=nö |
| 1708 | print 5: ${x%?} ${x%%?} . |
| 1709 | x=äh |
| 1710 | print 6: ${x#?} ${x##?} . |
| 1711 | x= |
| 1712 | print 7: ${x%?} ${x%%?} . |
| 1713 | x=mä |
| 1714 | print 8: ${x%?} ${x%%?} . |
| 1715 | x=ä½ |
| 1716 | print 9: ${x%?} ${x%%?} . |
| 1717 | expected-stdout: |
| 1718 | 1: bl . |
| 1719 | 2: x . |
| 1720 | 3: b . |
| 1721 | 4: x . |
| 1722 | 5: n n . |
| 1723 | 6: h h . |
| 1724 | 7: . |
| 1725 | 8: mä mä . |
| 1726 | 9: . |
| 1727 | --- |
| 1728 | name: glob-bad-1 |
| 1729 | description: |
| 1730 | Check that globbing isn't done when glob has syntax error |
| 1731 | file-setup: dir 755 "[x" |
| 1732 | file-setup: file 644 "[x/foo" |
| 1733 | stdin: |
| 1734 | echo [* |
| 1735 | echo *[x |
| 1736 | echo [x/* |
| 1737 | expected-stdout: |
| 1738 | [* |
| 1739 | *[x |
| 1740 | [x/foo |
| 1741 | --- |
| 1742 | name: glob-bad-2 |
| 1743 | description: |
| 1744 | Check that symbolic links aren't stat()'d |
| 1745 | file-setup: dir 755 "dir" |
| 1746 | file-setup: symlink 644 "dir/abc" |
| 1747 | non-existent-file |
| 1748 | stdin: |
| 1749 | echo d*/* |
| 1750 | echo d*/abc |
| 1751 | expected-stdout: |
| 1752 | dir/abc |
| 1753 | dir/abc |
| 1754 | --- |
| 1755 | name: glob-range-1 |
| 1756 | description: |
| 1757 | Test range matching |
| 1758 | file-setup: file 644 ".bc" |
| 1759 | file-setup: file 644 "abc" |
| 1760 | file-setup: file 644 "bbc" |
| 1761 | file-setup: file 644 "cbc" |
| 1762 | file-setup: file 644 "-bc" |
| 1763 | stdin: |
| 1764 | echo [ab-]* |
| 1765 | echo [-ab]* |
| 1766 | echo [!-ab]* |
| 1767 | echo [!ab]* |
| 1768 | echo []ab]* |
| 1769 | expected-stdout: |
| 1770 | -bc abc bbc |
| 1771 | -bc abc bbc |
| 1772 | cbc |
| 1773 | -bc cbc |
| 1774 | abc bbc |
| 1775 | --- |
| 1776 | name: glob-range-2 |
| 1777 | description: |
| 1778 | Test range matching |
| 1779 | (AT&T ksh fails this; POSIX says invalid) |
| 1780 | file-setup: file 644 "abc" |
| 1781 | stdin: |
| 1782 | echo [a--]* |
| 1783 | expected-stdout: |
| 1784 | [a--]* |
| 1785 | --- |
| 1786 | name: glob-range-3 |
| 1787 | description: |
| 1788 | Check that globbing matches the right things... |
| 1789 | # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition) |
| 1790 | category: !os:darwin |
| 1791 | file-setup: file 644 "aÂc" |
| 1792 | stdin: |
| 1793 | echo a[Á-Ú]* |
| 1794 | expected-stdout: |
| 1795 | aÂc |
| 1796 | --- |
| 1797 | name: glob-range-4 |
| 1798 | description: |
| 1799 | Results unspecified according to POSIX |
| 1800 | file-setup: file 644 ".bc" |
| 1801 | stdin: |
| 1802 | echo [a.]* |
| 1803 | expected-stdout: |
| 1804 | [a.]* |
| 1805 | --- |
| 1806 | name: glob-range-5 |
| 1807 | description: |
| 1808 | Results unspecified according to POSIX |
| 1809 | (AT&T ksh treats this like [a-cc-e]*) |
| 1810 | file-setup: file 644 "abc" |
| 1811 | file-setup: file 644 "bbc" |
| 1812 | file-setup: file 644 "cbc" |
| 1813 | file-setup: file 644 "dbc" |
| 1814 | file-setup: file 644 "ebc" |
| 1815 | file-setup: file 644 "-bc" |
| 1816 | stdin: |
| 1817 | echo [a-c-e]* |
| 1818 | expected-stdout: |
| 1819 | -bc abc bbc cbc ebc |
| 1820 | --- |
| 1821 | name: heredoc-1 |
| 1822 | description: |
| 1823 | Check ordering/content of redundent here documents. |
| 1824 | stdin: |
| 1825 | cat << EOF1 << EOF2 |
| 1826 | hi |
| 1827 | EOF1 |
| 1828 | there |
| 1829 | EOF2 |
| 1830 | expected-stdout: |
| 1831 | there |
| 1832 | --- |
| 1833 | name: heredoc-2 |
| 1834 | description: |
| 1835 | Check quoted here-doc is protected. |
| 1836 | stdin: |
| 1837 | a=foo |
| 1838 | cat << 'EOF' |
| 1839 | hi\ |
| 1840 | there$a |
| 1841 | stuff |
| 1842 | EO\ |
| 1843 | F |
| 1844 | EOF |
| 1845 | expected-stdout: |
| 1846 | hi\ |
| 1847 | there$a |
| 1848 | stuff |
| 1849 | EO\ |
| 1850 | F |
| 1851 | --- |
| 1852 | name: heredoc-3 |
| 1853 | description: |
| 1854 | Check that newline isn't needed after heredoc-delimiter marker. |
| 1855 | stdin: ! |
| 1856 | cat << EOF |
| 1857 | hi |
| 1858 | there |
| 1859 | EOF |
| 1860 | expected-stdout: |
| 1861 | hi |
| 1862 | there |
| 1863 | --- |
| 1864 | name: heredoc-4 |
| 1865 | description: |
| 1866 | Check that an error occurs if the heredoc-delimiter is missing. |
| 1867 | stdin: ! |
| 1868 | cat << EOF |
| 1869 | hi |
| 1870 | there |
| 1871 | expected-exit: e > 0 |
| 1872 | expected-stderr-pattern: /.*/ |
| 1873 | --- |
| 1874 | name: heredoc-5 |
| 1875 | description: |
| 1876 | Check that backslash quotes a $, ` and \ and kills a \newline |
| 1877 | stdin: |
| 1878 | a=BAD |
| 1879 | b=ok |
| 1880 | cat << EOF |
| 1881 | h\${a}i |
| 1882 | h\\${b}i |
| 1883 | th\`echo not-run\`ere |
| 1884 | th\\`echo is-run`ere |
| 1885 | fol\\ks |
| 1886 | more\\ |
| 1887 | last \ |
| 1888 | line |
| 1889 | EOF |
| 1890 | expected-stdout: |
| 1891 | h${a}i |
| 1892 | h\oki |
| 1893 | th`echo not-run`ere |
| 1894 | th\is-runere |
| 1895 | fol\ks |
| 1896 | more\ |
| 1897 | last line |
| 1898 | --- |
| 1899 | name: heredoc-6 |
| 1900 | description: |
| 1901 | Check that \newline in initial here-delim word doesn't imply |
| 1902 | a quoted here-doc. |
| 1903 | stdin: |
| 1904 | a=i |
| 1905 | cat << EO\ |
| 1906 | F |
| 1907 | h$a |
| 1908 | there |
| 1909 | EOF |
| 1910 | expected-stdout: |
| 1911 | hi |
| 1912 | there |
| 1913 | --- |
| 1914 | name: heredoc-7 |
| 1915 | description: |
| 1916 | Check that double quoted $ expressions in here delimiters are |
| 1917 | not expanded and match the delimiter. |
| 1918 | POSIX says only quote removal is applied to the delimiter. |
| 1919 | stdin: |
| 1920 | a=b |
| 1921 | cat << "E$a" |
| 1922 | hi |
| 1923 | h$a |
| 1924 | hb |
| 1925 | E$a |
| 1926 | echo done |
| 1927 | expected-stdout: |
| 1928 | hi |
| 1929 | h$a |
| 1930 | hb |
| 1931 | done |
| 1932 | --- |
| 1933 | name: heredoc-8 |
| 1934 | description: |
| 1935 | Check that double quoted escaped $ expressions in here |
| 1936 | delimiters are not expanded and match the delimiter. |
| 1937 | POSIX says only quote removal is applied to the delimiter |
| 1938 | (\ counts as a quote). |
| 1939 | stdin: |
| 1940 | a=b |
| 1941 | cat << "E\$a" |
| 1942 | hi |
| 1943 | h$a |
| 1944 | h\$a |
| 1945 | hb |
| 1946 | h\b |
| 1947 | E$a |
| 1948 | echo done |
| 1949 | expected-stdout: |
| 1950 | hi |
| 1951 | h$a |
| 1952 | h\$a |
| 1953 | hb |
| 1954 | h\b |
| 1955 | done |
| 1956 | --- |
| 1957 | name: heredoc-9a |
| 1958 | description: |
| 1959 | Check that here strings work. |
| 1960 | stdin: |
| 1961 | bar="bar |
| 1962 | baz" |
| 1963 | tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo |
| 1964 | "$__progname" -c "tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo" |
| 1965 | tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$bar" |
| 1966 | tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<'$bar' |
| 1967 | tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$bar |
| 1968 | tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<-foo |
| 1969 | expected-stdout: |
| 1970 | sbb |
| 1971 | sbb |
| 1972 | one |
| 1973 | onm |
| 1974 | $one |
| 1975 | $one |
| 1976 | -sbb |
| 1977 | --- |
| 1978 | name: heredoc-9b |
| 1979 | description: |
| 1980 | Check that a corner case of here strings works like bash |
| 1981 | stdin: |
| 1982 | fnord=42 |
| 1983 | bar="bar |
| 1984 | \$fnord baz" |
| 1985 | tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar |
| 1986 | expected-stdout: |
| 1987 | one $sabeq onm |
| 1988 | category: bash |
| 1989 | --- |
| 1990 | name: heredoc-9c |
| 1991 | description: |
| 1992 | Check that a corner case of here strings works like ksh93, zsh |
| 1993 | stdin: |
| 1994 | fnord=42 |
| 1995 | bar="bar |
| 1996 | \$fnord baz" |
| 1997 | tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar |
| 1998 | expected-stdout: |
| 1999 | one |
| 2000 | $sabeq onm |
| 2001 | --- |
| 2002 | name: heredoc-9d |
| 2003 | description: |
| 2004 | Check another corner case of here strings |
| 2005 | stdin: |
| 2006 | tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<< bar |
| 2007 | expected-stdout: |
| 2008 | one |
| 2009 | --- |
| 2010 | name: heredoc-quoting-unsubst |
| 2011 | description: |
| 2012 | Check for correct handling of quoted characters in |
| 2013 | here documents without substitution (marker is quoted). |
| 2014 | stdin: |
| 2015 | foo=bar |
| 2016 | cat <<-'EOF' |
| 2017 | x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x |
| 2018 | EOF |
| 2019 | expected-stdout: |
| 2020 | x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x |
| 2021 | --- |
| 2022 | name: heredoc-quoting-subst |
| 2023 | description: |
| 2024 | Check for correct handling of quoted characters in |
| 2025 | here documents with substitution (marker is not quoted). |
| 2026 | stdin: |
| 2027 | foo=bar |
| 2028 | cat <<-EOF |
| 2029 | x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x |
| 2030 | EOF |
| 2031 | expected-stdout: |
| 2032 | x " \" \ \ $ $ baz `echo baz` bar $foo x |
| 2033 | --- |
| 2034 | name: heredoc-tmpfile-1 |
| 2035 | description: |
| 2036 | Check that heredoc temp files aren't removed too soon or too late. |
| 2037 | Heredoc in simple command. |
| 2038 | stdin: |
| 2039 | TMPDIR=$PWD |
| 2040 | eval ' |
| 2041 | cat <<- EOF |
| 2042 | hi |
| 2043 | EOF |
| 2044 | for i in a b ; do |
| 2045 | cat <<- EOF |
| 2046 | more |
| 2047 | EOF |
| 2048 | done |
| 2049 | ' & |
| 2050 | sleep 1 |
| 2051 | echo Left overs: * |
| 2052 | expected-stdout: |
| 2053 | hi |
| 2054 | more |
| 2055 | more |
| 2056 | Left overs: * |
| 2057 | --- |
| 2058 | name: heredoc-tmpfile-2 |
| 2059 | description: |
| 2060 | Check that heredoc temp files aren't removed too soon or too late. |
| 2061 | Heredoc in function, multiple calls to function. |
| 2062 | stdin: |
| 2063 | TMPDIR=$PWD |
| 2064 | eval ' |
| 2065 | foo() { |
| 2066 | cat <<- EOF |
| 2067 | hi |
| 2068 | EOF |
| 2069 | } |
| 2070 | foo |
| 2071 | foo |
| 2072 | ' & |
| 2073 | sleep 1 |
| 2074 | echo Left overs: * |
| 2075 | expected-stdout: |
| 2076 | hi |
| 2077 | hi |
| 2078 | Left overs: * |
| 2079 | --- |
| 2080 | name: heredoc-tmpfile-3 |
| 2081 | description: |
| 2082 | Check that heredoc temp files aren't removed too soon or too late. |
| 2083 | Heredoc in function in loop, multiple calls to function. |
| 2084 | stdin: |
| 2085 | TMPDIR=$PWD |
| 2086 | eval ' |
| 2087 | foo() { |
| 2088 | cat <<- EOF |
| 2089 | hi |
| 2090 | EOF |
| 2091 | } |
| 2092 | for i in a b; do |
| 2093 | foo |
| 2094 | foo() { |
| 2095 | cat <<- EOF |
| 2096 | folks $i |
| 2097 | EOF |
| 2098 | } |
| 2099 | done |
| 2100 | foo |
| 2101 | ' & |
| 2102 | sleep 1 |
| 2103 | echo Left overs: * |
| 2104 | expected-stdout: |
| 2105 | hi |
| 2106 | folks b |
| 2107 | folks b |
| 2108 | Left overs: * |
| 2109 | --- |
| 2110 | name: heredoc-tmpfile-4 |
| 2111 | description: |
| 2112 | Check that heredoc temp files aren't removed too soon or too late. |
| 2113 | Backgrounded simple command with here doc |
| 2114 | stdin: |
| 2115 | TMPDIR=$PWD |
| 2116 | eval ' |
| 2117 | cat <<- EOF & |
| 2118 | hi |
| 2119 | EOF |
| 2120 | ' & |
| 2121 | sleep 1 |
| 2122 | echo Left overs: * |
| 2123 | expected-stdout: |
| 2124 | hi |
| 2125 | Left overs: * |
| 2126 | --- |
| 2127 | name: heredoc-tmpfile-5 |
| 2128 | description: |
| 2129 | Check that heredoc temp files aren't removed too soon or too late. |
| 2130 | Backgrounded subshell command with here doc |
| 2131 | stdin: |
| 2132 | TMPDIR=$PWD |
| 2133 | eval ' |
| 2134 | ( |
| 2135 | sleep 1 # so parent exits |
| 2136 | echo A |
| 2137 | cat <<- EOF |
| 2138 | hi |
| 2139 | EOF |
| 2140 | echo B |
| 2141 | ) & |
| 2142 | ' & |
| 2143 | sleep 2 |
| 2144 | echo Left overs: * |
| 2145 | expected-stdout: |
| 2146 | A |
| 2147 | hi |
| 2148 | B |
| 2149 | Left overs: * |
| 2150 | --- |
| 2151 | name: heredoc-tmpfile-6 |
| 2152 | description: |
| 2153 | Check that heredoc temp files aren't removed too soon or too late. |
| 2154 | Heredoc in pipeline. |
| 2155 | stdin: |
| 2156 | TMPDIR=$PWD |
| 2157 | eval ' |
| 2158 | cat <<- EOF | sed "s/hi/HI/" |
| 2159 | hi |
| 2160 | EOF |
| 2161 | ' & |
| 2162 | sleep 1 |
| 2163 | echo Left overs: * |
| 2164 | expected-stdout: |
| 2165 | HI |
| 2166 | Left overs: * |
| 2167 | --- |
| 2168 | name: heredoc-tmpfile-7 |
| 2169 | description: |
| 2170 | Check that heredoc temp files aren't removed too soon or too late. |
| 2171 | Heredoc in backgrounded pipeline. |
| 2172 | stdin: |
| 2173 | TMPDIR=$PWD |
| 2174 | eval ' |
| 2175 | cat <<- EOF | sed 's/hi/HI/' & |
| 2176 | hi |
| 2177 | EOF |
| 2178 | ' & |
| 2179 | sleep 1 |
| 2180 | echo Left overs: * |
| 2181 | expected-stdout: |
| 2182 | HI |
| 2183 | Left overs: * |
| 2184 | --- |
| 2185 | name: heredoc-tmpfile-8 |
| 2186 | description: |
| 2187 | Check that heredoc temp files aren't removed too soon or too |
| 2188 | late. Heredoc in function, backgrounded call to function. |
| 2189 | This check can fail on slow machines (<100 MHz), or Cygwin, |
| 2190 | that's normal. |
| 2191 | stdin: |
| 2192 | TMPDIR=$PWD |
| 2193 | # Background eval so main shell doesn't do parsing |
| 2194 | eval ' |
| 2195 | foo() { |
| 2196 | cat <<- EOF |
| 2197 | hi |
| 2198 | EOF |
| 2199 | } |
| 2200 | foo |
| 2201 | # sleep so eval can die |
| 2202 | (sleep 1; foo) & |
| 2203 | (sleep 1; foo) & |
| 2204 | foo |
| 2205 | ' & |
| 2206 | sleep 2 |
| 2207 | echo Left overs: * |
| 2208 | expected-stdout: |
| 2209 | hi |
| 2210 | hi |
| 2211 | hi |
| 2212 | hi |
| 2213 | Left overs: * |
| 2214 | --- |
| 2215 | name: history-basic |
| 2216 | description: |
| 2217 | See if we can test history at all |
| 2218 | arguments: !-i! |
| 2219 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 2220 | file-setup: file 644 "Env" |
| 2221 | PS1=X |
| 2222 | stdin: |
| 2223 | echo hi |
| 2224 | fc -l |
| 2225 | expected-stdout: |
| 2226 | hi |
| 2227 | 1 echo hi |
| 2228 | expected-stderr-pattern: |
| 2229 | /^X*$/ |
| 2230 | --- |
| 2231 | name: history-dups |
| 2232 | description: |
| 2233 | Verify duplicates and spaces are not entered |
| 2234 | arguments: !-i! |
| 2235 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 2236 | file-setup: file 644 "Env" |
| 2237 | PS1=X |
| 2238 | stdin: |
| 2239 | echo hi |
| 2240 | echo yo |
| 2241 | echo hi |
| 2242 | fc -l |
| 2243 | expected-stdout: |
| 2244 | hi |
| 2245 | yo |
| 2246 | hi |
| 2247 | 1 echo hi |
| 2248 | expected-stderr-pattern: |
| 2249 | /^X*$/ |
| 2250 | --- |
| 2251 | name: history-unlink |
| 2252 | description: |
| 2253 | Check if broken HISTFILEs do not cause trouble |
| 2254 | arguments: !-i! |
| 2255 | env-setup: !ENV=./Env!HISTFILE=foo/hist.file! |
| 2256 | file-setup: file 644 "Env" |
| 2257 | PS1=X |
| 2258 | file-setup: dir 755 "foo" |
| 2259 | file-setup: file 644 "foo/hist.file" |
| 2260 | sometext |
| 2261 | time-limit: 5 |
| 2262 | perl-setup: chmod(0555, "foo"); |
| 2263 | stdin: |
| 2264 | echo hi |
| 2265 | fc -l |
| 2266 | chmod 0755 foo |
| 2267 | expected-stdout: |
| 2268 | hi |
| 2269 | 1 echo hi |
| 2270 | expected-stderr-pattern: |
| 2271 | /(.*cannot unlink HISTFILE.*\n)?X*$/ |
| 2272 | --- |
| 2273 | name: history-e-minus-1 |
| 2274 | description: |
| 2275 | Check if more recent command is executed |
| 2276 | arguments: !-i! |
| 2277 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 2278 | file-setup: file 644 "Env" |
| 2279 | PS1=X |
| 2280 | stdin: |
| 2281 | echo hi |
| 2282 | echo there |
| 2283 | fc -e - |
| 2284 | expected-stdout: |
| 2285 | hi |
| 2286 | there |
| 2287 | there |
| 2288 | expected-stderr-pattern: |
| 2289 | /^X*echo there\nX*$/ |
| 2290 | --- |
| 2291 | name: history-e-minus-2 |
| 2292 | description: |
| 2293 | Check that repeated command is printed before command |
| 2294 | is re-executed. |
| 2295 | arguments: !-i! |
| 2296 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 2297 | file-setup: file 644 "Env" |
| 2298 | PS1=X |
| 2299 | stdin: |
| 2300 | exec 2>&1 |
| 2301 | echo hi |
| 2302 | echo there |
| 2303 | fc -e - |
| 2304 | expected-stdout-pattern: |
| 2305 | /X*hi\nX*there\nX*echo there\nthere\nX*/ |
| 2306 | expected-stderr-pattern: |
| 2307 | /^X*$/ |
| 2308 | --- |
| 2309 | name: history-e-minus-3 |
| 2310 | description: |
| 2311 | fc -e - fails when there is no history |
| 2312 | (ksh93 has a bug that causes this to fail) |
| 2313 | (ksh88 loops on this) |
| 2314 | arguments: !-i! |
| 2315 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 2316 | file-setup: file 644 "Env" |
| 2317 | PS1=X |
| 2318 | stdin: |
| 2319 | fc -e - |
| 2320 | echo ok |
| 2321 | expected-stdout: |
| 2322 | ok |
| 2323 | expected-stderr-pattern: |
| 2324 | /^X*.*:.*history.*\nX*$/ |
| 2325 | --- |
| 2326 | name: history-e-minus-4 |
| 2327 | description: |
| 2328 | Check if "fc -e -" command output goes to stdout. |
| 2329 | arguments: !-i! |
| 2330 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 2331 | file-setup: file 644 "Env" |
| 2332 | PS1=X |
| 2333 | stdin: |
| 2334 | echo abc |
| 2335 | fc -e - | (read x; echo "A $x") |
| 2336 | echo ok |
| 2337 | expected-stdout: |
| 2338 | abc |
| 2339 | A abc |
| 2340 | ok |
| 2341 | expected-stderr-pattern: |
| 2342 | /^X*echo abc\nX*/ |
| 2343 | --- |
| 2344 | name: history-e-minus-5 |
| 2345 | description: |
| 2346 | fc is replaced in history by new command. |
| 2347 | arguments: !-i! |
| 2348 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 2349 | file-setup: file 644 "Env" |
| 2350 | PS1=X |
| 2351 | stdin: |
| 2352 | echo abc def |
| 2353 | echo ghi jkl |
| 2354 | : |
| 2355 | fc -e - echo |
| 2356 | fc -l 2 5 |
| 2357 | expected-stdout: |
| 2358 | abc def |
| 2359 | ghi jkl |
| 2360 | ghi jkl |
| 2361 | 2 echo ghi jkl |
| 2362 | 3 : |
| 2363 | 4 echo ghi jkl |
| 2364 | 5 fc -l 2 5 |
| 2365 | expected-stderr-pattern: |
| 2366 | /^X*echo ghi jkl\nX*$/ |
| 2367 | --- |
| 2368 | name: history-list-1 |
| 2369 | description: |
| 2370 | List lists correct range |
| 2371 | (ksh88 fails 'cause it lists the fc command) |
| 2372 | arguments: !-i! |
| 2373 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 2374 | file-setup: file 644 "Env" |
| 2375 | PS1=X |
| 2376 | stdin: |
| 2377 | echo line 1 |
| 2378 | echo line 2 |
| 2379 | echo line 3 |
| 2380 | fc -l -- -2 |
| 2381 | expected-stdout: |
| 2382 | line 1 |
| 2383 | line 2 |
| 2384 | line 3 |
| 2385 | 2 echo line 2 |
| 2386 | 3 echo line 3 |
| 2387 | expected-stderr-pattern: |
| 2388 | /^X*$/ |
| 2389 | --- |
| 2390 | name: history-list-2 |
| 2391 | description: |
| 2392 | Lists oldest history if given pre-historic number |
| 2393 | (ksh93 has a bug that causes this to fail) |
| 2394 | (ksh88 fails 'cause it lists the fc command) |
| 2395 | arguments: !-i! |
| 2396 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 2397 | file-setup: file 644 "Env" |
| 2398 | PS1=X |
| 2399 | stdin: |
| 2400 | echo line 1 |
| 2401 | echo line 2 |
| 2402 | echo line 3 |
| 2403 | fc -l -- -40 |
| 2404 | expected-stdout: |
| 2405 | line 1 |
| 2406 | line 2 |
| 2407 | line 3 |
| 2408 | 1 echo line 1 |
| 2409 | 2 echo line 2 |
| 2410 | 3 echo line 3 |
| 2411 | expected-stderr-pattern: |
| 2412 | /^X*$/ |
| 2413 | --- |
| 2414 | name: history-list-3 |
| 2415 | description: |
| 2416 | Can give number 'options' to fc |
| 2417 | arguments: !-i! |
| 2418 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 2419 | file-setup: file 644 "Env" |
| 2420 | PS1=X |
| 2421 | stdin: |
| 2422 | echo line 1 |
| 2423 | echo line 2 |
| 2424 | echo line 3 |
| 2425 | echo line 4 |
| 2426 | fc -l -3 -2 |
| 2427 | expected-stdout: |
| 2428 | line 1 |
| 2429 | line 2 |
| 2430 | line 3 |
| 2431 | line 4 |
| 2432 | 2 echo line 2 |
| 2433 | 3 echo line 3 |
| 2434 | expected-stderr-pattern: |
| 2435 | /^X*$/ |
| 2436 | --- |
| 2437 | name: history-list-4 |
| 2438 | description: |
| 2439 | -1 refers to previous command |
| 2440 | arguments: !-i! |
| 2441 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 2442 | file-setup: file 644 "Env" |
| 2443 | PS1=X |
| 2444 | stdin: |
| 2445 | echo line 1 |
| 2446 | echo line 2 |
| 2447 | echo line 3 |
| 2448 | echo line 4 |
| 2449 | fc -l -1 -1 |
| 2450 | expected-stdout: |
| 2451 | line 1 |
| 2452 | line 2 |
| 2453 | line 3 |
| 2454 | line 4 |
| 2455 | 4 echo line 4 |
| 2456 | expected-stderr-pattern: |
| 2457 | /^X*$/ |
| 2458 | --- |
| 2459 | name: history-list-5 |
| 2460 | description: |
| 2461 | List command stays in history |
| 2462 | arguments: !-i! |
| 2463 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 2464 | file-setup: file 644 "Env" |
| 2465 | PS1=X |
| 2466 | stdin: |
| 2467 | echo line 1 |
| 2468 | echo line 2 |
| 2469 | echo line 3 |
| 2470 | echo line 4 |
| 2471 | fc -l -1 -1 |
| 2472 | fc -l -2 -1 |
| 2473 | expected-stdout: |
| 2474 | line 1 |
| 2475 | line 2 |
| 2476 | line 3 |
| 2477 | line 4 |
| 2478 | 4 echo line 4 |
| 2479 | 4 echo line 4 |
| 2480 | 5 fc -l -1 -1 |
| 2481 | expected-stderr-pattern: |
| 2482 | /^X*$/ |
| 2483 | --- |
| 2484 | name: history-list-6 |
| 2485 | description: |
| 2486 | HISTSIZE limits about of history kept. |
| 2487 | (ksh88 fails 'cause it lists the fc command) |
| 2488 | arguments: !-i! |
| 2489 | env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3! |
| 2490 | file-setup: file 644 "Env" |
| 2491 | PS1=X |
| 2492 | stdin: |
| 2493 | echo line 1 |
| 2494 | echo line 2 |
| 2495 | echo line 3 |
| 2496 | echo line 4 |
| 2497 | echo line 5 |
| 2498 | fc -l |
| 2499 | expected-stdout: |
| 2500 | line 1 |
| 2501 | line 2 |
| 2502 | line 3 |
| 2503 | line 4 |
| 2504 | line 5 |
| 2505 | 4 echo line 4 |
| 2506 | 5 echo line 5 |
| 2507 | expected-stderr-pattern: |
| 2508 | /^X*$/ |
| 2509 | --- |
| 2510 | name: history-list-7 |
| 2511 | description: |
| 2512 | fc allows too old/new errors in range specification |
| 2513 | arguments: !-i! |
| 2514 | env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3! |
| 2515 | file-setup: file 644 "Env" |
| 2516 | PS1=X |
| 2517 | stdin: |
| 2518 | echo line 1 |
| 2519 | echo line 2 |
| 2520 | echo line 3 |
| 2521 | echo line 4 |
| 2522 | echo line 5 |
| 2523 | fc -l 1 30 |
| 2524 | expected-stdout: |
| 2525 | line 1 |
| 2526 | line 2 |
| 2527 | line 3 |
| 2528 | line 4 |
| 2529 | line 5 |
| 2530 | 4 echo line 4 |
| 2531 | 5 echo line 5 |
| 2532 | 6 fc -l 1 30 |
| 2533 | expected-stderr-pattern: |
| 2534 | /^X*$/ |
| 2535 | --- |
| 2536 | name: history-list-r-1 |
| 2537 | description: |
| 2538 | test -r flag in history |
| 2539 | arguments: !-i! |
| 2540 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 2541 | file-setup: file 644 "Env" |
| 2542 | PS1=X |
| 2543 | stdin: |
| 2544 | echo line 1 |
| 2545 | echo line 2 |
| 2546 | echo line 3 |
| 2547 | echo line 4 |
| 2548 | echo line 5 |
| 2549 | fc -l -r 2 4 |
| 2550 | expected-stdout: |
| 2551 | line 1 |
| 2552 | line 2 |
| 2553 | line 3 |
| 2554 | line 4 |
| 2555 | line 5 |
| 2556 | 4 echo line 4 |
| 2557 | 3 echo line 3 |
| 2558 | 2 echo line 2 |
| 2559 | expected-stderr-pattern: |
| 2560 | /^X*$/ |
| 2561 | --- |
| 2562 | name: history-list-r-2 |
| 2563 | description: |
| 2564 | If first is newer than last, -r is implied. |
| 2565 | arguments: !-i! |
| 2566 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 2567 | file-setup: file 644 "Env" |
| 2568 | PS1=X |
| 2569 | stdin: |
| 2570 | echo line 1 |
| 2571 | echo line 2 |
| 2572 | echo line 3 |
| 2573 | echo line 4 |
| 2574 | echo line 5 |
| 2575 | fc -l 4 2 |
| 2576 | expected-stdout: |
| 2577 | line 1 |
| 2578 | line 2 |
| 2579 | line 3 |
| 2580 | line 4 |
| 2581 | line 5 |
| 2582 | 4 echo line 4 |
| 2583 | 3 echo line 3 |
| 2584 | 2 echo line 2 |
| 2585 | expected-stderr-pattern: |
| 2586 | /^X*$/ |
| 2587 | --- |
| 2588 | name: history-list-r-3 |
| 2589 | description: |
| 2590 | If first is newer than last, -r is cancelled. |
| 2591 | arguments: !-i! |
| 2592 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 2593 | file-setup: file 644 "Env" |
| 2594 | PS1=X |
| 2595 | stdin: |
| 2596 | echo line 1 |
| 2597 | echo line 2 |
| 2598 | echo line 3 |
| 2599 | echo line 4 |
| 2600 | echo line 5 |
| 2601 | fc -l -r 4 2 |
| 2602 | expected-stdout: |
| 2603 | line 1 |
| 2604 | line 2 |
| 2605 | line 3 |
| 2606 | line 4 |
| 2607 | line 5 |
| 2608 | 2 echo line 2 |
| 2609 | 3 echo line 3 |
| 2610 | 4 echo line 4 |
| 2611 | expected-stderr-pattern: |
| 2612 | /^X*$/ |
| 2613 | --- |
| 2614 | name: history-subst-1 |
| 2615 | description: |
| 2616 | Basic substitution |
| 2617 | arguments: !-i! |
| 2618 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 2619 | file-setup: file 644 "Env" |
| 2620 | PS1=X |
| 2621 | stdin: |
| 2622 | echo abc def |
| 2623 | echo ghi jkl |
| 2624 | fc -e - abc=AB 'echo a' |
| 2625 | expected-stdout: |
| 2626 | abc def |
| 2627 | ghi jkl |
| 2628 | AB def |
| 2629 | expected-stderr-pattern: |
| 2630 | /^X*echo AB def\nX*$/ |
| 2631 | --- |
| 2632 | name: history-subst-2 |
| 2633 | description: |
| 2634 | Does subst find previous command? |
| 2635 | arguments: !-i! |
| 2636 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 2637 | file-setup: file 644 "Env" |
| 2638 | PS1=X |
| 2639 | stdin: |
| 2640 | echo abc def |
| 2641 | echo ghi jkl |
| 2642 | fc -e - jkl=XYZQRT 'echo g' |
| 2643 | expected-stdout: |
| 2644 | abc def |
| 2645 | ghi jkl |
| 2646 | ghi XYZQRT |
| 2647 | expected-stderr-pattern: |
| 2648 | /^X*echo ghi XYZQRT\nX*$/ |
| 2649 | --- |
| 2650 | name: history-subst-3 |
| 2651 | description: |
| 2652 | Does subst find previous command when no arguments given |
| 2653 | arguments: !-i! |
| 2654 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 2655 | file-setup: file 644 "Env" |
| 2656 | PS1=X |
| 2657 | stdin: |
| 2658 | echo abc def |
| 2659 | echo ghi jkl |
| 2660 | fc -e - jkl=XYZQRT |
| 2661 | expected-stdout: |
| 2662 | abc def |
| 2663 | ghi jkl |
| 2664 | ghi XYZQRT |
| 2665 | expected-stderr-pattern: |
| 2666 | /^X*echo ghi XYZQRT\nX*$/ |
| 2667 | --- |
| 2668 | name: history-subst-4 |
| 2669 | description: |
| 2670 | Global substitutions work |
| 2671 | (ksh88 and ksh93 do not have -g option) |
| 2672 | arguments: !-i! |
| 2673 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 2674 | file-setup: file 644 "Env" |
| 2675 | PS1=X |
| 2676 | stdin: |
| 2677 | echo abc def asjj sadjhasdjh asdjhasd |
| 2678 | fc -e - -g a=FooBAR |
| 2679 | expected-stdout: |
| 2680 | abc def asjj sadjhasdjh asdjhasd |
| 2681 | FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd |
| 2682 | expected-stderr-pattern: |
| 2683 | /^X*echo FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd\nX*$/ |
| 2684 | --- |
| 2685 | name: history-subst-5 |
| 2686 | description: |
| 2687 | Make sure searches don't find current (fc) command |
| 2688 | (ksh88/ksh93 don't have the ? prefix thing so they fail this test) |
| 2689 | arguments: !-i! |
| 2690 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 2691 | file-setup: file 644 "Env" |
| 2692 | PS1=X |
| 2693 | stdin: |
| 2694 | echo abc def |
| 2695 | echo ghi jkl |
| 2696 | fc -e - abc=AB \?abc |
| 2697 | expected-stdout: |
| 2698 | abc def |
| 2699 | ghi jkl |
| 2700 | AB def |
| 2701 | expected-stderr-pattern: |
| 2702 | /^X*echo AB def\nX*$/ |
| 2703 | --- |
| 2704 | name: history-ed-1-old |
| 2705 | description: |
| 2706 | Basic (ed) editing works (assumes you have generic ed editor |
| 2707 | that prints no prompts). This is for oldish ed(1) which write |
| 2708 | the character count to stdout. |
| 2709 | category: stdout-ed |
| 2710 | arguments: !-i! |
| 2711 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 2712 | file-setup: file 644 "Env" |
| 2713 | PS1=X |
| 2714 | stdin: |
| 2715 | echo abc def |
| 2716 | fc echo |
| 2717 | s/abc/FOOBAR/ |
| 2718 | w |
| 2719 | q |
| 2720 | expected-stdout: |
| 2721 | abc def |
| 2722 | 13 |
| 2723 | 16 |
| 2724 | FOOBAR def |
| 2725 | expected-stderr-pattern: |
| 2726 | /^X*echo FOOBAR def\nX*$/ |
| 2727 | --- |
| 2728 | name: history-ed-2-old |
| 2729 | description: |
| 2730 | Correct command is edited when number given |
| 2731 | category: stdout-ed |
| 2732 | arguments: !-i! |
| 2733 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 2734 | file-setup: file 644 "Env" |
| 2735 | PS1=X |
| 2736 | stdin: |
| 2737 | echo line 1 |
| 2738 | echo line 2 is here |
| 2739 | echo line 3 |
| 2740 | echo line 4 |
| 2741 | fc 2 |
| 2742 | s/is here/is changed/ |
| 2743 | w |
| 2744 | q |
| 2745 | expected-stdout: |
| 2746 | line 1 |
| 2747 | line 2 is here |
| 2748 | line 3 |
| 2749 | line 4 |
| 2750 | 20 |
| 2751 | 23 |
| 2752 | line 2 is changed |
| 2753 | expected-stderr-pattern: |
| 2754 | /^X*echo line 2 is changed\nX*$/ |
| 2755 | --- |
| 2756 | name: history-ed-3-old |
| 2757 | description: |
| 2758 | Newly created multi line commands show up as single command |
| 2759 | in history. |
| 2760 | (NOTE: adjusted for COMPLEX HISTORY compile time option) |
| 2761 | (ksh88 fails 'cause it lists the fc command) |
| 2762 | category: stdout-ed |
| 2763 | arguments: !-i! |
| 2764 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 2765 | file-setup: file 644 "Env" |
| 2766 | PS1=X |
| 2767 | stdin: |
| 2768 | echo abc def |
| 2769 | fc echo |
| 2770 | s/abc/FOOBAR/ |
| 2771 | $a |
| 2772 | echo a new line |
| 2773 | . |
| 2774 | w |
| 2775 | q |
| 2776 | fc -l |
| 2777 | expected-stdout: |
| 2778 | abc def |
| 2779 | 13 |
| 2780 | 32 |
| 2781 | FOOBAR def |
| 2782 | a new line |
| 2783 | 1 echo abc def |
| 2784 | 2 echo FOOBAR def |
| 2785 | 3 echo a new line |
| 2786 | expected-stderr-pattern: |
| 2787 | /^X*echo FOOBAR def\necho a new line\nX*$/ |
| 2788 | --- |
| 2789 | name: history-ed-1 |
| 2790 | description: |
| 2791 | Basic (ed) editing works (assumes you have generic ed editor |
| 2792 | that prints no prompts). This is for newish ed(1) and stderr. |
| 2793 | category: !no-stderr-ed |
| 2794 | arguments: !-i! |
| 2795 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 2796 | file-setup: file 644 "Env" |
| 2797 | PS1=X |
| 2798 | stdin: |
| 2799 | echo abc def |
| 2800 | fc echo |
| 2801 | s/abc/FOOBAR/ |
| 2802 | w |
| 2803 | q |
| 2804 | expected-stdout: |
| 2805 | abc def |
| 2806 | FOOBAR def |
| 2807 | expected-stderr-pattern: |
| 2808 | /^X*13\n16\necho FOOBAR def\nX*$/ |
| 2809 | --- |
| 2810 | name: history-ed-2 |
| 2811 | description: |
| 2812 | Correct command is edited when number given |
| 2813 | category: !no-stderr-ed |
| 2814 | arguments: !-i! |
| 2815 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 2816 | file-setup: file 644 "Env" |
| 2817 | PS1=X |
| 2818 | stdin: |
| 2819 | echo line 1 |
| 2820 | echo line 2 is here |
| 2821 | echo line 3 |
| 2822 | echo line 4 |
| 2823 | fc 2 |
| 2824 | s/is here/is changed/ |
| 2825 | w |
| 2826 | q |
| 2827 | expected-stdout: |
| 2828 | line 1 |
| 2829 | line 2 is here |
| 2830 | line 3 |
| 2831 | line 4 |
| 2832 | line 2 is changed |
| 2833 | expected-stderr-pattern: |
| 2834 | /^X*20\n23\necho line 2 is changed\nX*$/ |
| 2835 | --- |
| 2836 | name: history-ed-3 |
| 2837 | description: |
| 2838 | Newly created multi line commands show up as single command |
| 2839 | in history. |
| 2840 | category: !no-stderr-ed |
| 2841 | arguments: !-i! |
| 2842 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 2843 | file-setup: file 644 "Env" |
| 2844 | PS1=X |
| 2845 | stdin: |
| 2846 | echo abc def |
| 2847 | fc echo |
| 2848 | s/abc/FOOBAR/ |
| 2849 | $a |
| 2850 | echo a new line |
| 2851 | . |
| 2852 | w |
| 2853 | q |
| 2854 | fc -l |
| 2855 | expected-stdout: |
| 2856 | abc def |
| 2857 | FOOBAR def |
| 2858 | a new line |
| 2859 | 1 echo abc def |
| 2860 | 2 echo FOOBAR def |
| 2861 | 3 echo a new line |
| 2862 | expected-stderr-pattern: |
| 2863 | /^X*13\n32\necho FOOBAR def\necho a new line\nX*$/ |
| 2864 | --- |
| 2865 | name: IFS-space-1 |
| 2866 | description: |
| 2867 | Simple test, default IFS |
| 2868 | stdin: |
| 2869 | showargs() { for i; do echo -n " <$i>"; done; echo; } |
| 2870 | set -- A B C |
| 2871 | showargs 1 $* |
| 2872 | showargs 2 "$*" |
| 2873 | showargs 3 $@ |
| 2874 | showargs 4 "$@" |
| 2875 | expected-stdout: |
| 2876 | <1> <A> <B> <C> |
| 2877 | <2> <A B C> |
| 2878 | <3> <A> <B> <C> |
| 2879 | <4> <A> <B> <C> |
| 2880 | --- |
| 2881 | name: IFS-colon-1 |
| 2882 | description: |
| 2883 | Simple test, IFS=: |
| 2884 | stdin: |
| 2885 | showargs() { for i; do echo -n " <$i>"; done; echo; } |
| 2886 | IFS=: |
| 2887 | set -- A B C |
| 2888 | showargs 1 $* |
| 2889 | showargs 2 "$*" |
| 2890 | showargs 3 $@ |
| 2891 | showargs 4 "$@" |
| 2892 | expected-stdout: |
| 2893 | <1> <A> <B> <C> |
| 2894 | <2> <A:B:C> |
| 2895 | <3> <A> <B> <C> |
| 2896 | <4> <A> <B> <C> |
| 2897 | --- |
| 2898 | name: IFS-null-1 |
| 2899 | description: |
| 2900 | Simple test, IFS="" |
| 2901 | stdin: |
| 2902 | showargs() { for i; do echo -n " <$i>"; done; echo; } |
| 2903 | IFS="" |
| 2904 | set -- A B C |
| 2905 | showargs 1 $* |
| 2906 | showargs 2 "$*" |
| 2907 | showargs 3 $@ |
| 2908 | showargs 4 "$@" |
| 2909 | expected-stdout: |
| 2910 | <1> <A B C> |
| 2911 | <2> <ABC> |
| 2912 | <3> <A B C> |
| 2913 | <4> <A B C> |
| 2914 | --- |
| 2915 | name: IFS-space-colon-1 |
| 2916 | description: |
| 2917 | Simple test, IFS=<white-space>: |
| 2918 | stdin: |
| 2919 | showargs() { for i; do echo -n " <$i>"; done; echo; } |
| 2920 | IFS="$IFS:" |
| 2921 | set -- |
| 2922 | showargs 1 $* |
| 2923 | showargs 2 "$*" |
| 2924 | showargs 3 $@ |
| 2925 | showargs 4 "$@" |
| 2926 | showargs 5 : "$@" |
| 2927 | expected-stdout: |
| 2928 | <1> |
| 2929 | <2> <> |
| 2930 | <3> |
| 2931 | <4> |
| 2932 | <5> <:> |
| 2933 | --- |
| 2934 | name: IFS-space-colon-2 |
| 2935 | description: |
| 2936 | Simple test, IFS=<white-space>: |
| 2937 | AT&T ksh fails this, POSIX says the test is correct. |
| 2938 | stdin: |
| 2939 | showargs() { for i; do echo -n " <$i>"; done; echo; } |
| 2940 | IFS="$IFS:" |
| 2941 | set -- |
| 2942 | showargs :"$@" |
| 2943 | expected-stdout: |
| 2944 | <:> |
| 2945 | --- |
| 2946 | name: IFS-space-colon-3 |
| 2947 | description: |
| 2948 | Simple test, IFS=<white-space>: |
| 2949 | pdksh fails both of these tests |
| 2950 | not sure whether #2 is correct |
| 2951 | stdin: |
| 2952 | showargs() { for i; do echo -n " <$i>"; done; echo; } |
| 2953 | IFS="$IFS:" |
| 2954 | x= |
| 2955 | set -- |
| 2956 | showargs "$x$@" 1 |
| 2957 | showargs "$@$x" 2 |
| 2958 | expected-fail: yes |
| 2959 | expected-stdout: |
| 2960 | <> <1> |
| 2961 | <> <2> |
| 2962 | --- |
| 2963 | name: IFS-space-colon-4 |
| 2964 | description: |
| 2965 | Simple test, IFS=<white-space>: |
| 2966 | stdin: |
| 2967 | showargs() { for i; do echo -n " <$i>"; done; echo; } |
| 2968 | IFS="$IFS:" |
| 2969 | set -- |
| 2970 | showargs "$@$@" |
| 2971 | expected-stdout: |
| 2972 | |
| 2973 | --- |
| 2974 | name: IFS-space-colon-5 |
| 2975 | description: |
| 2976 | Simple test, IFS=<white-space>: |
| 2977 | Don't know what POSIX thinks of this. AT&T ksh does not do this. |
| 2978 | stdin: |
| 2979 | showargs() { for i; do echo -n " <$i>"; done; echo; } |
| 2980 | IFS="$IFS:" |
| 2981 | set -- |
| 2982 | showargs "${@:-}" |
| 2983 | expected-stdout: |
| 2984 | <> |
| 2985 | --- |
| 2986 | name: IFS-subst-1 |
| 2987 | description: |
| 2988 | Simple test, IFS=<white-space>: |
| 2989 | stdin: |
| 2990 | showargs() { for i; do echo -n " <$i>"; done; echo; } |
| 2991 | IFS="$IFS:" |
| 2992 | x=":b: :" |
| 2993 | echo -n '1:'; for i in $x ; do echo -n " [$i]" ; done ; echo |
| 2994 | echo -n '2:'; for i in :b:: ; do echo -n " [$i]" ; done ; echo |
| 2995 | showargs 3 $x |
| 2996 | showargs 4 :b:: |
| 2997 | x="a:b:" |
| 2998 | echo -n '5:'; for i in $x ; do echo -n " [$i]" ; done ; echo |
| 2999 | showargs 6 $x |
| 3000 | x="a::c" |
| 3001 | echo -n '7:'; for i in $x ; do echo -n " [$i]" ; done ; echo |
| 3002 | showargs 8 $x |
| 3003 | echo -n '9:'; for i in ${FOO-`echo -n h:i`th:ere} ; do echo -n " [$i]" ; done ; echo |
| 3004 | showargs 10 ${FOO-`echo -n h:i`th:ere} |
| 3005 | showargs 11 "${FOO-`echo -n h:i`th:ere}" |
| 3006 | x=" A : B::D" |
| 3007 | echo -n '12:'; for i in $x ; do echo -n " [$i]" ; done ; echo |
| 3008 | showargs 13 $x |
| 3009 | expected-stdout: |
| 3010 | 1: [] [b] [] |
| 3011 | 2: [:b::] |
| 3012 | <3> <> <b> <> |
| 3013 | <4> <:b::> |
| 3014 | 5: [a] [b] |
| 3015 | <6> <a> <b> |
| 3016 | 7: [a] [] [c] |
| 3017 | <8> <a> <> <c> |
| 3018 | 9: [h] [ith] [ere] |
| 3019 | <10> <h> <ith> <ere> |
| 3020 | <11> <h:ith:ere> |
| 3021 | 12: [A] [B] [] [D] |
| 3022 | <13> <A> <B> <> <D> |
| 3023 | --- |
| 3024 | name: integer-base-err-1 |
| 3025 | description: |
| 3026 | Can't have 0 base (causes shell to exit) |
| 3027 | expected-exit: e != 0 |
| 3028 | stdin: |
| 3029 | typeset -i i |
| 3030 | i=3 |
| 3031 | i=0#4 |
| 3032 | echo $i |
| 3033 | expected-stderr-pattern: |
| 3034 | /^.*:.*0#4.*\n$/ |
| 3035 | --- |
| 3036 | name: integer-base-err-2 |
| 3037 | description: |
| 3038 | Can't have multiple bases in a 'constant' (causes shell to exit) |
| 3039 | (ksh88 fails this test) |
| 3040 | expected-exit: e != 0 |
| 3041 | stdin: |
| 3042 | typeset -i i |
| 3043 | i=3 |
| 3044 | i=2#110#11 |
| 3045 | echo $i |
| 3046 | expected-stderr-pattern: |
| 3047 | /^.*:.*2#110#11.*\n$/ |
| 3048 | --- |
| 3049 | name: integer-base-err-3 |
| 3050 | description: |
| 3051 | Syntax errors in expressions and effects on bases |
| 3052 | (interactive so errors don't cause exits) |
| 3053 | (ksh88 fails this test - shell exits, even with -i) |
| 3054 | arguments: !-i! |
| 3055 | stdin: |
| 3056 | PS1= # minimise prompt hassles |
| 3057 | typeset -i4 a=10 |
| 3058 | typeset -i a=2+ |
| 3059 | echo $a |
| 3060 | typeset -i4 a=10 |
| 3061 | typeset -i2 a=2+ |
| 3062 | echo $a |
| 3063 | expected-stderr-pattern: |
| 3064 | /^([#\$] )?.*:.*2+.*\n.*:.*2+.*\n$/ |
| 3065 | expected-stdout: |
| 3066 | 4#22 |
| 3067 | 4#22 |
| 3068 | --- |
| 3069 | name: integer-base-err-4 |
| 3070 | description: |
| 3071 | Are invalid digits (according to base) errors? |
| 3072 | (ksh93 fails this test) |
| 3073 | expected-exit: e != 0 |
| 3074 | stdin: |
| 3075 | typeset -i i; |
| 3076 | i=3#4 |
| 3077 | expected-stderr-pattern: |
| 3078 | /^([#\$] )?.*:.*3#4.*\n$/ |
| 3079 | --- |
| 3080 | name: integer-base-1 |
| 3081 | description: |
| 3082 | Missing number after base is treated as 0. |
| 3083 | stdin: |
| 3084 | typeset -i i |
| 3085 | i=3 |
| 3086 | i=2# |
| 3087 | echo $i |
| 3088 | expected-stdout: |
| 3089 | 0 |
| 3090 | --- |
| 3091 | name: integer-base-2 |
| 3092 | description: |
| 3093 | Check 'stickyness' of base in various situations |
| 3094 | stdin: |
| 3095 | typeset -i i=8 |
| 3096 | echo $i |
| 3097 | echo ---------- A |
| 3098 | typeset -i4 j=8 |
| 3099 | echo $j |
| 3100 | echo ---------- B |
| 3101 | typeset -i k=8 |
| 3102 | typeset -i4 k=8 |
| 3103 | echo $k |
| 3104 | echo ---------- C |
| 3105 | typeset -i4 l |
| 3106 | l=3#10 |
| 3107 | echo $l |
| 3108 | echo ---------- D |
| 3109 | typeset -i m |
| 3110 | m=3#10 |
| 3111 | echo $m |
| 3112 | echo ---------- E |
| 3113 | n=2#11 |
| 3114 | typeset -i n |
| 3115 | echo $n |
| 3116 | n=10 |
| 3117 | echo $n |
| 3118 | echo ---------- F |
| 3119 | typeset -i8 o=12 |
| 3120 | typeset -i4 o |
| 3121 | echo $o |
| 3122 | echo ---------- G |
| 3123 | typeset -i p |
| 3124 | let p=8#12 |
| 3125 | echo $p |
| 3126 | expected-stdout: |
| 3127 | 8 |
| 3128 | ---------- A |
| 3129 | 4#20 |
| 3130 | ---------- B |
| 3131 | 4#20 |
| 3132 | ---------- C |
| 3133 | 4#3 |
| 3134 | ---------- D |
| 3135 | 3#10 |
| 3136 | ---------- E |
| 3137 | 2#11 |
| 3138 | 2#1010 |
| 3139 | ---------- F |
| 3140 | 4#30 |
| 3141 | ---------- G |
| 3142 | 8#12 |
| 3143 | --- |
| 3144 | name: integer-base-3 |
| 3145 | description: |
| 3146 | More base parsing (hmm doesn't test much..) |
| 3147 | stdin: |
| 3148 | typeset -i aa |
| 3149 | aa=1+12#10+2 |
| 3150 | echo $aa |
| 3151 | typeset -i bb |
| 3152 | bb=1+$aa |
| 3153 | echo $bb |
| 3154 | typeset -i bb |
| 3155 | bb=$aa |
| 3156 | echo $bb |
| 3157 | typeset -i cc |
| 3158 | cc=$aa |
| 3159 | echo $cc |
| 3160 | expected-stdout: |
| 3161 | 15 |
| 3162 | 16 |
| 3163 | 15 |
| 3164 | 15 |
| 3165 | --- |
| 3166 | name: integer-base-4 |
| 3167 | description: |
| 3168 | Check that things not declared as integers are not made integers, |
| 3169 | also, check if base is not reset by -i with no arguments. |
| 3170 | (ksh93 fails - prints 10#20 - go figure) |
| 3171 | stdin: |
| 3172 | xx=20 |
| 3173 | let xx=10 |
| 3174 | typeset -i | grep '^xx=' |
| 3175 | typeset -i4 a=10 |
| 3176 | typeset -i a=20 |
| 3177 | echo $a |
| 3178 | expected-stdout: |
| 3179 | 4#110 |
| 3180 | --- |
| 3181 | name: integer-base-5 |
| 3182 | description: |
| 3183 | More base stuff |
| 3184 | stdin: |
| 3185 | typeset -i4 a=3#10 |
| 3186 | echo $a |
| 3187 | echo -- |
| 3188 | typeset -i j=3 |
| 3189 | j='~3' |
| 3190 | echo $j |
| 3191 | echo -- |
| 3192 | typeset -i k=1 |
| 3193 | x[k=k+1]=3 |
| 3194 | echo $k |
| 3195 | echo -- |
| 3196 | typeset -i l |
| 3197 | for l in 1 2+3 4; do echo $l; done |
| 3198 | expected-stdout: |
| 3199 | 4#3 |
| 3200 | -- |
| 3201 | -4 |
| 3202 | -- |
| 3203 | 2 |
| 3204 | -- |
| 3205 | 1 |
| 3206 | 5 |
| 3207 | 4 |
| 3208 | --- |
| 3209 | name: integer-base-6 |
| 3210 | description: |
| 3211 | Even more base stuff |
| 3212 | (ksh93 fails this test - prints 0) |
| 3213 | stdin: |
| 3214 | typeset -i7 i |
| 3215 | i= |
| 3216 | echo $i |
| 3217 | expected-stdout: |
| 3218 | 7#0 |
| 3219 | --- |
| 3220 | name: integer-base-7 |
| 3221 | description: |
| 3222 | Check that non-integer parameters don't get bases assigned |
| 3223 | stdin: |
| 3224 | echo $(( zz = 8#100 )) |
| 3225 | echo $zz |
| 3226 | expected-stdout: |
| 3227 | 64 |
| 3228 | 64 |
| 3229 | --- |
| 3230 | name: lineno-stdin |
| 3231 | description: |
| 3232 | See if $LINENO is updated and can be modified. |
| 3233 | stdin: |
| 3234 | echo A $LINENO |
| 3235 | echo B $LINENO |
| 3236 | LINENO=20 |
| 3237 | echo C $LINENO |
| 3238 | expected-stdout: |
| 3239 | A 1 |
| 3240 | B 2 |
| 3241 | C 20 |
| 3242 | --- |
| 3243 | name: lineno-inc |
| 3244 | description: |
| 3245 | See if $LINENO is set for .'d files. |
| 3246 | file-setup: file 644 "dotfile" |
| 3247 | echo dot A $LINENO |
| 3248 | echo dot B $LINENO |
| 3249 | LINENO=20 |
| 3250 | echo dot C $LINENO |
| 3251 | stdin: |
| 3252 | echo A $LINENO |
| 3253 | echo B $LINENO |
| 3254 | . ./dotfile |
| 3255 | expected-stdout: |
| 3256 | A 1 |
| 3257 | B 2 |
| 3258 | dot A 1 |
| 3259 | dot B 2 |
| 3260 | dot C 20 |
| 3261 | --- |
| 3262 | name: lineno-func |
| 3263 | description: |
| 3264 | See if $LINENO is set for commands in a function. |
| 3265 | stdin: |
| 3266 | echo A $LINENO |
| 3267 | echo B $LINENO |
| 3268 | bar() { |
| 3269 | echo func A $LINENO |
| 3270 | echo func B $LINENO |
| 3271 | } |
| 3272 | bar |
| 3273 | echo C $LINENO |
| 3274 | expected-stdout: |
| 3275 | A 1 |
| 3276 | B 2 |
| 3277 | func A 4 |
| 3278 | func B 5 |
| 3279 | C 8 |
| 3280 | --- |
| 3281 | name: lineno-unset |
| 3282 | description: |
| 3283 | See if unsetting LINENO makes it non-magic. |
| 3284 | file-setup: file 644 "dotfile" |
| 3285 | echo dot A $LINENO |
| 3286 | echo dot B $LINENO |
| 3287 | stdin: |
| 3288 | unset LINENO |
| 3289 | echo A $LINENO |
| 3290 | echo B $LINENO |
| 3291 | bar() { |
| 3292 | echo func A $LINENO |
| 3293 | echo func B $LINENO |
| 3294 | } |
| 3295 | bar |
| 3296 | . ./dotfile |
| 3297 | echo C $LINENO |
| 3298 | expected-stdout: |
| 3299 | A |
| 3300 | B |
| 3301 | func A |
| 3302 | func B |
| 3303 | dot A |
| 3304 | dot B |
| 3305 | C |
| 3306 | --- |
| 3307 | name: lineno-unset-use |
| 3308 | description: |
| 3309 | See if unsetting LINENO makes it non-magic even |
| 3310 | when it is re-used. |
| 3311 | file-setup: file 644 "dotfile" |
| 3312 | echo dot A $LINENO |
| 3313 | echo dot B $LINENO |
| 3314 | stdin: |
| 3315 | unset LINENO |
| 3316 | LINENO=3 |
| 3317 | echo A $LINENO |
| 3318 | echo B $LINENO |
| 3319 | bar() { |
| 3320 | echo func A $LINENO |
| 3321 | echo func B $LINENO |
| 3322 | } |
| 3323 | bar |
| 3324 | . ./dotfile |
| 3325 | echo C $LINENO |
| 3326 | expected-stdout: |
| 3327 | A 3 |
| 3328 | B 3 |
| 3329 | func A 3 |
| 3330 | func B 3 |
| 3331 | dot A 3 |
| 3332 | dot B 3 |
| 3333 | C 3 |
| 3334 | --- |
| 3335 | name: lineno-trap |
| 3336 | description: |
| 3337 | Check if LINENO is tracked in traps |
| 3338 | stdin: |
| 3339 | fail() { |
| 3340 | echo "line <$1>" |
| 3341 | exit 1 |
| 3342 | } |
| 3343 | trap 'fail $LINENO' INT ERR |
| 3344 | false |
| 3345 | expected-stdout: |
| 3346 | line <6> |
| 3347 | expected-exit: 1 |
| 3348 | --- |
| 3349 | name: read-IFS-1 |
| 3350 | description: |
| 3351 | Simple test, default IFS |
| 3352 | stdin: |
| 3353 | echo "A B " > IN |
| 3354 | unset x y z |
| 3355 | read x y z < IN |
| 3356 | echo 1: "x[$x] y[$y] z[$z]" |
| 3357 | echo 1a: ${z-z not set} |
| 3358 | read x < IN |
| 3359 | echo 2: "x[$x]" |
| 3360 | expected-stdout: |
| 3361 | 1: x[A] y[B] z[] |
| 3362 | 1a: |
| 3363 | 2: x[A B] |
| 3364 | --- |
| 3365 | name: read-ksh-1 |
| 3366 | description: |
| 3367 | If no var specified, REPLY is used |
| 3368 | stdin: |
| 3369 | echo "abc" > IN |
| 3370 | read < IN |
| 3371 | echo "[$REPLY]"; |
| 3372 | expected-stdout: |
| 3373 | [abc] |
| 3374 | --- |
| 3375 | name: regression-1 |
| 3376 | description: |
| 3377 | Lex array code had problems with this. |
| 3378 | stdin: |
| 3379 | echo foo[ |
| 3380 | n=bar |
| 3381 | echo "hi[ $n ]=1" |
| 3382 | expected-stdout: |
| 3383 | foo[ |
| 3384 | hi[ bar ]=1 |
| 3385 | --- |
| 3386 | name: regression-2 |
| 3387 | description: |
| 3388 | When PATH is set before running a command, the new path is |
| 3389 | not used in doing the path search |
| 3390 | $ echo echo hi > /tmp/q ; chmod a+rx /tmp/q |
| 3391 | $ PATH=/tmp q |
| 3392 | q: not found |
| 3393 | $ |
| 3394 | in comexec() the two lines |
| 3395 | while (*vp != NULL) |
| 3396 | (void) typeset(*vp++, xxx, 0); |
| 3397 | need to be moved out of the switch to before findcom() is |
| 3398 | called - I don't know what this will break. |
| 3399 | stdin: |
| 3400 | : ${PWD:-`pwd 2> /dev/null`} |
| 3401 | : ${PWD:?"PWD not set - can't do test"} |
| 3402 | mkdir Y |
| 3403 | cat > Y/xxxscript << EOF |
| 3404 | #!/bin/sh |
| 3405 | # Need to restore path so echo can be found (some shells don't have |
| 3406 | # it as a built-in) |
| 3407 | PATH=\$OLDPATH |
| 3408 | echo hi |
| 3409 | exit 0 |
| 3410 | EOF |
| 3411 | chmod a+rx Y/xxxscript |
| 3412 | export OLDPATH="$PATH" |
| 3413 | PATH=$PWD/Y xxxscript |
| 3414 | exit $? |
| 3415 | expected-stdout: |
| 3416 | hi |
| 3417 | --- |
| 3418 | name: regression-6 |
| 3419 | description: |
| 3420 | Parsing of $(..) expressions is non-optimal. It is |
| 3421 | impossible to have any parentheses inside the expression. |
| 3422 | I.e., |
| 3423 | $ ksh -c 'echo $(echo \( )' |
| 3424 | no closing quote |
| 3425 | $ ksh -c 'echo $(echo "(" )' |
| 3426 | no closing quote |
| 3427 | $ |
| 3428 | The solution is to hack the parsing clode in lex.c, the |
| 3429 | question is how to hack it: should any parentheses be |
| 3430 | escaped by a backslash, or should recursive parsing be done |
| 3431 | (so quotes could also be used to hide hem). The former is |
| 3432 | easier, the later better... |
| 3433 | stdin: |
| 3434 | echo $(echo \() |
| 3435 | expected-stdout: |
| 3436 | ( |
| 3437 | --- |
| 3438 | name: regression-9 |
| 3439 | description: |
| 3440 | Continue in a for loop does not work right: |
| 3441 | for i in a b c ; do |
| 3442 | if [ $i = b ] ; then |
| 3443 | continue |
| 3444 | fi |
| 3445 | echo $i |
| 3446 | done |
| 3447 | Prints a forever... |
| 3448 | stdin: |
| 3449 | first=yes |
| 3450 | for i in a b c ; do |
| 3451 | if [ $i = b ] ; then |
| 3452 | if [ $first = no ] ; then |
| 3453 | echo 'continue in for loop broken' |
| 3454 | break # hope break isn't broken too :-) |
| 3455 | fi |
| 3456 | first=no |
| 3457 | continue |
| 3458 | fi |
| 3459 | done |
| 3460 | echo bye |
| 3461 | expected-stdout: |
| 3462 | bye |
| 3463 | --- |
| 3464 | name: regression-10 |
| 3465 | description: |
| 3466 | The following: |
| 3467 | set -- `false` |
| 3468 | echo $? |
| 3469 | should print 0 according to POSIX (dash, bash, ksh93, posh) |
| 3470 | but not 0 according to the getopt(1) manual page, ksh88, and |
| 3471 | Bourne sh (such as /bin/sh on Solaris). |
| 3472 | In mksh R39b, we honour POSIX except when -o sh is set. |
| 3473 | stdin: |
| 3474 | showf() { |
| 3475 | [[ -o posix ]]; FPOSIX=$((1-$?)) |
| 3476 | [[ -o sh ]]; FSH=$((1-$?)) |
| 3477 | echo -n "FPOSIX=$FPOSIX FSH=$FSH " |
| 3478 | } |
| 3479 | set +o posix +o sh |
| 3480 | showf |
| 3481 | set -- `false` |
| 3482 | echo rv=$? |
| 3483 | set -o sh |
| 3484 | showf |
| 3485 | set -- `false` |
| 3486 | echo rv=$? |
| 3487 | set -o posix |
| 3488 | showf |
| 3489 | set -- `false` |
| 3490 | echo rv=$? |
| 3491 | expected-stdout: |
| 3492 | FPOSIX=0 FSH=0 rv=0 |
| 3493 | FPOSIX=0 FSH=1 rv=1 |
| 3494 | FPOSIX=1 FSH=0 rv=0 |
| 3495 | --- |
| 3496 | name: regression-11 |
| 3497 | description: |
| 3498 | The following: |
| 3499 | x=/foo/bar/blah |
| 3500 | echo ${x##*/} |
| 3501 | should echo blah but on some machines echos /foo/bar/blah. |
| 3502 | stdin: |
| 3503 | x=/foo/bar/blah |
| 3504 | echo ${x##*/} |
| 3505 | expected-stdout: |
| 3506 | blah |
| 3507 | --- |
| 3508 | name: regression-12 |
| 3509 | description: |
| 3510 | Both of the following echos produce the same output under sh/ksh.att: |
| 3511 | #!/bin/sh |
| 3512 | x="foo bar" |
| 3513 | echo "`echo \"$x\"`" |
| 3514 | echo "`echo "$x"`" |
| 3515 | pdksh produces different output for the former (foo instead of foo\tbar) |
| 3516 | stdin: |
| 3517 | x="foo bar" |
| 3518 | echo "`echo \"$x\"`" |
| 3519 | echo "`echo "$x"`" |
| 3520 | expected-stdout: |
| 3521 | foo bar |
| 3522 | foo bar |
| 3523 | --- |
| 3524 | name: regression-13 |
| 3525 | description: |
| 3526 | The following command hangs forever: |
| 3527 | $ (: ; cat /etc/termcap) | sleep 2 |
| 3528 | This is because the shell forks a shell to run the (..) command |
| 3529 | and this shell has the pipe open. When the sleep dies, the cat |
| 3530 | doesn't get a SIGPIPE 'cause a process (ie, the second shell) |
| 3531 | still has the pipe open. |
| 3532 | |
| 3533 | NOTE: this test provokes a bizarre bug in ksh93 (shell starts reading |
| 3534 | commands from /etc/termcap..) |
| 3535 | time-limit: 10 |
| 3536 | stdin: |
| 3537 | echo A line of text that will be duplicated quite a number of times.> t1 |
| 3538 | cat t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 > t2 |
| 3539 | cat t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 > t1 |
| 3540 | cat t1 t1 t1 t1 > t2 |
| 3541 | (: ; cat t2 2>&-) | sleep 1 |
| 3542 | --- |
| 3543 | name: regression-14 |
| 3544 | description: |
| 3545 | The command |
| 3546 | $ (foobar) 2> /dev/null |
| 3547 | generates no output under /bin/sh, but pdksh produces the error |
| 3548 | foobar: not found |
| 3549 | Also, the command |
| 3550 | $ foobar 2> /dev/null |
| 3551 | generates an error under /bin/sh and pdksh, but AT&T ksh88 produces |
| 3552 | no error (redirected to /dev/null). |
| 3553 | stdin: |
| 3554 | (you/should/not/see/this/error/1) 2> /dev/null |
| 3555 | you/should/not/see/this/error/2 2> /dev/null |
| 3556 | true |
| 3557 | --- |
| 3558 | name: regression-15 |
| 3559 | description: |
| 3560 | The command |
| 3561 | $ whence foobar |
| 3562 | generates a blank line under pdksh and sets the exit status to 0. |
| 3563 | AT&T ksh88 generates no output and sets the exit status to 1. Also, |
| 3564 | the command |
| 3565 | $ whence foobar cat |
| 3566 | generates no output under AT&T ksh88 (pdksh generates a blank line |
| 3567 | and /bin/cat). |
| 3568 | stdin: |
| 3569 | whence does/not/exist > /dev/null |
| 3570 | echo 1: $? |
| 3571 | echo 2: $(whence does/not/exist | wc -l) |
| 3572 | echo 3: $(whence does/not/exist cat | wc -l) |
| 3573 | expected-stdout: |
| 3574 | 1: 1 |
| 3575 | 2: 0 |
| 3576 | 3: 0 |
| 3577 | --- |
| 3578 | name: regression-16 |
| 3579 | description: |
| 3580 | ${var%%expr} seems to be broken in many places. On the mips |
| 3581 | the commands |
| 3582 | $ read line < /etc/passwd |
| 3583 | $ echo $line |
| 3584 | root:0:1:... |
| 3585 | $ echo ${line%%:*} |
| 3586 | root |
| 3587 | $ echo $line |
| 3588 | root |
| 3589 | $ |
| 3590 | change the value of line. On sun4s & pas, the echo ${line%%:*} doesn't |
| 3591 | work. Haven't checked elsewhere... |
| 3592 | script: |
| 3593 | read x |
| 3594 | y=$x |
| 3595 | echo ${x%%:*} |
| 3596 | echo $x |
| 3597 | stdin: |
| 3598 | root:asdjhasdasjhs:0:1:Root:/:/bin/sh |
| 3599 | expected-stdout: |
| 3600 | root |
| 3601 | root:asdjhasdasjhs:0:1:Root:/:/bin/sh |
| 3602 | --- |
| 3603 | name: regression-17 |
| 3604 | description: |
| 3605 | The command |
| 3606 | . /foo/bar |
| 3607 | should set the exit status to non-zero (sh and AT&T ksh88 do). |
| 3608 | XXX doting a non existent file is a fatal error for a script |
| 3609 | stdin: |
| 3610 | . does/not/exist |
| 3611 | expected-exit: e != 0 |
| 3612 | expected-stderr-pattern: /.?/ |
| 3613 | --- |
| 3614 | name: regression-19 |
| 3615 | description: |
| 3616 | Both of the following echos should produce the same thing, but don't: |
| 3617 | $ x=foo/bar |
| 3618 | $ echo ${x%/*} |
| 3619 | foo |
| 3620 | $ echo "${x%/*}" |
| 3621 | foo/bar |
| 3622 | stdin: |
| 3623 | x=foo/bar |
| 3624 | echo "${x%/*}" |
| 3625 | expected-stdout: |
| 3626 | foo |
| 3627 | --- |
| 3628 | name: regression-21 |
| 3629 | description: |
| 3630 | backslash does not work as expected in case labels: |
| 3631 | $ x='-x' |
| 3632 | $ case $x in |
| 3633 | -\?) echo hi |
| 3634 | esac |
| 3635 | hi |
| 3636 | $ x='-?' |
| 3637 | $ case $x in |
| 3638 | -\\?) echo hi |
| 3639 | esac |
| 3640 | hi |
| 3641 | $ |
| 3642 | stdin: |
| 3643 | case -x in |
| 3644 | -\?) echo fail |
| 3645 | esac |
| 3646 | --- |
| 3647 | name: regression-22 |
| 3648 | description: |
| 3649 | Quoting backquotes inside backquotes doesn't work: |
| 3650 | $ echo `echo hi \`echo there\` folks` |
| 3651 | asks for more info. sh and AT&T ksh88 both echo |
| 3652 | hi there folks |
| 3653 | stdin: |
| 3654 | echo `echo hi \`echo there\` folks` |
| 3655 | expected-stdout: |
| 3656 | hi there folks |
| 3657 | --- |
| 3658 | name: regression-23 |
| 3659 | description: |
| 3660 | )) is not treated `correctly': |
| 3661 | $ (echo hi ; (echo there ; echo folks)) |
| 3662 | missing (( |
| 3663 | $ |
| 3664 | instead of (as sh and ksh.att) |
| 3665 | $ (echo hi ; (echo there ; echo folks)) |
| 3666 | hi |
| 3667 | there |
| 3668 | folks |
| 3669 | $ |
| 3670 | stdin: |
| 3671 | ( : ; ( : ; echo hi)) |
| 3672 | expected-stdout: |
| 3673 | hi |
| 3674 | --- |
| 3675 | name: regression-25 |
| 3676 | description: |
| 3677 | Check reading stdin in a while loop. The read should only read |
| 3678 | a single line, not a whole stdio buffer; the cat should get |
| 3679 | the rest. |
| 3680 | stdin: |
| 3681 | (echo a; echo b) | while read x ; do |
| 3682 | echo $x |
| 3683 | cat > /dev/null |
| 3684 | done |
| 3685 | expected-stdout: |
| 3686 | a |
| 3687 | --- |
| 3688 | name: regression-26 |
| 3689 | description: |
| 3690 | Check reading stdin in a while loop. The read should read both |
| 3691 | lines, not just the first. |
| 3692 | script: |
| 3693 | a= |
| 3694 | while [ "$a" != xxx ] ; do |
| 3695 | last=$x |
| 3696 | read x |
| 3697 | cat /dev/null | sed 's/x/y/' |
| 3698 | a=x$a |
| 3699 | done |
| 3700 | echo $last |
| 3701 | stdin: |
| 3702 | a |
| 3703 | b |
| 3704 | expected-stdout: |
| 3705 | b |
| 3706 | --- |
| 3707 | name: regression-27 |
| 3708 | description: |
| 3709 | The command |
| 3710 | . /does/not/exist |
| 3711 | should cause a script to exit. |
| 3712 | stdin: |
| 3713 | . does/not/exist |
| 3714 | echo hi |
| 3715 | expected-exit: e != 0 |
| 3716 | expected-stderr-pattern: /does\/not\/exist/ |
| 3717 | --- |
| 3718 | name: regression-28 |
| 3719 | description: |
| 3720 | variable assignements not detected well |
| 3721 | stdin: |
| 3722 | a.x=1 echo hi |
| 3723 | expected-exit: e != 0 |
| 3724 | expected-stderr-pattern: /a\.x=1/ |
| 3725 | --- |
| 3726 | name: regression-29 |
| 3727 | description: |
| 3728 | alias expansion different from AT&T ksh88 |
| 3729 | stdin: |
| 3730 | alias a='for ' b='i in' |
| 3731 | a b hi ; do echo $i ; done |
| 3732 | expected-stdout: |
| 3733 | hi |
| 3734 | --- |
| 3735 | name: regression-30 |
| 3736 | description: |
| 3737 | strange characters allowed inside ${...} |
| 3738 | stdin: |
| 3739 | echo ${a{b}} |
| 3740 | expected-exit: e != 0 |
| 3741 | expected-stderr-pattern: /.?/ |
| 3742 | --- |
| 3743 | name: regression-31 |
| 3744 | description: |
| 3745 | Does read handle partial lines correctly |
| 3746 | script: |
| 3747 | a= ret= |
| 3748 | while [ "$a" != xxx ] ; do |
| 3749 | read x y z |
| 3750 | ret=$? |
| 3751 | a=x$a |
| 3752 | done |
| 3753 | echo "[$x]" |
| 3754 | echo $ret |
| 3755 | stdin: ! |
| 3756 | a A aA |
| 3757 | b B Bb |
| 3758 | c |
| 3759 | expected-stdout: |
| 3760 | [c] |
| 3761 | 1 |
| 3762 | --- |
| 3763 | name: regression-32 |
| 3764 | description: |
| 3765 | Does read set variables to null at eof? |
| 3766 | script: |
| 3767 | a= |
| 3768 | while [ "$a" != xxx ] ; do |
| 3769 | read x y z |
| 3770 | a=x$a |
| 3771 | done |
| 3772 | echo 1: ${x-x not set} ${y-y not set} ${z-z not set} |
| 3773 | echo 2: ${x:+x not null} ${y:+y not null} ${z:+z not null} |
| 3774 | stdin: |
| 3775 | a A Aa |
| 3776 | b B Bb |
| 3777 | expected-stdout: |
| 3778 | 1: |
| 3779 | 2: |
| 3780 | --- |
| 3781 | name: regression-33 |
| 3782 | description: |
| 3783 | Does umask print a leading 0 when umask is 3 digits? |
| 3784 | stdin: |
| 3785 | umask 222 |
| 3786 | umask |
| 3787 | expected-stdout: |
| 3788 | 0222 |
| 3789 | --- |
| 3790 | name: regression-35 |
| 3791 | description: |
| 3792 | Tempory files used for here-docs in functions get trashed after |
| 3793 | the function is parsed (before it is executed) |
| 3794 | stdin: |
| 3795 | f1() { |
| 3796 | cat <<- EOF |
| 3797 | F1 |
| 3798 | EOF |
| 3799 | f2() { |
| 3800 | cat <<- EOF |
| 3801 | F2 |
| 3802 | EOF |
| 3803 | } |
| 3804 | } |
| 3805 | f1 |
| 3806 | f2 |
| 3807 | unset -f f1 |
| 3808 | f2 |
| 3809 | expected-stdout: |
| 3810 | F1 |
| 3811 | F2 |
| 3812 | F2 |
| 3813 | --- |
| 3814 | name: regression-36 |
| 3815 | description: |
| 3816 | Command substitution breaks reading in while loop |
| 3817 | (test from <sjg@void.zen.oz.au>) |
| 3818 | stdin: |
| 3819 | (echo abcdef; echo; echo 123) | |
| 3820 | while read line |
| 3821 | do |
| 3822 | # the following line breaks it |
| 3823 | c=`echo $line | wc -c` |
| 3824 | echo $c |
| 3825 | done |
| 3826 | expected-stdout: |
| 3827 | 7 |
| 3828 | 1 |
| 3829 | 4 |
| 3830 | --- |
| 3831 | name: regression-37 |
| 3832 | description: |
| 3833 | Machines with broken times() (reported by <sjg@void.zen.oz.au>) |
| 3834 | time does not report correct real time |
| 3835 | stdin: |
| 3836 | time sleep 1 |
| 3837 | expected-stderr-pattern: !/^\s*0\.0[\s\d]+real|^\s*real[\s]+0+\.0/ |
| 3838 | --- |
| 3839 | name: regression-38 |
| 3840 | description: |
| 3841 | set -e doesn't ignore exit codes for if/while/until/&&/||/!. |
| 3842 | arguments: !-e! |
| 3843 | stdin: |
| 3844 | if false; then echo hi ; fi |
| 3845 | false || true |
| 3846 | false && true |
| 3847 | while false; do echo hi; done |
| 3848 | echo ok |
| 3849 | expected-stdout: |
| 3850 | ok |
| 3851 | --- |
| 3852 | name: regression-39 |
| 3853 | description: |
| 3854 | set -e: errors in command substitutions aren't ignored |
| 3855 | Not clear if they should be or not... bash passes here |
| 3856 | this may actually be required for make, so changed the |
| 3857 | test to make this an mksh feature, not a bug |
| 3858 | arguments: !-e! |
| 3859 | stdin: |
| 3860 | echo `false; echo hi` |
| 3861 | #expected-fail: yes |
| 3862 | #expected-stdout: |
| 3863 | # hi |
| 3864 | expected-stdout: |
| 3865 | |
| 3866 | --- |
| 3867 | name: regression-40 |
| 3868 | description: |
| 3869 | This used to cause a core dump |
| 3870 | env-setup: !RANDOM=12! |
| 3871 | stdin: |
| 3872 | echo hi |
| 3873 | expected-stdout: |
| 3874 | hi |
| 3875 | --- |
| 3876 | name: regression-41 |
| 3877 | description: |
| 3878 | foo should be set to bar (should not be empty) |
| 3879 | stdin: |
| 3880 | foo=` |
| 3881 | echo bar` |
| 3882 | echo "($foo)" |
| 3883 | expected-stdout: |
| 3884 | (bar) |
| 3885 | --- |
| 3886 | name: regression-42 |
| 3887 | description: |
| 3888 | Can't use command line assignments to assign readonly parameters. |
| 3889 | stdin: |
| 3890 | foo=bar |
| 3891 | readonly foo |
| 3892 | foo=stuff env | grep '^foo' |
| 3893 | expected-exit: e != 0 |
| 3894 | expected-stderr-pattern: |
| 3895 | /.*read *only.*/ |
| 3896 | --- |
| 3897 | name: regression-43 |
| 3898 | description: |
| 3899 | Can subshells be prefixed by redirections (historical shells allow |
| 3900 | this) |
| 3901 | stdin: |
| 3902 | < /dev/null (sed 's/^/X/') |
| 3903 | --- |
| 3904 | name: regression-45 |
| 3905 | description: |
| 3906 | Parameter assignments with [] recognised correctly |
| 3907 | stdin: |
| 3908 | FOO=*[12] |
| 3909 | BAR=abc[ |
| 3910 | MORE=[abc] |
| 3911 | JUNK=a[bc |
| 3912 | echo "<$FOO>" |
| 3913 | echo "<$BAR>" |
| 3914 | echo "<$MORE>" |
| 3915 | echo "<$JUNK>" |
| 3916 | expected-stdout: |
| 3917 | <*[12]> |
| 3918 | <abc[> |
| 3919 | <[abc]> |
| 3920 | <a[bc> |
| 3921 | --- |
| 3922 | name: regression-46 |
| 3923 | description: |
| 3924 | Check that alias expansion works in command substitutions and |
| 3925 | at the end of file. |
| 3926 | stdin: |
| 3927 | alias x='echo hi' |
| 3928 | FOO="`x` " |
| 3929 | echo "[$FOO]" |
| 3930 | x |
| 3931 | expected-stdout: |
| 3932 | [hi ] |
| 3933 | hi |
| 3934 | --- |
| 3935 | name: regression-47 |
| 3936 | description: |
| 3937 | Check that aliases are fully read. |
| 3938 | stdin: |
| 3939 | alias x='echo hi; |
| 3940 | echo there' |
| 3941 | x |
| 3942 | echo done |
| 3943 | expected-stdout: |
| 3944 | hi |
| 3945 | there |
| 3946 | done |
| 3947 | --- |
| 3948 | name: regression-48 |
| 3949 | description: |
| 3950 | Check that (here doc) temp files are not left behind after an exec. |
| 3951 | stdin: |
| 3952 | mkdir foo || exit 1 |
| 3953 | TMPDIR=$PWD/foo "$__progname" <<- 'EOF' |
| 3954 | x() { |
| 3955 | sed 's/^/X /' << E_O_F |
| 3956 | hi |
| 3957 | there |
| 3958 | folks |
| 3959 | E_O_F |
| 3960 | echo "done ($?)" |
| 3961 | } |
| 3962 | echo=echo; [ -x /bin/echo ] && echo=/bin/echo |
| 3963 | exec $echo subtest-1 hi |
| 3964 | EOF |
| 3965 | echo subtest-1 foo/* |
| 3966 | TMPDIR=$PWD/foo "$__progname" <<- 'EOF' |
| 3967 | echo=echo; [ -x /bin/echo ] && echo=/bin/echo |
| 3968 | sed 's/^/X /' << E_O_F; exec $echo subtest-2 hi |
| 3969 | a |
| 3970 | few |
| 3971 | lines |
| 3972 | E_O_F |
| 3973 | EOF |
| 3974 | echo subtest-2 foo/* |
| 3975 | expected-stdout: |
| 3976 | subtest-1 hi |
| 3977 | subtest-1 foo/* |
| 3978 | X a |
| 3979 | X few |
| 3980 | X lines |
| 3981 | subtest-2 hi |
| 3982 | subtest-2 foo/* |
| 3983 | --- |
| 3984 | name: regression-49 |
| 3985 | description: |
| 3986 | Check that unset params with attributes are reported by set, those |
| 3987 | sans attributes are not. |
| 3988 | stdin: |
| 3989 | unset FOO BAR |
| 3990 | echo X$FOO |
| 3991 | export BAR |
| 3992 | typeset -i BLAH |
| 3993 | set | grep FOO |
| 3994 | set | grep BAR |
| 3995 | set | grep BLAH |
| 3996 | expected-stdout: |
| 3997 | X |
| 3998 | BAR |
| 3999 | BLAH |
| 4000 | --- |
| 4001 | name: regression-50 |
| 4002 | description: |
| 4003 | Check that aliases do not use continuation prompt after trailing |
| 4004 | semi-colon. |
| 4005 | file-setup: file 644 "env" |
| 4006 | PS1=Y |
| 4007 | PS2=X |
| 4008 | env-setup: !ENV=./env! |
| 4009 | arguments: !-i! |
| 4010 | stdin: |
| 4011 | alias foo='echo hi ; ' |
| 4012 | foo |
| 4013 | foo echo there |
| 4014 | expected-stdout: |
| 4015 | hi |
| 4016 | hi |
| 4017 | there |
| 4018 | expected-stderr: ! |
| 4019 | YYYY |
| 4020 | --- |
| 4021 | name: regression-51 |
| 4022 | description: |
| 4023 | Check that set allows both +o and -o options on same command line. |
| 4024 | stdin: |
| 4025 | set a b c |
| 4026 | set -o noglob +o allexport |
| 4027 | echo A: $*, * |
| 4028 | expected-stdout: |
| 4029 | A: a b c, * |
| 4030 | --- |
| 4031 | name: regression-52 |
| 4032 | description: |
| 4033 | Check that globbing works in pipelined commands |
| 4034 | file-setup: file 644 "env" |
| 4035 | PS1=P |
| 4036 | file-setup: file 644 "abc" |
| 4037 | stuff |
| 4038 | env-setup: !ENV=./env! |
| 4039 | arguments: !-i! |
| 4040 | stdin: |
| 4041 | sed 's/^/X /' < ab* |
| 4042 | echo mark 1 |
| 4043 | sed 's/^/X /' < ab* | sed 's/^/Y /' |
| 4044 | echo mark 2 |
| 4045 | expected-stdout: |
| 4046 | X stuff |
| 4047 | mark 1 |
| 4048 | Y X stuff |
| 4049 | mark 2 |
| 4050 | expected-stderr: ! |
| 4051 | PPPPP |
| 4052 | --- |
| 4053 | name: regression-53 |
| 4054 | description: |
| 4055 | Check that getopts works in functions |
| 4056 | stdin: |
| 4057 | bfunc() { |
| 4058 | echo bfunc: enter "(args: $*; OPTIND=$OPTIND)" |
| 4059 | while getopts B oc; do |
| 4060 | case $oc in |
| 4061 | (B) |
| 4062 | echo bfunc: B option |
| 4063 | ;; |
| 4064 | (*) |
| 4065 | echo bfunc: odd option "($oc)" |
| 4066 | ;; |
| 4067 | esac |
| 4068 | done |
| 4069 | echo bfunc: leave |
| 4070 | } |
| 4071 | |
| 4072 | function kfunc { |
| 4073 | echo kfunc: enter "(args: $*; OPTIND=$OPTIND)" |
| 4074 | while getopts K oc; do |
| 4075 | case $oc in |
| 4076 | (K) |
| 4077 | echo kfunc: K option |
| 4078 | ;; |
| 4079 | (*) |
| 4080 | echo bfunc: odd option "($oc)" |
| 4081 | ;; |
| 4082 | esac |
| 4083 | done |
| 4084 | echo kfunc: leave |
| 4085 | } |
| 4086 | |
| 4087 | set -- -f -b -k -l |
| 4088 | echo "line 1: OPTIND=$OPTIND" |
| 4089 | getopts kbfl optc |
| 4090 | echo "line 2: ret=$?, optc=$optc, OPTIND=$OPTIND" |
| 4091 | bfunc -BBB blah |
| 4092 | echo "line 3: OPTIND=$OPTIND" |
| 4093 | getopts kbfl optc |
| 4094 | echo "line 4: ret=$?, optc=$optc, OPTIND=$OPTIND" |
| 4095 | kfunc -KKK blah |
| 4096 | echo "line 5: OPTIND=$OPTIND" |
| 4097 | getopts kbfl optc |
| 4098 | echo "line 6: ret=$?, optc=$optc, OPTIND=$OPTIND" |
| 4099 | echo |
| 4100 | |
| 4101 | OPTIND=1 |
| 4102 | set -- -fbkl |
| 4103 | echo "line 10: OPTIND=$OPTIND" |
| 4104 | getopts kbfl optc |
| 4105 | echo "line 20: ret=$?, optc=$optc, OPTIND=$OPTIND" |
| 4106 | bfunc -BBB blah |
| 4107 | echo "line 30: OPTIND=$OPTIND" |
| 4108 | getopts kbfl optc |
| 4109 | echo "line 40: ret=$?, optc=$optc, OPTIND=$OPTIND" |
| 4110 | kfunc -KKK blah |
| 4111 | echo "line 50: OPTIND=$OPTIND" |
| 4112 | getopts kbfl optc |
| 4113 | echo "line 60: ret=$?, optc=$optc, OPTIND=$OPTIND" |
| 4114 | expected-stdout: |
| 4115 | line 1: OPTIND=1 |
| 4116 | line 2: ret=0, optc=f, OPTIND=2 |
| 4117 | bfunc: enter (args: -BBB blah; OPTIND=2) |
| 4118 | bfunc: B option |
| 4119 | bfunc: B option |
| 4120 | bfunc: leave |
| 4121 | line 3: OPTIND=2 |
| 4122 | line 4: ret=0, optc=b, OPTIND=3 |
| 4123 | kfunc: enter (args: -KKK blah; OPTIND=1) |
| 4124 | kfunc: K option |
| 4125 | kfunc: K option |
| 4126 | kfunc: K option |
| 4127 | kfunc: leave |
| 4128 | line 5: OPTIND=3 |
| 4129 | line 6: ret=0, optc=k, OPTIND=4 |
| 4130 | |
| 4131 | line 10: OPTIND=1 |
| 4132 | line 20: ret=0, optc=f, OPTIND=2 |
| 4133 | bfunc: enter (args: -BBB blah; OPTIND=2) |
| 4134 | bfunc: B option |
| 4135 | bfunc: B option |
| 4136 | bfunc: leave |
| 4137 | line 30: OPTIND=2 |
| 4138 | line 40: ret=1, optc=?, OPTIND=2 |
| 4139 | kfunc: enter (args: -KKK blah; OPTIND=1) |
| 4140 | kfunc: K option |
| 4141 | kfunc: K option |
| 4142 | kfunc: K option |
| 4143 | kfunc: leave |
| 4144 | line 50: OPTIND=2 |
| 4145 | line 60: ret=1, optc=?, OPTIND=2 |
| 4146 | --- |
| 4147 | name: regression-54 |
| 4148 | description: |
| 4149 | Check that ; is not required before the then in if (( ... )) then ... |
| 4150 | stdin: |
| 4151 | if (( 1 )) then |
| 4152 | echo ok dparen |
| 4153 | fi |
| 4154 | if [[ -n 1 ]] then |
| 4155 | echo ok dbrackets |
| 4156 | fi |
| 4157 | expected-stdout: |
| 4158 | ok dparen |
| 4159 | ok dbrackets |
| 4160 | --- |
| 4161 | name: regression-55 |
| 4162 | description: |
| 4163 | Check ${foo:%bar} is allowed (ksh88 allows it...) |
| 4164 | stdin: |
| 4165 | x=fooXbarXblah |
| 4166 | echo 1 ${x%X*} |
| 4167 | echo 2 ${x:%X*} |
| 4168 | echo 3 ${x%%X*} |
| 4169 | echo 4 ${x:%%X*} |
| 4170 | echo 5 ${x#*X} |
| 4171 | echo 6 ${x:#*X} |
| 4172 | echo 7 ${x##*X} |
| 4173 | echo 8 ${x:##*X} |
| 4174 | expected-stdout: |
| 4175 | 1 fooXbar |
| 4176 | 2 fooXbar |
| 4177 | 3 foo |
| 4178 | 4 foo |
| 4179 | 5 barXblah |
| 4180 | 6 barXblah |
| 4181 | 7 blah |
| 4182 | 8 blah |
| 4183 | --- |
| 4184 | name: regression-57 |
| 4185 | description: |
| 4186 | Check if typeset output is correct for |
| 4187 | uninitialised array elements. |
| 4188 | stdin: |
| 4189 | typeset -i xxx[4] |
| 4190 | echo A |
| 4191 | typeset -i | grep xxx | sed 's/^/ /' |
| 4192 | echo B |
| 4193 | typeset | grep xxx | sed 's/^/ /' |
| 4194 | |
| 4195 | xxx[1]=2+5 |
| 4196 | echo M |
| 4197 | typeset -i | grep xxx | sed 's/^/ /' |
| 4198 | echo N |
| 4199 | typeset | grep xxx | sed 's/^/ /' |
| 4200 | expected-stdout: |
| 4201 | A |
| 4202 | xxx |
| 4203 | B |
| 4204 | typeset -i xxx |
| 4205 | M |
| 4206 | xxx[1]=7 |
| 4207 | N |
| 4208 | typeset -i xxx |
| 4209 | --- |
| 4210 | name: regression-58 |
| 4211 | description: |
| 4212 | Check if trap exit is ok (exit not mistaken for signal name) |
| 4213 | stdin: |
| 4214 | trap 'echo hi' exit |
| 4215 | trap exit 1 |
| 4216 | expected-stdout: |
| 4217 | hi |
| 4218 | --- |
| 4219 | name: regression-59 |
| 4220 | description: |
| 4221 | Check if ${#array[*]} is calculated correctly. |
| 4222 | stdin: |
| 4223 | a[12]=hi |
| 4224 | a[8]=there |
| 4225 | echo ${#a[*]} |
| 4226 | expected-stdout: |
| 4227 | 2 |
| 4228 | --- |
| 4229 | name: regression-60 |
| 4230 | description: |
| 4231 | Check if default exit status is previous command |
| 4232 | stdin: |
| 4233 | (true; exit) |
| 4234 | echo A $? |
| 4235 | (false; exit) |
| 4236 | echo B $? |
| 4237 | ( (exit 103) ; exit) |
| 4238 | echo C $? |
| 4239 | expected-stdout: |
| 4240 | A 0 |
| 4241 | B 1 |
| 4242 | C 103 |
| 4243 | --- |
| 4244 | name: regression-61 |
| 4245 | description: |
| 4246 | Check if EXIT trap is executed for sub shells. |
| 4247 | stdin: |
| 4248 | trap 'echo parent exit' EXIT |
| 4249 | echo start |
| 4250 | (echo A; echo A last) |
| 4251 | echo B |
| 4252 | (echo C; trap 'echo sub exit' EXIT; echo C last) |
| 4253 | echo parent last |
| 4254 | expected-stdout: |
| 4255 | start |
| 4256 | A |
| 4257 | A last |
| 4258 | B |
| 4259 | C |
| 4260 | C last |
| 4261 | sub exit |
| 4262 | parent last |
| 4263 | parent exit |
| 4264 | --- |
| 4265 | name: regression-62 |
| 4266 | description: |
| 4267 | Check if test -nt/-ot succeeds if second(first) file is missing. |
| 4268 | stdin: |
| 4269 | touch a |
| 4270 | test a -nt b && echo nt OK || echo nt BAD |
| 4271 | test b -ot a && echo ot OK || echo ot BAD |
| 4272 | expected-stdout: |
| 4273 | nt OK |
| 4274 | ot OK |
| 4275 | --- |
| 4276 | name: regression-63 |
| 4277 | description: |
| 4278 | Check if typeset, export, and readonly work |
| 4279 | stdin: |
| 4280 | { |
| 4281 | echo FNORD-0 |
| 4282 | FNORD_A=1 |
| 4283 | FNORD_B=2 |
| 4284 | FNORD_C=3 |
| 4285 | FNORD_D=4 |
| 4286 | FNORD_E=5 |
| 4287 | FNORD_F=6 |
| 4288 | FNORD_G=7 |
| 4289 | FNORD_H=8 |
| 4290 | integer FNORD_E FNORD_F FNORD_G FNORD_H |
| 4291 | export FNORD_C FNORD_D FNORD_G FNORD_H |
| 4292 | readonly FNORD_B FNORD_D FNORD_F FNORD_H |
| 4293 | echo FNORD-1 |
| 4294 | export |
| 4295 | echo FNORD-2 |
| 4296 | export -p |
| 4297 | echo FNORD-3 |
| 4298 | readonly |
| 4299 | echo FNORD-4 |
| 4300 | readonly -p |
| 4301 | echo FNORD-5 |
| 4302 | typeset |
| 4303 | echo FNORD-6 |
| 4304 | typeset -p |
| 4305 | echo FNORD-7 |
| 4306 | typeset - |
| 4307 | echo FNORD-8 |
| 4308 | } | fgrep FNORD |
| 4309 | expected-stdout: |
| 4310 | FNORD-0 |
| 4311 | FNORD-1 |
| 4312 | FNORD_C |
| 4313 | FNORD_D |
| 4314 | FNORD_G |
| 4315 | FNORD_H |
| 4316 | FNORD-2 |
| 4317 | export FNORD_C=3 |
| 4318 | export FNORD_D=4 |
| 4319 | export FNORD_G=7 |
| 4320 | export FNORD_H=8 |
| 4321 | FNORD-3 |
| 4322 | FNORD_B |
| 4323 | FNORD_D |
| 4324 | FNORD_F |
| 4325 | FNORD_H |
| 4326 | FNORD-4 |
| 4327 | readonly FNORD_B=2 |
| 4328 | readonly FNORD_D=4 |
| 4329 | readonly FNORD_F=6 |
| 4330 | readonly FNORD_H=8 |
| 4331 | FNORD-5 |
| 4332 | typeset FNORD_A |
| 4333 | typeset -r FNORD_B |
| 4334 | typeset -x FNORD_C |
| 4335 | typeset -x -r FNORD_D |
| 4336 | typeset -i FNORD_E |
| 4337 | typeset -i -r FNORD_F |
| 4338 | typeset -i -x FNORD_G |
| 4339 | typeset -i -x -r FNORD_H |
| 4340 | FNORD-6 |
| 4341 | typeset FNORD_A=1 |
| 4342 | typeset -r FNORD_B=2 |
| 4343 | typeset -x FNORD_C=3 |
| 4344 | typeset -x -r FNORD_D=4 |
| 4345 | typeset -i FNORD_E=5 |
| 4346 | typeset -i -r FNORD_F=6 |
| 4347 | typeset -i -x FNORD_G=7 |
| 4348 | typeset -i -x -r FNORD_H=8 |
| 4349 | FNORD-7 |
| 4350 | FNORD_A=1 |
| 4351 | FNORD_B=2 |
| 4352 | FNORD_C=3 |
| 4353 | FNORD_D=4 |
| 4354 | FNORD_E=5 |
| 4355 | FNORD_F=6 |
| 4356 | FNORD_G=7 |
| 4357 | FNORD_H=8 |
| 4358 | FNORD-8 |
| 4359 | --- |
| 4360 | name: regression-64 |
| 4361 | description: |
| 4362 | Check that we can redefine functions calling time builtin |
| 4363 | stdin: |
| 4364 | t() { |
| 4365 | time >/dev/null |
| 4366 | } |
| 4367 | t 2>/dev/null |
| 4368 | t() { |
| 4369 | time |
| 4370 | } |
| 4371 | --- |
| 4372 | name: syntax-1 |
| 4373 | description: |
| 4374 | Check that lone ampersand is a syntax error |
| 4375 | stdin: |
| 4376 | & |
| 4377 | expected-exit: e != 0 |
| 4378 | expected-stderr-pattern: |
| 4379 | /syntax error/ |
| 4380 | --- |
| 4381 | name: xxx-quoted-newline-1 |
| 4382 | description: |
| 4383 | Check that \<newline> works inside of ${} |
| 4384 | stdin: |
| 4385 | abc=2 |
| 4386 | echo ${ab\ |
| 4387 | c} |
| 4388 | expected-stdout: |
| 4389 | 2 |
| 4390 | --- |
| 4391 | name: xxx-quoted-newline-2 |
| 4392 | description: |
| 4393 | Check that \<newline> works at the start of a here document |
| 4394 | stdin: |
| 4395 | cat << EO\ |
| 4396 | F |
| 4397 | hi |
| 4398 | EOF |
| 4399 | expected-stdout: |
| 4400 | hi |
| 4401 | --- |
| 4402 | name: xxx-quoted-newline-3 |
| 4403 | description: |
| 4404 | Check that \<newline> works at the end of a here document |
| 4405 | stdin: |
| 4406 | cat << EOF |
| 4407 | hi |
| 4408 | EO\ |
| 4409 | F |
| 4410 | expected-stdout: |
| 4411 | hi |
| 4412 | --- |
| 4413 | name: xxx-multi-assignment-cmd |
| 4414 | description: |
| 4415 | Check that assignments in a command affect subsequent assignments |
| 4416 | in the same command |
| 4417 | stdin: |
| 4418 | FOO=abc |
| 4419 | FOO=123 BAR=$FOO |
| 4420 | echo $BAR |
| 4421 | expected-stdout: |
| 4422 | 123 |
| 4423 | --- |
| 4424 | name: xxx-multi-assignment-posix-cmd |
| 4425 | description: |
| 4426 | Check that the behaviour for multiple assignments with a |
| 4427 | command name matches POSIX. See: |
| 4428 | http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925 |
| 4429 | stdin: |
| 4430 | X=a Y=b; X=$Y Y=$X "$__progname" -c 'echo 1 $X $Y .'; echo 2 $X $Y . |
| 4431 | unset X Y Z |
| 4432 | X=a Y=${X=b} Z=$X "$__progname" -c 'echo 3 $Z .' |
| 4433 | unset X Y Z |
| 4434 | X=a Y=${X=b} Z=$X; echo 4 $Z . |
| 4435 | expected-stdout: |
| 4436 | 1 b a . |
| 4437 | 2 a b . |
| 4438 | 3 b . |
| 4439 | 4 a . |
| 4440 | --- |
| 4441 | name: xxx-multi-assignment-posix-nocmd |
| 4442 | description: |
| 4443 | Check that the behaviour for multiple assignments with no |
| 4444 | command name matches POSIX (Debian #334182). See: |
| 4445 | http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925 |
| 4446 | stdin: |
| 4447 | X=a Y=b; X=$Y Y=$X; echo 1 $X $Y . |
| 4448 | expected-stdout: |
| 4449 | 1 b b . |
| 4450 | --- |
| 4451 | name: xxx-multi-assignment-posix-subassign |
| 4452 | description: |
| 4453 | Check that the behaviour for multiple assignments matches POSIX: |
| 4454 | - The assignment words shall be expanded in the current execution |
| 4455 | environment. |
| 4456 | - The assignments happen in the temporary execution environment. |
| 4457 | stdin: |
| 4458 | unset X Y Z |
| 4459 | Z=a Y=${X:=b} sh -c 'echo +$X+ +$Y+ +$Z+' |
| 4460 | echo /$X/ |
| 4461 | # Now for the special case: |
| 4462 | unset X Y Z |
| 4463 | X= Y=${X:=b} sh -c 'echo +$X+ +$Y+' |
| 4464 | echo /$X/ |
| 4465 | expected-stdout: |
| 4466 | ++ +b+ +a+ |
| 4467 | /b/ |
| 4468 | ++ +b+ |
| 4469 | /b/ |
| 4470 | --- |
| 4471 | name: xxx-exec-environment-1 |
| 4472 | description: |
| 4473 | Check to see if exec sets it's environment correctly |
| 4474 | stdin: |
| 4475 | FOO=bar exec env |
| 4476 | expected-stdout-pattern: |
| 4477 | /(^|.*\n)FOO=bar\n/ |
| 4478 | --- |
| 4479 | name: xxx-exec-environment-2 |
| 4480 | description: |
| 4481 | Check to make sure exec doesn't change environment if a program |
| 4482 | isn't exec-ed |
| 4483 | stdin: |
| 4484 | sortprog=$(whence -p sort) || sortprog=cat |
| 4485 | env | $sortprog | grep -v '^RANDOM=' >bar1 |
| 4486 | FOO=bar exec; env | $sortprog | grep -v '^RANDOM=' >bar2 |
| 4487 | cmp -s bar1 bar2 |
| 4488 | --- |
| 4489 | name: exec-function-environment-1 |
| 4490 | description: |
| 4491 | Check assignments in function calls and whether they affect |
| 4492 | the current execution environment (ksh93, SUSv4) |
| 4493 | stdin: |
| 4494 | f() { a=2; }; g() { b=3; echo y$c-; }; a=1 f; b=2; c=1 g |
| 4495 | echo x$a-$b- z$c- |
| 4496 | expected-stdout: |
| 4497 | y1- |
| 4498 | x2-3- z1- |
| 4499 | --- |
| 4500 | name: xxx-what-do-you-call-this-1 |
| 4501 | stdin: |
| 4502 | echo "${foo:-"a"}*" |
| 4503 | expected-stdout: |
| 4504 | a* |
| 4505 | --- |
| 4506 | name: xxx-prefix-strip-1 |
| 4507 | stdin: |
| 4508 | foo='a cdef' |
| 4509 | echo ${foo#a c} |
| 4510 | expected-stdout: |
| 4511 | def |
| 4512 | --- |
| 4513 | name: xxx-prefix-strip-2 |
| 4514 | stdin: |
| 4515 | set a c |
| 4516 | x='a cdef' |
| 4517 | echo ${x#$*} |
| 4518 | expected-stdout: |
| 4519 | def |
| 4520 | --- |
| 4521 | name: xxx-variable-syntax-1 |
| 4522 | stdin: |
| 4523 | echo ${:} |
| 4524 | expected-stderr-pattern: |
| 4525 | /bad substitution/ |
| 4526 | expected-exit: 1 |
| 4527 | --- |
| 4528 | name: xxx-variable-syntax-2 |
| 4529 | stdin: |
| 4530 | set 0 |
| 4531 | echo ${*:0} |
| 4532 | expected-stderr-pattern: |
| 4533 | /bad substitution/ |
| 4534 | expected-exit: 1 |
| 4535 | --- |
| 4536 | name: xxx-variable-syntax-3 |
| 4537 | stdin: |
| 4538 | set -A foo 0 |
| 4539 | echo ${foo[*]:0} |
| 4540 | expected-stderr-pattern: |
| 4541 | /bad substitution/ |
| 4542 | expected-exit: 1 |
| 4543 | --- |
| 4544 | name: xxx-substitution-eval-order |
| 4545 | description: |
| 4546 | Check order of evaluation of expressions |
| 4547 | stdin: |
| 4548 | i=1 x= y= |
| 4549 | set -A A abc def GHI j G k |
| 4550 | echo ${A[x=(i+=1)]#${A[y=(i+=2)]}} |
| 4551 | echo $x $y |
| 4552 | expected-stdout: |
| 4553 | HI |
| 4554 | 2 4 |
| 4555 | --- |
| 4556 | name: xxx-set-option-1 |
| 4557 | description: |
| 4558 | Check option parsing in set |
| 4559 | stdin: |
| 4560 | set -vsA foo -- A 1 3 2 |
| 4561 | echo ${foo[*]} |
| 4562 | expected-stderr: |
| 4563 | echo ${foo[*]} |
| 4564 | expected-stdout: |
| 4565 | 1 2 3 A |
| 4566 | --- |
| 4567 | name: xxx-exec-1 |
| 4568 | description: |
| 4569 | Check that exec exits for built-ins |
| 4570 | arguments: !-i! |
| 4571 | stdin: |
| 4572 | exec echo hi |
| 4573 | echo still herre |
| 4574 | expected-stdout: |
| 4575 | hi |
| 4576 | expected-stderr-pattern: /.*/ |
| 4577 | --- |
| 4578 | name: xxx-while-1 |
| 4579 | description: |
| 4580 | Check the return value of while loops |
| 4581 | XXX need to do same for for/select/until loops |
| 4582 | stdin: |
| 4583 | i=x |
| 4584 | while [ $i != xxx ] ; do |
| 4585 | i=x$i |
| 4586 | if [ $i = xxx ] ; then |
| 4587 | false |
| 4588 | continue |
| 4589 | fi |
| 4590 | done |
| 4591 | echo loop1=$? |
| 4592 | |
| 4593 | i=x |
| 4594 | while [ $i != xxx ] ; do |
| 4595 | i=x$i |
| 4596 | if [ $i = xxx ] ; then |
| 4597 | false |
| 4598 | break |
| 4599 | fi |
| 4600 | done |
| 4601 | echo loop2=$? |
| 4602 | |
| 4603 | i=x |
| 4604 | while [ $i != xxx ] ; do |
| 4605 | i=x$i |
| 4606 | false |
| 4607 | done |
| 4608 | echo loop3=$? |
| 4609 | expected-stdout: |
| 4610 | loop1=0 |
| 4611 | loop2=0 |
| 4612 | loop3=1 |
| 4613 | --- |
| 4614 | name: xxx-status-1 |
| 4615 | description: |
| 4616 | Check that blank lines don't clear $? |
| 4617 | arguments: !-i! |
| 4618 | stdin: |
| 4619 | (exit 1) |
| 4620 | echo $? |
| 4621 | (exit 1) |
| 4622 | |
| 4623 | echo $? |
| 4624 | true |
| 4625 | expected-stdout: |
| 4626 | 1 |
| 4627 | 1 |
| 4628 | expected-stderr-pattern: /.*/ |
| 4629 | --- |
| 4630 | name: xxx-status-2 |
| 4631 | description: |
| 4632 | Check that $? is preserved in subshells, includes, traps. |
| 4633 | stdin: |
| 4634 | (exit 1) |
| 4635 | |
| 4636 | echo blank: $? |
| 4637 | |
| 4638 | (exit 2) |
| 4639 | (echo subshell: $?) |
| 4640 | |
| 4641 | echo 'echo include: $?' > foo |
| 4642 | (exit 3) |
| 4643 | . ./foo |
| 4644 | |
| 4645 | trap 'echo trap: $?' ERR |
| 4646 | (exit 4) |
| 4647 | echo exit: $? |
| 4648 | expected-stdout: |
| 4649 | blank: 1 |
| 4650 | subshell: 2 |
| 4651 | include: 3 |
| 4652 | trap: 4 |
| 4653 | exit: 4 |
| 4654 | --- |
| 4655 | name: xxx-clean-chars-1 |
| 4656 | description: |
| 4657 | Check MAGIC character is stuffed correctly |
| 4658 | stdin: |
| 4659 | echo `echo [£` |
| 4660 | expected-stdout: |
| 4661 | [£ |
| 4662 | --- |
| 4663 | name: xxx-param-subst-qmark-1 |
| 4664 | description: |
| 4665 | Check suppresion of error message with null string. According to |
| 4666 | POSIX, it shouldn't print the error as 'word' isn't ommitted. |
| 4667 | ksh88/93, Solaris /bin/sh and /usr/xpg4/bin/sh all print the error, |
| 4668 | that's why the condition is reversed. |
| 4669 | stdin: |
| 4670 | unset foo |
| 4671 | x= |
| 4672 | echo x${foo?$x} |
| 4673 | expected-exit: 1 |
| 4674 | # POSIX |
| 4675 | #expected-fail: yes |
| 4676 | #expected-stderr-pattern: !/not set/ |
| 4677 | # common use |
| 4678 | expected-stderr-pattern: /parameter null or not set/ |
| 4679 | --- |
| 4680 | name: xxx-param-_-1 |
| 4681 | # fails due to weirdness of execv stuff |
| 4682 | category: !os:uwin-nt |
| 4683 | description: |
| 4684 | Check c flag is set. |
| 4685 | arguments: !-c!echo "[$-]"! |
| 4686 | expected-stdout-pattern: /^\[.*c.*\]$/ |
| 4687 | --- |
| 4688 | name: tilde-expand-1 |
| 4689 | description: |
| 4690 | Check tilde expansion after equal signs |
| 4691 | env-setup: !HOME=/sweet! |
| 4692 | stdin: |
| 4693 | echo ${A=a=}~ b=~ c=d~ ~ |
| 4694 | set +o braceexpand |
| 4695 | echo ${A=a=}~ b=~ c=d~ ~ |
| 4696 | expected-stdout: |
| 4697 | a=/sweet b=/sweet c=d~ /sweet |
| 4698 | a=~ b=~ c=d~ /sweet |
| 4699 | --- |
| 4700 | name: exit-err-1 |
| 4701 | description: |
| 4702 | Check some "exit on error" conditions |
| 4703 | stdin: |
| 4704 | set -ex |
| 4705 | /usr/bin/env false && echo something |
| 4706 | echo END |
| 4707 | expected-stdout: |
| 4708 | END |
| 4709 | expected-stderr: |
| 4710 | + /usr/bin/env false |
| 4711 | + echo END |
| 4712 | --- |
| 4713 | name: exit-err-2 |
| 4714 | description: |
| 4715 | Check some "exit on error" edge conditions (POSIXly) |
| 4716 | stdin: |
| 4717 | set -ex |
| 4718 | if /usr/bin/env true; then |
| 4719 | /usr/bin/env false && echo something |
| 4720 | fi |
| 4721 | echo END |
| 4722 | expected-stdout: |
| 4723 | END |
| 4724 | expected-stderr: |
| 4725 | + /usr/bin/env true |
| 4726 | + /usr/bin/env false |
| 4727 | + echo END |
| 4728 | --- |
| 4729 | name: exit-err-3 |
| 4730 | description: |
| 4731 | pdksh regression which AT&T ksh does right |
| 4732 | TFM says: [set] -e | errexit |
| 4733 | Exit (after executing the ERR trap) ... |
| 4734 | stdin: |
| 4735 | trap 'echo EXIT' EXIT |
| 4736 | trap 'echo ERR' ERR |
| 4737 | set -e |
| 4738 | cd /XXXXX 2>/dev/null |
| 4739 | echo DONE |
| 4740 | exit 0 |
| 4741 | expected-stdout: |
| 4742 | ERR |
| 4743 | EXIT |
| 4744 | expected-exit: e != 0 |
| 4745 | --- |
| 4746 | name: exit-err-4 |
| 4747 | description: |
| 4748 | "set -e" test suite (POSIX) |
| 4749 | stdin: |
| 4750 | set -e |
| 4751 | echo pre |
| 4752 | if true ; then |
| 4753 | false && echo foo |
| 4754 | fi |
| 4755 | echo bar |
| 4756 | expected-stdout: |
| 4757 | pre |
| 4758 | bar |
| 4759 | --- |
| 4760 | name: exit-err-5 |
| 4761 | description: |
| 4762 | "set -e" test suite (POSIX) |
| 4763 | stdin: |
| 4764 | set -e |
| 4765 | foo() { |
| 4766 | while [ "$1" ]; do |
| 4767 | for E in $x; do |
| 4768 | [ "$1" = "$E" ] && { shift ; continue 2 ; } |
| 4769 | done |
| 4770 | x="$x $1" |
| 4771 | shift |
| 4772 | done |
| 4773 | echo $x |
| 4774 | } |
| 4775 | echo pre |
| 4776 | foo a b b c |
| 4777 | echo post |
| 4778 | expected-stdout: |
| 4779 | pre |
| 4780 | a b c |
| 4781 | post |
| 4782 | --- |
| 4783 | name: exit-err-6 |
| 4784 | description: |
| 4785 | "set -e" test suite (BSD make) |
| 4786 | category: os:mirbsd |
| 4787 | stdin: |
| 4788 | mkdir zd zd/a zd/b |
| 4789 | print 'all:\n\t@echo eins\n\t@exit 42\n' >zd/a/Makefile |
| 4790 | print 'all:\n\t@echo zwei\n' >zd/b/Makefile |
| 4791 | wd=$(pwd) |
| 4792 | set -e |
| 4793 | 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" |
| 4794 | expected-stdout: |
| 4795 | ===> a |
| 4796 | eins |
| 4797 | *** Error code 42 |
| 4798 | |
| 4799 | Stop in WD/zd/a (line 2 of Makefile). |
| 4800 | --- |
| 4801 | name: exit-enoent-1 |
| 4802 | description: |
| 4803 | SUSv4 says that the shell should exit with 126/127 in some situations |
| 4804 | stdin: |
| 4805 | i=0 |
| 4806 | (echo; echo :) >x |
| 4807 | "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r . |
| 4808 | "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r . |
| 4809 | echo exit 42 >x |
| 4810 | "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r . |
| 4811 | "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r . |
| 4812 | rm -f x |
| 4813 | "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r . |
| 4814 | "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r . |
| 4815 | expected-stdout: |
| 4816 | 0 0 . |
| 4817 | 1 126 . |
| 4818 | 2 42 . |
| 4819 | 3 126 . |
| 4820 | 4 127 . |
| 4821 | 5 127 . |
| 4822 | --- |
| 4823 | name: exit-eval-1 |
| 4824 | description: |
| 4825 | Check eval vs substitution exit codes (ksh93 alike) |
| 4826 | stdin: |
| 4827 | eval $(false) |
| 4828 | echo A $? |
| 4829 | eval ' $(false)' |
| 4830 | echo B $? |
| 4831 | eval " $(false)" |
| 4832 | echo C $? |
| 4833 | eval "eval $(false)" |
| 4834 | echo D $? |
| 4835 | eval 'eval '"$(false)" |
| 4836 | echo E $? |
| 4837 | IFS="$IFS:" |
| 4838 | eval $(echo :; false) |
| 4839 | echo F $? |
| 4840 | expected-stdout: |
| 4841 | A 0 |
| 4842 | B 1 |
| 4843 | C 0 |
| 4844 | D 0 |
| 4845 | E 0 |
| 4846 | F 0 |
| 4847 | --- |
| 4848 | name: test-stlt-1 |
| 4849 | description: |
| 4850 | Check that test also can handle string1 < string2 etc. |
| 4851 | stdin: |
| 4852 | test 2005/10/08 '<' 2005/08/21 && echo ja || echo nein |
| 4853 | test 2005/08/21 \< 2005/10/08 && echo ja || echo nein |
| 4854 | test 2005/10/08 '>' 2005/08/21 && echo ja || echo nein |
| 4855 | test 2005/08/21 \> 2005/10/08 && echo ja || echo nein |
| 4856 | expected-stdout: |
| 4857 | nein |
| 4858 | ja |
| 4859 | ja |
| 4860 | nein |
| 4861 | expected-stderr-pattern: !/unexpected op/ |
| 4862 | --- |
| 4863 | name: test-precedence-1 |
| 4864 | description: |
| 4865 | Check a weird precedence case (and POSIX echo) |
| 4866 | stdin: |
| 4867 | test \( -f = -f \) |
| 4868 | rv=$? |
| 4869 | test -n "$POSH_VERSION" || set -o sh |
| 4870 | echo -e $rv |
| 4871 | expected-stdout: |
| 4872 | -e 0 |
| 4873 | --- |
| 4874 | name: test-option-1 |
| 4875 | description: |
| 4876 | Test the test -o operator |
| 4877 | stdin: |
| 4878 | runtest() { |
| 4879 | test -o $1; echo $? |
| 4880 | [ -o $1 ]; echo $? |
| 4881 | [[ -o $1 ]]; echo $? |
| 4882 | } |
| 4883 | if_test() { |
| 4884 | test -o $1 -o -o !$1; echo $? |
| 4885 | [ -o $1 -o -o !$1 ]; echo $? |
| 4886 | [[ -o $1 || -o !$1 ]]; echo $? |
| 4887 | test -o ?$1; echo $? |
| 4888 | } |
| 4889 | echo 0y $(if_test utf8-mode) = |
| 4890 | echo 0n $(if_test utf8-hack) = |
| 4891 | echo 1= $(runtest utf8-hack) = |
| 4892 | echo 2= $(runtest !utf8-hack) = |
| 4893 | echo 3= $(runtest ?utf8-hack) = |
| 4894 | set +U |
| 4895 | echo 1+ $(runtest utf8-mode) = |
| 4896 | echo 2+ $(runtest !utf8-mode) = |
| 4897 | echo 3+ $(runtest ?utf8-mode) = |
| 4898 | set -U |
| 4899 | echo 1- $(runtest utf8-mode) = |
| 4900 | echo 2- $(runtest !utf8-mode) = |
| 4901 | echo 3- $(runtest ?utf8-mode) = |
| 4902 | echo = short flags = |
| 4903 | echo 0y $(if_test -U) = |
| 4904 | echo 0y $(if_test +U) = |
| 4905 | echo 0n $(if_test -_) = |
| 4906 | echo 0n $(if_test -U-) = |
| 4907 | echo 1= $(runtest -_) = |
| 4908 | echo 2= $(runtest !-_) = |
| 4909 | echo 3= $(runtest ?-_) = |
| 4910 | set +U |
| 4911 | echo 1+ $(runtest -U) = |
| 4912 | echo 2+ $(runtest !-U) = |
| 4913 | echo 3+ $(runtest ?-U) = |
| 4914 | echo 1+ $(runtest +U) = |
| 4915 | echo 2+ $(runtest !+U) = |
| 4916 | echo 3+ $(runtest ?+U) = |
| 4917 | set -U |
| 4918 | echo 1- $(runtest -U) = |
| 4919 | echo 2- $(runtest !-U) = |
| 4920 | echo 3- $(runtest ?-U) = |
| 4921 | echo 1- $(runtest +U) = |
| 4922 | echo 2- $(runtest !+U) = |
| 4923 | echo 3- $(runtest ?+U) = |
| 4924 | expected-stdout: |
| 4925 | 0y 0 0 0 0 = |
| 4926 | 0n 1 1 1 1 = |
| 4927 | 1= 1 1 1 = |
| 4928 | 2= 1 1 1 = |
| 4929 | 3= 1 1 1 = |
| 4930 | 1+ 1 1 1 = |
| 4931 | 2+ 0 0 0 = |
| 4932 | 3+ 0 0 0 = |
| 4933 | 1- 0 0 0 = |
| 4934 | 2- 1 1 1 = |
| 4935 | 3- 0 0 0 = |
| 4936 | = short flags = |
| 4937 | 0y 0 0 0 0 = |
| 4938 | 0y 0 0 0 0 = |
| 4939 | 0n 1 1 1 1 = |
| 4940 | 0n 1 1 1 1 = |
| 4941 | 1= 1 1 1 = |
| 4942 | 2= 1 1 1 = |
| 4943 | 3= 1 1 1 = |
| 4944 | 1+ 1 1 1 = |
| 4945 | 2+ 0 0 0 = |
| 4946 | 3+ 0 0 0 = |
| 4947 | 1+ 1 1 1 = |
| 4948 | 2+ 0 0 0 = |
| 4949 | 3+ 0 0 0 = |
| 4950 | 1- 0 0 0 = |
| 4951 | 2- 1 1 1 = |
| 4952 | 3- 0 0 0 = |
| 4953 | 1- 0 0 0 = |
| 4954 | 2- 1 1 1 = |
| 4955 | 3- 0 0 0 = |
| 4956 | --- |
| 4957 | name: mkshrc-1 |
| 4958 | description: |
| 4959 | Check that ~/.mkshrc works correctly. |
| 4960 | Part 1: verify user environment is not read (internal) |
| 4961 | stdin: |
| 4962 | echo x $FNORD |
| 4963 | expected-stdout: |
| 4964 | x |
| 4965 | --- |
| 4966 | name: mkshrc-2a |
| 4967 | description: |
| 4968 | Check that ~/.mkshrc works correctly. |
| 4969 | Part 2: verify mkshrc is not read (non-interactive shells) |
| 4970 | file-setup: file 644 ".mkshrc" |
| 4971 | FNORD=42 |
| 4972 | env-setup: !HOME=.!ENV=! |
| 4973 | stdin: |
| 4974 | echo x $FNORD |
| 4975 | expected-stdout: |
| 4976 | x |
| 4977 | --- |
| 4978 | name: mkshrc-2b |
| 4979 | description: |
| 4980 | Check that ~/.mkshrc works correctly. |
| 4981 | Part 2: verify mkshrc can be read (interactive shells) |
| 4982 | file-setup: file 644 ".mkshrc" |
| 4983 | FNORD=42 |
| 4984 | arguments: !-i! |
| 4985 | env-setup: !HOME=.!ENV=!PS1=! |
| 4986 | stdin: |
| 4987 | echo x $FNORD |
| 4988 | expected-stdout: |
| 4989 | x 42 |
| 4990 | expected-stderr-pattern: |
| 4991 | /(# )*/ |
| 4992 | --- |
| 4993 | name: mkshrc-3 |
| 4994 | description: |
| 4995 | Check that ~/.mkshrc works correctly. |
| 4996 | Part 3: verify mkshrc can be turned off |
| 4997 | file-setup: file 644 ".mkshrc" |
| 4998 | FNORD=42 |
| 4999 | env-setup: !HOME=.!ENV=nonexistant! |
| 5000 | stdin: |
| 5001 | echo x $FNORD |
| 5002 | expected-stdout: |
| 5003 | x |
| 5004 | --- |
| 5005 | name: sh-mode-1 |
| 5006 | description: |
| 5007 | Check that sh mode turns braceexpand off |
| 5008 | and that that works correctly |
| 5009 | stdin: |
| 5010 | set -o braceexpand |
| 5011 | set +o sh |
| 5012 | [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh |
| 5013 | [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex |
| 5014 | echo {a,b,c} |
| 5015 | set +o braceexpand |
| 5016 | echo {a,b,c} |
| 5017 | set -o braceexpand |
| 5018 | echo {a,b,c} |
| 5019 | set -o sh |
| 5020 | echo {a,b,c} |
| 5021 | [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh |
| 5022 | [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex |
| 5023 | set -o braceexpand |
| 5024 | echo {a,b,c} |
| 5025 | [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh |
| 5026 | [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex |
| 5027 | expected-stdout: |
| 5028 | nosh |
| 5029 | brex |
| 5030 | a b c |
| 5031 | {a,b,c} |
| 5032 | a b c |
| 5033 | {a,b,c} |
| 5034 | sh |
| 5035 | nobrex |
| 5036 | a b c |
| 5037 | sh |
| 5038 | brex |
| 5039 | --- |
| 5040 | name: sh-mode-2a |
| 5041 | description: |
| 5042 | Check that sh mode is *not* automatically turned on |
| 5043 | category: !binsh |
| 5044 | stdin: |
| 5045 | ln -s "$__progname" ksh |
| 5046 | ln -s "$__progname" sh |
| 5047 | ln -s "$__progname" ./-ksh |
| 5048 | ln -s "$__progname" ./-sh |
| 5049 | for shell in {,-}{,k}sh; do |
| 5050 | print -- $shell $(./$shell +l -c \ |
| 5051 | '[[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh') |
| 5052 | done |
| 5053 | expected-stdout: |
| 5054 | sh nosh |
| 5055 | ksh nosh |
| 5056 | -sh nosh |
| 5057 | -ksh nosh |
| 5058 | --- |
| 5059 | name: sh-mode-2b |
| 5060 | description: |
| 5061 | Check that sh mode *is* automatically turned on |
| 5062 | category: binsh |
| 5063 | stdin: |
| 5064 | ln -s "$__progname" ksh |
| 5065 | ln -s "$__progname" sh |
| 5066 | ln -s "$__progname" ./-ksh |
| 5067 | ln -s "$__progname" ./-sh |
| 5068 | for shell in {,-}{,k}sh; do |
| 5069 | print -- $shell $(./$shell +l -c \ |
| 5070 | '[[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh') |
| 5071 | done |
| 5072 | expected-stdout: |
| 5073 | sh sh |
| 5074 | ksh nosh |
| 5075 | -sh sh |
| 5076 | -ksh nosh |
| 5077 | --- |
| 5078 | name: pipeline-1 |
| 5079 | description: |
| 5080 | pdksh bug: last command of a pipeline is executed in a |
| 5081 | subshell - make sure it still is, scripts depend on it |
| 5082 | file-setup: file 644 "abcx" |
| 5083 | file-setup: file 644 "abcy" |
| 5084 | stdin: |
| 5085 | echo * |
| 5086 | echo a | while read d; do |
| 5087 | echo $d |
| 5088 | echo $d* |
| 5089 | echo * |
| 5090 | set -o noglob |
| 5091 | echo $d* |
| 5092 | echo * |
| 5093 | done |
| 5094 | echo * |
| 5095 | expected-stdout: |
| 5096 | abcx abcy |
| 5097 | a |
| 5098 | abcx abcy |
| 5099 | abcx abcy |
| 5100 | a* |
| 5101 | * |
| 5102 | abcx abcy |
| 5103 | --- |
| 5104 | name: pipeline-2 |
| 5105 | description: |
| 5106 | check that co-processes work with TCOMs, TPIPEs and TPARENs |
| 5107 | stdin: |
| 5108 | "$__progname" -c 'i=100; echo hi |& while read -p line; do echo "$((i++)) $line"; done' |
| 5109 | "$__progname" -c 'i=200; echo hi | cat |& while read -p line; do echo "$((i++)) $line"; done' |
| 5110 | "$__progname" -c 'i=300; (echo hi | cat) |& while read -p line; do echo "$((i++)) $line"; done' |
| 5111 | expected-stdout: |
| 5112 | 100 hi |
| 5113 | 200 hi |
| 5114 | 300 hi |
| 5115 | --- |
| 5116 | name: persist-history-1 |
| 5117 | description: |
| 5118 | Check if persistent history saving works |
| 5119 | category: !no-histfile |
| 5120 | arguments: !-i! |
| 5121 | env-setup: !ENV=./Env!HISTFILE=hist.file! |
| 5122 | file-setup: file 644 "Env" |
| 5123 | PS1=X |
| 5124 | stdin: |
| 5125 | cat hist.file |
| 5126 | expected-stdout-pattern: |
| 5127 | /cat hist.file/ |
| 5128 | expected-stderr-pattern: |
| 5129 | /^X*$/ |
| 5130 | --- |
| 5131 | name: typeset-padding-1 |
| 5132 | description: |
| 5133 | Check if left/right justification works as per TFM |
| 5134 | stdin: |
| 5135 | typeset -L10 ln=0hall0 |
| 5136 | typeset -R10 rn=0hall0 |
| 5137 | typeset -ZL10 lz=0hall0 |
| 5138 | typeset -ZR10 rz=0hall0 |
| 5139 | typeset -Z10 rx=" hallo " |
| 5140 | echo "<$ln> <$rn> <$lz> <$rz> <$rx>" |
| 5141 | expected-stdout: |
| 5142 | <0hall0 > < 0hall0> <hall0 > <00000hall0> <0000 hallo> |
| 5143 | --- |
| 5144 | name: typeset-padding-2 |
| 5145 | description: |
| 5146 | Check if base-!10 integers are padded right |
| 5147 | stdin: |
| 5148 | typeset -Uui16 -L9 ln=16#1 |
| 5149 | typeset -Uui16 -R9 rn=16#1 |
| 5150 | typeset -Uui16 -Z9 zn=16#1 |
| 5151 | typeset -L9 ls=16#1 |
| 5152 | typeset -R9 rs=16#1 |
| 5153 | typeset -Z9 zs=16#1 |
| 5154 | echo "<$ln> <$rn> <$zn> <$ls> <$rs> <$zs>" |
| 5155 | expected-stdout: |
| 5156 | <16#1 > < 16#1> <16#000001> <16#1 > < 16#1> <0000016#1> |
| 5157 | --- |
| 5158 | name: utf8bom-1 |
| 5159 | description: |
| 5160 | Check that the UTF-8 Byte Order Mark is ignored as the first |
| 5161 | multibyte character of the shell input (with -c, from standard |
| 5162 | input, as file, or as eval argument), but nowhere else |
| 5163 | # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition) |
| 5164 | category: !os:darwin |
| 5165 | stdin: |
| 5166 | mkdir foo |
| 5167 | print '#!/bin/sh\necho ohne' >foo/fnord |
| 5168 | print '#!/bin/sh\necho mit' >foo/fnord |
| 5169 | print 'fnord\nfnord\nfnord\nfnord' >foo/bar |
| 5170 | print eval \''fnord\nfnord\nfnord\nfnord'\' >foo/zoo |
| 5171 | set -A anzahl -- foo/* |
| 5172 | echo got ${#anzahl[*]} files |
| 5173 | chmod +x foo/* |
| 5174 | export PATH=$(pwd)/foo:$PATH |
| 5175 | "$__progname" -c 'fnord' |
| 5176 | echo = |
| 5177 | "$__progname" -c 'fnord; fnord; fnord; fnord' |
| 5178 | echo = |
| 5179 | "$__progname" foo/bar |
| 5180 | echo = |
| 5181 | "$__progname" <foo/bar |
| 5182 | echo = |
| 5183 | "$__progname" foo/zoo |
| 5184 | echo = |
| 5185 | "$__progname" -c 'echo : $(fnord)' |
| 5186 | rm -rf foo |
| 5187 | expected-stdout: |
| 5188 | got 4 files |
| 5189 | ohne |
| 5190 | = |
| 5191 | ohne |
| 5192 | ohne |
| 5193 | mit |
| 5194 | ohne |
| 5195 | = |
| 5196 | ohne |
| 5197 | ohne |
| 5198 | mit |
| 5199 | ohne |
| 5200 | = |
| 5201 | ohne |
| 5202 | ohne |
| 5203 | mit |
| 5204 | ohne |
| 5205 | = |
| 5206 | ohne |
| 5207 | ohne |
| 5208 | mit |
| 5209 | ohne |
| 5210 | = |
| 5211 | : mit |
| 5212 | --- |
| 5213 | name: utf8bom-2 |
| 5214 | description: |
| 5215 | Check that we can execute BOM-shebangs (failures not fatal) |
| 5216 | XXX if the OS can already execute them, we lose |
| 5217 | note: cygwin execve(2) doesn't return to us with ENOEXEC, we lose |
| 5218 | note: Ultrix perl5 t4 returns 65280 (exit-code 255) and no text |
| 5219 | category: !os:cygwin,!os:uwin-nt,!os:ultrix,!smksh |
| 5220 | env-setup: !FOO=BAR! |
| 5221 | stdin: |
| 5222 | print '#!'"$__progname"'\nprint "1 a=$ENV{FOO}";' >t1 |
| 5223 | print '#!'"$__progname"'\nprint "2 a=$ENV{FOO}";' >t2 |
| 5224 | print '#!'"$__perlname"'\nprint "3 a=$ENV{FOO}\n";' >t3 |
| 5225 | print '#!'"$__perlname"'\nprint "4 a=$ENV{FOO}\n";' >t4 |
| 5226 | chmod +x t? |
| 5227 | ./t1 |
| 5228 | ./t2 |
| 5229 | ./t3 |
| 5230 | ./t4 |
| 5231 | expected-stdout: |
| 5232 | 1 a=/nonexistant{FOO} |
| 5233 | 2 a=/nonexistant{FOO} |
| 5234 | 3 a=BAR |
| 5235 | 4 a=BAR |
| 5236 | expected-stderr-pattern: |
| 5237 | /(Unrecognized character .... ignored at \..t4 line 1)*/ |
| 5238 | --- |
| 5239 | name: utf8bom-3 |
| 5240 | description: |
| 5241 | Reading the UTF-8 BOM should enable the utf8-mode flag |
| 5242 | stdin: |
| 5243 | "$__progname" -c ':; if [[ $- = *U* ]]; then echo 1 on; else echo 1 off; fi' |
| 5244 | "$__progname" -c ':; if [[ $- = *U* ]]; then echo 2 on; else echo 2 off; fi' |
| 5245 | expected-stdout: |
| 5246 | 1 off |
| 5247 | 2 on |
| 5248 | --- |
| 5249 | name: utf8opt-1a |
| 5250 | description: |
| 5251 | Check that the utf8-mode flag is not set at non-interactive startup |
| 5252 | category: !os:hpux |
| 5253 | env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8! |
| 5254 | stdin: |
| 5255 | if [[ $- = *U* ]]; then |
| 5256 | echo is set |
| 5257 | else |
| 5258 | echo is not set |
| 5259 | fi |
| 5260 | expected-stdout: |
| 5261 | is not set |
| 5262 | --- |
| 5263 | name: utf8opt-1b |
| 5264 | description: |
| 5265 | Check that the utf8-mode flag is not set at non-interactive startup |
| 5266 | category: os:hpux |
| 5267 | env-setup: !PS1=!PS2=!LC_CTYPE=en_US.utf8! |
| 5268 | stdin: |
| 5269 | if [[ $- = *U* ]]; then |
| 5270 | echo is set |
| 5271 | else |
| 5272 | echo is not set |
| 5273 | fi |
| 5274 | expected-stdout: |
| 5275 | is not set |
| 5276 | --- |
| 5277 | name: utf8opt-2a |
| 5278 | description: |
| 5279 | Check that the utf8-mode flag is set at interactive startup. |
| 5280 | -DMKSH_ASSUME_UTF8=0 => expected failure, please ignore |
| 5281 | -DMKSH_ASSUME_UTF8=1 => not expected, please investigate |
| 5282 | -UMKSH_ASSUME_UTF8 => not expected, but if your OS is old, |
| 5283 | try passing HAVE_SETLOCALE_CTYPE=0 to Build.sh |
| 5284 | category: !os:hpux |
| 5285 | arguments: !-i! |
| 5286 | env-setup: !PS1=!PS2=!LC_CTYPE=en_US.UTF-8! |
| 5287 | stdin: |
| 5288 | if [[ $- = *U* ]]; then |
| 5289 | echo is set |
| 5290 | else |
| 5291 | echo is not set |
| 5292 | fi |
| 5293 | expected-stdout: |
| 5294 | is set |
| 5295 | expected-stderr-pattern: |
| 5296 | /(# )*/ |
| 5297 | --- |
| 5298 | name: utf8opt-2b |
| 5299 | description: |
| 5300 | Check that the utf8-mode flag is set at interactive startup |
| 5301 | Expected failure if -DMKSH_ASSUME_UTF8=0 |
| 5302 | category: os:hpux |
| 5303 | arguments: !-i! |
| 5304 | env-setup: !PS1=!PS2=!LC_CTYPE=en_US.utf8! |
| 5305 | stdin: |
| 5306 | if [[ $- = *U* ]]; then |
| 5307 | echo is set |
| 5308 | else |
| 5309 | echo is not set |
| 5310 | fi |
| 5311 | expected-stdout: |
| 5312 | is set |
| 5313 | expected-stderr-pattern: |
| 5314 | /(# )*/ |
| 5315 | --- |
| 5316 | name: utf8opt-3 |
| 5317 | description: |
| 5318 | Ensure ±U on the command line is honoured |
| 5319 | (this test may pass falsely depending on CPPFLAGS) |
| 5320 | stdin: |
| 5321 | export i=0 |
| 5322 | code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi' |
| 5323 | let i++; "$__progname" -U -c "$code" |
| 5324 | let i++; "$__progname" +U -c "$code" |
| 5325 | let i++; "$__progname" -U -ic "$code" |
| 5326 | let i++; "$__progname" +U -ic "$code" |
| 5327 | echo $((++i)) done |
| 5328 | expected-stdout: |
| 5329 | 1 on |
| 5330 | 2 off |
| 5331 | 3 on |
| 5332 | 4 off |
| 5333 | 5 done |
| 5334 | --- |
| 5335 | name: aliases-1 |
| 5336 | description: |
| 5337 | Check if built-in shell aliases are okay |
| 5338 | category: !arge |
| 5339 | stdin: |
| 5340 | alias |
| 5341 | typeset -f |
| 5342 | expected-stdout: |
| 5343 | autoload='typeset -fu' |
| 5344 | functions='typeset -f' |
| 5345 | hash='alias -t' |
| 5346 | history='fc -l' |
| 5347 | integer='typeset -i' |
| 5348 | local=typeset |
| 5349 | login='exec login' |
| 5350 | nameref='typeset -n' |
| 5351 | nohup='nohup ' |
| 5352 | r='fc -e -' |
| 5353 | source='PATH=$PATH:. command .' |
Thorsten Glaser | ba2627c | 2010-08-24 18:21:37 +0200 | [diff] [blame] | 5354 | suspend='kill -STOP $$' |
| 5355 | type='whence -v' |
| 5356 | --- |
| 5357 | name: aliases-1-hartz4 |
| 5358 | description: |
| 5359 | Check if built-in shell aliases are okay |
| 5360 | category: arge |
| 5361 | stdin: |
| 5362 | alias |
| 5363 | typeset -f |
| 5364 | expected-stdout: |
| 5365 | autoload='typeset -fu' |
| 5366 | functions='typeset -f' |
| 5367 | hash='alias -t' |
| 5368 | history='fc -l' |
| 5369 | integer='typeset -i' |
| 5370 | local=typeset |
| 5371 | login='exec login' |
| 5372 | nameref='typeset -n' |
| 5373 | nohup='nohup ' |
| 5374 | r='fc -e -' |
| 5375 | source='PATH=$PATH:. command .' |
| 5376 | type='whence -v' |
| 5377 | --- |
| 5378 | name: aliases-2a |
| 5379 | description: |
| 5380 | Check if âset -o shâ disables built-in aliases (except a few) |
| 5381 | category: disabled |
| 5382 | arguments: !-o!sh! |
| 5383 | stdin: |
| 5384 | alias |
| 5385 | typeset -f |
| 5386 | expected-stdout: |
| 5387 | integer='typeset -i' |
| 5388 | local=typeset |
| 5389 | --- |
| 5390 | name: aliases-3a |
| 5391 | description: |
| 5392 | Check if running as sh disables built-in aliases (except a few) |
| 5393 | category: disabled |
| 5394 | arguments: !-o!sh! |
| 5395 | stdin: |
| 5396 | cp "$__progname" sh |
| 5397 | ./sh -c 'alias; typeset -f' |
| 5398 | rm -f sh |
| 5399 | expected-stdout: |
| 5400 | integer='typeset -i' |
| 5401 | local=typeset |
| 5402 | --- |
| 5403 | name: aliases-2b |
| 5404 | description: |
| 5405 | Check if âset -o shâ does not influence built-in aliases |
| 5406 | category: !arge |
| 5407 | arguments: !-o!sh! |
| 5408 | stdin: |
| 5409 | alias |
| 5410 | typeset -f |
| 5411 | expected-stdout: |
| 5412 | autoload='typeset -fu' |
| 5413 | functions='typeset -f' |
| 5414 | hash='alias -t' |
| 5415 | history='fc -l' |
| 5416 | integer='typeset -i' |
| 5417 | local=typeset |
| 5418 | login='exec login' |
| 5419 | nameref='typeset -n' |
| 5420 | nohup='nohup ' |
| 5421 | r='fc -e -' |
| 5422 | source='PATH=$PATH:. command .' |
Thorsten Glaser | ba2627c | 2010-08-24 18:21:37 +0200 | [diff] [blame] | 5423 | suspend='kill -STOP $$' |
| 5424 | type='whence -v' |
| 5425 | --- |
| 5426 | name: aliases-3b |
| 5427 | description: |
| 5428 | Check if running as sh does not influence built-in aliases |
| 5429 | category: !arge |
| 5430 | arguments: !-o!sh! |
| 5431 | stdin: |
| 5432 | cp "$__progname" sh |
| 5433 | ./sh -c 'alias; typeset -f' |
| 5434 | rm -f sh |
| 5435 | expected-stdout: |
| 5436 | autoload='typeset -fu' |
| 5437 | functions='typeset -f' |
| 5438 | hash='alias -t' |
| 5439 | history='fc -l' |
| 5440 | integer='typeset -i' |
| 5441 | local=typeset |
| 5442 | login='exec login' |
| 5443 | nameref='typeset -n' |
| 5444 | nohup='nohup ' |
| 5445 | r='fc -e -' |
| 5446 | source='PATH=$PATH:. command .' |
Thorsten Glaser | ba2627c | 2010-08-24 18:21:37 +0200 | [diff] [blame] | 5447 | suspend='kill -STOP $$' |
| 5448 | type='whence -v' |
| 5449 | --- |
| 5450 | name: aliases-2b-hartz4 |
| 5451 | description: |
| 5452 | Check if âset -o shâ does not influence built-in aliases |
| 5453 | category: arge |
| 5454 | arguments: !-o!sh! |
| 5455 | stdin: |
| 5456 | alias |
| 5457 | typeset -f |
| 5458 | expected-stdout: |
| 5459 | autoload='typeset -fu' |
| 5460 | functions='typeset -f' |
| 5461 | hash='alias -t' |
| 5462 | history='fc -l' |
| 5463 | integer='typeset -i' |
| 5464 | local=typeset |
| 5465 | login='exec login' |
| 5466 | nameref='typeset -n' |
| 5467 | nohup='nohup ' |
| 5468 | r='fc -e -' |
| 5469 | source='PATH=$PATH:. command .' |
| 5470 | type='whence -v' |
| 5471 | --- |
| 5472 | name: aliases-3b-hartz4 |
| 5473 | description: |
| 5474 | Check if running as sh does not influence built-in aliases |
| 5475 | category: arge |
| 5476 | arguments: !-o!sh! |
| 5477 | stdin: |
| 5478 | cp "$__progname" sh |
| 5479 | ./sh -c 'alias; typeset -f' |
| 5480 | rm -f sh |
| 5481 | expected-stdout: |
| 5482 | autoload='typeset -fu' |
| 5483 | functions='typeset -f' |
| 5484 | hash='alias -t' |
| 5485 | history='fc -l' |
| 5486 | integer='typeset -i' |
| 5487 | local=typeset |
| 5488 | login='exec login' |
| 5489 | nameref='typeset -n' |
| 5490 | nohup='nohup ' |
| 5491 | r='fc -e -' |
| 5492 | source='PATH=$PATH:. command .' |
| 5493 | type='whence -v' |
| 5494 | --- |
| 5495 | name: aliases-funcdef-1 |
| 5496 | description: |
| 5497 | Check if POSIX functions take precedences over aliases |
| 5498 | stdin: |
| 5499 | alias foo='echo makro' |
| 5500 | foo() { |
| 5501 | echo funktion |
| 5502 | } |
| 5503 | foo |
| 5504 | expected-stdout: |
| 5505 | funktion |
| 5506 | --- |
| 5507 | name: aliases-funcdef-2 |
| 5508 | description: |
| 5509 | Check if POSIX functions take precedences over aliases |
| 5510 | stdin: |
| 5511 | alias foo='echo makro' |
| 5512 | foo () { |
| 5513 | echo funktion |
| 5514 | } |
| 5515 | foo |
| 5516 | expected-stdout: |
| 5517 | funktion |
| 5518 | --- |
| 5519 | name: aliases-funcdef-3 |
| 5520 | description: |
| 5521 | Check if aliases take precedences over Korn functions |
| 5522 | stdin: |
| 5523 | alias foo='echo makro' |
| 5524 | function foo { |
| 5525 | echo funktion |
| 5526 | } |
| 5527 | foo |
| 5528 | expected-stdout: |
| 5529 | makro |
| 5530 | --- |
| 5531 | name: arrays-1 |
| 5532 | description: |
| 5533 | Check if Korn Shell arrays work as expected |
| 5534 | stdin: |
| 5535 | v="c d" |
| 5536 | set -A foo -- a \$v "$v" '$v' b |
| 5537 | echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|" |
| 5538 | expected-stdout: |
| 5539 | 5|a|$v|c d|$v|b| |
| 5540 | --- |
| 5541 | name: arrays-2 |
| 5542 | description: |
| 5543 | Check if bash-style arrays work as expected |
| 5544 | category: !smksh |
| 5545 | stdin: |
| 5546 | v="c d" |
| 5547 | foo=(a \$v "$v" '$v' b) |
| 5548 | echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|" |
| 5549 | expected-stdout: |
| 5550 | 5|a|$v|c d|$v|b| |
| 5551 | --- |
| 5552 | name: arrays-3 |
| 5553 | description: |
| 5554 | Check if array bounds are uint32_t |
| 5555 | stdin: |
| 5556 | set -A foo a b c |
| 5557 | foo[4097]=d |
| 5558 | foo[2147483637]=e |
| 5559 | echo ${foo[*]} |
| 5560 | foo[-1]=f |
| 5561 | echo ${foo[4294967295]} g ${foo[*]} |
| 5562 | expected-stdout: |
| 5563 | a b c d e |
| 5564 | f g a b c d e f |
| 5565 | --- |
| 5566 | name: arrays-4 |
| 5567 | description: |
| 5568 | Check if Korn Shell arrays with specified indices work as expected |
| 5569 | category: !smksh |
| 5570 | stdin: |
| 5571 | v="c d" |
| 5572 | set -A foo -- [1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b |
| 5573 | echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|" |
| 5574 | expected-stdout: |
| 5575 | 5|a|$v|c d||$v|b| |
| 5576 | --- |
| 5577 | name: arrays-5 |
| 5578 | description: |
| 5579 | Check if bash-style arrays with specified indices work as expected |
| 5580 | category: !smksh |
| 5581 | stdin: |
| 5582 | v="c d" |
| 5583 | foo=([1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b) |
| 5584 | echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|" |
| 5585 | x=([128]=foo bar baz) |
| 5586 | echo k= ${!x[*]} . |
| 5587 | echo v= ${x[*]} . |
| 5588 | expected-stdout: |
| 5589 | 5|a|$v|c d||$v|b| |
| 5590 | k= 128 129 130 . |
| 5591 | v= foo bar baz . |
| 5592 | --- |
| 5593 | name: arrays-6 |
| 5594 | description: |
| 5595 | Check if we can get the array keys (indices) for indexed arrays, |
| 5596 | Korn shell style |
| 5597 | stdin: |
| 5598 | of() { |
| 5599 | i=0 |
| 5600 | for x in "$@"; do |
| 5601 | echo -n "$((i++))<$x>" |
| 5602 | done |
| 5603 | echo |
| 5604 | } |
| 5605 | foo[1]=eins |
| 5606 | set | grep '^foo' |
| 5607 | echo = |
| 5608 | foo[0]=zwei |
| 5609 | foo[4]=drei |
| 5610 | set | grep '^foo' |
| 5611 | echo = |
| 5612 | echo a $(of ${foo[*]}) = $(of ${bar[*]}) a |
| 5613 | echo b $(of "${foo[*]}") = $(of "${bar[*]}") b |
| 5614 | echo c $(of ${foo[@]}) = $(of ${bar[@]}) c |
| 5615 | echo d $(of "${foo[@]}") = $(of "${bar[@]}") d |
| 5616 | echo e $(of ${!foo[*]}) = $(of ${!bar[*]}) e |
| 5617 | echo f $(of "${!foo[*]}") = $(of "${!bar[*]}") f |
| 5618 | echo g $(of ${!foo[@]}) = $(of ${!bar[@]}) g |
| 5619 | echo h $(of "${!foo[@]}") = $(of "${!bar[@]}") h |
| 5620 | expected-stdout: |
| 5621 | foo[1]=eins |
| 5622 | = |
| 5623 | foo[0]=zwei |
| 5624 | foo[1]=eins |
| 5625 | foo[4]=drei |
| 5626 | = |
| 5627 | a 0<zwei>1<eins>2<drei> = a |
| 5628 | b 0<zwei eins drei> = 0<> b |
| 5629 | c 0<zwei>1<eins>2<drei> = c |
| 5630 | d 0<zwei>1<eins>2<drei> = d |
| 5631 | e 0<0>1<1>2<4> = e |
| 5632 | f 0<0 1 4> = 0<> f |
| 5633 | g 0<0>1<1>2<4> = g |
| 5634 | h 0<0>1<1>2<4> = h |
| 5635 | --- |
| 5636 | name: arrays-7 |
| 5637 | description: |
| 5638 | Check if we can get the array keys (indices) for indexed arrays, |
| 5639 | Korn shell style, in some corner cases |
| 5640 | stdin: |
| 5641 | echo !arz: ${!arz} |
| 5642 | echo !arz[0]: ${!arz[0]} |
| 5643 | echo !arz[1]: ${!arz[1]} |
| 5644 | arz=foo |
| 5645 | echo !arz: ${!arz} |
| 5646 | echo !arz[0]: ${!arz[0]} |
| 5647 | echo !arz[1]: ${!arz[1]} |
| 5648 | unset arz |
| 5649 | echo !arz: ${!arz} |
| 5650 | echo !arz[0]: ${!arz[0]} |
| 5651 | echo !arz[1]: ${!arz[1]} |
| 5652 | expected-stdout: |
| 5653 | !arz: 0 |
| 5654 | !arz[0]: |
| 5655 | !arz[1]: |
| 5656 | !arz: arz |
| 5657 | !arz[0]: 0 |
| 5658 | !arz[1]: |
| 5659 | !arz: 0 |
| 5660 | !arz[0]: |
| 5661 | !arz[1]: |
| 5662 | --- |
| 5663 | name: arrays-8 |
| 5664 | description: |
| 5665 | Check some behavioural rules for arrays. |
| 5666 | stdin: |
| 5667 | fna() { |
| 5668 | set -A aa 9 |
| 5669 | } |
| 5670 | fnb() { |
| 5671 | typeset ab |
| 5672 | set -A ab 9 |
| 5673 | } |
| 5674 | fnc() { |
| 5675 | typeset ac |
| 5676 | set -A ac 91 |
| 5677 | unset ac |
| 5678 | set -A ac 92 |
| 5679 | } |
| 5680 | fnd() { |
| 5681 | set +A ad 9 |
| 5682 | } |
| 5683 | fne() { |
| 5684 | unset ae |
| 5685 | set +A ae 9 |
| 5686 | } |
| 5687 | fnf() { |
| 5688 | unset af[0] |
| 5689 | set +A af 9 |
| 5690 | } |
| 5691 | fng() { |
| 5692 | unset ag[*] |
| 5693 | set +A ag 9 |
| 5694 | } |
| 5695 | set -A aa 1 2 |
| 5696 | set -A ab 1 2 |
| 5697 | set -A ac 1 2 |
| 5698 | set -A ad 1 2 |
| 5699 | set -A ae 1 2 |
| 5700 | set -A af 1 2 |
| 5701 | set -A ag 1 2 |
| 5702 | set -A ah 1 2 |
| 5703 | typeset -Z3 aa ab ac ad ae af ag |
| 5704 | print 1a ${aa[*]} . |
| 5705 | print 1b ${ab[*]} . |
| 5706 | print 1c ${ac[*]} . |
| 5707 | print 1d ${ad[*]} . |
| 5708 | print 1e ${ae[*]} . |
| 5709 | print 1f ${af[*]} . |
| 5710 | print 1g ${ag[*]} . |
| 5711 | print 1h ${ah[*]} . |
| 5712 | fna |
| 5713 | fnb |
| 5714 | fnc |
| 5715 | fnd |
| 5716 | fne |
| 5717 | fnf |
| 5718 | fng |
| 5719 | typeset -Z5 ah[*] |
| 5720 | print 2a ${aa[*]} . |
| 5721 | print 2b ${ab[*]} . |
| 5722 | print 2c ${ac[*]} . |
| 5723 | print 2d ${ad[*]} . |
| 5724 | print 2e ${ae[*]} . |
| 5725 | print 2f ${af[*]} . |
| 5726 | print 2g ${ag[*]} . |
| 5727 | print 2h ${ah[*]} . |
| 5728 | expected-stdout: |
| 5729 | 1a 001 002 . |
| 5730 | 1b 001 002 . |
| 5731 | 1c 001 002 . |
| 5732 | 1d 001 002 . |
| 5733 | 1e 001 002 . |
| 5734 | 1f 001 002 . |
| 5735 | 1g 001 002 . |
| 5736 | 1h 1 2 . |
| 5737 | 2a 9 . |
| 5738 | 2b 001 002 . |
| 5739 | 2c 92 . |
| 5740 | 2d 009 002 . |
| 5741 | 2e 9 . |
| 5742 | 2f 9 002 . |
| 5743 | 2g 009 . |
| 5744 | 2h 00001 00002 . |
| 5745 | --- |
| 5746 | name: varexpand-substr-1 |
| 5747 | description: |
| 5748 | Check if bash-style substring expansion works |
| 5749 | when using positive numerics |
| 5750 | stdin: |
| 5751 | x=abcdefghi |
| 5752 | typeset -i y=123456789 |
| 5753 | typeset -i 16 z=123456789 # 16#75bcd15 |
| 5754 | echo a t${x:2:2} ${y:2:3} ${z:2:3} a |
| 5755 | echo b ${x::3} ${y::3} ${z::3} b |
| 5756 | echo c ${x:2:} ${y:2:} ${z:2:} c |
| 5757 | echo d ${x:2} ${y:2} ${z:2} d |
| 5758 | echo e ${x:2:6} ${y:2:6} ${z:2:7} e |
| 5759 | echo f ${x:2:7} ${y:2:7} ${z:2:8} f |
| 5760 | echo g ${x:2:8} ${y:2:8} ${z:2:9} g |
| 5761 | expected-stdout: |
| 5762 | a tcd 345 #75 a |
| 5763 | b abc 123 16# b |
| 5764 | c c |
| 5765 | d cdefghi 3456789 #75bcd15 d |
| 5766 | e cdefgh 345678 #75bcd1 e |
| 5767 | f cdefghi 3456789 #75bcd15 f |
| 5768 | g cdefghi 3456789 #75bcd15 g |
| 5769 | --- |
| 5770 | name: varexpand-substr-2 |
| 5771 | description: |
| 5772 | Check if bash-style substring expansion works |
| 5773 | when using negative numerics or expressions |
| 5774 | stdin: |
| 5775 | x=abcdefghi |
| 5776 | typeset -i y=123456789 |
| 5777 | typeset -i 16 z=123456789 # 16#75bcd15 |
| 5778 | n=2 |
| 5779 | echo a ${x:$n:3} ${y:$n:3} ${z:$n:3} a |
| 5780 | echo b ${x:(n):3} ${y:(n):3} ${z:(n):3} b |
| 5781 | echo c ${x:(-2):1} ${y:(-2):1} ${z:(-2):1} c |
| 5782 | echo d t${x: n:2} ${y: n:3} ${z: n:3} d |
| 5783 | expected-stdout: |
| 5784 | a cde 345 #75 a |
| 5785 | b cde 345 #75 b |
| 5786 | c h 8 1 c |
| 5787 | d tcd 345 #75 d |
| 5788 | --- |
| 5789 | name: varexpand-substr-3 |
| 5790 | description: |
| 5791 | Check that some things that work in bash fail. |
| 5792 | This is by design. And that some things fail in both. |
| 5793 | stdin: |
| 5794 | export x=abcdefghi n=2 |
| 5795 | "$__progname" -c 'echo v${x:(n)}x' |
| 5796 | "$__progname" -c 'echo w${x: n}x' |
| 5797 | "$__progname" -c 'echo x${x:n}x' |
| 5798 | "$__progname" -c 'echo y${x:}x' |
| 5799 | "$__progname" -c 'echo z${x}x' |
| 5800 | "$__progname" -c 'x=abcdef;y=123;echo ${x:${y:2:1}:2}' >/dev/null 2>&1; echo $? |
| 5801 | expected-stdout: |
| 5802 | vcdefghix |
| 5803 | wcdefghix |
| 5804 | zabcdefghix |
| 5805 | 1 |
| 5806 | expected-stderr-pattern: |
| 5807 | /x:n.*bad substitution.*\n.*bad substitution/ |
| 5808 | --- |
| 5809 | name: varexpand-substr-4 |
| 5810 | description: |
| 5811 | Check corner cases for substring expansion |
| 5812 | stdin: |
| 5813 | x=abcdefghi |
| 5814 | integer y=2 |
| 5815 | echo a ${x:(y == 1 ? 2 : 3):4} a |
| 5816 | expected-stdout: |
| 5817 | a defg a |
| 5818 | --- |
| 5819 | name: varexpand-substr-5A |
| 5820 | description: |
| 5821 | Check that substring expansions work on characters |
| 5822 | stdin: |
| 5823 | set +U |
| 5824 | x=mäh |
| 5825 | echo a ${x::1} ${x: -1} a |
| 5826 | echo b ${x::3} ${x: -3} b |
| 5827 | echo c ${x:1:2} ${x: -3:2} c |
| 5828 | echo d ${#x} d |
| 5829 | expected-stdout: |
| 5830 | a m h a |
| 5831 | b mä äh b |
| 5832 | c ä ä c |
| 5833 | d 4 d |
| 5834 | --- |
| 5835 | name: varexpand-substr-5W |
| 5836 | description: |
| 5837 | Check that substring expansions work on characters |
| 5838 | stdin: |
| 5839 | set -U |
| 5840 | x=mäh |
| 5841 | echo a ${x::1} ${x: -1} a |
| 5842 | echo b ${x::2} ${x: -2} b |
| 5843 | echo c ${x:1:1} ${x: -2:1} c |
| 5844 | echo d ${#x} d |
| 5845 | expected-stdout: |
| 5846 | a m h a |
| 5847 | b mä äh b |
| 5848 | c ä ä c |
| 5849 | d 3 d |
| 5850 | --- |
| 5851 | name: varexpand-substr-6 |
| 5852 | description: |
| 5853 | Check that string substitution works correctly |
| 5854 | stdin: |
| 5855 | foo=1 |
| 5856 | bar=2 |
| 5857 | baz=qwertyuiop |
| 5858 | echo a ${baz: foo: bar} |
| 5859 | echo b ${baz: foo: $bar} |
| 5860 | echo c ${baz: $foo: bar} |
| 5861 | echo d ${baz: $foo: $bar} |
| 5862 | expected-stdout: |
| 5863 | a we |
| 5864 | b we |
| 5865 | c we |
| 5866 | d we |
| 5867 | --- |
| 5868 | name: varexpand-null-1 |
| 5869 | description: |
| 5870 | Ensure empty strings expand emptily |
| 5871 | stdin: |
| 5872 | print x ${a} ${b} y |
| 5873 | print z ${a#?} ${b%?} w |
| 5874 | print v ${a=} ${b/c/d} u |
| 5875 | expected-stdout: |
| 5876 | x y |
| 5877 | z w |
| 5878 | v u |
| 5879 | --- |
| 5880 | name: varexpand-null-2 |
| 5881 | description: |
| 5882 | Ensure empty strings, when quoted, are expanded as empty strings |
| 5883 | stdin: |
| 5884 | printf '<%s> ' 1 "${a}" 2 "${a#?}" + "${b%?}" 3 "${a=}" + "${b/c/d}" |
| 5885 | echo . |
| 5886 | expected-stdout: |
| 5887 | <1> <> <2> <> <+> <> <3> <> <+> <> . |
| 5888 | --- |
| 5889 | name: print-funny-chars |
| 5890 | description: |
| 5891 | Check print builtin's capability to output designated characters |
| 5892 | stdin: |
| 5893 | print '<\0144\0344\xDB\u00DB\u20AC\uDB\x40>' |
| 5894 | expected-stdout: |
| 5895 | <däÛÃâ¬Ã@> |
| 5896 | --- |
| 5897 | name: print-bksl-c |
| 5898 | description: |
| 5899 | Check print builtin's \c escape |
| 5900 | stdin: |
| 5901 | print '\ca'; print b |
| 5902 | expected-stdout: |
| 5903 | ab |
| 5904 | --- |
| 5905 | name: print-nul-chars |
| 5906 | description: |
| 5907 | Check handling of NUL characters for print and read |
| 5908 | note: second line should output â4 3â but we cannot |
| 5909 | handle NUL characters in strings yet |
| 5910 | stdin: |
| 5911 | print $(($(print '<\0>' | wc -c))) |
| 5912 | x=$(print '<\0>') |
| 5913 | print $(($(print "$x" | wc -c))) ${#x} |
| 5914 | expected-stdout: |
| 5915 | 4 |
| 5916 | 3 2 |
| 5917 | --- |
| 5918 | name: print-escapes |
| 5919 | description: |
| 5920 | Check backslash expansion by the print builtin |
| 5921 | stdin: |
| 5922 | print '\ \!\"\#\$\%\&'\\\''\(\)\*\+\,\-\.\/\0\1\2\3\4\5\6\7\8' \ |
| 5923 | '\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T' \ |
| 5924 | '\U\V\W\X\Y\Z\[\\\]\^\_\`\a\b \d\e\f\g\h\i\j\k\l\m\n\o\p' \ |
| 5925 | '\q\r\s\t\u\v\w\x\y\z\{\|\}\~' '\u20acd' '\U20acd' '\x123' \ |
| 5926 | '\0x' '\0123' '\01234' | { |
| 5927 | typeset -Uui16 -Z11 pos=0 |
| 5928 | typeset -Uui16 -Z5 hv |
| 5929 | typeset -i1 wc=0x0A |
| 5930 | dasc= |
| 5931 | nl=${wc#1#} |
| 5932 | while IFS= read -r line; do |
| 5933 | line=$line$nl |
| 5934 | while [[ -n $line ]]; do |
| 5935 | hv=1#${line::1} |
| 5936 | if (( (pos & 15) == 0 )); then |
| 5937 | (( pos )) && print "$dasc|" |
| 5938 | print -n "${pos#16#} " |
| 5939 | dasc=' |' |
| 5940 | fi |
| 5941 | print -n "${hv#16#} " |
| 5942 | if (( (hv < 32) || (hv > 126) )); then |
| 5943 | dasc=$dasc. |
| 5944 | else |
| 5945 | dasc=$dasc${line::1} |
| 5946 | fi |
| 5947 | (( (pos++ & 15) == 7 )) && print -n -- '- ' |
| 5948 | line=${line:1} |
| 5949 | done |
| 5950 | done |
| 5951 | if (( (pos & 15) != 1 )); then |
| 5952 | while (( pos & 15 )); do |
| 5953 | print -n ' ' |
| 5954 | (( (pos++ & 15) == 7 )) && print -n -- '- ' |
| 5955 | done |
| 5956 | print "$dasc|" |
| 5957 | fi |
| 5958 | } |
| 5959 | expected-stdout: |
| 5960 | 00000000 5C 20 5C 21 5C 22 5C 23 - 5C 24 5C 25 5C 26 5C 27 |\ \!\"\#\$\%\&\'| |
| 5961 | 00000010 5C 28 5C 29 5C 2A 5C 2B - 5C 2C 5C 2D 5C 2E 5C 2F |\(\)\*\+\,\-\.\/| |
| 5962 | 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| |
| 5963 | 00000030 20 5C 39 5C 3A 5C 3B 5C - 3C 5C 3D 5C 3E 5C 3F 5C | \9\:\;\<\=\>\?\| |
| 5964 | 00000040 40 5C 41 5C 42 5C 43 5C - 44 1B 5C 46 5C 47 5C 48 |@\A\B\C\D.\F\G\H| |
| 5965 | 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| |
| 5966 | 00000060 5C 51 5C 52 5C 53 5C 54 - 20 5C 56 5C 57 5C 58 5C |\Q\R\S\T \V\W\X\| |
| 5967 | 00000070 59 5C 5A 5C 5B 5C 5C 5D - 5C 5E 5C 5F 5C 60 07 08 |Y\Z\[\]\^\_\`..| |
| 5968 | 00000080 20 20 5C 64 1B 0C 5C 67 - 5C 68 5C 69 5C 6A 5C 6B | \d..\g\h\i\j\k| |
| 5969 | 00000090 5C 6C 5C 6D 0A 5C 6F 5C - 70 20 5C 71 0D 5C 73 09 |\l\m.\o\p \q.\s.| |
| 5970 | 000000A0 0B 5C 77 5C 79 5C 7A 5C - 7B 5C 7C 5C 7D 5C 7E 20 |.\w\y\z\{\|\}\~ | |
| 5971 | 000000B0 E2 82 AC 64 20 EF BF BD - 20 12 33 20 78 20 53 20 |...d ... .3 x S | |
| 5972 | 000000C0 53 34 0A - |S4.| |
| 5973 | --- |
| 5974 | name: dollar-quoted-strings |
| 5975 | description: |
| 5976 | Check backslash expansion by $'â¦' strings |
| 5977 | stdin: |
| 5978 | printf '%s\n' $'\ \!\"\#\$\%\&\'\(\)\*\+\,\-\.\/ \1\2\3\4\5\6' \ |
| 5979 | $'a\0b' $'a\01b' $'\7\8\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I' \ |
| 5980 | $'\J\K\L\M\N\O\P\Q\R\S\T\U1\V\W\X\Y\Z\[\\\]\^\_\`\a\b\d\e' \ |
| 5981 | $'\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u1\v\w\x1\y\z\{\|\}\~ $x' \ |
| 5982 | $'\u20acd' $'\U20acd' $'\x123' $'fn\x0rd' $'\0234' $'\234' \ |
| 5983 | $'\2345' $'\ca' $'\c!' $'\c?' $'\câ¬' $'a\ |
| 5984 | b' | { |
| 5985 | typeset -Uui16 -Z11 pos=0 |
| 5986 | typeset -Uui16 -Z5 hv |
| 5987 | typeset -i1 wc=0x0A |
| 5988 | dasc= |
| 5989 | nl=${wc#1#} |
| 5990 | while IFS= read -r line; do |
| 5991 | line=$line$nl |
| 5992 | while [[ -n $line ]]; do |
| 5993 | hv=1#${line::1} |
| 5994 | if (( (pos & 15) == 0 )); then |
| 5995 | (( pos )) && print "$dasc|" |
| 5996 | print -n "${pos#16#} " |
| 5997 | dasc=' |' |
| 5998 | fi |
| 5999 | print -n "${hv#16#} " |
| 6000 | if (( (hv < 32) || (hv > 126) )); then |
| 6001 | dasc=$dasc. |
| 6002 | else |
| 6003 | dasc=$dasc${line::1} |
| 6004 | fi |
| 6005 | (( (pos++ & 15) == 7 )) && print -n -- '- ' |
| 6006 | line=${line:1} |
| 6007 | done |
| 6008 | done |
| 6009 | if (( (pos & 15) != 1 )); then |
| 6010 | while (( pos & 15 )); do |
| 6011 | print -n ' ' |
| 6012 | (( (pos++ & 15) == 7 )) && print -n -- '- ' |
| 6013 | done |
| 6014 | print "$dasc|" |
| 6015 | fi |
| 6016 | } |
| 6017 | expected-stdout: |
| 6018 | 00000000 20 21 22 23 24 25 26 27 - 28 29 2A 2B 2C 2D 2E 2F | !"#$%&'()*+,-./| |
| 6019 | 00000010 20 01 02 03 04 05 06 0A - 61 0A 61 01 62 0A 07 38 | .......a.a.b..8| |
| 6020 | 00000020 39 3A 3B 3C 3D 3E 3F 40 - 41 42 43 44 1B 46 47 48 |9:;<=>?@ABCD.FGH| |
| 6021 | 00000030 49 0A 4A 4B 4C 4D 4E 4F - 50 51 52 53 54 01 56 57 |I.JKLMNOPQRST.VW| |
| 6022 | 00000040 58 59 5A 5B 5C 5D 5E 5F - 60 07 08 64 1B 0A 0C 67 |XYZ[\]^_`..d...g| |
| 6023 | 00000050 68 69 6A 6B 6C 6D 0A 6F - 70 71 0D 73 09 01 0B 77 |hijklm.opq.s...w| |
| 6024 | 00000060 01 79 7A 7B 7C 7D 7E 20 - 24 78 0A E2 82 AC 64 0A |.yz{|}~ $x....d.| |
| 6025 | 00000070 EF BF BD 0A C4 A3 0A 66 - 6E 0A 13 34 0A 9C 0A 9C |.......fn..4....| |
| 6026 | 00000080 35 0A 01 0A 01 0A 7F 0A - 02 82 AC 0A 61 0A 62 0A |5...........a.b.| |
| 6027 | --- |
| 6028 | name: dollar-quotes-in-heredocs |
| 6029 | description: |
| 6030 | They are, however, not parsed in here documents |
| 6031 | stdin: |
| 6032 | cat <<EOF |
| 6033 | dollar = strchr(s, '$'); /* ' */ |
| 6034 | EOF |
| 6035 | cat <<$'a\tb' |
| 6036 | a\tb |
| 6037 | a b |
| 6038 | expected-stdout: |
| 6039 | dollar = strchr(s, '$'); /* ' */ |
| 6040 | a\tb |
| 6041 | --- |
| 6042 | name: dollar-quotes-in-herestrings |
| 6043 | description: |
| 6044 | They are, not parsed in here strings either |
| 6045 | stdin: |
| 6046 | cat <<<"dollar = strchr(s, '$'); /* ' */" |
| 6047 | cat <<<'dollar = strchr(s, '\''$'\''); /* '\'' */' |
| 6048 | x="dollar = strchr(s, '$'); /* ' */" |
| 6049 | cat <<<"$x" |
| 6050 | cat <<<$'a\E[0m\tb' |
| 6051 | expected-stdout: |
| 6052 | dollar = strchr(s, '$'); /* ' */ |
| 6053 | dollar = strchr(s, '$'); /* ' */ |
| 6054 | dollar = strchr(s, '$'); /* ' */ |
| 6055 | a[0m b |
| 6056 | --- |
| 6057 | name: dot-needs-argument |
| 6058 | description: |
| 6059 | check Debian #415167 solution: '.' without arguments should fail |
| 6060 | stdin: |
| 6061 | "$__progname" -c . |
| 6062 | "$__progname" -c source |
| 6063 | expected-exit: e != 0 |
| 6064 | expected-stderr-pattern: |
| 6065 | /\.: missing argument.*\n.*\.: missing argument/ |
| 6066 | --- |
| 6067 | name: alias-function-no-conflict |
| 6068 | description: |
| 6069 | make aliases not conflict with functions |
| 6070 | note: for ksh-like functions, the order of preference is |
| 6071 | different; bash outputs baz instead of bar in line 2 below |
| 6072 | stdin: |
| 6073 | alias foo='echo bar' |
| 6074 | foo() { |
| 6075 | echo baz |
| 6076 | } |
| 6077 | alias korn='echo bar' |
| 6078 | function korn { |
| 6079 | echo baz |
| 6080 | } |
| 6081 | foo |
| 6082 | korn |
| 6083 | unset -f foo |
| 6084 | foo 2>&- || echo rab |
| 6085 | expected-stdout: |
| 6086 | baz |
| 6087 | bar |
| 6088 | rab |
| 6089 | --- |
| 6090 | name: bash-function-parens |
| 6091 | description: |
| 6092 | ensure the keyword function is ignored when preceding |
| 6093 | POSIX style function declarations (bashism) |
| 6094 | stdin: |
| 6095 | mk() { |
| 6096 | echo '#!'"$__progname" |
| 6097 | echo "$1 {" |
| 6098 | echo ' echo "bar='\''$0'\'\" |
| 6099 | echo '}' |
| 6100 | echo ${2:-foo} |
| 6101 | } |
| 6102 | mk 'function foo' >f-korn |
| 6103 | mk 'foo ()' >f-dash |
| 6104 | mk 'function foo ()' >f-bash |
| 6105 | mk 'function stop ()' stop >f-stop |
| 6106 | chmod +x f-* |
| 6107 | echo "korn: $(./f-korn)" |
| 6108 | echo "dash: $(./f-dash)" |
| 6109 | echo "bash: $(./f-bash)" |
| 6110 | echo "stop: $(./f-stop)" |
| 6111 | expected-stdout: |
| 6112 | korn: bar='foo' |
| 6113 | dash: bar='./f-dash' |
| 6114 | bash: bar='./f-bash' |
| 6115 | stop: bar='./f-stop' |
| 6116 | --- |
| 6117 | name: integer-base-one-1 |
| 6118 | description: |
| 6119 | check if the use of fake integer base 1 works |
| 6120 | stdin: |
| 6121 | set -U |
| 6122 | typeset -Uui16 i0=1#ï i1=1#⬠|
| 6123 | typeset -i1 o0a=64 |
| 6124 | typeset -i1 o1a=0x263A |
| 6125 | typeset -Uui1 o0b=0x7E |
| 6126 | typeset -Uui1 o1b=0xFDD0 |
| 6127 | integer px=0xCAFE 'p0=1# ' p1=1#⦠pl=1#f |
| 6128 | echo "in <$i0> <$i1>" |
| 6129 | echo "out <${o0a#1#}|${o0b#1#}> <${o1a#1#}|${o1b#1#}>" |
| 6130 | typeset -Uui1 i0 i1 |
| 6131 | echo "pass <$px> <$p0> <$p1> <$pl> <${i0#1#}|${i1#1#}>" |
| 6132 | typeset -Uui16 tv1=1#~ tv2=1# tv3=1# tv4=1# tv5=1#À tv6=1#Á tv7=1#Â tv8=1#Â |
| 6133 | echo "specX <${tv1#16#}> <${tv2#16#}> <${tv3#16#}> <${tv4#16#}> <${tv5#16#}> <${tv6#16#}> <${tv7#16#}> <${tv8#16#}>" |
| 6134 | typeset -i1 tv1 tv2 tv3 tv4 tv5 tv6 tv7 tv8 |
| 6135 | echo "specW <${tv1#1#}> <${tv2#1#}> <${tv3#1#}> <${tv4#1#}> <${tv5#1#}> <${tv6#1#}> <${tv7#1#}> <${tv8#1#}>" |
| 6136 | typeset -i1 xs1=0xEF7F xs2=0xEF80 xs3=0xFDD0 |
| 6137 | echo "specU <${xs1#1#}> <${xs2#1#}> <${xs3#1#}>" |
| 6138 | expected-stdout: |
| 6139 | in <16#EFEF> <16#20AC> |
| 6140 | out <@|~> <âº|ï·> |
| 6141 | pass <16#cafe> <1# > <1#â¦> <1#f> <ï|â¬> |
| 6142 | specX <7E> <7F> <EF80> <EF81> <EFC0> <EFC1> <A0> <80> |
| 6143 | specW <~> <> <> <> <À> <Á> <Â > <Â> |
| 6144 | specU <> <> <ï·> |
| 6145 | --- |
| 6146 | name: integer-base-one-2a |
| 6147 | description: |
| 6148 | check if the use of fake integer base 1 stops at correct characters |
| 6149 | stdin: |
| 6150 | set -U |
| 6151 | integer x=1#foo |
| 6152 | echo /$x/ |
| 6153 | expected-stderr-pattern: |
| 6154 | /1#foo: unexpected 'oo'/ |
| 6155 | expected-exit: e != 0 |
| 6156 | --- |
| 6157 | name: integer-base-one-2b |
| 6158 | description: |
| 6159 | check if the use of fake integer base 1 stops at correct characters |
| 6160 | stdin: |
| 6161 | set -U |
| 6162 | integer x=1#À |
| 6163 | echo /$x/ |
| 6164 | expected-stderr-pattern: |
| 6165 | /1#À: unexpected ''/ |
| 6166 | expected-exit: e != 0 |
| 6167 | --- |
| 6168 | name: integer-base-one-2c1 |
| 6169 | description: |
| 6170 | check if the use of fake integer base 1 stops at correct characters |
| 6171 | stdin: |
| 6172 | set -U |
| 6173 | integer x=1#⦠|
| 6174 | echo /$x/ |
| 6175 | expected-stdout: |
| 6176 | /1#â¦/ |
| 6177 | --- |
| 6178 | name: integer-base-one-2c2 |
| 6179 | description: |
| 6180 | check if the use of fake integer base 1 stops at correct characters |
| 6181 | stdin: |
| 6182 | set +U |
| 6183 | integer x=1#⦠|
| 6184 | echo /$x/ |
| 6185 | expected-stderr-pattern: |
| 6186 | /1#â¦: unexpected ''/ |
| 6187 | expected-exit: e != 0 |
| 6188 | --- |
| 6189 | name: integer-base-one-2d1 |
| 6190 | description: |
| 6191 | check if the use of fake integer base 1 handles octets okay |
| 6192 | stdin: |
| 6193 | set -U |
| 6194 | typeset -i16 x=1#ÿ |
| 6195 | echo /$x/ # invalid utf-8 |
| 6196 | expected-stdout: |
| 6197 | /16#efff/ |
| 6198 | --- |
| 6199 | name: integer-base-one-2d2 |
| 6200 | description: |
| 6201 | check if the use of fake integer base 1 handles octets |
| 6202 | stdin: |
| 6203 | set -U |
| 6204 | typeset -i16 x=1#Â |
| 6205 | echo /$x/ # invalid 2-byte |
| 6206 | expected-stdout: |
| 6207 | /16#efc2/ |
| 6208 | --- |
| 6209 | name: integer-base-one-2d3 |
| 6210 | description: |
| 6211 | check if the use of fake integer base 1 handles octets |
| 6212 | stdin: |
| 6213 | set -U |
| 6214 | typeset -i16 x=1#ï |
| 6215 | echo /$x/ # invalid 2-byte |
| 6216 | expected-stdout: |
| 6217 | /16#efef/ |
| 6218 | --- |
| 6219 | name: integer-base-one-2d4 |
| 6220 | description: |
| 6221 | check if the use of fake integer base 1 stops at invalid input |
| 6222 | stdin: |
| 6223 | set -U |
| 6224 | typeset -i16 x=1#ï¿À |
| 6225 | echo /$x/ # invalid 3-byte |
| 6226 | expected-stderr-pattern: |
| 6227 | /1#ï¿À: unexpected '¿'/ |
| 6228 | expected-exit: e != 0 |
| 6229 | --- |
| 6230 | name: integer-base-one-2d5 |
| 6231 | description: |
| 6232 | check if the use of fake integer base 1 stops at invalid input |
| 6233 | stdin: |
| 6234 | set -U |
| 6235 | typeset -i16 x=1#À |
| 6236 | echo /$x/ # non-minimalistic |
| 6237 | expected-stderr-pattern: |
| 6238 | /1#À: unexpected ''/ |
| 6239 | expected-exit: e != 0 |
| 6240 | --- |
| 6241 | name: integer-base-one-2d6 |
| 6242 | description: |
| 6243 | check if the use of fake integer base 1 stops at invalid input |
| 6244 | stdin: |
| 6245 | set -U |
| 6246 | typeset -i16 x=1#à |
| 6247 | echo /$x/ # non-minimalistic |
| 6248 | expected-stderr-pattern: |
| 6249 | /1#à: unexpected ''/ |
| 6250 | expected-exit: e != 0 |
| 6251 | --- |
| 6252 | name: integer-base-one-3A |
| 6253 | description: |
| 6254 | some sample code for hexdumping |
| 6255 | stdin: |
| 6256 | { |
| 6257 | print 'Hello, World!\\\nããã«ã¡ã¯ï¼' |
| 6258 | typeset -Uui16 i=0x100 |
| 6259 | # change that to 0xFF once we can handle embedded |
| 6260 | # NUL characters in strings / here documents |
| 6261 | while (( i++ < 0x1FF )); do |
| 6262 | print -n "\x${i#16#1}" |
| 6263 | done |
| 6264 | print |
| 6265 | } | { |
| 6266 | typeset -Uui16 -Z11 pos=0 |
| 6267 | typeset -Uui16 -Z5 hv |
| 6268 | typeset -i1 wc=0x0A |
| 6269 | dasc= |
| 6270 | nl=${wc#1#} |
| 6271 | while IFS= read -r line; do |
| 6272 | line=$line$nl |
| 6273 | while [[ -n $line ]]; do |
| 6274 | hv=1#${line::1} |
| 6275 | if (( (pos & 15) == 0 )); then |
| 6276 | (( pos )) && print "$dasc|" |
| 6277 | print -n "${pos#16#} " |
| 6278 | dasc=' |' |
| 6279 | fi |
| 6280 | print -n "${hv#16#} " |
| 6281 | if (( (hv < 32) || (hv > 126) )); then |
| 6282 | dasc=$dasc. |
| 6283 | else |
| 6284 | dasc=$dasc${line::1} |
| 6285 | fi |
| 6286 | (( (pos++ & 15) == 7 )) && print -n -- '- ' |
| 6287 | line=${line:1} |
| 6288 | done |
| 6289 | done |
| 6290 | if (( (pos & 15) != 1 )); then |
| 6291 | while (( pos & 15 )); do |
| 6292 | print -n ' ' |
| 6293 | (( (pos++ & 15) == 7 )) && print -n -- '- ' |
| 6294 | done |
| 6295 | print "$dasc|" |
| 6296 | fi |
| 6297 | } |
| 6298 | expected-stdout: |
| 6299 | 00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..| |
| 6300 | 00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................| |
| 6301 | 00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................| |
| 6302 | 00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................| |
| 6303 | 00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.| |
| 6304 | 00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>| |
| 6305 | 00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN| |
| 6306 | 00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^| |
| 6307 | 00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn| |
| 6308 | 00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~| |
| 6309 | 000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................| |
| 6310 | 000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................| |
| 6311 | 000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................| |
| 6312 | 000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................| |
| 6313 | 000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................| |
| 6314 | 000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................| |
| 6315 | 00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................| |
| 6316 | 00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................| |
| 6317 | 00000120 FF 0A - |..| |
| 6318 | --- |
| 6319 | name: integer-base-one-3W |
| 6320 | description: |
| 6321 | some sample code for hexdumping Unicode |
| 6322 | stdin: |
| 6323 | set -U |
| 6324 | { |
| 6325 | print 'Hello, World!\\\nããã«ã¡ã¯ï¼' |
| 6326 | typeset -Uui16 i=0x100 |
| 6327 | # change that to 0xFF once we can handle embedded |
| 6328 | # NUL characters in strings / here documents |
| 6329 | while (( i++ < 0x1FF )); do |
| 6330 | print -n "\u${i#16#1}" |
| 6331 | done |
| 6332 | print |
| 6333 | print \\xff # invalid utf-8 |
| 6334 | print \\xc2 # invalid 2-byte |
| 6335 | print \\xef\\xbf\\xc0 # invalid 3-byte |
| 6336 | print \\xc0\\x80 # non-minimalistic |
| 6337 | print \\xe0\\x80\\x80 # non-minimalistic |
| 6338 | print '�￾￿' # end of range |
| 6339 | } | { |
| 6340 | typeset -Uui16 -Z11 pos=0 |
| 6341 | typeset -Uui16 -Z7 hv |
| 6342 | typeset -i1 wc=0x0A |
| 6343 | typeset -i lpos |
| 6344 | dasc= |
| 6345 | nl=${wc#1#} |
| 6346 | while IFS= read -r line; do |
| 6347 | line=$line$nl |
| 6348 | lpos=0 |
| 6349 | while (( lpos < ${#line} )); do |
| 6350 | wc=1#${line:(lpos++):1} |
| 6351 | if (( (wc < 32) || \ |
| 6352 | ((wc > 126) && (wc < 160)) )); then |
| 6353 | dch=. |
| 6354 | elif (( (wc & 0xFF80) == 0xEF80 )); then |
| 6355 | dch=� |
| 6356 | else |
| 6357 | dch=${wc#1#} |
| 6358 | fi |
| 6359 | if (( (pos & 7) == 7 )); then |
| 6360 | dasc=$dasc$dch |
| 6361 | dch= |
| 6362 | elif (( (pos & 7) == 0 )); then |
| 6363 | (( pos )) && print "$dasc|" |
| 6364 | print -n "${pos#16#} " |
| 6365 | dasc=' |' |
| 6366 | fi |
| 6367 | let hv=wc |
| 6368 | print -n "${hv#16#} " |
| 6369 | (( (pos++ & 7) == 3 )) && \ |
| 6370 | print -n -- '- ' |
| 6371 | dasc=$dasc$dch |
| 6372 | done |
| 6373 | done |
| 6374 | if (( pos & 7 )); then |
| 6375 | while (( pos & 7 )); do |
| 6376 | print -n ' ' |
| 6377 | (( (pos++ & 7) == 3 )) && print -n -- '- ' |
| 6378 | done |
| 6379 | print "$dasc|" |
| 6380 | fi |
| 6381 | } |
| 6382 | expected-stdout: |
| 6383 | 00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W| |
| 6384 | 00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.ã| |
| 6385 | 00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |ãã«ã¡ã¯ï¼...| |
| 6386 | 00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........| |
| 6387 | 00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........| |
| 6388 | 00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........| |
| 6389 | 00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"| |
| 6390 | 00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*| |
| 6391 | 00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012| |
| 6392 | 00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:| |
| 6393 | 00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB| |
| 6394 | 00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ| |
| 6395 | 00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR| |
| 6396 | 00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ| |
| 6397 | 00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab| |
| 6398 | 00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij| |
| 6399 | 00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr| |
| 6400 | 00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz| |
| 6401 | 00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....| |
| 6402 | 00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........| |
| 6403 | 000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........| |
| 6404 | 000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........| |
| 6405 | 000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |..... ¡¢| |
| 6406 | 000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA |£¤¥¦§¨©ª| |
| 6407 | 000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 |«¬Â®¯°±²| |
| 6408 | 000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA |³´µ¶·¸¹º| |
| 6409 | 000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 |»¼½¾¿ÃÃÃ| |
| 6410 | 000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA |ÃÃÃ
ÃÃÃÃÃ| |
| 6411 | 000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 |ÃÃÃÃÃÃÃÃ| |
| 6412 | 000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA |ÃÃÃÃÃÃÃÃ| |
| 6413 | 000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 |ÃÃÃÃÃà áâ| |
| 6414 | 000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA |ãäåæçèéê| |
| 6415 | 00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 |ëìÃîïðñò| |
| 6416 | 00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA |óôõö÷øùú| |
| 6417 | 00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |ûüýþÿ.�.| |
| 6418 | 00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |�.���.��| |
| 6419 | 00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |.���.���| |
| 6420 | 00000128 EFBE EFEF EFBF EFBF - 000A |����.| |
| 6421 | --- |
| 6422 | name: integer-base-one-4 |
| 6423 | description: |
| 6424 | Check if ksh93-style base-one integers work |
| 6425 | category: !smksh |
| 6426 | stdin: |
| 6427 | set -U |
| 6428 | echo 1 $(('a')) |
| 6429 | (echo 2f $(('aa'))) 2>&1 | sed "s/^[^']*'/2p '/" |
| 6430 | echo 3 $(('â¦')) |
| 6431 | x="'a'" |
| 6432 | echo "4 <$x>" |
| 6433 | echo 5 $(($x)) |
| 6434 | echo 6 $((x)) |
| 6435 | expected-stdout: |
| 6436 | 1 97 |
| 6437 | 2p 'aa': multi-character character constant |
| 6438 | 3 8230 |
| 6439 | 4 <'a'> |
| 6440 | 5 97 |
| 6441 | 6 97 |
| 6442 | --- |
| 6443 | name: ulimit-1 |
| 6444 | description: |
| 6445 | Check if we can use a specific syntax idiom for ulimit |
| 6446 | stdin: |
| 6447 | if ! x=$(ulimit -d) || [[ $x = unknown ]]; then |
| 6448 | #echo expected to fail on this OS |
| 6449 | echo okay |
| 6450 | else |
| 6451 | ulimit -dS $x && echo okay |
| 6452 | fi |
| 6453 | expected-stdout: |
| 6454 | okay |
| 6455 | --- |
| 6456 | name: bashiop-1 |
| 6457 | description: |
| 6458 | Check if GNU bash-like I/O redirection works |
| 6459 | Part 1: this is also supported by GNU bash |
| 6460 | stdin: |
| 6461 | exec 3>&1 |
| 6462 | function threeout { |
| 6463 | echo ras |
| 6464 | echo dwa >&2 |
| 6465 | echo tri >&3 |
| 6466 | } |
| 6467 | threeout &>foo |
| 6468 | echo === |
| 6469 | cat foo |
| 6470 | expected-stdout: |
| 6471 | tri |
| 6472 | === |
| 6473 | ras |
| 6474 | dwa |
| 6475 | --- |
| 6476 | name: bashiop-2a |
| 6477 | description: |
| 6478 | Check if GNU bash-like I/O redirection works |
| 6479 | Part 2: this is *not* supported by GNU bash |
| 6480 | stdin: |
| 6481 | exec 3>&1 |
| 6482 | function threeout { |
| 6483 | echo ras |
| 6484 | echo dwa >&2 |
| 6485 | echo tri >&3 |
| 6486 | } |
| 6487 | threeout 3&>foo |
| 6488 | echo === |
| 6489 | cat foo |
| 6490 | expected-stdout: |
| 6491 | ras |
| 6492 | === |
| 6493 | dwa |
| 6494 | tri |
| 6495 | --- |
| 6496 | name: bashiop-2b |
| 6497 | description: |
| 6498 | Check if GNU bash-like I/O redirection works |
| 6499 | Part 2: this is *not* supported by GNU bash |
| 6500 | stdin: |
| 6501 | exec 3>&1 |
| 6502 | function threeout { |
| 6503 | echo ras |
| 6504 | echo dwa >&2 |
| 6505 | echo tri >&3 |
| 6506 | } |
| 6507 | threeout 3>foo &>&3 |
| 6508 | echo === |
| 6509 | cat foo |
| 6510 | expected-stdout: |
| 6511 | === |
| 6512 | ras |
| 6513 | dwa |
| 6514 | tri |
| 6515 | --- |
| 6516 | name: bashiop-2c |
| 6517 | description: |
| 6518 | Check if GNU bash-like I/O redirection works |
| 6519 | Part 2: this is supported by GNU bash 4 only |
| 6520 | stdin: |
| 6521 | echo mir >foo |
| 6522 | set -o noclobber |
| 6523 | exec 3>&1 |
| 6524 | function threeout { |
| 6525 | echo ras |
| 6526 | echo dwa >&2 |
| 6527 | echo tri >&3 |
| 6528 | } |
| 6529 | threeout &>>foo |
| 6530 | echo === |
| 6531 | cat foo |
| 6532 | expected-stdout: |
| 6533 | tri |
| 6534 | === |
| 6535 | mir |
| 6536 | ras |
| 6537 | dwa |
| 6538 | --- |
| 6539 | name: bashiop-3a |
| 6540 | description: |
| 6541 | Check if GNU bash-like I/O redirection fails correctly |
| 6542 | Part 1: this is also supported by GNU bash |
| 6543 | stdin: |
| 6544 | echo mir >foo |
| 6545 | set -o noclobber |
| 6546 | exec 3>&1 |
| 6547 | function threeout { |
| 6548 | echo ras |
| 6549 | echo dwa >&2 |
| 6550 | echo tri >&3 |
| 6551 | } |
| 6552 | threeout &>foo |
| 6553 | echo === |
| 6554 | cat foo |
| 6555 | expected-stdout: |
| 6556 | === |
| 6557 | mir |
| 6558 | expected-stderr-pattern: /.*: cannot (create|overwrite) .*/ |
| 6559 | --- |
| 6560 | name: bashiop-3b |
| 6561 | description: |
| 6562 | Check if GNU bash-like I/O redirection fails correctly |
| 6563 | Part 2: this is *not* supported by GNU bash |
| 6564 | stdin: |
| 6565 | echo mir >foo |
| 6566 | set -o noclobber |
| 6567 | exec 3>&1 |
| 6568 | function threeout { |
| 6569 | echo ras |
| 6570 | echo dwa >&2 |
| 6571 | echo tri >&3 |
| 6572 | } |
| 6573 | threeout &>|foo |
| 6574 | echo === |
| 6575 | cat foo |
| 6576 | expected-stdout: |
| 6577 | tri |
| 6578 | === |
| 6579 | ras |
| 6580 | dwa |
| 6581 | --- |
| 6582 | name: bashiop-4 |
| 6583 | description: |
| 6584 | Check if GNU bash-like I/O redirection works |
| 6585 | Part 4: this is also supported by GNU bash, |
| 6586 | but failed in some mksh versions |
| 6587 | stdin: |
| 6588 | exec 3>&1 |
| 6589 | function threeout { |
| 6590 | echo ras |
| 6591 | echo dwa >&2 |
| 6592 | echo tri >&3 |
| 6593 | } |
| 6594 | function blubb { |
| 6595 | [[ -e bar ]] && threeout "$bf" &>foo |
| 6596 | } |
| 6597 | blubb |
| 6598 | echo -n >bar |
| 6599 | blubb |
| 6600 | echo === |
| 6601 | cat foo |
| 6602 | expected-stdout: |
| 6603 | tri |
| 6604 | === |
| 6605 | ras |
| 6606 | dwa |
| 6607 | --- |
| 6608 | name: mkshiop-1 |
| 6609 | description: |
| 6610 | Check for support of more than 9 file descriptors |
| 6611 | category: !convfds |
| 6612 | stdin: |
| 6613 | read -u10 foo 10<<< bar |
| 6614 | echo x$foo |
| 6615 | expected-stdout: |
| 6616 | xbar |
| 6617 | --- |
| 6618 | name: mkshiop-2 |
| 6619 | description: |
| 6620 | Check for support of more than 9 file descriptors |
| 6621 | category: !convfds |
| 6622 | stdin: |
| 6623 | exec 12>foo |
| 6624 | print -u12 bar |
| 6625 | echo baz >&12 |
| 6626 | cat foo |
| 6627 | expected-stdout: |
| 6628 | bar |
| 6629 | baz |
| 6630 | --- |
| 6631 | name: oksh-shcrash |
| 6632 | description: |
| 6633 | src/regress/bin/ksh/shcrash.sh,v 1.1 |
| 6634 | stdin: |
| 6635 | 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" |
| 6636 | 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" |
| 6637 | for deplib in $deplibs; do |
| 6638 | case $deplib in |
| 6639 | -L*) |
| 6640 | new_libs="$deplib $new_libs" |
| 6641 | ;; |
| 6642 | *) |
| 6643 | case " $specialdeplibs " in |
| 6644 | *" $deplib "*) |
| 6645 | new_libs="$deplib $new_libs";; |
| 6646 | esac |
| 6647 | ;; |
| 6648 | esac |
| 6649 | done |
| 6650 | --- |
| 6651 | name: oksh-varfunction-mod1 |
| 6652 | description: |
| 6653 | $OpenBSD: varfunction.sh,v 1.1 2003/12/15 05:28:40 otto Exp $ |
| 6654 | Calling |
| 6655 | FOO=bar f |
| 6656 | where f is a ksh style function, should not set FOO in the current |
| 6657 | env. If f is a Bourne style function, FOO should be set. Furthermore, |
| 6658 | the function should receive a correct value of FOO. However, differing |
| 6659 | from oksh, setting FOO in the function itself must change the value in |
| 6660 | setting FOO in the function itself should not change the value in |
| 6661 | global environment. |
| 6662 | Inspired by PR 2450. |
| 6663 | stdin: |
| 6664 | function k { |
| 6665 | if [ x$FOO != xbar ]; then |
| 6666 | echo 1 |
| 6667 | return 1 |
| 6668 | fi |
| 6669 | x=$(env | grep FOO) |
| 6670 | if [ "x$x" != "xFOO=bar" ]; then |
| 6671 | echo 2 |
| 6672 | return 1; |
| 6673 | fi |
| 6674 | FOO=foo |
| 6675 | return 0 |
| 6676 | } |
| 6677 | b () { |
| 6678 | if [ x$FOO != xbar ]; then |
| 6679 | echo 3 |
| 6680 | return 1 |
| 6681 | fi |
| 6682 | x=$(env | grep FOO) |
| 6683 | if [ "x$x" != "xFOO=bar" ]; then |
| 6684 | echo 4 |
| 6685 | return 1; |
| 6686 | fi |
| 6687 | FOO=foo |
| 6688 | return 0 |
| 6689 | } |
| 6690 | FOO=bar k |
| 6691 | if [ $? != 0 ]; then |
| 6692 | exit 1 |
| 6693 | fi |
| 6694 | if [ x$FOO != x ]; then |
| 6695 | exit 1 |
| 6696 | fi |
| 6697 | FOO=bar b |
| 6698 | if [ $? != 0 ]; then |
| 6699 | exit 1 |
| 6700 | fi |
| 6701 | if [ x$FOO != xfoo ]; then |
| 6702 | exit 1 |
| 6703 | fi |
| 6704 | FOO=barbar |
| 6705 | FOO=bar k |
| 6706 | if [ $? != 0 ]; then |
| 6707 | exit 1 |
| 6708 | fi |
| 6709 | if [ x$FOO != xbarbar ]; then |
| 6710 | exit 1 |
| 6711 | fi |
| 6712 | FOO=bar b |
| 6713 | if [ $? != 0 ]; then |
| 6714 | exit 1 |
| 6715 | fi |
| 6716 | if [ x$FOO != xfoo ]; then |
| 6717 | exit 1 |
| 6718 | fi |
| 6719 | --- |
| 6720 | name: fd-cloexec-1 |
| 6721 | description: |
| 6722 | Verify that file descriptors > 2 are private for Korn shells |
| 6723 | file-setup: file 644 "test.sh" |
| 6724 | print -u3 Fowl |
| 6725 | stdin: |
| 6726 | exec 3>&1 |
| 6727 | "$__progname" test.sh |
| 6728 | expected-exit: e != 0 |
| 6729 | expected-stderr: |
| 6730 | test.sh[1]: print: -u: 3: bad file descriptor |
| 6731 | --- |
| 6732 | name: fd-cloexec-2 |
| 6733 | description: |
| 6734 | Verify that file descriptors > 2 are not private for POSIX shells |
| 6735 | See Debian Bug #154540, Closes: #499139 |
| 6736 | file-setup: file 644 "test.sh" |
| 6737 | print -u3 Fowl |
| 6738 | stdin: |
| 6739 | test -n "$POSH_VERSION" || set -o sh |
| 6740 | exec 3>&1 |
| 6741 | "$__progname" test.sh |
| 6742 | expected-stdout: |
| 6743 | Fowl |
| 6744 | --- |
| 6745 | name: comsub-1 |
| 6746 | description: |
| 6747 | COMSUB are currently parsed by hacking lex.c instead of |
| 6748 | recursively (see regression-6): matching parenthesÄs bug |
| 6749 | Fails on: pdksh mksh bash2 bash3 zsh |
| 6750 | Passes on: bash4 ksh93 |
| 6751 | expected-fail: yes |
| 6752 | stdin: |
| 6753 | echo $(case 1 in (1) echo yes;; (2) echo no;; esac) |
| 6754 | echo $(case 1 in 1) echo yes;; 2) echo no;; esac) |
| 6755 | expected-stdout: |
| 6756 | yes |
| 6757 | yes |
| 6758 | --- |
| 6759 | name: comsub-2 |
| 6760 | description: |
| 6761 | RedHat BZ#496791 â another case of missing recursion |
| 6762 | in parsing COMSUB expressions |
| 6763 | Fails on: pdksh mksh bash2 bash3¹ bash4¹ zsh |
| 6764 | Passes on: ksh93 |
| 6765 | â bash[34] seem to choke on comment ending with backslash-newline |
| 6766 | expected-fail: yes |
| 6767 | stdin: |
| 6768 | # a comment with " ' \ |
| 6769 | x=$( |
| 6770 | echo yes |
| 6771 | # a comment with " ' \ |
| 6772 | ) |
| 6773 | echo $x |
| 6774 | expected-stdout: |
| 6775 | yes |
| 6776 | --- |
| 6777 | name: test-stnze-1 |
| 6778 | description: |
| 6779 | Check that the short form [ $x ] works |
| 6780 | stdin: |
| 6781 | i=0 |
| 6782 | [ -n $x ] |
| 6783 | rv=$?; echo $((++i)) $rv |
| 6784 | [ $x ] |
| 6785 | rv=$?; echo $((++i)) $rv |
| 6786 | [ -n "$x" ] |
| 6787 | rv=$?; echo $((++i)) $rv |
| 6788 | [ "$x" ] |
| 6789 | rv=$?; echo $((++i)) $rv |
| 6790 | x=0 |
| 6791 | [ -n $x ] |
| 6792 | rv=$?; echo $((++i)) $rv |
| 6793 | [ $x ] |
| 6794 | rv=$?; echo $((++i)) $rv |
| 6795 | [ -n "$x" ] |
| 6796 | rv=$?; echo $((++i)) $rv |
| 6797 | [ "$x" ] |
| 6798 | rv=$?; echo $((++i)) $rv |
| 6799 | x='1 -a 1 = 2' |
| 6800 | [ -n $x ] |
| 6801 | rv=$?; echo $((++i)) $rv |
| 6802 | [ $x ] |
| 6803 | rv=$?; echo $((++i)) $rv |
| 6804 | [ -n "$x" ] |
| 6805 | rv=$?; echo $((++i)) $rv |
| 6806 | [ "$x" ] |
| 6807 | rv=$?; echo $((++i)) $rv |
| 6808 | expected-stdout: |
| 6809 | 1 0 |
| 6810 | 2 1 |
| 6811 | 3 1 |
| 6812 | 4 1 |
| 6813 | 5 0 |
| 6814 | 6 0 |
| 6815 | 7 0 |
| 6816 | 8 0 |
| 6817 | 9 1 |
| 6818 | 10 1 |
| 6819 | 11 0 |
| 6820 | 12 0 |
| 6821 | --- |
| 6822 | name: test-stnze-2 |
| 6823 | description: |
| 6824 | Check that the short form [[ $x ]] works (ksh93 extension) |
| 6825 | stdin: |
| 6826 | i=0 |
| 6827 | [[ -n $x ]] |
| 6828 | rv=$?; echo $((++i)) $rv |
| 6829 | [[ $x ]] |
| 6830 | rv=$?; echo $((++i)) $rv |
| 6831 | [[ -n "$x" ]] |
| 6832 | rv=$?; echo $((++i)) $rv |
| 6833 | [[ "$x" ]] |
| 6834 | rv=$?; echo $((++i)) $rv |
| 6835 | x=0 |
| 6836 | [[ -n $x ]] |
| 6837 | rv=$?; echo $((++i)) $rv |
| 6838 | [[ $x ]] |
| 6839 | rv=$?; echo $((++i)) $rv |
| 6840 | [[ -n "$x" ]] |
| 6841 | rv=$?; echo $((++i)) $rv |
| 6842 | [[ "$x" ]] |
| 6843 | rv=$?; echo $((++i)) $rv |
| 6844 | x='1 -a 1 = 2' |
| 6845 | [[ -n $x ]] |
| 6846 | rv=$?; echo $((++i)) $rv |
| 6847 | [[ $x ]] |
| 6848 | rv=$?; echo $((++i)) $rv |
| 6849 | [[ -n "$x" ]] |
| 6850 | rv=$?; echo $((++i)) $rv |
| 6851 | [[ "$x" ]] |
| 6852 | rv=$?; echo $((++i)) $rv |
| 6853 | expected-stdout: |
| 6854 | 1 1 |
| 6855 | 2 1 |
| 6856 | 3 1 |
| 6857 | 4 1 |
| 6858 | 5 0 |
| 6859 | 6 0 |
| 6860 | 7 0 |
| 6861 | 8 0 |
| 6862 | 9 0 |
| 6863 | 10 0 |
| 6864 | 11 0 |
| 6865 | 12 0 |
| 6866 | --- |
| 6867 | name: event-subst-1a |
| 6868 | description: |
| 6869 | Check that '!' substitution in interactive mode works |
| 6870 | category: !smksh |
| 6871 | file-setup: file 755 "falsetto" |
| 6872 | #! /bin/sh |
| 6873 | echo molto bene |
| 6874 | exit 42 |
| 6875 | file-setup: file 755 "!false" |
| 6876 | #! /bin/sh |
| 6877 | echo si |
| 6878 | arguments: !-i! |
| 6879 | stdin: |
| 6880 | export PATH=.:$PATH |
| 6881 | falsetto |
| 6882 | echo yeap |
| 6883 | !false |
| 6884 | expected-exit: 42 |
| 6885 | expected-stdout: |
| 6886 | molto bene |
| 6887 | yeap |
| 6888 | molto bene |
| 6889 | expected-stderr-pattern: |
| 6890 | /.*/ |
| 6891 | --- |
| 6892 | name: event-subst-1b |
| 6893 | description: |
| 6894 | Check that '!' substitution in interactive mode works |
| 6895 | even when a space separates it from the search command, |
| 6896 | which is not what GNU bash provides but required for the |
| 6897 | other regression tests below to check |
| 6898 | category: !smksh |
| 6899 | file-setup: file 755 "falsetto" |
| 6900 | #! /bin/sh |
| 6901 | echo molto bene |
| 6902 | exit 42 |
| 6903 | file-setup: file 755 "!" |
| 6904 | #! /bin/sh |
| 6905 | echo si |
| 6906 | arguments: !-i! |
| 6907 | stdin: |
| 6908 | export PATH=.:$PATH |
| 6909 | falsetto |
| 6910 | echo yeap |
| 6911 | ! false |
| 6912 | expected-exit: 42 |
| 6913 | expected-stdout: |
| 6914 | molto bene |
| 6915 | yeap |
| 6916 | molto bene |
| 6917 | expected-stderr-pattern: |
| 6918 | /.*/ |
| 6919 | --- |
| 6920 | name: event-subst-2 |
| 6921 | description: |
| 6922 | Check that '!' substitution in interactive mode |
| 6923 | does not break things |
| 6924 | category: !smksh |
| 6925 | file-setup: file 755 "falsetto" |
| 6926 | #! /bin/sh |
| 6927 | echo molto bene |
| 6928 | exit 42 |
| 6929 | file-setup: file 755 "!" |
| 6930 | #! /bin/sh |
| 6931 | echo si |
| 6932 | arguments: !-i! |
| 6933 | env-setup: !ENV=./Env! |
| 6934 | file-setup: file 644 "Env" |
| 6935 | PS1=X |
| 6936 | stdin: |
| 6937 | export PATH=.:$PATH |
| 6938 | falsetto |
| 6939 | echo yeap |
| 6940 | !false |
| 6941 | echo meow |
| 6942 | ! false |
| 6943 | echo = $? |
| 6944 | if |
| 6945 | ! false; then echo foo; else echo bar; fi |
| 6946 | expected-stdout: |
| 6947 | molto bene |
| 6948 | yeap |
| 6949 | molto bene |
| 6950 | meow |
| 6951 | molto bene |
| 6952 | = 42 |
| 6953 | foo |
| 6954 | expected-stderr-pattern: |
| 6955 | /.*/ |
| 6956 | --- |
| 6957 | name: event-subst-3 |
| 6958 | description: |
| 6959 | Check that '!' substitution in noninteractive mode is ignored |
| 6960 | category: !smksh |
| 6961 | file-setup: file 755 "falsetto" |
| 6962 | #! /bin/sh |
| 6963 | echo molto bene |
| 6964 | exit 42 |
| 6965 | file-setup: file 755 "!false" |
| 6966 | #! /bin/sh |
| 6967 | echo si |
| 6968 | stdin: |
| 6969 | export PATH=.:$PATH |
| 6970 | falsetto |
| 6971 | echo yeap |
| 6972 | !false |
| 6973 | echo meow |
| 6974 | ! false |
| 6975 | echo = $? |
| 6976 | if |
| 6977 | ! false; then echo foo; else echo bar; fi |
| 6978 | expected-stdout: |
| 6979 | molto bene |
| 6980 | yeap |
| 6981 | si |
| 6982 | meow |
| 6983 | = 0 |
| 6984 | foo |
| 6985 | --- |
| 6986 | name: nounset-1 |
| 6987 | description: |
| 6988 | Check that "set -u" matches (future) SUSv4 requirement |
| 6989 | stdin: |
| 6990 | (set -u |
| 6991 | try() { |
| 6992 | local v |
| 6993 | eval v=\$$1 |
| 6994 | if [[ -n $v ]]; then |
| 6995 | echo $1=nz |
| 6996 | else |
| 6997 | echo $1=zf |
| 6998 | fi |
| 6999 | } |
| 7000 | x=y |
| 7001 | (echo $x) |
| 7002 | echo =1 |
| 7003 | (echo $y) |
| 7004 | echo =2 |
| 7005 | (try x) |
| 7006 | echo =3 |
| 7007 | (try y) |
| 7008 | echo =4 |
| 7009 | (try 0) |
| 7010 | echo =5 |
| 7011 | (try 2) |
| 7012 | echo =6 |
| 7013 | (try) |
| 7014 | echo =7 |
| 7015 | (echo at=$@) |
| 7016 | echo =8 |
| 7017 | (echo asterisk=$*) |
| 7018 | echo =9 |
| 7019 | (echo $?) |
| 7020 | echo =10 |
| 7021 | (echo $!) |
| 7022 | echo =11 |
| 7023 | (echo $-) |
| 7024 | echo =12 |
| 7025 | #(echo $_) |
| 7026 | #echo =13 |
| 7027 | (echo $#) |
| 7028 | echo =14 |
| 7029 | (mypid=$$; try mypid) |
| 7030 | echo =15 |
| 7031 | ) 2>&1 | sed -e 's/^[^]]*]//' -e 's/^[^:]*: *//' |
| 7032 | expected-stdout: |
| 7033 | y |
| 7034 | =1 |
| 7035 | y: parameter not set |
| 7036 | =2 |
| 7037 | x=nz |
| 7038 | =3 |
| 7039 | y: parameter not set |
| 7040 | =4 |
| 7041 | 0=nz |
| 7042 | =5 |
| 7043 | 2: parameter not set |
| 7044 | =6 |
| 7045 | 1: parameter not set |
| 7046 | =7 |
| 7047 | at= |
| 7048 | =8 |
| 7049 | asterisk= |
| 7050 | =9 |
| 7051 | 0 |
| 7052 | =10 |
| 7053 | !: parameter not set |
| 7054 | =11 |
| 7055 | ush |
| 7056 | =12 |
| 7057 | 0 |
| 7058 | =14 |
| 7059 | mypid=nz |
| 7060 | =15 |
| 7061 | --- |
| 7062 | name: nameref-1 |
| 7063 | description: |
| 7064 | Testsuite for nameref (bound variables) |
| 7065 | stdin: |
| 7066 | bar=global |
| 7067 | typeset -n ir2=bar |
| 7068 | typeset -n ind=ir2 |
| 7069 | echo !ind: ${!ind} |
| 7070 | echo ind: $ind |
| 7071 | echo !ir2: ${!ir2} |
| 7072 | echo ir2: $ir2 |
| 7073 | typeset +n ind |
| 7074 | echo !ind: ${!ind} |
| 7075 | echo ind: $ind |
| 7076 | typeset -n ir2=ind |
| 7077 | echo !ir2: ${!ir2} |
| 7078 | echo ir2: $ir2 |
| 7079 | set|grep ^ir2|sed 's/^/s1: /' |
| 7080 | typeset|grep ' ir2'|sed -e 's/^/s2: /' -e 's/nameref/typeset -n/' |
| 7081 | set -A blub -- e1 e2 e3 |
| 7082 | typeset -n ind=blub |
| 7083 | typeset -n ir2=blub[2] |
| 7084 | echo !ind[1]: ${!ind[1]} |
| 7085 | echo !ir2: $!ir2 |
| 7086 | echo ind[1]: ${ind[1]} |
| 7087 | echo ir2: $ir2 |
| 7088 | expected-stdout: |
| 7089 | !ind: bar |
| 7090 | ind: global |
| 7091 | !ir2: bar |
| 7092 | ir2: global |
| 7093 | !ind: ind |
| 7094 | ind: ir2 |
| 7095 | !ir2: ind |
| 7096 | ir2: ir2 |
| 7097 | s1: ir2=ind |
| 7098 | s2: typeset -n ir2 |
| 7099 | !ind[1]: 1 |
| 7100 | !ir2: ir2 |
| 7101 | ind[1]: e2 |
| 7102 | ir2: e3 |
| 7103 | --- |
| 7104 | name: nameref-2da |
| 7105 | description: |
| 7106 | Testsuite for nameref (bound variables) |
| 7107 | Functions, argument given directly, after local |
| 7108 | stdin: |
| 7109 | function foo { |
| 7110 | typeset bar=lokal baz=auch |
| 7111 | typeset -n v=bar |
| 7112 | echo entering |
| 7113 | echo !v: ${!v} |
| 7114 | echo !bar: ${!bar} |
| 7115 | echo !baz: ${!baz} |
| 7116 | echo bar: $bar |
| 7117 | echo v: $v |
| 7118 | v=123 |
| 7119 | echo bar: $bar |
| 7120 | echo v: $v |
| 7121 | echo exiting |
| 7122 | } |
| 7123 | bar=global |
| 7124 | echo bar: $bar |
| 7125 | foo bar |
| 7126 | echo bar: $bar |
| 7127 | expected-stdout: |
| 7128 | bar: global |
| 7129 | entering |
| 7130 | !v: bar |
| 7131 | !bar: bar |
| 7132 | !baz: baz |
| 7133 | bar: lokal |
| 7134 | v: lokal |
| 7135 | bar: 123 |
| 7136 | v: 123 |
| 7137 | exiting |
| 7138 | bar: global |
| 7139 | --- |
| 7140 | name: nameref-3 |
| 7141 | description: |
| 7142 | Advanced testsuite for bound variables (ksh93 fails this) |
| 7143 | stdin: |
| 7144 | typeset -n foo=bar[i] |
| 7145 | set -A bar -- b c a |
| 7146 | for i in 0 1 2 3; do |
| 7147 | print $i $foo . |
| 7148 | done |
| 7149 | expected-stdout: |
| 7150 | 0 b . |
| 7151 | 1 c . |
| 7152 | 2 a . |
| 7153 | 3 . |
| 7154 | --- |
| 7155 | name: better-parens-1a |
| 7156 | description: |
| 7157 | Check support for ((â¦)) and $((â¦)) vs (â¦) and $(â¦) |
| 7158 | stdin: |
| 7159 | if ( (echo fubar) | tr u x); then |
| 7160 | echo ja |
| 7161 | else |
| 7162 | echo nein |
| 7163 | fi |
| 7164 | expected-stdout: |
| 7165 | fxbar |
| 7166 | ja |
| 7167 | --- |
| 7168 | name: better-parens-1b |
| 7169 | description: |
| 7170 | Check support for ((â¦)) and $((â¦)) vs (â¦) and $(â¦) |
| 7171 | stdin: |
| 7172 | echo $( (echo fubar) | tr u x) $? |
| 7173 | expected-stdout: |
| 7174 | fxbar 0 |
| 7175 | --- |
| 7176 | name: better-parens-2a |
| 7177 | description: |
| 7178 | Check support for ((â¦)) and $((â¦)) vs (â¦) and $(â¦) |
| 7179 | stdin: |
| 7180 | if ((echo fubar) | tr u x); then |
| 7181 | echo ja |
| 7182 | else |
| 7183 | echo nein |
| 7184 | fi |
| 7185 | expected-stdout: |
| 7186 | fxbar |
| 7187 | ja |
| 7188 | --- |
| 7189 | name: better-parens-2b |
| 7190 | description: |
| 7191 | Check support for ((â¦)) and $((â¦)) vs (â¦) and $(â¦) |
| 7192 | stdin: |
| 7193 | echo $((echo fubar) | tr u x) $? |
| 7194 | expected-stdout: |
| 7195 | fxbar 0 |
| 7196 | --- |
| 7197 | name: better-parens-3a |
| 7198 | description: |
| 7199 | Check support for ((â¦)) and $((â¦)) vs (â¦) and $(â¦) |
| 7200 | stdin: |
| 7201 | if ( (echo fubar) | (tr u x)); then |
| 7202 | echo ja |
| 7203 | else |
| 7204 | echo nein |
| 7205 | fi |
| 7206 | expected-stdout: |
| 7207 | fxbar |
| 7208 | ja |
| 7209 | --- |
| 7210 | name: better-parens-3b |
| 7211 | description: |
| 7212 | Check support for ((â¦)) and $((â¦)) vs (â¦) and $(â¦) |
| 7213 | stdin: |
| 7214 | echo $( (echo fubar) | (tr u x)) $? |
| 7215 | expected-stdout: |
| 7216 | fxbar 0 |
| 7217 | --- |
| 7218 | name: better-parens-4a |
| 7219 | description: |
| 7220 | Check support for ((â¦)) and $((â¦)) vs (â¦) and $(â¦) |
| 7221 | stdin: |
| 7222 | if ((echo fubar) | (tr u x)); then |
| 7223 | echo ja |
| 7224 | else |
| 7225 | echo nein |
| 7226 | fi |
| 7227 | expected-stdout: |
| 7228 | fxbar |
| 7229 | ja |
| 7230 | --- |
| 7231 | name: better-parens-4b |
| 7232 | description: |
| 7233 | Check support for ((â¦)) and $((â¦)) vs (â¦) and $(â¦) |
| 7234 | stdin: |
| 7235 | echo $((echo fubar) | (tr u x)) $? |
| 7236 | expected-stdout: |
| 7237 | fxbar 0 |
| 7238 | --- |
| 7239 | name: echo-test-1 |
| 7240 | description: |
| 7241 | Test what the echo builtin does (mksh) |
| 7242 | stdin: |
| 7243 | echo -n 'foo\x40bar' |
| 7244 | echo -e '\tbaz' |
| 7245 | expected-stdout: |
| 7246 | foo@bar baz |
| 7247 | --- |
| 7248 | name: echo-test-2 |
| 7249 | description: |
| 7250 | Test what the echo builtin does (POSIX) |
| 7251 | Note: this follows Debian Policy 10.4 which mandates |
| 7252 | that -n shall be treated as an option, not XSI which |
| 7253 | mandates it shall be treated as string but escapes |
| 7254 | shall be expanded. |
| 7255 | stdin: |
| 7256 | test -n "$POSH_VERSION" || set -o sh |
| 7257 | echo -n 'foo\x40bar' |
| 7258 | echo -e '\tbaz' |
| 7259 | expected-stdout: |
| 7260 | foo\x40bar-e \tbaz |
| 7261 | --- |
| 7262 | name: utilities-getopts-1 |
| 7263 | description: |
| 7264 | getopts sets OPTIND correctly for unparsed option |
| 7265 | stdin: |
| 7266 | set -- -a -a -x |
| 7267 | while getopts :a optc; do |
| 7268 | echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc." |
| 7269 | done |
| 7270 | echo done |
| 7271 | expected-stdout: |
| 7272 | OPTARG=, OPTIND=2, optc=a. |
| 7273 | OPTARG=, OPTIND=3, optc=a. |
| 7274 | OPTARG=x, OPTIND=4, optc=?. |
| 7275 | done |
| 7276 | --- |
| 7277 | name: utilities-getopts-2 |
| 7278 | description: |
| 7279 | Check OPTARG |
| 7280 | stdin: |
| 7281 | set -- -a Mary -x |
| 7282 | while getopts a: optc; do |
| 7283 | echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc." |
| 7284 | done |
| 7285 | echo done |
| 7286 | expected-stdout: |
| 7287 | OPTARG=Mary, OPTIND=3, optc=a. |
| 7288 | OPTARG=, OPTIND=4, optc=?. |
| 7289 | done |
| 7290 | expected-stderr-pattern: /.*-x.*option/ |
| 7291 | --- |
| 7292 | name: wcswidth-1 |
| 7293 | description: |
| 7294 | Check the new wcswidth feature |
| 7295 | stdin: |
| 7296 | s=ä½ |
| 7297 | set +U |
| 7298 | print octets: ${#s} . |
| 7299 | print 8-bit width: ${%s} . |
| 7300 | set -U |
| 7301 | print characters: ${#s} . |
| 7302 | print columns: ${%s} . |
| 7303 | s=� |
| 7304 | set +U |
| 7305 | print octets: ${#s} . |
| 7306 | print 8-bit width: ${%s} . |
| 7307 | set -U |
| 7308 | print characters: ${#s} . |
| 7309 | print columns: ${%s} . |
| 7310 | expected-stdout: |
| 7311 | octets: 3 . |
| 7312 | 8-bit width: -1 . |
| 7313 | characters: 1 . |
| 7314 | columns: 2 . |
| 7315 | octets: 3 . |
| 7316 | 8-bit width: 3 . |
| 7317 | characters: 1 . |
| 7318 | columns: 1 . |
| 7319 | --- |
| 7320 | name: wcswidth-2 |
| 7321 | description: |
| 7322 | Check some corner cases |
| 7323 | stdin: |
| 7324 | print % $% . |
| 7325 | set -U |
| 7326 | x='a b' |
| 7327 | print c ${%x} . |
| 7328 | set +U |
| 7329 | x='a b' |
| 7330 | print d ${%x} . |
| 7331 | expected-stdout: |
| 7332 | % $% . |
| 7333 | c -1 . |
| 7334 | d -1 . |
| 7335 | --- |
| 7336 | name: wcswidth-3 |
| 7337 | description: |
| 7338 | Check some corner cases |
| 7339 | stdin: |
| 7340 | print ${%} . |
| 7341 | expected-stderr-pattern: |
| 7342 | /bad substitution/ |
| 7343 | expected-exit: 1 |
| 7344 | --- |
| 7345 | name: wcswidth-4a |
| 7346 | description: |
| 7347 | Check some corner cases |
| 7348 | stdin: |
| 7349 | print ${%*} . |
| 7350 | expected-stderr-pattern: |
| 7351 | /bad substitution/ |
| 7352 | expected-exit: 1 |
| 7353 | --- |
| 7354 | name: wcswidth-4b |
| 7355 | description: |
| 7356 | Check some corner cases |
| 7357 | stdin: |
| 7358 | print ${%@} . |
| 7359 | expected-stderr-pattern: |
| 7360 | /bad substitution/ |
| 7361 | expected-exit: 1 |
| 7362 | --- |
| 7363 | name: wcswidth-4c |
| 7364 | description: |
| 7365 | Check some corner cases |
| 7366 | stdin: |
| 7367 | : |
| 7368 | print ${%?} . |
| 7369 | expected-stdout: |
| 7370 | 1 . |
| 7371 | --- |
| 7372 | name: realpath-1 |
| 7373 | description: |
| 7374 | Check proper return values for realpath |
| 7375 | category: os:mirbsd |
| 7376 | stdin: |
| 7377 | wd=$(realpath .) |
| 7378 | mkdir dir |
| 7379 | :>file |
| 7380 | :>dir/file |
| 7381 | ln -s dir lndir |
| 7382 | ln -s file lnfile |
| 7383 | ln -s nix lnnix |
| 7384 | ln -s . lnself |
| 7385 | i=0 |
| 7386 | chk() { |
| 7387 | typeset x y |
| 7388 | x=$(realpath "$wd/$1" 2>&1); y=$? |
| 7389 | print $((++i)) "?$1" =${x##*$wd/} !$y |
| 7390 | } |
| 7391 | chk dir |
| 7392 | chk dir/ |
| 7393 | chk dir/file |
| 7394 | chk dir/nix |
| 7395 | chk file |
| 7396 | chk file/ |
| 7397 | chk file/file |
| 7398 | chk file/nix |
| 7399 | chk nix |
| 7400 | chk nix/ |
| 7401 | chk nix/file |
| 7402 | chk nix/nix |
| 7403 | chk lndir |
| 7404 | chk lndir/ |
| 7405 | chk lndir/file |
| 7406 | chk lndir/nix |
| 7407 | chk lnfile |
| 7408 | chk lnfile/ |
| 7409 | chk lnfile/file |
| 7410 | chk lnfile/nix |
| 7411 | chk lnnix |
| 7412 | chk lnnix/ |
| 7413 | chk lnnix/file |
| 7414 | chk lnnix/nix |
| 7415 | 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 |
| 7416 | rm lnself |
| 7417 | expected-stdout: |
| 7418 | 1 ?dir =dir !0 |
| 7419 | 2 ?dir/ =dir !0 |
| 7420 | 3 ?dir/file =dir/file !0 |
| 7421 | 4 ?dir/nix =dir/nix !0 |
| 7422 | 5 ?file =file !0 |
| 7423 | 6 ?file/ =file/: Not a directory !20 |
| 7424 | 7 ?file/file =file/file: Not a directory !20 |
| 7425 | 8 ?file/nix =file/nix: Not a directory !20 |
| 7426 | 9 ?nix =nix !0 |
| 7427 | 10 ?nix/ =nix !0 |
| 7428 | 11 ?nix/file =nix/file: No such file or directory !2 |
| 7429 | 12 ?nix/nix =nix/nix: No such file or directory !2 |
| 7430 | 13 ?lndir =dir !0 |
| 7431 | 14 ?lndir/ =dir !0 |
| 7432 | 15 ?lndir/file =dir/file !0 |
| 7433 | 16 ?lndir/nix =dir/nix !0 |
| 7434 | 17 ?lnfile =file !0 |
| 7435 | 18 ?lnfile/ =lnfile/: Not a directory !20 |
| 7436 | 19 ?lnfile/file =lnfile/file: Not a directory !20 |
| 7437 | 20 ?lnfile/nix =lnfile/nix: Not a directory !20 |
| 7438 | 21 ?lnnix =nix !0 |
| 7439 | 22 ?lnnix/ =nix !0 |
| 7440 | 23 ?lnnix/file =lnnix/file: No such file or directory !2 |
| 7441 | 24 ?lnnix/nix =lnnix/nix: No such file or directory !2 |
| 7442 | 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 |
| 7443 | --- |