1 # $MirOS: src/bin/mksh/check.t,v 1.801 2018/01/14 01:47:33 tg Exp $ 2 # -*- mode: sh -*- 3 #- 4 # Copyright 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 5 # 2011, 2012, 2013, 2014, 2015, 2016, 2017 6 # mirabilos <m (a] mirbsd.org> 7 # 8 # Provided that these terms and disclaimer and all copyright notices 9 # are retained or reproduced in an accompanying document, permission 10 # is granted to deal in this work without restriction, including un 11 # limited rights to use, publicly perform, distribute, sell, modify, 12 # merge, give away, or sublicence. 13 # 14 # This work is provided AS IS and WITHOUT WARRANTY of any kind, to 15 # the utmost extent permitted by applicable law, neither express nor 16 # implied; without malicious intent or gross negligence. In no event 17 # may a licensor, author or contributor be held liable for indirect, 18 # direct, other damage, loss, or other issues arising in any way out 19 # of dealing in the work, even if advised of the possibility of such 20 # damage or existence of a defect, except proven that it results out 21 # of said persons immediate fault when using the work as intended. 22 #- 23 # You may also want to test IFS with the script at 24 # http://www.research.att.com/~gsf/public/ifs.sh 25 # 26 # More testsuites at: 27 # http://svnweb.freebsd.org/base/head/bin/test/tests/legacy_test.sh?view=co&content-type=text%2Fplain 28 # 29 # Integrated testsuites from: 30 # (2013/12/02 20:39:44) http://cvsweb.openbsd.org/cgi-bin/cvsweb/src/regress/bin/ksh/?sortby=date 31 32 expected-stdout: 33 @(#)MIRBSD KSH R56 2018/01/14 34 description: 35 Check base version of full shell 36 stdin: 37 echo ${KSH_VERSION%%' +'*} 38 name: KSH_VERSION 39 category: !shell:legacy-yes 40 --- 41 expected-stdout: 42 @(#)LEGACY KSH R56 2018/01/14 43 description: 44 Check base version of legacy shell 45 stdin: 46 echo ${KSH_VERSION%%' +'*} 47 name: KSH_VERSION-legacy 48 category: !shell:legacy-no 49 --- 50 name: KSH_VERSION-ascii 51 description: 52 Check that the shell version tag does not include EBCDIC 53 category: !shell:ebcdic-yes 54 stdin: 55 for x in $KSH_VERSION; do 56 [[ $x = '+EBCDIC' ]] && exit 1 57 done 58 exit 0 59 --- 60 name: KSH_VERSION-ebcdic 61 description: 62 Check that the shell version tag includes EBCDIC 63 category: !shell:ebcdic-no 64 stdin: 65 for x in $KSH_VERSION; do 66 [[ $x = '+EBCDIC' ]] && exit 0 67 done 68 exit 1 69 --- 70 name: KSH_VERSION-binmode 71 description: 72 Check that the shell version tag does not include TEXTMODE 73 category: !shell:textmode-yes 74 stdin: 75 for x in $KSH_VERSION; do 76 [[ $x = '+TEXTMODE' ]] && exit 1 77 done 78 exit 0 79 --- 80 name: KSH_VERSION-textmode 81 description: 82 Check that the shell version tag includes TEXTMODE 83 category: !shell:textmode-no 84 stdin: 85 for x in $KSH_VERSION; do 86 [[ $x = '+TEXTMODE' ]] && exit 0 87 done 88 exit 1 89 --- 90 name: selftest-1 91 description: 92 Regression test self-testing 93 stdin: 94 echo ${foo:-baz} 95 expected-stdout: 96 baz 97 --- 98 name: selftest-2 99 description: 100 Regression test self-testing 101 env-setup: !foo=bar! 102 stdin: 103 echo ${foo:-baz} 104 expected-stdout: 105 bar 106 --- 107 name: selftest-3 108 description: 109 Regression test self-testing 110 env-setup: !ENV=fnord! 111 stdin: 112 echo "<$ENV>" 113 expected-stdout: 114 <fnord> 115 --- 116 name: selftest-exec 117 description: 118 Ensure that the test run directory (default /tmp but can be changed 119 with check.pl flag -T or test.sh $TMPDIR) is not mounted noexec, as 120 we execute scripts from the scratch directory during several tests. 121 stdin: 122 print '#!'"$__progname"'\necho tf' >lq 123 chmod +x lq 124 ./lq 125 expected-stdout: 126 tf 127 --- 128 name: selftest-env 129 description: 130 Just output the environment variables set (always fails) 131 category: disabled 132 stdin: 133 set 134 --- 135 name: selftest-direct-builtin-call 136 description: 137 Check that direct builtin calls work 138 stdin: 139 ln -s "$__progname" cat || cp "$__progname" cat 140 ln -s "$__progname" echo || cp "$__progname" echo 141 ./echo -c 'echo foo' | ./cat -u 142 expected-stdout: 143 -c echo foo 144 --- 145 name: selftest-pathsep-unix 146 description: 147 Check that $PATHSEP is set correctly. 148 category: !os:os2 149 stdin: 150 PATHSEP=.; export PATHSEP 151 "$__progname" -c 'print -r -- $PATHSEP' 152 expected-stdout: 153 : 154 --- 155 name: selftest-pathsep-dospath 156 description: 157 Check that $PATHSEP is set correctly. 158 category: os:os2 159 stdin: 160 PATHSEP=.; export PATHSEP 161 "$__progname" -c 'print -r -- $PATHSEP' 162 expected-stdout: 163 ; 164 --- 165 name: alias-1 166 description: 167 Check that recursion is detected/avoided in aliases. 168 stdin: 169 alias fooBar=fooBar 170 fooBar 171 exit 0 172 expected-stderr-pattern: 173 /fooBar.*not found.*/ 174 --- 175 name: alias-2 176 description: 177 Check that recursion is detected/avoided in aliases. 178 stdin: 179 alias fooBar=barFoo 180 alias barFoo=fooBar 181 fooBar 182 barFoo 183 exit 0 184 expected-stderr-pattern: 185 /fooBar.*not found.*\n.*barFoo.*not found/ 186 --- 187 name: alias-3 188 description: 189 Check that recursion is detected/avoided in aliases. 190 stdin: 191 alias Echo='echo ' 192 alias fooBar=barFoo 193 alias barFoo=fooBar 194 Echo fooBar 195 unalias barFoo 196 Echo fooBar 197 expected-stdout: 198 fooBar 199 barFoo 200 --- 201 name: alias-4 202 description: 203 Check that alias expansion isn't done on keywords (in keyword 204 postitions). 205 stdin: 206 alias Echo='echo ' 207 alias while=While 208 while false; do echo hi ; done 209 Echo while 210 expected-stdout: 211 While 212 --- 213 name: alias-5 214 description: 215 Check that alias expansion done after alias with trailing space. 216 stdin: 217 alias Echo='echo ' 218 alias foo='bar stuff ' 219 alias bar='Bar1 Bar2 ' 220 alias stuff='Stuff' 221 alias blah='Blah' 222 Echo foo blah 223 expected-stdout: 224 Bar1 Bar2 Stuff Blah 225 --- 226 name: alias-6 227 description: 228 Check that alias expansion done after alias with trailing space. 229 stdin: 230 alias Echo='echo ' 231 alias foo='bar bar' 232 alias bar='Bar ' 233 alias blah=Blah 234 Echo foo blah 235 expected-stdout: 236 Bar Bar Blah 237 --- 238 name: alias-7 239 description: 240 Check that alias expansion done after alias with trailing space 241 after a keyword. 242 stdin: 243 alias X='case ' 244 alias Y=Z 245 X Y in 'Y') echo is y ;; Z) echo is z ;; esac 246 expected-stdout: 247 is z 248 --- 249 name: alias-8 250 description: 251 Check that newlines in an alias don't cause the command to be lost. 252 stdin: 253 alias foo=' 254 255 256 echo hi 257 258 259 260 echo there 261 262 263 ' 264 foo 265 expected-stdout: 266 hi 267 there 268 --- 269 name: alias-9 270 description: 271 Check that recursion is detected/avoided in aliases. 272 This check fails for slow machines or Cygwin, raise 273 the time-limit clause (e.g. to 7) if this occurs. 274 time-limit: 3 275 stdin: 276 print '#!'"$__progname"'\necho tf' >lq 277 chmod +x lq 278 PATH=$PWD$PATHSEP$PATH 279 alias lq=lq 280 lq 281 echo = now 282 i=`lq` 283 print -r -- $i 284 echo = out 285 exit 0 286 expected-stdout: 287 tf 288 = now 289 tf 290 = out 291 --- 292 name: alias-10 293 description: 294 Check that recursion is detected/avoided in aliases. 295 Regression, introduced during an old bugfix. 296 stdin: 297 alias foo='print hello ' 298 alias bar='foo world' 299 echo $(bar) 300 expected-stdout: 301 hello world 302 --- 303 name: alias-11 304 description: 305 Check that special argument handling still applies with escaped aliases 306 stdin: 307 alias local1='\typeset' 308 alias local2='\\builtin typeset' 309 function fooa { 310 local1 x=$1 y=z 311 print -r -- "$x,$y" 312 } 313 function foob { 314 local2 x=$1 y=z 315 print -r -- "$x,$y" 316 } 317 x=1 y=2; fooa 'bar - baz' 318 x=1 y=2; foob 'bar - baz' 319 expected-stdout: 320 bar - baz,z 321 bar - baz,z 322 --- 323 name: alias-12 324 description: 325 Something weird from Martijn Dekker 326 stdin: 327 alias echo=print 328 x() { echo a; (echo b); x=$(echo c); } 329 typeset -f x 330 alias OPEN='{' CLOSE='};' 331 { OPEN echo hi1; CLOSE } 332 var=`{ OPEN echo hi2; CLOSE }` && echo "$var" 333 var=$({ OPEN echo hi3; CLOSE }) && echo "$var" 334 expected-stdout: 335 x() { 336 \print a 337 ( \print b ) 338 x=$(\print c ) 339 } 340 hi1 341 hi2 342 hi3 343 --- 344 name: arith-compound 345 description: 346 Check that arithmetic expressions are compound constructs 347 stdin: 348 { ! (( 0$(cat >&2) )) <<<1; } <<<2 349 expected-stderr: 350 1 351 --- 352 name: arith-lazy-1 353 description: 354 Check that only one side of ternary operator is evaluated 355 stdin: 356 x=i+=2 357 y=j+=2 358 typeset -i i=1 j=1 359 echo $((1 ? 20 : (x+=2))) 360 echo $i,$x 361 echo $((0 ? (y+=2) : 30)) 362 echo $j,$y 363 expected-stdout: 364 20 365 1,i+=2 366 30 367 1,j+=2 368 --- 369 name: arith-lazy-2 370 description: 371 Check that assignments not done on non-evaluated side of ternary 372 operator 373 stdin: 374 x=i+=2 375 y=j+=2 376 typeset -i i=1 j=1 377 echo $((1 ? 20 : (x+=2))) 378 echo $i,$x 379 echo $((0 ? (y+=2) : 30)) 380 echo $i,$y 381 expected-stdout: 382 20 383 1,i+=2 384 30 385 1,j+=2 386 --- 387 name: arith-lazy-3 388 description: 389 Check that assignments not done on non-evaluated side of ternary 390 operator and this construct is parsed correctly (Debian #445651) 391 stdin: 392 x=4 393 y=$((0 ? x=1 : 2)) 394 echo = $x $y = 395 expected-stdout: 396 = 4 2 = 397 --- 398 name: arith-lazy-4 399 description: 400 Check that preun/postun not done on non-evaluated side of ternary 401 operator 402 stdin: 403 (( m = n = 0, 1 ? n++ : m++ ? 2 : 3 )) 404 echo "($n, $m)" 405 m=0; echo $(( 0 ? ++m : 2 )); echo $m 406 m=0; echo $(( 0 ? m++ : 2 )); echo $m 407 expected-stdout: 408 (1, 0) 409 2 410 0 411 2 412 0 413 --- 414 name: arith-lazy-5-arr-n 415 description: Check lazy evaluation with side effects 416 stdin: 417 a=0; echo "$((0&&b[a++],a))" 418 expected-stdout: 419 0 420 --- 421 name: arith-lazy-5-arr-p 422 description: Check lazy evaluation with side effects 423 stdin: 424 a=0; echo "$((0&&(b[a++]),a))" 425 expected-stdout: 426 0 427 --- 428 name: arith-lazy-5-str-n 429 description: Check lazy evaluation with side effects 430 stdin: 431 a=0 b=a++; ((0&&b)); echo $a 432 expected-stdout: 433 0 434 --- 435 name: arith-lazy-5-str-p 436 description: Check lazy evaluation with side effects 437 stdin: 438 a=0 b=a++; ((0&&(b))); echo $a 439 expected-stdout: 440 0 441 --- 442 name: arith-lazy-5-tern-l-n 443 description: Check lazy evaluation with side effects 444 stdin: 445 a=0; echo "$((0?b[a++]:999,a))" 446 expected-stdout: 447 0 448 --- 449 name: arith-lazy-5-tern-l-p 450 description: Check lazy evaluation with side effects 451 stdin: 452 a=0; echo "$((0?(b[a++]):999,a))" 453 expected-stdout: 454 0 455 --- 456 name: arith-lazy-5-tern-r-n 457 description: Check lazy evaluation with side effects 458 stdin: 459 a=0; echo "$((1?999:b[a++],a))" 460 expected-stdout: 461 0 462 --- 463 name: arith-lazy-5-tern-r-p 464 description: Check lazy evaluation with side effects 465 stdin: 466 a=0; echo "$((1?999:(b[a++]),a))" 467 expected-stdout: 468 0 469 --- 470 name: arith-ternary-prec-1 471 description: 472 Check precedence of ternary operator vs assignment 473 stdin: 474 typeset -i x=2 475 y=$((1 ? 20 : x+=2)) 476 expected-exit: e != 0 477 expected-stderr-pattern: 478 /.*:.*1 \? 20 : x\+=2.*lvalue.*\n$/ 479 --- 480 name: arith-ternary-prec-2 481 description: 482 Check precedence of ternary operator vs assignment 483 stdin: 484 typeset -i x=2 485 echo $((0 ? x+=2 : 20)) 486 expected-stdout: 487 20 488 --- 489 name: arith-prec-1 490 description: 491 Prove arithmetic expressions with embedded parameter 492 substitutions cannot be parsed ahead of time 493 stdin: 494 a='3 + 4' 495 print 1 $((2 * a)) . 496 print 2 $((2 * $a)) . 497 expected-stdout: 498 1 14 . 499 2 10 . 500 --- 501 name: arith-div-assoc-1 502 description: 503 Check associativity of division operator 504 stdin: 505 echo $((20 / 2 / 2)) 506 expected-stdout: 507 5 508 --- 509 name: arith-div-byzero 510 description: 511 Check division by zero errors out 512 stdin: 513 x=$(echo $((1 / 0))) 514 echo =$?:$x. 515 expected-stdout: 516 =1:. 517 expected-stderr-pattern: 518 /.*divisor/ 519 --- 520 name: arith-div-intmin-by-minusone 521 description: 522 Check division overflow wraps around silently 523 category: int:32 524 stdin: 525 echo signed:$((-2147483648 / -1))r$((-2147483648 % -1)). 526 echo unsigned:$((# -2147483648 / -1))r$((# -2147483648 % -1)). 527 expected-stdout: 528 signed:-2147483648r0. 529 unsigned:0r2147483648. 530 --- 531 name: arith-div-intmin-by-minusone-64 532 description: 533 Check division overflow wraps around silently 534 category: int:64 535 stdin: 536 echo signed:$((-9223372036854775808 / -1))r$((-9223372036854775808 % -1)). 537 echo unsigned:$((# -9223372036854775808 / -1))r$((# -9223372036854775808 % -1)). 538 expected-stdout: 539 signed:-9223372036854775808r0. 540 unsigned:0r9223372036854775808. 541 --- 542 name: arith-assop-assoc-1 543 description: 544 Check associativity of assignment-operator operator 545 stdin: 546 typeset -i i=1 j=2 k=3 547 echo $((i += j += k)) 548 echo $i,$j,$k 549 expected-stdout: 550 6 551 6,5,3 552 --- 553 name: arith-mandatory 554 description: 555 Passing of this test is *mandatory* for a valid mksh executable! 556 category: shell:legacy-no 557 stdin: 558 typeset -i sari=0 559 typeset -Ui uari=0 560 typeset -i x=0 561 print -r -- $((x++)):$sari=$uari. #0 562 let --sari --uari 563 print -r -- $((x++)):$sari=$uari. #1 564 sari=2147483647 uari=2147483647 565 print -r -- $((x++)):$sari=$uari. #2 566 let ++sari ++uari 567 print -r -- $((x++)):$sari=$uari. #3 568 let --sari --uari 569 let 'sari *= 2' 'uari *= 2' 570 let ++sari ++uari 571 print -r -- $((x++)):$sari=$uari. #4 572 let ++sari ++uari 573 print -r -- $((x++)):$sari=$uari. #5 574 sari=-2147483648 uari=-2147483648 575 print -r -- $((x++)):$sari=$uari. #6 576 let --sari --uari 577 print -r -- $((x++)):$sari=$uari. #7 578 (( sari = -5 >> 1 )) 579 ((# uari = -5 >> 1 )) 580 print -r -- $((x++)):$sari=$uari. #8 581 (( sari = -2 )) 582 ((# uari = sari )) 583 print -r -- $((x++)):$sari=$uari. #9 584 expected-stdout: 585 0:0=0. 586 1:-1=4294967295. 587 2:2147483647=2147483647. 588 3:-2147483648=2147483648. 589 4:-1=4294967295. 590 5:0=0. 591 6:-2147483648=2147483648. 592 7:2147483647=2147483647. 593 8:-3=2147483645. 594 9:-2=4294967294. 595 --- 596 name: arith-unsigned-1 597 description: 598 Check if unsigned arithmetics work 599 category: int:32 600 stdin: 601 # signed vs unsigned 602 echo x1 $((-1)) $((#-1)) 603 # calculating 604 typeset -i vs 605 typeset -Ui vu 606 vs=4123456789; vu=4123456789 607 echo x2 $vs $vu 608 (( vs %= 2147483647 )) 609 (( vu %= 2147483647 )) 610 echo x3 $vs $vu 611 vs=4123456789; vu=4123456789 612 (( # vs %= 2147483647 )) 613 (( # vu %= 2147483647 )) 614 echo x4 $vs $vu 615 # make sure the calculation does not change unsigned flag 616 vs=4123456789; vu=4123456789 617 echo x5 $vs $vu 618 # short form 619 echo x6 $((# vs % 2147483647)) $((# vu % 2147483647)) 620 # array refs 621 set -A va 622 va[1975973142]=right 623 va[4123456789]=wrong 624 echo x7 ${va[#4123456789%2147483647]} 625 # make sure multiple calculations don't interfere with each other 626 let '# mca = -4 % -2' ' mcb = -4 % -2' 627 echo x8 $mca $mcb 628 expected-stdout: 629 x1 -1 4294967295 630 x2 -171510507 4123456789 631 x3 -171510507 4123456789 632 x4 1975973142 1975973142 633 x5 -171510507 4123456789 634 x6 1975973142 1975973142 635 x7 right 636 x8 -4 0 637 --- 638 name: arith-limit32-1 639 description: 640 Check if arithmetics are 32 bit 641 category: int:32 642 stdin: 643 # signed vs unsigned 644 echo x1 $((-1)) $((#-1)) 645 # calculating 646 typeset -i vs 647 typeset -Ui vu 648 vs=2147483647; vu=2147483647 649 echo x2 $vs $vu 650 let vs++ vu++ 651 echo x3 $vs $vu 652 vs=4294967295; vu=4294967295 653 echo x4 $vs $vu 654 let vs++ vu++ 655 echo x5 $vs $vu 656 let vs++ vu++ 657 echo x6 $vs $vu 658 expected-stdout: 659 x1 -1 4294967295 660 x2 2147483647 2147483647 661 x3 -2147483648 2147483648 662 x4 -1 4294967295 663 x5 0 0 664 x6 1 1 665 --- 666 name: arith-limit64-1 667 description: 668 Check if arithmetics are 64 bit 669 category: int:64 670 stdin: 671 # signed vs unsigned 672 echo x1 $((-1)) $((#-1)) 673 # calculating 674 typeset -i vs 675 typeset -Ui vu 676 vs=9223372036854775807; vu=9223372036854775807 677 echo x2 $vs $vu 678 let vs++ vu++ 679 echo x3 $vs $vu 680 vs=18446744073709551615; vu=18446744073709551615 681 echo x4 $vs $vu 682 let vs++ vu++ 683 echo x5 $vs $vu 684 let vs++ vu++ 685 echo x6 $vs $vu 686 expected-stdout: 687 x1 -1 18446744073709551615 688 x2 9223372036854775807 9223372036854775807 689 x3 -9223372036854775808 9223372036854775808 690 x4 -1 18446744073709551615 691 x5 0 0 692 x6 1 1 693 --- 694 name: bksl-nl-ign-1 695 description: 696 Check that \newline is not collapsed after # 697 stdin: 698 echo hi #there \ 699 echo folks 700 expected-stdout: 701 hi 702 folks 703 --- 704 name: bksl-nl-ign-2 705 description: 706 Check that \newline is not collapsed inside single quotes 707 stdin: 708 echo 'hi \ 709 there' 710 echo folks 711 expected-stdout: 712 hi \ 713 there 714 folks 715 --- 716 name: bksl-nl-ign-3 717 description: 718 Check that \newline is not collapsed inside single quotes 719 stdin: 720 cat << \EOF 721 hi \ 722 there 723 EOF 724 expected-stdout: 725 hi \ 726 there 727 --- 728 name: bksl-nl-ign-4 729 description: 730 Check interaction of aliases, single quotes and here-documents 731 with backslash-newline 732 (don't know what POSIX has to say about this) 733 stdin: 734 a=2 735 alias x='echo hi 736 cat << "EOF" 737 foo\ 738 bar 739 some' 740 x 741 more\ 742 stuff$a 743 EOF 744 expected-stdout: 745 hi 746 foo\ 747 bar 748 some 749 more\ 750 stuff$a 751 --- 752 name: bksl-nl-ign-5 753 description: 754 Check what happens with backslash at end of input 755 (the old Bourne shell trashes them; so do we) 756 stdin: ! 757 echo `echo foo\\`bar 758 echo hi\ 759 expected-stdout: 760 foobar 761 hi 762 --- 763 # 764 # Places \newline should be collapsed 765 # 766 name: bksl-nl-1 767 description: 768 Check that \newline is collapsed before, in the middle of, and 769 after words 770 stdin: 771 \ 772 echo hi\ 773 There, \ 774 folks 775 expected-stdout: 776 hiThere, folks 777 --- 778 name: bksl-nl-2 779 description: 780 Check that \newline is collapsed in $ sequences 781 (ksh93 fails this) 782 stdin: 783 a=12 784 ab=19 785 echo $\ 786 a 787 echo $a\ 788 b 789 echo $\ 790 {a} 791 echo ${a\ 792 b} 793 echo ${ab\ 794 } 795 expected-stdout: 796 12 797 19 798 12 799 19 800 19 801 --- 802 name: bksl-nl-3 803 description: 804 Check that \newline is collapsed in $(..) and `...` sequences 805 (ksh93 fails this) 806 stdin: 807 echo $\ 808 (echo foobar1) 809 echo $(\ 810 echo foobar2) 811 echo $(echo foo\ 812 bar3) 813 echo $(echo foobar4\ 814 ) 815 echo ` 816 echo stuff1` 817 echo `echo st\ 818 uff2` 819 expected-stdout: 820 foobar1 821 foobar2 822 foobar3 823 foobar4 824 stuff1 825 stuff2 826 --- 827 name: bksl-nl-4 828 description: 829 Check that \newline is collapsed in $((..)) sequences 830 (ksh93 fails this) 831 stdin: 832 echo $\ 833 ((1+2)) 834 echo $(\ 835 (1+2+3)) 836 echo $((\ 837 1+2+3+4)) 838 echo $((1+\ 839 2+3+4+5)) 840 echo $((1+2+3+4+5+6)\ 841 ) 842 expected-stdout: 843 3 844 6 845 10 846 15 847 21 848 --- 849 name: bksl-nl-5 850 description: 851 Check that \newline is collapsed in double quoted strings 852 stdin: 853 echo "\ 854 hi" 855 echo "foo\ 856 bar" 857 echo "folks\ 858 " 859 expected-stdout: 860 hi 861 foobar 862 folks 863 --- 864 name: bksl-nl-6 865 description: 866 Check that \newline is collapsed in here document delimiters 867 (ksh93 fails second part of this) 868 stdin: 869 a=12 870 cat << EO\ 871 F 872 a=$a 873 foo\ 874 bar 875 EOF 876 cat << E_O_F 877 foo 878 E_O_\ 879 F 880 echo done 881 expected-stdout: 882 a=12 883 foobar 884 foo 885 done 886 --- 887 name: bksl-nl-7 888 description: 889 Check that \newline is collapsed in double-quoted here-document 890 delimiter. 891 stdin: 892 a=12 893 cat << "EO\ 894 F" 895 a=$a 896 foo\ 897 bar 898 EOF 899 echo done 900 expected-stdout: 901 a=$a 902 foo\ 903 bar 904 done 905 --- 906 name: bksl-nl-8 907 description: 908 Check that \newline is collapsed in various 2+ character tokens 909 delimiter. 910 (ksh93 fails this) 911 stdin: 912 echo hi &\ 913 & echo there 914 echo foo |\ 915 | echo bar 916 cat <\ 917 < EOF 918 stuff 919 EOF 920 cat <\ 921 <\ 922 - EOF 923 more stuff 924 EOF 925 cat <<\ 926 EOF 927 abcdef 928 EOF 929 echo hi >\ 930 > /dev/null 931 echo $? 932 i=1 933 case $i in 934 (\ 935 x|\ 936 1\ 937 ) echo hi;\ 938 ; 939 (*) echo oops 940 esac 941 expected-stdout: 942 hi 943 there 944 foo 945 stuff 946 more stuff 947 abcdef 948 0 949 hi 950 --- 951 name: bksl-nl-9 952 description: 953 Check that \ at the end of an alias is collapsed when followed 954 by a newline 955 (don't know what POSIX has to say about this) 956 stdin: 957 alias x='echo hi\' 958 x 959 echo there 960 expected-stdout: 961 hiecho there 962 --- 963 name: bksl-nl-10 964 description: 965 Check that \newline in a keyword is collapsed 966 stdin: 967 i\ 968 f true; then\ 969 echo pass; el\ 970 se echo fail; fi 971 expected-stdout: 972 pass 973 --- 974 # 975 # Places \newline should be collapsed (ksh extensions) 976 # 977 name: bksl-nl-ksh-1 978 description: 979 Check that \newline is collapsed in extended globbing 980 (ksh93 fails this) 981 stdin: 982 xxx=foo 983 case $xxx in 984 (f*\ 985 (\ 986 o\ 987 )\ 988 ) echo ok ;; 989 *) echo bad 990 esac 991 expected-stdout: 992 ok 993 --- 994 name: bksl-nl-ksh-2 995 description: 996 Check that \newline is collapsed in ((...)) expressions 997 (ksh93 fails this) 998 stdin: 999 i=1 1000 (\ 1001 (\ 1002 i=i+2\ 1003 )\ 1004 ) 1005 echo $i 1006 expected-stdout: 1007 3 1008 --- 1009 name: break-1 1010 description: 1011 See if break breaks out of loops 1012 stdin: 1013 for i in a b c; do echo $i; break; echo bad-$i; done 1014 echo end-1 1015 for i in a b c; do echo $i; break 1; echo bad-$i; done 1016 echo end-2 1017 for i in a b c; do 1018 for j in x y z; do 1019 echo $i:$j 1020 break 1021 echo bad-$i 1022 done 1023 echo end-$i 1024 done 1025 echo end-3 1026 for i in a b c; do echo $i; eval break; echo bad-$i; done 1027 echo end-4 1028 expected-stdout: 1029 a 1030 end-1 1031 a 1032 end-2 1033 a:x 1034 end-a 1035 b:x 1036 end-b 1037 c:x 1038 end-c 1039 end-3 1040 a 1041 end-4 1042 --- 1043 name: break-2 1044 description: 1045 See if break breaks out of nested loops 1046 stdin: 1047 for i in a b c; do 1048 for j in x y z; do 1049 echo $i:$j 1050 break 2 1051 echo bad-$i 1052 done 1053 echo end-$i 1054 done 1055 echo end 1056 expected-stdout: 1057 a:x 1058 end 1059 --- 1060 name: break-3 1061 description: 1062 What if break used outside of any loops 1063 (ksh88,ksh93 don't print error messages here) 1064 stdin: 1065 break 1066 expected-stderr-pattern: 1067 /.*break.*/ 1068 --- 1069 name: break-4 1070 description: 1071 What if break N used when only N-1 loops 1072 (ksh88,ksh93 don't print error messages here) 1073 stdin: 1074 for i in a b c; do echo $i; break 2; echo bad-$i; done 1075 echo end 1076 expected-stdout: 1077 a 1078 end 1079 expected-stderr-pattern: 1080 /.*break.*/ 1081 --- 1082 name: break-5 1083 description: 1084 Error if break argument isn't a number 1085 stdin: 1086 for i in a b c; do echo $i; break abc; echo more-$i; done 1087 echo end 1088 expected-stdout: 1089 a 1090 expected-exit: e != 0 1091 expected-stderr-pattern: 1092 /.*break.*/ 1093 --- 1094 name: continue-1 1095 description: 1096 See if continue continues loops 1097 stdin: 1098 for i in a b c; do echo $i; continue; echo bad-$i ; done 1099 echo end-1 1100 for i in a b c; do echo $i; continue 1; echo bad-$i; done 1101 echo end-2 1102 for i in a b c; do 1103 for j in x y z; do 1104 echo $i:$j 1105 continue 1106 echo bad-$i-$j 1107 done 1108 echo end-$i 1109 done 1110 echo end-3 1111 for i in a b c; do echo $i; eval continue; echo bad-$i ; done 1112 echo end-4 1113 expected-stdout: 1114 a 1115 b 1116 c 1117 end-1 1118 a 1119 b 1120 c 1121 end-2 1122 a:x 1123 a:y 1124 a:z 1125 end-a 1126 b:x 1127 b:y 1128 b:z 1129 end-b 1130 c:x 1131 c:y 1132 c:z 1133 end-c 1134 end-3 1135 a 1136 b 1137 c 1138 end-4 1139 --- 1140 name: continue-2 1141 description: 1142 See if continue breaks out of nested loops 1143 stdin: 1144 for i in a b c; do 1145 for j in x y z; do 1146 echo $i:$j 1147 continue 2 1148 echo bad-$i-$j 1149 done 1150 echo end-$i 1151 done 1152 echo end 1153 expected-stdout: 1154 a:x 1155 b:x 1156 c:x 1157 end 1158 --- 1159 name: continue-3 1160 description: 1161 What if continue used outside of any loops 1162 (ksh88,ksh93 don't print error messages here) 1163 stdin: 1164 continue 1165 expected-stderr-pattern: 1166 /.*continue.*/ 1167 --- 1168 name: continue-4 1169 description: 1170 What if continue N used when only N-1 loops 1171 (ksh88,ksh93 don't print error messages here) 1172 stdin: 1173 for i in a b c; do echo $i; continue 2; echo bad-$i; done 1174 echo end 1175 expected-stdout: 1176 a 1177 b 1178 c 1179 end 1180 expected-stderr-pattern: 1181 /.*continue.*/ 1182 --- 1183 name: continue-5 1184 description: 1185 Error if continue argument isn't a number 1186 stdin: 1187 for i in a b c; do echo $i; continue abc; echo more-$i; done 1188 echo end 1189 expected-stdout: 1190 a 1191 expected-exit: e != 0 1192 expected-stderr-pattern: 1193 /.*continue.*/ 1194 --- 1195 name: cd-history 1196 description: 1197 Test someone's CD history package (uses arrays) 1198 stdin: 1199 # go to known place before doing anything 1200 cd / 1201 1202 alias cd=_cd 1203 function _cd 1204 { 1205 typeset -i cdlen i 1206 typeset t 1207 1208 if [ $# -eq 0 ] 1209 then 1210 set -- $HOME 1211 fi 1212 1213 if [ "$CDHISTFILE" -a -r "$CDHISTFILE" ] # if directory history exists 1214 then 1215 typeset CDHIST 1216 i=-1 1217 while read -r t # read directory history file 1218 do 1219 CDHIST[i=i+1]=$t 1220 done <$CDHISTFILE 1221 fi 1222 1223 if [ "${CDHIST[0]}" != "$PWD" -a "$PWD" != "" ] 1224 then 1225 _cdins # insert $PWD into cd history 1226 fi 1227 1228 cdlen=${#CDHIST[*]} # number of elements in history 1229 1230 case "$@" in 1231 -) # cd to new dir 1232 if [ "$OLDPWD" = "" ] && ((cdlen>1)) 1233 then 1234 'print' ${CDHIST[1]} 1235 'cd' ${CDHIST[1]} 1236 _pwd 1237 else 1238 'cd' $@ 1239 _pwd 1240 fi 1241 ;; 1242 -l) # print directory list 1243 typeset -R3 num 1244 ((i=cdlen)) 1245 while (((i=i-1)>=0)) 1246 do 1247 num=$i 1248 'print' "$num ${CDHIST[i]}" 1249 done 1250 return 1251 ;; 1252 -[0-9]|-[0-9][0-9]) # cd to dir in list 1253 if (((i=${1#-})<cdlen)) 1254 then 1255 'print' ${CDHIST[i]} 1256 'cd' ${CDHIST[i]} 1257 _pwd 1258 else 1259 'cd' $@ 1260 _pwd 1261 fi 1262 ;; 1263 -*) # cd to matched dir in list 1264 t=${1#-} 1265 i=1 1266 while ((i<cdlen)) 1267 do 1268 case ${CDHIST[i]} in 1269 *$t*) 1270 'print' ${CDHIST[i]} 1271 'cd' ${CDHIST[i]} 1272 _pwd 1273 break 1274 ;; 1275 esac 1276 ((i=i+1)) 1277 done 1278 if ((i>=cdlen)) 1279 then 1280 'cd' $@ 1281 _pwd 1282 fi 1283 ;; 1284 *) # cd to new dir 1285 'cd' $@ 1286 _pwd 1287 ;; 1288 esac 1289 1290 _cdins # insert $PWD into cd history 1291 1292 if [ "$CDHISTFILE" ] 1293 then 1294 cdlen=${#CDHIST[*]} # number of elements in history 1295 1296 i=0 1297 while ((i<cdlen)) 1298 do 1299 'print' -r ${CDHIST[i]} # update directory history 1300 ((i=i+1)) 1301 done >$CDHISTFILE 1302 fi 1303 } 1304 1305 function _cdins # insert $PWD into cd history 1306 { # meant to be called only by _cd 1307 typeset -i i 1308 1309 ((i=0)) 1310 while ((i<${#CDHIST[*]})) # see if dir is already in list 1311 do 1312 if [ "${CDHIST[$i]}" = "$PWD" ] 1313 then 1314 break 1315 fi 1316 ((i=i+1)) 1317 done 1318 1319 if ((i>22)) # limit max size of list 1320 then 1321 i=22 1322 fi 1323 1324 while (((i=i-1)>=0)) # bump old dirs in list 1325 do 1326 CDHIST[i+1]=${CDHIST[i]} 1327 done 1328 1329 CDHIST[0]=$PWD # insert new directory in list 1330 } 1331 1332 1333 function _pwd 1334 { 1335 if [ -n "$ECD" ] 1336 then 1337 pwd 1>&6 1338 fi 1339 } 1340 # Start of test 1341 cd /tmp 1342 cd /bin 1343 cd /etc 1344 cd - 1345 cd -2 1346 cd -l 1347 expected-stdout: 1348 /bin 1349 /tmp 1350 3 / 1351 2 /etc 1352 1 /bin 1353 0 /tmp 1354 --- 1355 name: cd-pe 1356 description: 1357 Check package for cd -Pe 1358 need-pass: no 1359 # the mv command fails on Cygwin and z/OS 1360 # Hurd aborts the testsuite (permission denied) 1361 # QNX does not find subdir to cd into 1362 category: !os:cygwin,!os:gnu,!os:msys,!os:nto,!os:os390,!nosymlink 1363 file-setup: file 644 "x" 1364 mkdir noread noread/target noread/target/subdir 1365 ln -s noread link 1366 chmod 311 noread 1367 cd -P$1 . 1368 echo 0=$? 1369 bwd=$PWD 1370 cd -P$1 link/target 1371 echo 1=$?,${PWD#$bwd/} 1372 epwd=$($TSHELL -c pwd 2>/dev/null) 1373 # This unexpectedly succeeds on GNU/Linux and MidnightBSD 1374 #echo pwd=$?,$epwd 1375 # expect: pwd=1, 1376 mv ../../noread ../../renamed 1377 cd -P$1 subdir 1378 echo 2=$?,${PWD#$bwd/} 1379 cd $bwd 1380 chmod 755 noread renamed 2>/dev/null 1381 rm -rf noread link renamed 1382 stdin: 1383 export TSHELL="$__progname" 1384 "$__progname" x 1385 echo "now with -e:" 1386 "$__progname" x e 1387 expected-stdout: 1388 0=0 1389 1=0,noread/target 1390 2=0,noread/target/subdir 1391 now with -e: 1392 0=0 1393 1=0,noread/target 1394 2=1,noread/target/subdir 1395 --- 1396 name: env-prompt 1397 description: 1398 Check that prompt not printed when processing ENV 1399 env-setup: !ENV=./foo! 1400 file-setup: file 644 "foo" 1401 XXX=_ 1402 PS1=X 1403 false && echo hmmm 1404 need-ctty: yes 1405 arguments: !-i! 1406 stdin: 1407 echo hi${XXX}there 1408 expected-stdout: 1409 hi_there 1410 expected-stderr: ! 1411 XX 1412 --- 1413 name: expand-ugly 1414 description: 1415 Check that weird ${foo+bar} constructs are parsed correctly 1416 stdin: 1417 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn 1418 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "<$x> "; done' >pfs 1419 chmod +x pfn pfs 1420 (echo 1 ${IFS+'}'z}) 2>/dev/null || echo failed in 1 1421 (echo 2 "${IFS+'}'z}") 2>/dev/null || echo failed in 2 1422 (echo 3 "foo ${IFS+'bar} baz") 2>/dev/null || echo failed in 3 1423 (echo -n '4 '; ./pfn "foo ${IFS+"b c"} baz") 2>/dev/null || echo failed in 4 1424 (echo -n '5 '; ./pfn "foo ${IFS+b c} baz") 2>/dev/null || echo failed in 5 1425 (echo 6 ${IFS+"}"z}) 2>/dev/null || echo failed in 6 1426 (echo 7 "${IFS+"}"z}") 2>/dev/null || echo failed in 7 1427 (echo 8 "${IFS+\"}\"z}") 2>/dev/null || echo failed in 8 1428 (echo 9 "${IFS+\"\}\"z}") 2>/dev/null || echo failed in 9 1429 (echo 10 foo ${IFS+'bar} baz'}) 2>/dev/null || echo failed in 10 1430 (echo 11 "$(echo "${IFS+'}'z}")") 2>/dev/null || echo failed in 11 1431 (echo 12 "$(echo ${IFS+'}'z})") 2>/dev/null || echo failed in 12 1432 (echo 13 ${IFS+\}z}) 2>/dev/null || echo failed in 13 1433 (echo 14 "${IFS+\}z}") 2>/dev/null || echo failed in 14 1434 u=x; (echo -n '15 '; ./pfs "foo ${IFS+a"b$u{ {"{{\}b} c ${IFS+d{}} bar" ${IFS-e{}} baz; echo .) 2>/dev/null || echo failed in 15 1435 l=t; (echo 16 ${IFS+h`echo -n i ${IFS+$l}h`ere}) 2>/dev/null || echo failed in 16 1436 l=t; (echo 17 ${IFS+h$(echo -n i ${IFS+$l}h)ere}) 2>/dev/null || echo failed in 17 1437 l=t; (echo 18 "${IFS+h`echo -n i ${IFS+$l}h`ere}") 2>/dev/null || echo failed in 18 1438 l=t; (echo 19 "${IFS+h$(echo -n i ${IFS+$l}h)ere}") 2>/dev/null || echo failed in 19 1439 l=t; (echo 20 ${IFS+h`echo -n i "${IFS+$l}"h`ere}) 2>/dev/null || echo failed in 20 1440 l=t; (echo 21 ${IFS+h$(echo -n i "${IFS+$l}"h)ere}) 2>/dev/null || echo failed in 21 1441 l=t; (echo 22 "${IFS+h`echo -n i "${IFS+$l}"h`ere}") 2>/dev/null || echo failed in 22 1442 l=t; (echo 23 "${IFS+h$(echo -n i "${IFS+$l}"h)ere}") 2>/dev/null || echo failed in 23 1443 key=value; (echo -n '24 '; ./pfn "${IFS+'$key'}") 2>/dev/null || echo failed in 24 1444 key=value; (echo -n '25 '; ./pfn "${IFS+"'$key'"}") 2>/dev/null || echo failed in 25 # ksh93: '$key' 1445 key=value; (echo -n '26 '; ./pfn ${IFS+'$key'}) 2>/dev/null || echo failed in 26 1446 key=value; (echo -n '27 '; ./pfn ${IFS+"'$key'"}) 2>/dev/null || echo failed in 27 1447 (echo -n '28 '; ./pfn "${IFS+"'"x ~ x'}'x"'}"x}" #') 2>/dev/null || echo failed in 28 1448 u=x; (echo -n '29 '; ./pfs foo ${IFS+a"b$u{ {"{ {\}b} c ${IFS+d{}} bar ${IFS-e{}} baz; echo .) 2>/dev/null || echo failed in 29 1449 (echo -n '30 '; ./pfs ${IFS+foo 'b\ 1450 ar' baz}; echo .) 2>/dev/null || (echo failed in 30; echo failed in 31) 1451 (echo -n '32 '; ./pfs ${IFS+foo "b\ 1452 ar" baz}; echo .) 2>/dev/null || echo failed in 32 1453 (echo -n '33 '; ./pfs "${IFS+foo 'b\ 1454 ar' baz}"; echo .) 2>/dev/null || echo failed in 33 1455 (echo -n '34 '; ./pfs "${IFS+foo "b\ 1456 ar" baz}"; echo .) 2>/dev/null || echo failed in 34 1457 (echo -n '35 '; ./pfs ${v=a\ b} x ${v=c\ d}; echo .) 2>/dev/null || echo failed in 35 1458 (echo -n '36 '; ./pfs "${v=a\ b}" x "${v=c\ d}"; echo .) 2>/dev/null || echo failed in 36 1459 (echo -n '37 '; ./pfs ${v-a\ b} x ${v-c\ d}; echo .) 2>/dev/null || echo failed in 37 1460 (echo 38 ${IFS+x'a'y} / "${IFS+x'a'y}" .) 2>/dev/null || echo failed in 38 1461 foo="x'a'y"; (echo 39 ${foo%*'a'*} / "${foo%*'a'*}" .) 2>/dev/null || echo failed in 39 1462 foo="a b c"; (echo -n '40 '; ./pfs "${foo#a}"; echo .) 2>/dev/null || echo failed in 40 1463 (foo() { return 100; }; foo; echo 41 ${#+${#:+${#?}}\ \}\}\}}) 2>/dev/null || echo failed in 41 1464 expected-stdout: 1465 1 }z 1466 2 ''z} 1467 3 foo 'bar baz 1468 4 foo b c baz 1469 5 foo b c baz 1470 6 }z 1471 7 }z 1472 8 ""z} 1473 9 "}"z 1474 10 foo bar} baz 1475 11 ''z} 1476 12 }z 1477 13 }z 1478 14 }z 1479 15 <foo abx{ {{{}b c d{} bar> <}> <baz> . 1480 16 hi there 1481 17 hi there 1482 18 hi there 1483 19 hi there 1484 20 hi there 1485 21 hi there 1486 22 hi there 1487 23 hi there 1488 24 'value' 1489 25 'value' 1490 26 $key 1491 27 'value' 1492 28 'x ~ x''x}"x}" # 1493 29 <foo> <abx{ {{> <{}b> <c> <d{}> <bar> <}> <baz> . 1494 30 <foo> <b\ 1495 ar> <baz> . 1496 32 <foo> <bar> <baz> . 1497 33 <foo 'bar' baz> . 1498 34 <foo bar baz> . 1499 35 <a> <b> <x> <a> <b> . 1500 36 <a\ b> <x> <a\ b> . 1501 37 <a b> <x> <c d> . 1502 38 xay / x'a'y . 1503 39 x' / x' . 1504 40 < b c> . 1505 41 3 }}} 1506 --- 1507 name: expand-unglob-dblq 1508 description: 1509 Check that regular "${foo+bar}" constructs are parsed correctly 1510 stdin: 1511 u=x 1512 tl_norm() { 1513 v=$2 1514 test x"$v" = x"-" && unset v 1515 (echo "$1 plus norm foo ${v+'bar'} baz") 1516 (echo "$1 dash norm foo ${v-'bar'} baz") 1517 (echo "$1 eqal norm foo ${v='bar'} baz") 1518 (echo "$1 qstn norm foo ${v?'bar'} baz") 2>/dev/null || \ 1519 echo "$1 qstn norm -> error" 1520 (echo "$1 PLUS norm foo ${v:+'bar'} baz") 1521 (echo "$1 DASH norm foo ${v:-'bar'} baz") 1522 (echo "$1 EQAL norm foo ${v:='bar'} baz") 1523 (echo "$1 QSTN norm foo ${v:?'bar'} baz") 2>/dev/null || \ 1524 echo "$1 QSTN norm -> error" 1525 } 1526 tl_paren() { 1527 v=$2 1528 test x"$v" = x"-" && unset v 1529 (echo "$1 plus parn foo ${v+(bar)} baz") 1530 (echo "$1 dash parn foo ${v-(bar)} baz") 1531 (echo "$1 eqal parn foo ${v=(bar)} baz") 1532 (echo "$1 qstn parn foo ${v?(bar)} baz") 2>/dev/null || \ 1533 echo "$1 qstn parn -> error" 1534 (echo "$1 PLUS parn foo ${v:+(bar)} baz") 1535 (echo "$1 DASH parn foo ${v:-(bar)} baz") 1536 (echo "$1 EQAL parn foo ${v:=(bar)} baz") 1537 (echo "$1 QSTN parn foo ${v:?(bar)} baz") 2>/dev/null || \ 1538 echo "$1 QSTN parn -> error" 1539 } 1540 tl_brace() { 1541 v=$2 1542 test x"$v" = x"-" && unset v 1543 (echo "$1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz") 1544 (echo "$1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz") 1545 (echo "$1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz") 1546 (echo "$1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz") 2>/dev/null || \ 1547 echo "$1 qstn brac -> error" 1548 (echo "$1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz") 1549 (echo "$1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz") 1550 (echo "$1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz") 1551 (echo "$1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz") 2>/dev/null || \ 1552 echo "$1 QSTN brac -> error" 1553 } 1554 : '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' 1555 tl_norm 1 - 1556 tl_norm 2 '' 1557 tl_norm 3 x 1558 tl_paren 4 - 1559 tl_paren 5 '' 1560 tl_paren 6 x 1561 tl_brace 7 - 1562 tl_brace 8 '' 1563 tl_brace 9 x 1564 expected-stdout: 1565 1 plus norm foo baz 1566 1 dash norm foo 'bar' baz 1567 1 eqal norm foo 'bar' baz 1568 1 qstn norm -> error 1569 1 PLUS norm foo baz 1570 1 DASH norm foo 'bar' baz 1571 1 EQAL norm foo 'bar' baz 1572 1 QSTN norm -> error 1573 2 plus norm foo 'bar' baz 1574 2 dash norm foo baz 1575 2 eqal norm foo baz 1576 2 qstn norm foo baz 1577 2 PLUS norm foo baz 1578 2 DASH norm foo 'bar' baz 1579 2 EQAL norm foo 'bar' baz 1580 2 QSTN norm -> error 1581 3 plus norm foo 'bar' baz 1582 3 dash norm foo x baz 1583 3 eqal norm foo x baz 1584 3 qstn norm foo x baz 1585 3 PLUS norm foo 'bar' baz 1586 3 DASH norm foo x baz 1587 3 EQAL norm foo x baz 1588 3 QSTN norm foo x baz 1589 4 plus parn foo baz 1590 4 dash parn foo (bar) baz 1591 4 eqal parn foo (bar) baz 1592 4 qstn parn -> error 1593 4 PLUS parn foo baz 1594 4 DASH parn foo (bar) baz 1595 4 EQAL parn foo (bar) baz 1596 4 QSTN parn -> error 1597 5 plus parn foo (bar) baz 1598 5 dash parn foo baz 1599 5 eqal parn foo baz 1600 5 qstn parn foo baz 1601 5 PLUS parn foo baz 1602 5 DASH parn foo (bar) baz 1603 5 EQAL parn foo (bar) baz 1604 5 QSTN parn -> error 1605 6 plus parn foo (bar) baz 1606 6 dash parn foo x baz 1607 6 eqal parn foo x baz 1608 6 qstn parn foo x baz 1609 6 PLUS parn foo (bar) baz 1610 6 DASH parn foo x baz 1611 6 EQAL parn foo x baz 1612 6 QSTN parn foo x baz 1613 7 plus brac foo c } baz 1614 7 dash brac foo ax{{{}b c d{} baz 1615 7 eqal brac foo ax{{{}b c ax{{{}b} baz 1616 7 qstn brac -> error 1617 7 PLUS brac foo c } baz 1618 7 DASH brac foo ax{{{}b c d{} baz 1619 7 EQAL brac foo ax{{{}b c ax{{{}b} baz 1620 7 QSTN brac -> error 1621 8 plus brac foo ax{{{}b c d{} baz 1622 8 dash brac foo c } baz 1623 8 eqal brac foo c } baz 1624 8 qstn brac foo c } baz 1625 8 PLUS brac foo c } baz 1626 8 DASH brac foo ax{{{}b c d{} baz 1627 8 EQAL brac foo ax{{{}b c ax{{{}b} baz 1628 8 QSTN brac -> error 1629 9 plus brac foo ax{{{}b c d{} baz 1630 9 dash brac foo x c x} baz 1631 9 eqal brac foo x c x} baz 1632 9 qstn brac foo x c x} baz 1633 9 PLUS brac foo ax{{{}b c d{} baz 1634 9 DASH brac foo x c x} baz 1635 9 EQAL brac foo x c x} baz 1636 9 QSTN brac foo x c x} baz 1637 --- 1638 name: expand-unglob-unq 1639 description: 1640 Check that regular ${foo+bar} constructs are parsed correctly 1641 stdin: 1642 u=x 1643 tl_norm() { 1644 v=$2 1645 test x"$v" = x"-" && unset v 1646 (echo $1 plus norm foo ${v+'bar'} baz) 1647 (echo $1 dash norm foo ${v-'bar'} baz) 1648 (echo $1 eqal norm foo ${v='bar'} baz) 1649 (echo $1 qstn norm foo ${v?'bar'} baz) 2>/dev/null || \ 1650 echo "$1 qstn norm -> error" 1651 (echo $1 PLUS norm foo ${v:+'bar'} baz) 1652 (echo $1 DASH norm foo ${v:-'bar'} baz) 1653 (echo $1 EQAL norm foo ${v:='bar'} baz) 1654 (echo $1 QSTN norm foo ${v:?'bar'} baz) 2>/dev/null || \ 1655 echo "$1 QSTN norm -> error" 1656 } 1657 tl_paren() { 1658 v=$2 1659 test x"$v" = x"-" && unset v 1660 (echo $1 plus parn foo ${v+\(bar')'} baz) 1661 (echo $1 dash parn foo ${v-\(bar')'} baz) 1662 (echo $1 eqal parn foo ${v=\(bar')'} baz) 1663 (echo $1 qstn parn foo ${v?\(bar')'} baz) 2>/dev/null || \ 1664 echo "$1 qstn parn -> error" 1665 (echo $1 PLUS parn foo ${v:+\(bar')'} baz) 1666 (echo $1 DASH parn foo ${v:-\(bar')'} baz) 1667 (echo $1 EQAL parn foo ${v:=\(bar')'} baz) 1668 (echo $1 QSTN parn foo ${v:?\(bar')'} baz) 2>/dev/null || \ 1669 echo "$1 QSTN parn -> error" 1670 } 1671 tl_brace() { 1672 v=$2 1673 test x"$v" = x"-" && unset v 1674 (echo $1 plus brac foo ${v+a$u{{{\}b} c ${v+d{}} baz) 1675 (echo $1 dash brac foo ${v-a$u{{{\}b} c ${v-d{}} baz) 1676 (echo $1 eqal brac foo ${v=a$u{{{\}b} c ${v=d{}} baz) 1677 (echo $1 qstn brac foo ${v?a$u{{{\}b} c ${v?d{}} baz) 2>/dev/null || \ 1678 echo "$1 qstn brac -> error" 1679 (echo $1 PLUS brac foo ${v:+a$u{{{\}b} c ${v:+d{}} baz) 1680 (echo $1 DASH brac foo ${v:-a$u{{{\}b} c ${v:-d{}} baz) 1681 (echo $1 EQAL brac foo ${v:=a$u{{{\}b} c ${v:=d{}} baz) 1682 (echo $1 QSTN brac foo ${v:?a$u{{{\}b} c ${v:?d{}} baz) 2>/dev/null || \ 1683 echo "$1 QSTN brac -> error" 1684 } 1685 : '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' '}}}' 1686 tl_norm 1 - 1687 tl_norm 2 '' 1688 tl_norm 3 x 1689 tl_paren 4 - 1690 tl_paren 5 '' 1691 tl_paren 6 x 1692 tl_brace 7 - 1693 tl_brace 8 '' 1694 tl_brace 9 x 1695 expected-stdout: 1696 1 plus norm foo baz 1697 1 dash norm foo bar baz 1698 1 eqal norm foo bar baz 1699 1 qstn norm -> error 1700 1 PLUS norm foo baz 1701 1 DASH norm foo bar baz 1702 1 EQAL norm foo bar baz 1703 1 QSTN norm -> error 1704 2 plus norm foo bar baz 1705 2 dash norm foo baz 1706 2 eqal norm foo baz 1707 2 qstn norm foo baz 1708 2 PLUS norm foo baz 1709 2 DASH norm foo bar baz 1710 2 EQAL norm foo bar baz 1711 2 QSTN norm -> error 1712 3 plus norm foo bar baz 1713 3 dash norm foo x baz 1714 3 eqal norm foo x baz 1715 3 qstn norm foo x baz 1716 3 PLUS norm foo bar baz 1717 3 DASH norm foo x baz 1718 3 EQAL norm foo x baz 1719 3 QSTN norm foo x baz 1720 4 plus parn foo baz 1721 4 dash parn foo (bar) baz 1722 4 eqal parn foo (bar) baz 1723 4 qstn parn -> error 1724 4 PLUS parn foo baz 1725 4 DASH parn foo (bar) baz 1726 4 EQAL parn foo (bar) baz 1727 4 QSTN parn -> error 1728 5 plus parn foo (bar) baz 1729 5 dash parn foo baz 1730 5 eqal parn foo baz 1731 5 qstn parn foo baz 1732 5 PLUS parn foo baz 1733 5 DASH parn foo (bar) baz 1734 5 EQAL parn foo (bar) baz 1735 5 QSTN parn -> error 1736 6 plus parn foo (bar) baz 1737 6 dash parn foo x baz 1738 6 eqal parn foo x baz 1739 6 qstn parn foo x baz 1740 6 PLUS parn foo (bar) baz 1741 6 DASH parn foo x baz 1742 6 EQAL parn foo x baz 1743 6 QSTN parn foo x baz 1744 7 plus brac foo c } baz 1745 7 dash brac foo ax{{{}b c d{} baz 1746 7 eqal brac foo ax{{{}b c ax{{{}b} baz 1747 7 qstn brac -> error 1748 7 PLUS brac foo c } baz 1749 7 DASH brac foo ax{{{}b c d{} baz 1750 7 EQAL brac foo ax{{{}b c ax{{{}b} baz 1751 7 QSTN brac -> error 1752 8 plus brac foo ax{{{}b c d{} baz 1753 8 dash brac foo c } baz 1754 8 eqal brac foo c } baz 1755 8 qstn brac foo c } baz 1756 8 PLUS brac foo c } baz 1757 8 DASH brac foo ax{{{}b c d{} baz 1758 8 EQAL brac foo ax{{{}b c ax{{{}b} baz 1759 8 QSTN brac -> error 1760 9 plus brac foo ax{{{}b c d{} baz 1761 9 dash brac foo x c x} baz 1762 9 eqal brac foo x c x} baz 1763 9 qstn brac foo x c x} baz 1764 9 PLUS brac foo ax{{{}b c d{} baz 1765 9 DASH brac foo x c x} baz 1766 9 EQAL brac foo x c x} baz 1767 9 QSTN brac foo x c x} baz 1768 --- 1769 name: expand-threecolons-dblq 1770 description: 1771 Check for a particular thing that used to segfault 1772 stdin: 1773 TEST=1234 1774 echo "${TEST:1:2:3}" 1775 echo $? but still living 1776 expected-stderr-pattern: 1777 /bad substitution/ 1778 expected-exit: 1 1779 --- 1780 name: expand-threecolons-unq 1781 description: 1782 Check for a particular thing that used to not error out 1783 stdin: 1784 TEST=1234 1785 echo ${TEST:1:2:3} 1786 echo $? but still living 1787 expected-stderr-pattern: 1788 /bad substitution/ 1789 expected-exit: 1 1790 --- 1791 name: expand-weird-1 1792 description: 1793 Check corner cases of trim expansion vs. $# vs. ${#var} vs. ${var?} 1794 stdin: 1795 set 1 2 3 4 5 6 7 8 9 10 11 1796 echo ${#} # value of $# 1797 echo ${##} # length of $# 1798 echo ${##1} # $# trimmed 1 1799 set 1 2 3 4 5 6 7 8 9 10 11 12 1800 echo ${##1} 1801 (exit 0) 1802 echo $? = ${#?} . 1803 (exit 111) 1804 echo $? = ${#?} . 1805 expected-stdout: 1806 11 1807 2 1808 1 1809 2 1810 0 = 1 . 1811 111 = 3 . 1812 --- 1813 name: expand-weird-2 1814 description: 1815 Check more substitution and extension corner cases 1816 stdin: 1817 :& set -C; pid=$$; sub=$!; flg=$-; set -- i; exec 3>x.tmp 1818 #echo "D: !=$! #=$# \$=$$ -=$- ?=$?" 1819 echo >&3 3 = s^${!-word} , ${#-word} , p^${$-word} , f^${--word} , ${?-word} . 1820 echo >&3 4 = ${!+word} , ${#+word} , ${$+word} , ${-+word} , ${?+word} . 1821 echo >&3 5 = s^${!=word} , ${#=word} , p^${$=word} , f^${-=word} , ${?=word} . 1822 echo >&3 6 = s^${!?word} , ${#?word} , p^${$?word} , f^${-?word} , ${??word} . 1823 echo >&3 7 = sl^${#!} , ${##} , pl^${#$} , fl^${#-} , ${#?} . 1824 echo >&3 8 = sw^${%!} , ${%#} , pw^${%$} , fw^${%-} , ${%?} . 1825 echo >&3 9 = ${!!} , s^${!#} , ${!$} , s^${!-} , s^${!?} . 1826 echo >&3 10 = s^${!#pattern} , ${##pattern} , p^${$#pattern} , f^${-#pattern} , ${?#pattern} . 1827 echo >&3 11 = s^${!%pattern} , ${#%pattern} , p^${$%pattern} , f^${-%pattern} , ${?%pattern} . 1828 echo >&3 12 = $# : ${##} , ${##1} . 1829 set -- 1830 echo >&3 14 = $# : ${##} , ${##1} . 1831 set -- 1 2 3 4 5 1832 echo >&3 16 = $# : ${##} , ${##1} . 1833 set -- 1 2 3 4 5 6 7 8 9 a b c d e 1834 echo >&3 18 = $# : ${##} , ${##1} . 1835 exec 3>&- 1836 <x.tmp sed \ 1837 -e "s/ pl^${#pid} / PID /g" -e "s/ sl^${#sub} / SUB /g" -e "s/ fl^${#flg} / FLG /g" \ 1838 -e "s/ pw^${%pid} / PID /g" -e "s/ sw^${%sub} / SUB /g" -e "s/ fw^${%flg} / FLG /g" \ 1839 -e "s/ p^$pid / PID /g" -e "s/ s^$sub / SUB /g" -e "s/ f^$flg / FLG /g" 1840 expected-stdout: 1841 3 = SUB , 1 , PID , FLG , 0 . 1842 4 = word , word , word , word , word . 1843 5 = SUB , 1 , PID , FLG , 0 . 1844 6 = SUB , 1 , PID , FLG , 0 . 1845 7 = SUB , 1 , PID , FLG , 1 . 1846 8 = SUB , 1 , PID , FLG , 1 . 1847 9 = ! , SUB , $ , SUB , SUB . 1848 10 = SUB , 1 , PID , FLG , 0 . 1849 11 = SUB , 1 , PID , FLG , 0 . 1850 12 = 1 : 1 , . 1851 14 = 0 : 1 , 0 . 1852 16 = 5 : 1 , 5 . 1853 18 = 14 : 2 , 4 . 1854 --- 1855 name: expand-weird-3 1856 description: 1857 Check that trimming works with positional parameters (Debian #48453) 1858 stdin: 1859 A=9999-02 1860 B=9999 1861 echo 1=${A#$B?}. 1862 set -- $A $B 1863 echo 2=${1#$2?}. 1864 expected-stdout: 1865 1=02. 1866 2=02. 1867 --- 1868 name: expand-weird-4 1869 description: 1870 Check that tilde expansion is enabled in ${x#~} 1871 and cases that are modelled after it (${x/~/~}) 1872 stdin: 1873 HOME=/etc 1874 a="~/x" 1875 echo "<${a#~}> <${a#\~}> <${b:-~}> <${b:-\~}> <${c:=~}><$c> <${a/~}> <${a/x/~}> <${a/x/\~}>" 1876 expected-stdout: 1877 <~/x> </x> <~> <\~> <~><~> <~/x> <~//etc> <~/~> 1878 --- 1879 name: expand-bang-1 1880 description: 1881 Check corner case of ${!?} with ! being var vs. op 1882 stdin: 1883 echo ${!?} 1884 expected-exit: 1 1885 expected-stderr-pattern: /not set/ 1886 --- 1887 name: expand-bang-2 1888 description: 1889 Check corner case of ${!var} vs. ${var op} with var=! 1890 stdin: 1891 echo 1 $! . 1892 echo 2 ${!#} . 1893 echo 3 ${!#[0-9]} . 1894 echo 4 ${!-foo} . 1895 # get an at least three-digit bg pid 1896 while :; do 1897 :& 1898 x=$! 1899 if [[ $x != +([0-9]) ]]; then 1900 echo >&2 "cannot test, pid '$x' not numeric" 1901 echo >&2 report this with as many details as possible 1902 exit 1 1903 fi 1904 [[ $x = [0-9][0-9][0-9]* ]] && break 1905 done 1906 y=${x#?} 1907 t=$!; [[ $t = $x ]]; echo 5 $? . 1908 t=${!#}; [[ $t = $x ]]; echo 6 $? . 1909 t=${!#[0-9]}; [[ $t = $y ]]; echo 7 $? . 1910 t=${!-foo}; [[ $t = $x ]]; echo 8 $? . 1911 t=${!?bar}; [[ $t = $x ]]; echo 9 $? . 1912 expected-stdout: 1913 1 . 1914 2 . 1915 3 . 1916 4 foo . 1917 5 0 . 1918 6 0 . 1919 7 0 . 1920 8 0 . 1921 9 0 . 1922 --- 1923 name: expand-number-1 1924 description: 1925 Check that positional arguments do not overflow 1926 stdin: 1927 echo "1 ${12345678901234567890} ." 1928 expected-stdout: 1929 1 . 1930 --- 1931 name: expand-slashes-1 1932 description: 1933 Check that side effects in substring replacement are handled correctly 1934 stdin: 1935 foo=n1n1n1n2n3 1936 i=2 1937 n=1 1938 echo 1 ${foo//n$((n++))/[$((++i))]} . 1939 echo 2 $n , $i . 1940 expected-stdout: 1941 1 [3][3][3]n2n3 . 1942 2 2 , 3 . 1943 --- 1944 name: expand-slashes-2 1945 description: 1946 Check that side effects in substring replacement are handled correctly 1947 stdin: 1948 foo=n1n1n1n2n3 1949 i=2 1950 n=1 1951 echo 1 ${foo@/n$((n++))/[$((++i))]} . 1952 echo 2 $n , $i . 1953 expected-stdout: 1954 1 [3]n1n1[4][5] . 1955 2 5 , 5 . 1956 --- 1957 name: expand-slashes-3 1958 description: 1959 Check that we can access the replaced string 1960 stdin: 1961 foo=n1n1n1n2n3 1962 echo 1 ${foo@/n[12]/[$KSH_MATCH]} . 1963 expected-stdout: 1964 1 [n1][n1][n1][n2]n3 . 1965 --- 1966 name: eglob-bad-1 1967 description: 1968 Check that globbing isn't done when glob has syntax error 1969 category: !os:cygwin,!os:msys,!os:os2 1970 file-setup: file 644 "@(a[b|)c]foo" 1971 stdin: 1972 echo @(a[b|)c]* 1973 expected-stdout: 1974 @(a[b|)c]* 1975 --- 1976 name: eglob-bad-2 1977 description: 1978 Check that globbing isn't done when glob has syntax error 1979 (AT&T ksh fails this test) 1980 file-setup: file 644 "abcx" 1981 file-setup: file 644 "abcz" 1982 file-setup: file 644 "bbc" 1983 stdin: 1984 echo [a*(]*)z 1985 expected-stdout: 1986 [a*(]*)z 1987 --- 1988 name: eglob-infinite-plus 1989 description: 1990 Check that shell doesn't go into infinite loop expanding +(...) 1991 expressions. 1992 file-setup: file 644 "abc" 1993 time-limit: 3 1994 stdin: 1995 echo +()c 1996 echo +()x 1997 echo +(*)c 1998 echo +(*)x 1999 expected-stdout: 2000 +()c 2001 +()x 2002 abc 2003 +(*)x 2004 --- 2005 name: eglob-subst-1 2006 description: 2007 Check that eglobbing isn't done on substitution results 2008 file-setup: file 644 "abc" 2009 stdin: 2010 x='@(*)' 2011 echo $x 2012 expected-stdout: 2013 @(*) 2014 --- 2015 name: eglob-nomatch-1 2016 description: 2017 Check that the pattern doesn't match 2018 stdin: 2019 echo 1: no-file+(a|b)stuff 2020 echo 2: no-file+(a*(c)|b)stuff 2021 echo 3: no-file+((((c)))|b)stuff 2022 expected-stdout: 2023 1: no-file+(a|b)stuff 2024 2: no-file+(a*(c)|b)stuff 2025 3: no-file+((((c)))|b)stuff 2026 --- 2027 name: eglob-match-1 2028 description: 2029 Check that the pattern matches correctly 2030 file-setup: file 644 "abd" 2031 file-setup: file 644 "acd" 2032 file-setup: file 644 "abac" 2033 stdin: 2034 echo 1: a+(b|c)d 2035 echo 2: a!(@(b|B))d 2036 echo 3: *(a(b|c)) # (...|...) can be used within X(..) 2037 echo 4: a[b*(foo|bar)]d # patterns not special inside [...] 2038 expected-stdout: 2039 1: abd acd 2040 2: acd 2041 3: abac 2042 4: abd 2043 --- 2044 name: eglob-case-1 2045 description: 2046 Simple negation tests 2047 stdin: 2048 case foo in !(foo|bar)) echo yes;; *) echo no;; esac 2049 case bar in !(foo|bar)) echo yes;; *) echo no;; esac 2050 expected-stdout: 2051 no 2052 no 2053 --- 2054 name: eglob-case-2 2055 description: 2056 Simple kleene tests 2057 stdin: 2058 case foo in *(a|b[)) echo yes;; *) echo no;; esac 2059 case foo in *(a|b[)|f*) echo yes;; *) echo no;; esac 2060 case '*(a|b[)' in *(a|b[)) echo yes;; *) echo no;; esac 2061 case 'aab[b[ab[a' in *(a|b[)) echo yes;; *) echo no;; esac 2062 expected-stdout: 2063 no 2064 yes 2065 no 2066 yes 2067 --- 2068 name: eglob-trim-1 2069 description: 2070 Eglobbing in trim expressions... 2071 (AT&T ksh fails this - docs say # matches shortest string, ## matches 2072 longest...) 2073 stdin: 2074 x=abcdef 2075 echo 1: ${x#a|abc} 2076 echo 2: ${x##a|abc} 2077 echo 3: ${x%def|f} 2078 echo 4: ${x%%f|def} 2079 expected-stdout: 2080 1: bcdef 2081 2: def 2082 3: abcde 2083 4: abc 2084 --- 2085 name: eglob-trim-2 2086 description: 2087 Check eglobbing works in trims... 2088 stdin: 2089 x=abcdef 2090 echo 1: ${x#*(a|b)cd} 2091 echo 2: "${x#*(a|b)cd}" 2092 echo 3: ${x#"*(a|b)cd"} 2093 echo 4: ${x#a(b|c)} 2094 expected-stdout: 2095 1: ef 2096 2: ef 2097 3: abcdef 2098 4: cdef 2099 --- 2100 name: eglob-trim-3 2101 description: 2102 Check eglobbing works in trims, for Korn Shell 2103 Ensure eglobbing does not work for reduced-feature /bin/sh 2104 stdin: 2105 set +o sh 2106 x=foobar 2107 y=foobaz 2108 z=fooba\? 2109 echo "<${x%bar|baz},${y%bar|baz},${z%\?}>" 2110 echo "<${x%ba(r|z)},${y%ba(r|z)}>" 2111 set -o sh 2112 echo "<${x%bar|baz},${y%bar|baz},${z%\?}>" 2113 z='foo(bar' 2114 echo "<${z%(*}>" 2115 expected-stdout: 2116 <foo,foo,fooba> 2117 <foo,foo> 2118 <foobar,foobaz,fooba> 2119 <foo> 2120 --- 2121 name: eglob-substrpl-1 2122 description: 2123 Check eglobbing works in substs... and they work at all 2124 stdin: 2125 [[ -n $BASH_VERSION ]] && shopt -s extglob 2126 x=1222321_ab/cde_b/c_1221 2127 y=xyz 2128 echo 1: ${x/2} . ${x/} 2129 echo 2: ${x//2} 2130 echo 3: ${x/+(2)} 2131 echo 4: ${x//+(2)} 2132 echo 5: ${x/2/4} 2133 echo 6: ${x//2/4} 2134 echo 7: ${x/+(2)/4} 2135 echo 8: ${x//+(2)/4} 2136 echo 9: ${x/b/c/e/f} 2137 echo 10: ${x/b\/c/e/f} 2138 echo 11: ${x/b\/c/e\/f} 2139 echo 12: ${x/b\/c/e\\/f} 2140 echo 13: ${x/b\\/c/e\\/f} 2141 echo 14: ${x//b/c/e/f} 2142 echo 15: ${x//b\/c/e/f} 2143 echo 16: ${x//b\/c/e\/f} 2144 echo 17: ${x//b\/c/e\\/f} 2145 echo 18: ${x//b\\/c/e\\/f} 2146 echo 19: ${x/b\/*\/c/x} 2147 echo 20: ${x/\//.} 2148 echo 21: ${x//\//.} 2149 echo 22: ${x///.} 2150 echo 23: ${x/#1/9} 2151 echo 24: ${x//#1/9} 2152 echo 25: ${x/%1/9} 2153 echo 26: ${x//%1/9} 2154 echo 27: ${x//\%1/9} 2155 echo 28: ${x//\\%1/9} 2156 echo 29: ${x//\a/9} 2157 echo 30: ${x//\\a/9} 2158 echo 31: ${x/2/$y} 2159 expected-stdout: 2160 1: 122321_ab/cde_b/c_1221 . 1222321_ab/cde_b/c_1221 2161 2: 131_ab/cde_b/c_11 2162 3: 1321_ab/cde_b/c_1221 2163 4: 131_ab/cde_b/c_11 2164 5: 1422321_ab/cde_b/c_1221 2165 6: 1444341_ab/cde_b/c_1441 2166 7: 14321_ab/cde_b/c_1221 2167 8: 14341_ab/cde_b/c_141 2168 9: 1222321_ac/e/f/cde_b/c_1221 2169 10: 1222321_ae/fde_b/c_1221 2170 11: 1222321_ae/fde_b/c_1221 2171 12: 1222321_ae\/fde_b/c_1221 2172 13: 1222321_ab/cde_b/c_1221 2173 14: 1222321_ac/e/f/cde_c/e/f/c_1221 2174 15: 1222321_ae/fde_e/f_1221 2175 16: 1222321_ae/fde_e/f_1221 2176 17: 1222321_ae\/fde_e\/f_1221 2177 18: 1222321_ab/cde_b/c_1221 2178 19: 1222321_ax_1221 2179 20: 1222321_ab.cde_b/c_1221 2180 21: 1222321_ab.cde_b.c_1221 2181 22: 1222321_ab/cde_b/c_1221 2182 23: 9222321_ab/cde_b/c_1221 2183 24: 1222321_ab/cde_b/c_1221 2184 25: 1222321_ab/cde_b/c_1229 2185 26: 1222321_ab/cde_b/c_1221 2186 27: 1222321_ab/cde_b/c_1221 2187 28: 1222321_ab/cde_b/c_1221 2188 29: 1222321_9b/cde_b/c_1221 2189 30: 1222321_ab/cde_b/c_1221 2190 31: 1xyz22321_ab/cde_b/c_1221 2191 --- 2192 name: eglob-substrpl-2 2193 description: 2194 Check anchored substring replacement works, corner cases 2195 stdin: 2196 foo=123 2197 echo 1: ${foo/#/x} 2198 echo 2: ${foo/%/x} 2199 echo 3: ${foo/#/} 2200 echo 4: ${foo/#} 2201 echo 5: ${foo/%/} 2202 echo 6: ${foo/%} 2203 expected-stdout: 2204 1: x123 2205 2: 123x 2206 3: 123 2207 4: 123 2208 5: 123 2209 6: 123 2210 --- 2211 name: eglob-substrpl-3a 2212 description: 2213 Check substring replacement works with variables and slashes, too 2214 stdin: 2215 HOME=/etc 2216 pfx=/home/user 2217 wd=/home/user/tmp 2218 echo "${wd/#$pfx/~}" 2219 echo "${wd/#\$pfx/~}" 2220 echo "${wd/#"$pfx"/~}" 2221 echo "${wd/#'$pfx'/~}" 2222 echo "${wd/#"\$pfx"/~}" 2223 echo "${wd/#'\$pfx'/~}" 2224 expected-stdout: 2225 /etc/tmp 2226 /home/user/tmp 2227 /etc/tmp 2228 /home/user/tmp 2229 /home/user/tmp 2230 /home/user/tmp 2231 --- 2232 name: eglob-substrpl-3b 2233 description: 2234 More of this, bash fails it (bash4 passes) 2235 stdin: 2236 HOME=/etc 2237 pfx=/home/user 2238 wd=/home/user/tmp 2239 echo "${wd/#$(echo /home/user)/~}" 2240 echo "${wd/#"$(echo /home/user)"/~}" 2241 echo "${wd/#'$(echo /home/user)'/~}" 2242 expected-stdout: 2243 /etc/tmp 2244 /etc/tmp 2245 /home/user/tmp 2246 --- 2247 name: eglob-substrpl-3c 2248 description: 2249 Even more weird cases 2250 stdin: 2251 HOME=/etc 2252 pfx=/home/user 2253 wd='$pfx/tmp' 2254 echo 1: ${wd/#$pfx/~} 2255 echo 2: ${wd/#\$pfx/~} 2256 echo 3: ${wd/#"$pfx"/~} 2257 echo 4: ${wd/#'$pfx'/~} 2258 echo 5: ${wd/#"\$pfx"/~} 2259 echo 6: ${wd/#'\$pfx'/~} 2260 ts='a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp)' 2261 tp=a/b 2262 tr=c/d 2263 [[ -n $BASH_VERSION ]] && shopt -s extglob 2264 echo 7: ${ts/a\/b/$tr} 2265 echo 8: ${ts/a\/b/\$tr} 2266 echo 9: ${ts/$tp/$tr} 2267 echo 10: ${ts/\$tp/$tr} 2268 echo 11: ${ts/\\$tp/$tr} 2269 echo 12: ${ts/$tp/c/d} 2270 echo 13: ${ts/$tp/c\/d} 2271 echo 14: ${ts/$tp/c\\/d} 2272 echo 15: ${ts/+(a\/b)/$tr} 2273 echo 16: ${ts/+(a\/b)/\$tr} 2274 echo 17: ${ts/+($tp)/$tr} 2275 echo 18: ${ts/+($tp)/c/d} 2276 echo 19: ${ts/+($tp)/c\/d} 2277 echo 20: ${ts//a\/b/$tr} 2278 echo 21: ${ts//a\/b/\$tr} 2279 echo 22: ${ts//$tp/$tr} 2280 echo 23: ${ts//$tp/c/d} 2281 echo 24: ${ts//$tp/c\/d} 2282 echo 25: ${ts//+(a\/b)/$tr} 2283 echo 26: ${ts//+(a\/b)/\$tr} 2284 echo 27: ${ts//+($tp)/$tr} 2285 echo 28: ${ts//+($tp)/c/d} 2286 echo 29: ${ts//+($tp)/c\/d} 2287 tp="+($tp)" 2288 echo 30: ${ts/$tp/$tr} 2289 echo 31: ${ts//$tp/$tr} 2290 expected-stdout: 2291 1: $pfx/tmp 2292 2: /etc/tmp 2293 3: $pfx/tmp 2294 4: /etc/tmp 2295 5: /etc/tmp 2296 6: $pfx/tmp 2297 7: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp) 2298 8: $tra/b$tp$tp_a/b$tp_*(a/b)_*($tp) 2299 9: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp) 2300 10: a/ba/bc/d$tp_a/b$tp_*(a/b)_*($tp) 2301 11: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp) 2302 12: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp) 2303 13: c/da/b$tp$tp_a/b$tp_*(a/b)_*($tp) 2304 14: c\/da/b$tp$tp_a/b$tp_*(a/b)_*($tp) 2305 15: c/d$tp$tp_a/b$tp_*(a/b)_*($tp) 2306 16: $tr$tp$tp_a/b$tp_*(a/b)_*($tp) 2307 17: c/d$tp$tp_a/b$tp_*(a/b)_*($tp) 2308 18: c/d$tp$tp_a/b$tp_*(a/b)_*($tp) 2309 19: c/d$tp$tp_a/b$tp_*(a/b)_*($tp) 2310 20: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp) 2311 21: $tr$tr$tp$tp_$tr$tp_*($tr)_*($tp) 2312 22: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp) 2313 23: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp) 2314 24: c/dc/d$tp$tp_c/d$tp_*(c/d)_*($tp) 2315 25: c/d$tp$tp_c/d$tp_*(c/d)_*($tp) 2316 26: $tr$tp$tp_$tr$tp_*($tr)_*($tp) 2317 27: c/d$tp$tp_c/d$tp_*(c/d)_*($tp) 2318 28: c/d$tp$tp_c/d$tp_*(c/d)_*($tp) 2319 29: c/d$tp$tp_c/d$tp_*(c/d)_*($tp) 2320 30: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp) 2321 31: a/ba/b$tp$tp_a/b$tp_*(a/b)_*($tp) 2322 # This is what GNU bash does: 2323 # 30: c/d$tp$tp_a/b$tp_*(a/b)_*($tp) 2324 # 31: c/d$tp$tp_c/d$tp_*(c/d)_*($tp) 2325 --- 2326 name: eglob-utf8-1 2327 description: 2328 UTF-8 mode differences for eglobbing 2329 category: !shell:ebcdic-yes 2330 stdin: 2331 s=bld 2332 set +U 2333 print 1: ${s%???} . 2334 print 2: ${s/b???d/x} . 2335 set -U 2336 print 3: ${s%???} . 2337 print 4: ${s/b??d/x} . 2338 x=n 2339 print 5: ${x%?} ${x%%?} . 2340 x=h 2341 print 6: ${x#?} ${x##?} . 2342 x= 2343 print 7: ${x%?} ${x%%?} . 2344 x=m 2345 print 8: ${x%?} ${x%%?} . 2346 x= 2347 print 9: ${x%?} ${x%%?} . 2348 expected-stdout: 2349 1: bl . 2350 2: x . 2351 3: b . 2352 4: x . 2353 5: n n . 2354 6: h h . 2355 7: . 2356 8: m m . 2357 9: . 2358 --- 2359 name: glob-bad-1 2360 description: 2361 Check that [ matches itself if it's not a valid bracket expr 2362 but does not prevent globbing, while backslash-escaping does 2363 file-setup: dir 755 "[x" 2364 file-setup: file 644 "[x/foo" 2365 stdin: 2366 echo [* 2367 echo *[x 2368 echo [x/* 2369 :>'ab[x' 2370 :>'a[a-z][x' 2371 echo a[a-z][* 2372 echo a[a-z]* 2373 echo a[a\-z]* 2374 expected-stdout: 2375 [x 2376 [x 2377 [x/foo 2378 ab[x 2379 ab[x 2380 a[a-z]* 2381 --- 2382 name: glob-bad-2 2383 description: 2384 Check that symbolic links aren't stat()'d 2385 # breaks on Dell UNIX 4.0 R2.2 (SVR4) where unlink also fails 2386 # breaks on FreeMiNT (cannot unlink dangling symlinks) 2387 # breaks on MSYS, OS/2 (do not support symlinks) 2388 category: !os:mint,!os:msys,!os:svr4.0,!nosymlink 2389 file-setup: dir 755 "dir" 2390 file-setup: symlink 644 "dir/abc" 2391 non-existent-file 2392 stdin: 2393 echo d*/* 2394 echo d*/abc 2395 expected-stdout: 2396 dir/abc 2397 dir/abc 2398 --- 2399 name: glob-bad-3 2400 description: 2401 Check that the slash is parsed before the glob 2402 stdin: 2403 mkdir a 'a[b' 2404 (cd 'a[b'; echo ok >'c]d') 2405 echo nok >abd 2406 echo fail >a/d 2407 cat a[b/c]d 2408 expected-stdout: 2409 ok 2410 --- 2411 name: glob-range-1 2412 description: 2413 Test range matching 2414 file-setup: file 644 ".bc" 2415 file-setup: file 644 "abc" 2416 file-setup: file 644 "bbc" 2417 file-setup: file 644 "cbc" 2418 file-setup: file 644 "-bc" 2419 file-setup: file 644 "!bc" 2420 file-setup: file 644 "^bc" 2421 file-setup: file 644 "+bc" 2422 file-setup: file 644 ",bc" 2423 file-setup: file 644 "0bc" 2424 file-setup: file 644 "1bc" 2425 stdin: 2426 echo [ab-]* 2427 echo [-ab]* 2428 echo [!-ab]* 2429 echo [!ab]* 2430 echo []ab]* 2431 echo [^ab]* 2432 echo [+--]* 2433 echo [--1]* 2434 2435 expected-stdout: 2436 -bc abc bbc 2437 -bc abc bbc 2438 !bc +bc ,bc 0bc 1bc ^bc cbc 2439 !bc +bc ,bc -bc 0bc 1bc ^bc cbc 2440 abc bbc 2441 ^bc abc bbc 2442 +bc ,bc -bc 2443 -bc 0bc 1bc 2444 --- 2445 name: glob-range-2 2446 description: 2447 Test range matching 2448 (AT&T ksh fails this; POSIX says invalid) 2449 file-setup: file 644 "abc" 2450 stdin: 2451 echo [a--]* 2452 expected-stdout: 2453 [a--]* 2454 --- 2455 name: glob-range-3 2456 description: 2457 Check that globbing matches the right things... 2458 # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition) 2459 # breaks on Cygwin 1.7 (files are now UTF-16 or something) 2460 # breaks on QNX 6.4.1 (says RT) 2461 category: !os:cygwin,!os:darwin,!os:msys,!os:nto,!os:os2,!os:os390 2462 need-pass: no 2463 file-setup: file 644 "ac" 2464 stdin: 2465 echo a[-]* 2466 expected-stdout: 2467 ac 2468 --- 2469 name: glob-range-4 2470 description: 2471 Results unspecified according to POSIX 2472 file-setup: file 644 ".bc" 2473 stdin: 2474 echo [a.]* 2475 expected-stdout: 2476 [a.]* 2477 --- 2478 name: glob-range-5 2479 description: 2480 Results unspecified according to POSIX 2481 (AT&T ksh treats this like [a-cc-e]*) 2482 file-setup: file 644 "abc" 2483 file-setup: file 644 "bbc" 2484 file-setup: file 644 "cbc" 2485 file-setup: file 644 "dbc" 2486 file-setup: file 644 "ebc" 2487 file-setup: file 644 "-bc" 2488 file-setup: file 644 "@bc" 2489 stdin: 2490 echo [a-c-e]* 2491 echo [a--@]* 2492 expected-stdout: 2493 -bc abc bbc cbc ebc 2494 @bc 2495 --- 2496 name: glob-word-1 2497 description: 2498 Check BSD word boundary matches 2499 stdin: 2500 t() { [[ $1 = *[[:\<:]]bar[[:\>:]]* ]]; echo =$?; } 2501 t 'foo bar baz' 2502 t 'foobar baz' 2503 t 'foo barbaz' 2504 t 'bar' 2505 t '_bar' 2506 t 'bar_' 2507 expected-stdout: 2508 =0 2509 =1 2510 =1 2511 =0 2512 =1 2513 =1 2514 --- 2515 name: glob-trim-1 2516 description: 2517 Check against a regression from fixing IFS-subst-2 2518 stdin: 2519 x='#foo' 2520 print -r "before='$x'" 2521 x=${x%%#*} 2522 print -r "after ='$x'" 2523 expected-stdout: 2524 before='#foo' 2525 after ='' 2526 --- 2527 name: heredoc-1 2528 description: 2529 Check ordering/content of redundent here documents. 2530 stdin: 2531 cat << EOF1 << EOF2 2532 hi 2533 EOF1 2534 there 2535 EOF2 2536 expected-stdout: 2537 there 2538 --- 2539 name: heredoc-2 2540 description: 2541 Check quoted here-doc is protected. 2542 stdin: 2543 a=foo 2544 cat << 'EOF' 2545 hi\ 2546 there$a 2547 stuff 2548 EO\ 2549 F 2550 EOF 2551 expected-stdout: 2552 hi\ 2553 there$a 2554 stuff 2555 EO\ 2556 F 2557 --- 2558 name: heredoc-3 2559 description: 2560 Check that newline isn't needed after heredoc-delimiter marker. 2561 stdin: ! 2562 cat << EOF 2563 hi 2564 there 2565 EOF 2566 expected-stdout: 2567 hi 2568 there 2569 --- 2570 name: heredoc-4a 2571 description: 2572 Check that an error occurs if the heredoc-delimiter is missing. 2573 stdin: ! 2574 cat << EOF 2575 hi 2576 there 2577 expected-exit: e > 0 2578 expected-stderr-pattern: /.*/ 2579 --- 2580 name: heredoc-4an 2581 description: 2582 Check that an error occurs if the heredoc-delimiter is missing. 2583 arguments: !-n! 2584 stdin: ! 2585 cat << EOF 2586 hi 2587 there 2588 expected-exit: e > 0 2589 expected-stderr-pattern: /.*/ 2590 --- 2591 name: heredoc-4b 2592 description: 2593 Check that an error occurs if the heredoc is missing. 2594 stdin: ! 2595 cat << EOF 2596 expected-exit: e > 0 2597 expected-stderr-pattern: /.*/ 2598 --- 2599 name: heredoc-4bn 2600 description: 2601 Check that an error occurs if the heredoc is missing. 2602 arguments: !-n! 2603 stdin: ! 2604 cat << EOF 2605 expected-exit: e > 0 2606 expected-stderr-pattern: /.*/ 2607 --- 2608 name: heredoc-5 2609 description: 2610 Check that backslash quotes a $, ` and \ and kills a \newline 2611 stdin: 2612 a=BAD 2613 b=ok 2614 cat << EOF 2615 h\${a}i 2616 h\\${b}i 2617 th\`echo not-run\`ere 2618 th\\`echo is-run`ere 2619 fol\\ks 2620 more\\ 2621 last \ 2622 line 2623 EOF 2624 expected-stdout: 2625 h${a}i 2626 h\oki 2627 th`echo not-run`ere 2628 th\is-runere 2629 fol\ks 2630 more\ 2631 last line 2632 --- 2633 name: heredoc-6 2634 description: 2635 Check that \newline in initial here-delim word doesn't imply 2636 a quoted here-doc. 2637 stdin: 2638 a=i 2639 cat << EO\ 2640 F 2641 h$a 2642 there 2643 EOF 2644 expected-stdout: 2645 hi 2646 there 2647 --- 2648 name: heredoc-7 2649 description: 2650 Check that double quoted $ expressions in here delimiters are 2651 not expanded and match the delimiter. 2652 POSIX says only quote removal is applied to the delimiter. 2653 stdin: 2654 a=b 2655 cat << "E$a" 2656 hi 2657 h$a 2658 hb 2659 E$a 2660 echo done 2661 expected-stdout: 2662 hi 2663 h$a 2664 hb 2665 done 2666 --- 2667 name: heredoc-8 2668 description: 2669 Check that double quoted escaped $ expressions in here 2670 delimiters are not expanded and match the delimiter. 2671 POSIX says only quote removal is applied to the delimiter 2672 (\ counts as a quote). 2673 stdin: 2674 a=b 2675 cat << "E\$a" 2676 hi 2677 h$a 2678 h\$a 2679 hb 2680 h\b 2681 E$a 2682 echo done 2683 expected-stdout: 2684 hi 2685 h$a 2686 h\$a 2687 hb 2688 h\b 2689 done 2690 --- 2691 name: heredoc-9a 2692 description: 2693 Check that here strings work. 2694 stdin: 2695 bar="bar 2696 baz" 2697 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo 2698 "$__progname" -c "tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<foo" 2699 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$bar" 2700 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<'$bar' 2701 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$bar 2702 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<-foo 2703 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"$(echo "foo bar")" 2704 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<"A $(echo "foo bar") B" 2705 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<\$b\$b$bar 2706 expected-stdout: 2707 sbb 2708 sbb 2709 one 2710 onm 2711 $one 2712 $one 2713 -sbb 2714 sbb one 2715 A sbb one B 2716 $o$oone 2717 onm 2718 --- 2719 name: heredoc-9b 2720 description: 2721 Check that a corner case of here strings works like bash 2722 stdin: 2723 fnord=42 2724 bar="bar 2725 \$fnord baz" 2726 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar 2727 expected-stdout: 2728 one $sabeq onm 2729 category: bash 2730 --- 2731 name: heredoc-9c 2732 description: 2733 Check that a corner case of here strings works like ksh93, zsh 2734 stdin: 2735 fnord=42 2736 bar="bar 2737 \$fnord baz" 2738 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<<$bar 2739 expected-stdout: 2740 one 2741 $sabeq onm 2742 --- 2743 name: heredoc-9d 2744 description: 2745 Check another corner case of here strings 2746 stdin: 2747 tr abcdefghijklmnopqrstuvwxyz nopqrstuvwxyzabcdefghijklm <<< bar 2748 expected-stdout: 2749 one 2750 --- 2751 name: heredoc-9e 2752 description: 2753 Check here string related regression with multiple iops 2754 stdin: 2755 echo $(tr r z <<<'bar' 2>/dev/null) 2756 expected-stdout: 2757 baz 2758 --- 2759 name: heredoc-9f 2760 description: 2761 Check long here strings 2762 stdin: 2763 cat <<< "$( : )aa" 2764 expected-stdout: 2765 aa 2766 --- 2767 name: heredoc-10 2768 description: 2769 Check direct here document assignment 2770 category: !shell:ebcdic-yes 2771 stdin: 2772 x=u 2773 va=<<EOF 2774 =a $x \x40= 2775 EOF 2776 vb=<<'EOF' 2777 =b $x \x40= 2778 EOF 2779 function foo { 2780 vc=<<-EOF 2781 =c $x \x40= 2782 EOF 2783 } 2784 fnd=$(typeset -f foo) 2785 print -r -- "$fnd" 2786 function foo { 2787 echo blub 2788 } 2789 foo 2790 eval "$fnd" 2791 foo 2792 # rather nonsensical, but 2793 vd=<<<"=d $x \x40=" 2794 ve=<<<'=e $x \x40=' 2795 vf=<<<$'=f $x \x40=' 2796 # now check 2797 print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} ve={$ve} vf={$vf} |" 2798 # check append 2799 v=<<-EOF 2800 vapp1 2801 EOF 2802 v+=<<-EOF 2803 vapp2 2804 EOF 2805 print -r -- "| ${v//$'\n'/^} |" 2806 expected-stdout: 2807 function foo { 2808 vc=<<-EOF 2809 =c $x \x40= 2810 EOF 2811 2812 } 2813 blub 2814 | va={=a u \x40= 2815 } vb={=b $x \x40= 2816 } vc={=c u \x40= 2817 } vd={=d u \x40= 2818 } ve={=e $x \x40= 2819 } vf={=f $x @= 2820 } | 2821 | vapp1^vapp2^ | 2822 --- 2823 name: heredoc-10-ebcdic 2824 description: 2825 Check direct here document assignment 2826 category: !shell:ebcdic-no 2827 stdin: 2828 x=u 2829 va=<<EOF 2830 =a $x \x7C= 2831 EOF 2832 vb=<<'EOF' 2833 =b $x \x7C= 2834 EOF 2835 function foo { 2836 vc=<<-EOF 2837 =c $x \x7C= 2838 EOF 2839 } 2840 fnd=$(typeset -f foo) 2841 print -r -- "$fnd" 2842 function foo { 2843 echo blub 2844 } 2845 foo 2846 eval "$fnd" 2847 foo 2848 # rather nonsensical, but 2849 vd=<<<"=d $x \x7C=" 2850 ve=<<<'=e $x \x7C=' 2851 vf=<<<$'=f $x \x7C=' 2852 # now check 2853 print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} ve={$ve} vf={$vf} |" 2854 # check append 2855 v=<<-EOF 2856 vapp1 2857 EOF 2858 v+=<<-EOF 2859 vapp2 2860 EOF 2861 print -r -- "| ${v//$'\n'/^} |" 2862 expected-stdout: 2863 function foo { 2864 vc=<<-EOF 2865 =c $x \x7C= 2866 EOF 2867 2868 } 2869 blub 2870 | va={=a u \x7C= 2871 } vb={=b $x \x7C= 2872 } vc={=c u \x7C= 2873 } vd={=d u \x7C= 2874 } ve={=e $x \x7C= 2875 } vf={=f $x @= 2876 } | 2877 | vapp1^vapp2^ | 2878 --- 2879 name: heredoc-11 2880 description: 2881 Check here documents with no or empty delimiter 2882 stdin: 2883 x=u 2884 va=<< 2885 =a $x \x40= 2886 << 2887 vb=<<'' 2888 =b $x \x40= 2889 2890 function foo { 2891 vc=<<- 2892 =c $x \x40= 2893 << 2894 vd=<<-'' 2895 =d $x \x40= 2896 2897 } 2898 fnd=$(typeset -f foo) 2899 print -r -- "$fnd" 2900 function foo { 2901 echo blub 2902 } 2903 foo 2904 eval "$fnd" 2905 foo 2906 print -r -- "| va={$va} vb={$vb} vc={$vc} vd={$vd} |" 2907 x=y 2908 foo 2909 typeset -f foo 2910 print -r -- "| vc={$vc} vd={$vd} |" 2911 # check append 2912 v=<<- 2913 vapp1 2914 << 2915 v+=<<-'' 2916 vapp2 2917 2918 print -r -- "| ${v//$'\n'/^} |" 2919 expected-stdout: 2920 function foo { 2921 vc=<<- 2922 =c $x \x40= 2923 << 2924 2925 vd=<<-"" 2926 =d $x \x40= 2927 2928 2929 } 2930 blub 2931 | va={=a u \x40= 2932 } vb={=b $x \x40= 2933 } vc={=c u \x40= 2934 } vd={=d $x \x40= 2935 } | 2936 function foo { 2937 vc=<<- 2938 =c $x \x40= 2939 << 2940 2941 vd=<<-"" 2942 =d $x \x40= 2943 2944 2945 } 2946 | vc={=c y \x40= 2947 } vd={=d $x \x40= 2948 } | 2949 | vapp1^vapp2^ | 2950 --- 2951 name: heredoc-12 2952 description: 2953 Check here documents can use $* and $@; note shells vary: 2954 pdksh 5.2.14 acts the same 2955 dash has 1 and 2 the same but 3 lacks the space 2956 ksh93, bash4 differ in 2 by using space ipv colon 2957 stdin: 2958 set -- a b 2959 nl=' 2960 ' 2961 IFS=" $nl"; n=1 2962 cat <<EOF 2963 $n foo $* foo 2964 $n bar "$*" bar 2965 $n baz $@ baz 2966 $n bla "$@" bla 2967 EOF 2968 IFS=":"; n=2 2969 cat <<EOF 2970 $n foo $* foo 2971 $n bar "$*" bar 2972 $n baz $@ baz 2973 $n bla "$@" bla 2974 EOF 2975 IFS=; n=3 2976 cat <<EOF 2977 $n foo $* foo 2978 $n bar "$*" bar 2979 $n baz $@ baz 2980 $n bla "$@" bla 2981 EOF 2982 expected-stdout: 2983 1 foo a b foo 2984 1 bar "a b" bar 2985 1 baz a b baz 2986 1 bla "a b" bla 2987 2 foo a:b foo 2988 2 bar "a:b" bar 2989 2 baz a:b baz 2990 2 bla "a:b" bla 2991 3 foo a b foo 2992 3 bar "a b" bar 2993 3 baz a b baz 2994 3 bla "a b" bla 2995 --- 2996 name: heredoc-14 2997 description: 2998 Check that using multiple here documents works 2999 stdin: 3000 foo() { 3001 echo "got $(cat) on stdin" 3002 echo "got $(cat <&4) on fd#4" 3003 echo "got $(cat <&5) on fd#5" 3004 } 3005 bar() { 3006 foo 4<<-a <<-b 5<<-c 3007 four 3008 a 3009 zero 3010 b 3011 five 3012 c 3013 } 3014 x=$(typeset -f bar) 3015 eval "$x" 3016 y=$(typeset -f bar) 3017 [[ $x = "$y" ]]; echo $? 3018 typeset -f bar 3019 bar 3020 expected-stdout: 3021 0 3022 bar() { 3023 \foo 4<<-a <<-b 5<<-c 3024 four 3025 a 3026 zero 3027 b 3028 five 3029 c 3030 3031 } 3032 got zero on stdin 3033 got four on fd#4 3034 got five on fd#5 3035 --- 3036 name: heredoc-comsub-1 3037 description: 3038 Tests for here documents in COMSUB, taken from Austin ML 3039 stdin: 3040 text=$(cat <<EOF 3041 here is the text 3042 EOF) 3043 echo = $text = 3044 expected-stdout: 3045 = here is the text = 3046 --- 3047 name: heredoc-comsub-2 3048 description: 3049 Tests for here documents in COMSUB, taken from Austin ML 3050 stdin: 3051 unbalanced=$(cat <<EOF 3052 this paren ) is a problem 3053 EOF) 3054 echo = $unbalanced = 3055 expected-stdout: 3056 = this paren ) is a problem = 3057 --- 3058 name: heredoc-comsub-3 3059 description: 3060 Tests for here documents in COMSUB, taken from Austin ML 3061 stdin: 3062 balanced=$(cat <<EOF 3063 these parens ( ) are not a problem 3064 EOF) 3065 echo = $balanced = 3066 expected-stdout: 3067 = these parens ( ) are not a problem = 3068 --- 3069 name: heredoc-comsub-4 3070 description: 3071 Tests for here documents in COMSUB, taken from Austin ML 3072 stdin: 3073 balanced=$(cat <<EOF 3074 these parens \( ) are a problem 3075 EOF) 3076 echo = $balanced = 3077 expected-stdout: 3078 = these parens \( ) are a problem = 3079 --- 3080 name: heredoc-comsub-5 3081 description: 3082 Check heredoc and COMSUB mixture in input 3083 stdin: 3084 prefix() { sed -e "s/^/$1:/"; } 3085 XXX() { echo x-en; } 3086 YYY() { echo y-es; } 3087 3088 prefix A <<XXX && echo "$(prefix B <<XXX 3089 echo line 1 3090 XXX 3091 echo line 2)" && prefix C <<YYY 3092 echo line 3 3093 XXX 3094 echo line 4)" 3095 echo line 5 3096 YYY 3097 XXX 3098 expected-stdout: 3099 A:echo line 3 3100 B:echo line 1 3101 line 2 3102 C:echo line 4)" 3103 C:echo line 5 3104 x-en 3105 --- 3106 name: heredoc-comsub-6 3107 description: 3108 Check here documents and here strings can be used 3109 without a specific command, like $(<) (extension) 3110 stdin: 3111 foo=bar 3112 x=$(<<<EO${foo}F) 3113 echo "3<$x>" 3114 y=$(<<-EOF 3115 hi! 3116 3117 $foo) is not a problem 3118 3119 3120 EOF) 3121 echo "7<$y>" 3122 expected-stdout: 3123 3<EObarF> 3124 7<hi! 3125 3126 bar) is not a problem> 3127 --- 3128 name: heredoc-subshell-1 3129 description: 3130 Tests for here documents in subshells, taken from Austin ML 3131 stdin: 3132 (cat <<EOF 3133 some text 3134 EOF) 3135 echo end 3136 expected-stdout: 3137 some text 3138 end 3139 --- 3140 name: heredoc-subshell-2 3141 description: 3142 Tests for here documents in subshells, taken from Austin ML 3143 stdin: 3144 (cat <<EOF 3145 some text 3146 EOF 3147 ) 3148 echo end 3149 expected-stdout: 3150 some text 3151 end 3152 --- 3153 name: heredoc-subshell-3 3154 description: 3155 Tests for here documents in subshells, taken from Austin ML 3156 stdin: 3157 (cat <<EOF; ) 3158 some text 3159 EOF 3160 echo end 3161 expected-stdout: 3162 some text 3163 end 3164 --- 3165 name: heredoc-weird-1 3166 description: 3167 Tests for here documents, taken from Austin ML 3168 Documents current state in mksh, *NOT* necessarily correct! 3169 stdin: 3170 cat <<END 3171 hello 3172 END\ 3173 END 3174 END 3175 echo end 3176 expected-stdout: 3177 hello 3178 ENDEND 3179 end 3180 --- 3181 name: heredoc-weird-2 3182 description: 3183 Tests for here documents, taken from Austin ML 3184 stdin: 3185 cat <<' END ' 3186 hello 3187 END 3188 echo end 3189 expected-stdout: 3190 hello 3191 end 3192 --- 3193 name: heredoc-weird-4 3194 description: 3195 Tests for here documents, taken from Austin ML 3196 Documents current state in mksh, *NOT* necessarily correct! 3197 stdin: 3198 cat <<END 3199 hello\ 3200 END 3201 END 3202 echo end 3203 expected-stdout: 3204 helloEND 3205 end 3206 --- 3207 name: heredoc-weird-5 3208 description: 3209 Tests for here documents, taken from Austin ML 3210 Documents current state in mksh, *NOT* necessarily correct! 3211 stdin: 3212 cat <<END 3213 hello 3214 \END 3215 END 3216 echo end 3217 expected-stdout: 3218 hello 3219 \END 3220 end 3221 --- 3222 name: heredoc-tmpfile-1 3223 description: 3224 Check that heredoc temp files aren't removed too soon or too late. 3225 Heredoc in simple command. 3226 stdin: 3227 TMPDIR=$PWD 3228 eval ' 3229 cat <<- EOF 3230 hi 3231 EOF 3232 for i in a b ; do 3233 cat <<- EOF 3234 more 3235 EOF 3236 done 3237 ' & 3238 sleep 1 3239 echo Left overs: * 3240 expected-stdout: 3241 hi 3242 more 3243 more 3244 Left overs: * 3245 --- 3246 name: heredoc-tmpfile-2 3247 description: 3248 Check that heredoc temp files aren't removed too soon or too late. 3249 Heredoc in function, multiple calls to function. 3250 stdin: 3251 TMPDIR=$PWD 3252 eval ' 3253 foo() { 3254 cat <<- EOF 3255 hi 3256 EOF 3257 } 3258 foo 3259 foo 3260 ' & 3261 sleep 1 3262 echo Left overs: * 3263 expected-stdout: 3264 hi 3265 hi 3266 Left overs: * 3267 --- 3268 name: heredoc-tmpfile-3 3269 description: 3270 Check that heredoc temp files aren't removed too soon or too late. 3271 Heredoc in function in loop, multiple calls to function. 3272 stdin: 3273 TMPDIR=$PWD 3274 eval ' 3275 foo() { 3276 cat <<- EOF 3277 hi 3278 EOF 3279 } 3280 for i in a b; do 3281 foo 3282 foo() { 3283 cat <<- EOF 3284 folks $i 3285 EOF 3286 } 3287 done 3288 foo 3289 ' & 3290 sleep 1 3291 echo Left overs: * 3292 expected-stdout: 3293 hi 3294 folks b 3295 folks b 3296 Left overs: * 3297 --- 3298 name: heredoc-tmpfile-4 3299 description: 3300 Check that heredoc temp files aren't removed too soon or too late. 3301 Backgrounded simple command with here doc 3302 stdin: 3303 TMPDIR=$PWD 3304 eval ' 3305 cat <<- EOF & 3306 hi 3307 EOF 3308 ' & 3309 sleep 1 3310 echo Left overs: * 3311 expected-stdout: 3312 hi 3313 Left overs: * 3314 --- 3315 name: heredoc-tmpfile-5 3316 description: 3317 Check that heredoc temp files aren't removed too soon or too late. 3318 Backgrounded subshell command with here doc 3319 stdin: 3320 TMPDIR=$PWD 3321 eval ' 3322 ( 3323 sleep 1 # so parent exits 3324 echo A 3325 cat <<- EOF 3326 hi 3327 EOF 3328 echo B 3329 ) & 3330 ' & 3331 sleep 5 3332 echo Left overs: * 3333 expected-stdout: 3334 A 3335 hi 3336 B 3337 Left overs: * 3338 --- 3339 name: heredoc-tmpfile-6 3340 description: 3341 Check that heredoc temp files aren't removed too soon or too late. 3342 Heredoc in pipeline. 3343 stdin: 3344 TMPDIR=$PWD 3345 eval ' 3346 cat <<- EOF | sed "s/hi/HI/" 3347 hi 3348 EOF 3349 ' & 3350 sleep 1 3351 echo Left overs: * 3352 expected-stdout: 3353 HI 3354 Left overs: * 3355 --- 3356 name: heredoc-tmpfile-7 3357 description: 3358 Check that heredoc temp files aren't removed too soon or too late. 3359 Heredoc in backgrounded pipeline. 3360 stdin: 3361 TMPDIR=$PWD 3362 eval ' 3363 cat <<- EOF | sed 's/hi/HI/' & 3364 hi 3365 EOF 3366 ' & 3367 sleep 1 3368 echo Left overs: * 3369 expected-stdout: 3370 HI 3371 Left overs: * 3372 --- 3373 name: heredoc-tmpfile-8 3374 description: 3375 Check that heredoc temp files aren't removed too soon or too 3376 late. Heredoc in function, backgrounded call to function. 3377 This check can fail on slow machines (<100 MHz), or Cygwin, 3378 that's normal. 3379 need-pass: no 3380 stdin: 3381 TMPDIR=$PWD 3382 # Background eval so main shell doesn't do parsing 3383 eval ' 3384 foo() { 3385 cat <<- EOF 3386 hi 3387 EOF 3388 } 3389 foo 3390 # sleep so eval can die 3391 (sleep 1; foo) & 3392 (sleep 1; foo) & 3393 foo 3394 ' & 3395 sleep 5 3396 echo Left overs: * 3397 expected-stdout: 3398 hi 3399 hi 3400 hi 3401 hi 3402 Left overs: * 3403 --- 3404 name: heredoc-quoting-unsubst 3405 description: 3406 Check for correct handling of quoted characters in 3407 here documents without substitution (marker is quoted). 3408 stdin: 3409 foo=bar 3410 cat <<-'EOF' 3411 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x 3412 EOF 3413 expected-stdout: 3414 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x 3415 --- 3416 name: heredoc-quoting-subst 3417 description: 3418 Check for correct handling of quoted characters in 3419 here documents with substitution (marker is not quoted). 3420 stdin: 3421 foo=bar 3422 cat <<-EOF 3423 x " \" \ \\ $ \$ `echo baz` \`echo baz\` $foo \$foo x 3424 EOF 3425 expected-stdout: 3426 x " \" \ \ $ $ baz `echo baz` bar $foo x 3427 --- 3428 name: single-quotes-in-braces 3429 description: 3430 Check that single quotes inside unquoted {} are treated as quotes 3431 stdin: 3432 foo=1 3433 echo ${foo:+'blah $foo'} 3434 expected-stdout: 3435 blah $foo 3436 --- 3437 name: single-quotes-in-quoted-braces 3438 description: 3439 Check that single quotes inside quoted {} are treated as 3440 normal char 3441 stdin: 3442 foo=1 3443 echo "${foo:+'blah $foo'}" 3444 expected-stdout: 3445 'blah 1' 3446 --- 3447 name: single-quotes-in-braces-nested 3448 description: 3449 Check that single quotes inside unquoted {} are treated as quotes, 3450 even if that's inside a double-quoted command expansion 3451 stdin: 3452 foo=1 3453 echo "$( echo ${foo:+'blah $foo'})" 3454 expected-stdout: 3455 blah $foo 3456 --- 3457 name: single-quotes-in-brace-pattern 3458 description: 3459 Check that single quotes inside {} pattern are treated as quotes 3460 stdin: 3461 foo=1234 3462 echo ${foo%'2'*} "${foo%'2'*}" ${foo%2'*'} "${foo%2'*'}" 3463 expected-stdout: 3464 1 1 1234 1234 3465 --- 3466 name: single-quotes-in-heredoc-braces 3467 description: 3468 Check that single quotes inside {} in heredoc are treated 3469 as normal char 3470 stdin: 3471 foo=1 3472 cat <<EOM 3473 ${foo:+'blah $foo'} 3474 EOM 3475 expected-stdout: 3476 'blah 1' 3477 --- 3478 name: single-quotes-in-nested-braces 3479 description: 3480 Check that single quotes inside nested unquoted {} are 3481 treated as quotes 3482 stdin: 3483 foo=1 3484 echo ${foo:+${foo:+'blah $foo'}} 3485 expected-stdout: 3486 blah $foo 3487 --- 3488 name: single-quotes-in-nested-quoted-braces 3489 description: 3490 Check that single quotes inside nested quoted {} are treated 3491 as normal char 3492 stdin: 3493 foo=1 3494 echo "${foo:+${foo:+'blah $foo'}}" 3495 expected-stdout: 3496 'blah 1' 3497 --- 3498 name: single-quotes-in-nested-braces-nested 3499 description: 3500 Check that single quotes inside nested unquoted {} are treated 3501 as quotes, even if that's inside a double-quoted command expansion 3502 stdin: 3503 foo=1 3504 echo "$( echo ${foo:+${foo:+'blah $foo'}})" 3505 expected-stdout: 3506 blah $foo 3507 --- 3508 name: single-quotes-in-nested-brace-pattern 3509 description: 3510 Check that single quotes inside nested {} pattern are treated as quotes 3511 stdin: 3512 foo=1234 3513 echo ${foo:+${foo%'2'*}} "${foo:+${foo%'2'*}}" ${foo:+${foo%2'*'}} "${foo:+${foo%2'*'}}" 3514 expected-stdout: 3515 1 1 1234 1234 3516 --- 3517 name: single-quotes-in-heredoc-nested-braces 3518 description: 3519 Check that single quotes inside nested {} in heredoc are treated 3520 as normal char 3521 stdin: 3522 foo=1 3523 cat <<EOM 3524 ${foo:+${foo:+'blah $foo'}} 3525 EOM 3526 expected-stdout: 3527 'blah 1' 3528 --- 3529 name: history-basic 3530 description: 3531 See if we can test history at all 3532 need-ctty: yes 3533 arguments: !-i! 3534 env-setup: !ENV=./Env!HISTFILE=hist.file! 3535 file-setup: file 644 "Env" 3536 PS1=X 3537 stdin: 3538 echo hi 3539 fc -l 3540 expected-stdout: 3541 hi 3542 1 echo hi 3543 expected-stderr-pattern: 3544 /^X*$/ 3545 --- 3546 name: history-dups 3547 description: 3548 Verify duplicates and spaces are not entered 3549 need-ctty: yes 3550 arguments: !-i! 3551 env-setup: !ENV=./Env!HISTFILE=hist.file! 3552 file-setup: file 644 "Env" 3553 PS1=X 3554 stdin: 3555 echo hi 3556 echo yo 3557 echo hi 3558 fc -l 3559 expected-stdout: 3560 hi 3561 yo 3562 hi 3563 1 echo hi 3564 expected-stderr-pattern: 3565 /^X*$/ 3566 --- 3567 name: history-unlink 3568 description: 3569 Check if broken HISTFILEs do not cause trouble 3570 need-ctty: yes 3571 arguments: !-i! 3572 env-setup: !ENV=./Env!HISTFILE=foo/hist.file! 3573 file-setup: file 644 "Env" 3574 PS1=X 3575 file-setup: dir 755 "foo" 3576 file-setup: file 644 "foo/hist.file" 3577 sometext 3578 time-limit: 5 3579 perl-setup: chmod(0555, "foo"); 3580 stdin: 3581 echo hi 3582 fc -l 3583 chmod 0755 foo 3584 expected-stdout: 3585 hi 3586 1 echo hi 3587 expected-stderr-pattern: 3588 /(.*can't unlink HISTFILE.*\n)?X*$/ 3589 --- 3590 name: history-multiline 3591 description: 3592 Check correct multiline history, Debian #783978 3593 need-ctty: yes 3594 arguments: !-i! 3595 env-setup: !ENV=./Env! 3596 file-setup: file 644 "Env" 3597 PS1=X 3598 PS2=Y 3599 stdin: 3600 for i in A B C 3601 do 3602 print $i 3603 print $i 3604 done 3605 fc -l 3606 expected-stdout: 3607 A 3608 A 3609 B 3610 B 3611 C 3612 C 3613 1 for i in A B C 3614 do 3615 print $i 3616 print $i 3617 done 3618 expected-stderr-pattern: 3619 /^XYYYYXX$/ 3620 --- 3621 name: history-e-minus-1 3622 description: 3623 Check if more recent command is executed 3624 need-ctty: yes 3625 arguments: !-i! 3626 env-setup: !ENV=./Env!HISTFILE=hist.file! 3627 file-setup: file 644 "Env" 3628 PS1=X 3629 stdin: 3630 echo hi 3631 echo there 3632 fc -e - 3633 expected-stdout: 3634 hi 3635 there 3636 there 3637 expected-stderr-pattern: 3638 /^X*echo there\nX*$/ 3639 --- 3640 name: history-e-minus-2 3641 description: 3642 Check that repeated command is printed before command 3643 is re-executed. 3644 need-ctty: yes 3645 arguments: !-i! 3646 env-setup: !ENV=./Env!HISTFILE=hist.file! 3647 file-setup: file 644 "Env" 3648 PS1=X 3649 stdin: 3650 exec 2>&1 3651 echo hi 3652 echo there 3653 fc -e - 3654 expected-stdout-pattern: 3655 /X*hi\nX*there\nX*echo there\nthere\nX*/ 3656 expected-stderr-pattern: 3657 /^X*$/ 3658 --- 3659 name: history-e-minus-3 3660 description: 3661 fc -e - fails when there is no history 3662 (ksh93 has a bug that causes this to fail) 3663 (ksh88 loops on this) 3664 need-ctty: yes 3665 arguments: !-i! 3666 env-setup: !ENV=./Env!HISTFILE=hist.file! 3667 file-setup: file 644 "Env" 3668 PS1=X 3669 stdin: 3670 fc -e - 3671 echo ok 3672 expected-stdout: 3673 ok 3674 expected-stderr-pattern: 3675 /^X*.*:.*history.*\nX*$/ 3676 --- 3677 name: history-e-minus-4 3678 description: 3679 Check if "fc -e -" command output goes to stdout. 3680 need-ctty: yes 3681 arguments: !-i! 3682 env-setup: !ENV=./Env!HISTFILE=hist.file! 3683 file-setup: file 644 "Env" 3684 PS1=X 3685 stdin: 3686 echo abc 3687 fc -e - | (read x; echo "A $x") 3688 echo ok 3689 expected-stdout: 3690 abc 3691 A abc 3692 ok 3693 expected-stderr-pattern: 3694 /^X*echo abc\nX*/ 3695 --- 3696 name: history-e-minus-5 3697 description: 3698 fc is replaced in history by new command. 3699 need-ctty: yes 3700 arguments: !-i! 3701 env-setup: !ENV=./Env!HISTFILE=hist.file! 3702 file-setup: file 644 "Env" 3703 PS1=X 3704 stdin: 3705 echo abc def 3706 echo ghi jkl 3707 : 3708 fc -e - echo 3709 fc -l 2 5 3710 expected-stdout: 3711 abc def 3712 ghi jkl 3713 ghi jkl 3714 2 echo ghi jkl 3715 3 : 3716 4 echo ghi jkl 3717 5 fc -l 2 5 3718 expected-stderr-pattern: 3719 /^X*echo ghi jkl\nX*$/ 3720 --- 3721 name: history-list-1 3722 description: 3723 List lists correct range 3724 (ksh88 fails 'cause it lists the fc command) 3725 need-ctty: yes 3726 arguments: !-i! 3727 env-setup: !ENV=./Env!HISTFILE=hist.file! 3728 file-setup: file 644 "Env" 3729 PS1=X 3730 stdin: 3731 echo line 1 3732 echo line 2 3733 echo line 3 3734 fc -l -- -2 3735 expected-stdout: 3736 line 1 3737 line 2 3738 line 3 3739 2 echo line 2 3740 3 echo line 3 3741 expected-stderr-pattern: 3742 /^X*$/ 3743 --- 3744 name: history-list-2 3745 description: 3746 Lists oldest history if given pre-historic number 3747 (ksh93 has a bug that causes this to fail) 3748 (ksh88 fails 'cause it lists the fc command) 3749 need-ctty: yes 3750 arguments: !-i! 3751 env-setup: !ENV=./Env!HISTFILE=hist.file! 3752 file-setup: file 644 "Env" 3753 PS1=X 3754 stdin: 3755 echo line 1 3756 echo line 2 3757 echo line 3 3758 fc -l -- -40 3759 expected-stdout: 3760 line 1 3761 line 2 3762 line 3 3763 1 echo line 1 3764 2 echo line 2 3765 3 echo line 3 3766 expected-stderr-pattern: 3767 /^X*$/ 3768 --- 3769 name: history-list-3 3770 description: 3771 Can give number 'options' to fc 3772 need-ctty: yes 3773 arguments: !-i! 3774 env-setup: !ENV=./Env!HISTFILE=hist.file! 3775 file-setup: file 644 "Env" 3776 PS1=X 3777 stdin: 3778 echo line 1 3779 echo line 2 3780 echo line 3 3781 echo line 4 3782 fc -l -3 -2 3783 expected-stdout: 3784 line 1 3785 line 2 3786 line 3 3787 line 4 3788 2 echo line 2 3789 3 echo line 3 3790 expected-stderr-pattern: 3791 /^X*$/ 3792 --- 3793 name: history-list-4 3794 description: 3795 -1 refers to previous command 3796 need-ctty: yes 3797 arguments: !-i! 3798 env-setup: !ENV=./Env!HISTFILE=hist.file! 3799 file-setup: file 644 "Env" 3800 PS1=X 3801 stdin: 3802 echo line 1 3803 echo line 2 3804 echo line 3 3805 echo line 4 3806 fc -l -1 -1 3807 expected-stdout: 3808 line 1 3809 line 2 3810 line 3 3811 line 4 3812 4 echo line 4 3813 expected-stderr-pattern: 3814 /^X*$/ 3815 --- 3816 name: history-list-5 3817 description: 3818 List command stays in history 3819 need-ctty: yes 3820 arguments: !-i! 3821 env-setup: !ENV=./Env!HISTFILE=hist.file! 3822 file-setup: file 644 "Env" 3823 PS1=X 3824 stdin: 3825 echo line 1 3826 echo line 2 3827 echo line 3 3828 echo line 4 3829 fc -l -1 -1 3830 fc -l -2 -1 3831 expected-stdout: 3832 line 1 3833 line 2 3834 line 3 3835 line 4 3836 4 echo line 4 3837 4 echo line 4 3838 5 fc -l -1 -1 3839 expected-stderr-pattern: 3840 /^X*$/ 3841 --- 3842 name: history-list-6 3843 description: 3844 HISTSIZE limits about of history kept. 3845 (ksh88 fails 'cause it lists the fc command) 3846 need-ctty: yes 3847 arguments: !-i! 3848 env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3! 3849 file-setup: file 644 "Env" 3850 PS1=X 3851 stdin: 3852 echo line 1 3853 echo line 2 3854 echo line 3 3855 echo line 4 3856 echo line 5 3857 fc -l 3858 expected-stdout: 3859 line 1 3860 line 2 3861 line 3 3862 line 4 3863 line 5 3864 4 echo line 4 3865 5 echo line 5 3866 expected-stderr-pattern: 3867 /^X*$/ 3868 --- 3869 name: history-list-7 3870 description: 3871 fc allows too old/new errors in range specification 3872 need-ctty: yes 3873 arguments: !-i! 3874 env-setup: !ENV=./Env!HISTFILE=hist.file!HISTSIZE=3! 3875 file-setup: file 644 "Env" 3876 PS1=X 3877 stdin: 3878 echo line 1 3879 echo line 2 3880 echo line 3 3881 echo line 4 3882 echo line 5 3883 fc -l 1 30 3884 expected-stdout: 3885 line 1 3886 line 2 3887 line 3 3888 line 4 3889 line 5 3890 4 echo line 4 3891 5 echo line 5 3892 6 fc -l 1 30 3893 expected-stderr-pattern: 3894 /^X*$/ 3895 --- 3896 name: history-list-r-1 3897 description: 3898 test -r flag in history 3899 need-ctty: yes 3900 arguments: !-i! 3901 env-setup: !ENV=./Env!HISTFILE=hist.file! 3902 file-setup: file 644 "Env" 3903 PS1=X 3904 stdin: 3905 echo line 1 3906 echo line 2 3907 echo line 3 3908 echo line 4 3909 echo line 5 3910 fc -l -r 2 4 3911 expected-stdout: 3912 line 1 3913 line 2 3914 line 3 3915 line 4 3916 line 5 3917 4 echo line 4 3918 3 echo line 3 3919 2 echo line 2 3920 expected-stderr-pattern: 3921 /^X*$/ 3922 --- 3923 name: history-list-r-2 3924 description: 3925 If first is newer than last, -r is implied. 3926 need-ctty: yes 3927 arguments: !-i! 3928 env-setup: !ENV=./Env!HISTFILE=hist.file! 3929 file-setup: file 644 "Env" 3930 PS1=X 3931 stdin: 3932 echo line 1 3933 echo line 2 3934 echo line 3 3935 echo line 4 3936 echo line 5 3937 fc -l 4 2 3938 expected-stdout: 3939 line 1 3940 line 2 3941 line 3 3942 line 4 3943 line 5 3944 4 echo line 4 3945 3 echo line 3 3946 2 echo line 2 3947 expected-stderr-pattern: 3948 /^X*$/ 3949 --- 3950 name: history-list-r-3 3951 description: 3952 If first is newer than last, -r is cancelled. 3953 need-ctty: yes 3954 arguments: !-i! 3955 env-setup: !ENV=./Env!HISTFILE=hist.file! 3956 file-setup: file 644 "Env" 3957 PS1=X 3958 stdin: 3959 echo line 1 3960 echo line 2 3961 echo line 3 3962 echo line 4 3963 echo line 5 3964 fc -l -r 4 2 3965 expected-stdout: 3966 line 1 3967 line 2 3968 line 3 3969 line 4 3970 line 5 3971 2 echo line 2 3972 3 echo line 3 3973 4 echo line 4 3974 expected-stderr-pattern: 3975 /^X*$/ 3976 --- 3977 name: history-subst-1 3978 description: 3979 Basic substitution 3980 need-ctty: yes 3981 arguments: !-i! 3982 env-setup: !ENV=./Env!HISTFILE=hist.file! 3983 file-setup: file 644 "Env" 3984 PS1=X 3985 stdin: 3986 echo abc def 3987 echo ghi jkl 3988 fc -e - abc=AB 'echo a' 3989 expected-stdout: 3990 abc def 3991 ghi jkl 3992 AB def 3993 expected-stderr-pattern: 3994 /^X*echo AB def\nX*$/ 3995 --- 3996 name: history-subst-2 3997 description: 3998 Does subst find previous command? 3999 need-ctty: yes 4000 arguments: !-i! 4001 env-setup: !ENV=./Env!HISTFILE=hist.file! 4002 file-setup: file 644 "Env" 4003 PS1=X 4004 stdin: 4005 echo abc def 4006 echo ghi jkl 4007 fc -e - jkl=XYZQRT 'echo g' 4008 expected-stdout: 4009 abc def 4010 ghi jkl 4011 ghi XYZQRT 4012 expected-stderr-pattern: 4013 /^X*echo ghi XYZQRT\nX*$/ 4014 --- 4015 name: history-subst-3 4016 description: 4017 Does subst find previous command when no arguments given 4018 need-ctty: yes 4019 arguments: !-i! 4020 env-setup: !ENV=./Env!HISTFILE=hist.file! 4021 file-setup: file 644 "Env" 4022 PS1=X 4023 stdin: 4024 echo abc def 4025 echo ghi jkl 4026 fc -e - jkl=XYZQRT 4027 expected-stdout: 4028 abc def 4029 ghi jkl 4030 ghi XYZQRT 4031 expected-stderr-pattern: 4032 /^X*echo ghi XYZQRT\nX*$/ 4033 --- 4034 name: history-subst-4 4035 description: 4036 Global substitutions work 4037 (ksh88 and ksh93 do not have -g option) 4038 need-ctty: yes 4039 arguments: !-i! 4040 env-setup: !ENV=./Env!HISTFILE=hist.file! 4041 file-setup: file 644 "Env" 4042 PS1=X 4043 stdin: 4044 echo abc def asjj sadjhasdjh asdjhasd 4045 fc -e - -g a=FooBAR 4046 expected-stdout: 4047 abc def asjj sadjhasdjh asdjhasd 4048 FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd 4049 expected-stderr-pattern: 4050 /^X*echo FooBARbc def FooBARsjj sFooBARdjhFooBARsdjh FooBARsdjhFooBARsd\nX*$/ 4051 --- 4052 name: history-subst-5 4053 description: 4054 Make sure searches don't find current (fc) command 4055 (ksh88/ksh93 don't have the ? prefix thing so they fail this test) 4056 need-ctty: yes 4057 arguments: !-i! 4058 env-setup: !ENV=./Env!HISTFILE=hist.file! 4059 file-setup: file 644 "Env" 4060 PS1=X 4061 stdin: 4062 echo abc def 4063 echo ghi jkl 4064 fc -e - abc=AB \?abc 4065 expected-stdout: 4066 abc def 4067 ghi jkl 4068 AB def 4069 expected-stderr-pattern: 4070 /^X*echo AB def\nX*$/ 4071 --- 4072 name: history-ed-1-old 4073 description: 4074 Basic (ed) editing works (assumes you have generic ed editor 4075 that prints no prompts). This is for oldish ed(1) which write 4076 the character count to stdout. 4077 category: stdout-ed 4078 need-ctty: yes 4079 need-pass: no 4080 arguments: !-i! 4081 env-setup: !ENV=./Env!HISTFILE=hist.file! 4082 file-setup: file 644 "Env" 4083 PS1=X 4084 stdin: 4085 echo abc def 4086 fc echo 4087 s/abc/FOOBAR/ 4088 w 4089 q 4090 expected-stdout: 4091 abc def 4092 13 4093 16 4094 FOOBAR def 4095 expected-stderr-pattern: 4096 /^X*echo FOOBAR def\nX*$/ 4097 --- 4098 name: history-ed-2-old 4099 description: 4100 Correct command is edited when number given 4101 category: stdout-ed 4102 need-ctty: yes 4103 need-pass: no 4104 arguments: !-i! 4105 env-setup: !ENV=./Env!HISTFILE=hist.file! 4106 file-setup: file 644 "Env" 4107 PS1=X 4108 stdin: 4109 echo line 1 4110 echo line 2 is here 4111 echo line 3 4112 echo line 4 4113 fc 2 4114 s/is here/is changed/ 4115 w 4116 q 4117 expected-stdout: 4118 line 1 4119 line 2 is here 4120 line 3 4121 line 4 4122 20 4123 23 4124 line 2 is changed 4125 expected-stderr-pattern: 4126 /^X*echo line 2 is changed\nX*$/ 4127 --- 4128 name: history-ed-3-old 4129 description: 4130 Newly created multi line commands show up as single command 4131 in history. 4132 (ksh88 fails 'cause it lists the fc command) 4133 category: stdout-ed 4134 need-ctty: yes 4135 need-pass: no 4136 arguments: !-i! 4137 env-setup: !ENV=./Env!HISTFILE=hist.file! 4138 file-setup: file 644 "Env" 4139 PS1=X 4140 stdin: 4141 echo abc def 4142 fc echo 4143 s/abc/FOOBAR/ 4144 $a 4145 echo a new line 4146 . 4147 w 4148 q 4149 fc -l 4150 expected-stdout: 4151 abc def 4152 13 4153 32 4154 FOOBAR def 4155 a new line 4156 1 echo abc def 4157 2 echo FOOBAR def 4158 echo a new line 4159 expected-stderr-pattern: 4160 /^X*echo FOOBAR def\necho a new line\nX*$/ 4161 --- 4162 name: history-ed-1 4163 description: 4164 Basic (ed) editing works (assumes you have generic ed editor 4165 that prints no prompts). This is for newish ed(1) and stderr. 4166 category: !no-stderr-ed 4167 need-ctty: yes 4168 need-pass: no 4169 arguments: !-i! 4170 env-setup: !ENV=./Env!HISTFILE=hist.file! 4171 file-setup: file 644 "Env" 4172 PS1=X 4173 stdin: 4174 echo abc def 4175 fc echo 4176 s/abc/FOOBAR/ 4177 w 4178 q 4179 expected-stdout: 4180 abc def 4181 FOOBAR def 4182 expected-stderr-pattern: 4183 /^X*13\n16\necho FOOBAR def\nX*$/ 4184 --- 4185 name: history-ed-2 4186 description: 4187 Correct command is edited when number given 4188 category: !no-stderr-ed 4189 need-ctty: yes 4190 need-pass: no 4191 arguments: !-i! 4192 env-setup: !ENV=./Env!HISTFILE=hist.file! 4193 file-setup: file 644 "Env" 4194 PS1=X 4195 stdin: 4196 echo line 1 4197 echo line 2 is here 4198 echo line 3 4199 echo line 4 4200 fc 2 4201 s/is here/is changed/ 4202 w 4203 q 4204 expected-stdout: 4205 line 1 4206 line 2 is here 4207 line 3 4208 line 4 4209 line 2 is changed 4210 expected-stderr-pattern: 4211 /^X*20\n23\necho line 2 is changed\nX*$/ 4212 --- 4213 name: history-ed-3 4214 description: 4215 Newly created multi line commands show up as single command 4216 in history. 4217 category: !no-stderr-ed 4218 need-ctty: yes 4219 need-pass: no 4220 arguments: !-i! 4221 env-setup: !ENV=./Env!HISTFILE=hist.file! 4222 file-setup: file 644 "Env" 4223 PS1=X 4224 stdin: 4225 echo abc def 4226 fc echo 4227 s/abc/FOOBAR/ 4228 $a 4229 echo a new line 4230 . 4231 w 4232 q 4233 fc -l 4234 expected-stdout: 4235 abc def 4236 FOOBAR def 4237 a new line 4238 1 echo abc def 4239 2 echo FOOBAR def 4240 echo a new line 4241 expected-stderr-pattern: 4242 /^X*13\n32\necho FOOBAR def\necho a new line\nX*$/ 4243 --- 4244 name: IFS-space-1 4245 description: 4246 Simple test, default IFS 4247 stdin: 4248 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } 4249 set -- A B C 4250 showargs 1 $* 4251 showargs 2 "$*" 4252 showargs 3 $@ 4253 showargs 4 "$@" 4254 expected-stdout: 4255 <1> <A> <B> <C> . 4256 <2> <A B C> . 4257 <3> <A> <B> <C> . 4258 <4> <A> <B> <C> . 4259 --- 4260 name: IFS-colon-1 4261 description: 4262 Simple test, IFS=: 4263 stdin: 4264 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } 4265 IFS=: 4266 set -- A B C 4267 showargs 1 $* 4268 showargs 2 "$*" 4269 showargs 3 $@ 4270 showargs 4 "$@" 4271 expected-stdout: 4272 <1> <A> <B> <C> . 4273 <2> <A:B:C> . 4274 <3> <A> <B> <C> . 4275 <4> <A> <B> <C> . 4276 --- 4277 name: IFS-null-1 4278 description: 4279 Simple test, IFS="" 4280 stdin: 4281 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } 4282 IFS="" 4283 set -- A B C 4284 showargs 1 $* 4285 showargs 2 "$*" 4286 showargs 3 $@ 4287 showargs 4 "$@" 4288 expected-stdout: 4289 <1> <A> <B> <C> . 4290 <2> <ABC> . 4291 <3> <A> <B> <C> . 4292 <4> <A> <B> <C> . 4293 --- 4294 name: IFS-space-colon-1 4295 description: 4296 Simple test, IFS=<white-space>: 4297 stdin: 4298 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } 4299 IFS="$IFS:" 4300 set -- 4301 showargs 1 $* 4302 showargs 2 "$*" 4303 showargs 3 $@ 4304 showargs 4 "$@" 4305 showargs 5 : "$@" 4306 expected-stdout: 4307 <1> . 4308 <2> <> . 4309 <3> . 4310 <4> . 4311 <5> <:> . 4312 --- 4313 name: IFS-space-colon-2 4314 description: 4315 Simple test, IFS=<white-space>: 4316 AT&T ksh fails this, POSIX says the test is correct. 4317 stdin: 4318 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } 4319 IFS="$IFS:" 4320 set -- 4321 showargs :"$@" 4322 expected-stdout: 4323 <:> . 4324 --- 4325 name: IFS-space-colon-4 4326 description: 4327 Simple test, IFS=<white-space>: 4328 stdin: 4329 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } 4330 IFS="$IFS:" 4331 set -- 4332 showargs "$@$@" 4333 expected-stdout: 4334 . 4335 --- 4336 name: IFS-space-colon-5 4337 description: 4338 Simple test, IFS=<white-space>: 4339 Don't know what POSIX thinks of this. AT&T ksh does not do this. 4340 stdin: 4341 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } 4342 IFS="$IFS:" 4343 set -- 4344 showargs "${@:-}" 4345 expected-stdout: 4346 <> . 4347 --- 4348 name: IFS-subst-1 4349 description: 4350 Simple test, IFS=<white-space>: 4351 stdin: 4352 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } 4353 IFS="$IFS:" 4354 x=":b: :" 4355 echo -n '1:'; for i in $x ; do echo -n " [$i]" ; done ; echo 4356 echo -n '2:'; for i in :b:: ; do echo -n " [$i]" ; done ; echo 4357 showargs 3 $x 4358 showargs 4 :b:: 4359 x="a:b:" 4360 echo -n '5:'; for i in $x ; do echo -n " [$i]" ; done ; echo 4361 showargs 6 $x 4362 x="a::c" 4363 echo -n '7:'; for i in $x ; do echo -n " [$i]" ; done ; echo 4364 showargs 8 $x 4365 echo -n '9:'; for i in ${FOO-`echo -n h:i`th:ere} ; do echo -n " [$i]" ; done ; echo 4366 showargs 10 ${FOO-`echo -n h:i`th:ere} 4367 showargs 11 "${FOO-`echo -n h:i`th:ere}" 4368 x=" A : B::D" 4369 echo -n '12:'; for i in $x ; do echo -n " [$i]" ; done ; echo 4370 showargs 13 $x 4371 expected-stdout: 4372 1: [] [b] [] 4373 2: [:b::] 4374 <3> <> <b> <> . 4375 <4> <:b::> . 4376 5: [a] [b] 4377 <6> <a> <b> . 4378 7: [a] [] [c] 4379 <8> <a> <> <c> . 4380 9: [h] [ith] [ere] 4381 <10> <h> <ith> <ere> . 4382 <11> <h:ith:ere> . 4383 12: [A] [B] [] [D] 4384 <13> <A> <B> <> <D> . 4385 --- 4386 name: IFS-subst-2 4387 description: 4388 Check leading whitespace after trim does not make a field 4389 stdin: 4390 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } 4391 x="X 1 2" 4392 showargs 1 shift ${x#X} 4393 expected-stdout: 4394 <1> <shift> <1> <2> . 4395 --- 4396 name: IFS-subst-3-arr 4397 description: 4398 Check leading IFS non-whitespace after trim does make a field 4399 but leading IFS whitespace does not, nor empty replacements 4400 stdin: 4401 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } 4402 showargs 0 ${-+} 4403 IFS=: 4404 showargs 1 ${-+:foo:bar} 4405 IFS=' ' 4406 showargs 2 ${-+ foo bar} 4407 expected-stdout: 4408 <0> . 4409 <1> <> <foo> <bar> . 4410 <2> <foo> <bar> . 4411 --- 4412 name: IFS-subst-3-ass 4413 description: 4414 Check non-field semantics 4415 stdin: 4416 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } 4417 showargs 0 x=${-+} 4418 IFS=: 4419 showargs 1 x=${-+:foo:bar} 4420 IFS=' ' 4421 showargs 2 x=${-+ foo bar} 4422 expected-stdout: 4423 <0> <x=> . 4424 <1> <x=> <foo> <bar> . 4425 <2> <x=> <foo> <bar> . 4426 --- 4427 name: IFS-subst-3-lcl 4428 description: 4429 Check non-field semantics, smaller corner case (LP#1381965) 4430 stdin: 4431 set -x 4432 local regex=${2:-} 4433 exit 1 4434 expected-exit: e != 0 4435 expected-stderr-pattern: 4436 /regex=/ 4437 --- 4438 name: IFS-subst-4-1 4439 description: 4440 reported by mikeserv 4441 stdin: 4442 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; } 4443 a='space divded argument 4444 here' 4445 IFS=\ ; set -- $a 4446 IFS= ; q="$*" ; nq=$* 4447 pfn "$*" $* "$q" "$nq" 4448 [ "$q" = "$nq" ] && echo =true || echo =false 4449 expected-stdout: 4450 <spacedivdedargument 4451 here> 4452 <space> 4453 <divded> 4454 <argument 4455 here> 4456 <spacedivdedargument 4457 here> 4458 <spacedivdedargument 4459 here> 4460 =true 4461 --- 4462 name: IFS-subst-4-2 4463 description: 4464 extended testsuite based on problem by mikeserv 4465 stdin: 4466 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; } 4467 a='space divded argument 4468 here' 4469 IFS=\ ; set -- $a 4470 IFS= ; q="$@" ; nq=$@ 4471 pfn "$*" $* "$q" "$nq" 4472 [ "$q" = "$nq" ] && echo =true || echo =false 4473 expected-stdout: 4474 <spacedivdedargument 4475 here> 4476 <space> 4477 <divded> 4478 <argument 4479 here> 4480 <space divded argument 4481 here> 4482 <space divded argument 4483 here> 4484 =true 4485 --- 4486 name: IFS-subst-4-3 4487 description: 4488 extended testsuite based on problem by mikeserv 4489 stdin: 4490 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; } 4491 a='space divded argument 4492 here' 4493 IFS=\ ; set -- $a; IFS= 4494 qs="$*" 4495 nqs=$* 4496 qk="$@" 4497 nqk=$@ 4498 print -nr -- '= qs '; pfn "$qs" 4499 print -nr -- '=nqs '; pfn "$nqs" 4500 print -nr -- '= qk '; pfn "$qk" 4501 print -nr -- '=nqk '; pfn "$nqk" 4502 print -nr -- '~ qs '; pfn "$*" 4503 print -nr -- '~nqs '; pfn $* 4504 print -nr -- '~ qk '; pfn "$@" 4505 print -nr -- '~nqk '; pfn $@ 4506 expected-stdout: 4507 = qs <spacedivdedargument 4508 here> 4509 =nqs <spacedivdedargument 4510 here> 4511 = qk <space divded argument 4512 here> 4513 =nqk <space divded argument 4514 here> 4515 ~ qs <spacedivdedargument 4516 here> 4517 ~nqs <space> 4518 <divded> 4519 <argument 4520 here> 4521 ~ qk <space> 4522 <divded> 4523 <argument 4524 here> 4525 ~nqk <space> 4526 <divded> 4527 <argument 4528 here> 4529 --- 4530 name: IFS-subst-4-4 4531 description: 4532 extended testsuite based on problem by mikeserv 4533 stdin: 4534 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; } 4535 a='space divded argument 4536 here' 4537 IFS=\ ; set -- $a; IFS= 4538 qs="$*" 4539 print -nr -- '= qs '; pfn "$qs" 4540 print -nr -- '~ qs '; pfn "$*" 4541 nqs=$* 4542 print -nr -- '=nqs '; pfn "$nqs" 4543 print -nr -- '~nqs '; pfn $* 4544 qk="$@" 4545 print -nr -- '= qk '; pfn "$qk" 4546 print -nr -- '~ qk '; pfn "$@" 4547 nqk=$@ 4548 print -nr -- '=nqk '; pfn "$nqk" 4549 print -nr -- '~nqk '; pfn $@ 4550 expected-stdout: 4551 = qs <spacedivdedargument 4552 here> 4553 ~ qs <spacedivdedargument 4554 here> 4555 =nqs <spacedivdedargument 4556 here> 4557 ~nqs <space> 4558 <divded> 4559 <argument 4560 here> 4561 = qk <space divded argument 4562 here> 4563 ~ qk <space> 4564 <divded> 4565 <argument 4566 here> 4567 =nqk <space divded argument 4568 here> 4569 ~nqk <space> 4570 <divded> 4571 <argument 4572 here> 4573 --- 4574 name: IFS-subst-4-4p 4575 description: 4576 extended testsuite based on problem by mikeserv 4577 stdin: 4578 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; } 4579 a='space divded argument 4580 here' 4581 IFS=\ ; set -- $a; IFS= 4582 unset v 4583 qs=${v:-"$*"} 4584 print -nr -- '= qs '; pfn "$qs" 4585 print -nr -- '~ qs '; pfn ${v:-"$*"} 4586 nqs=${v:-$*} 4587 print -nr -- '=nqs '; pfn "$nqs" 4588 print -nr -- '~nqs '; pfn ${v:-$*} 4589 qk=${v:-"$@"} 4590 print -nr -- '= qk '; pfn "$qk" 4591 print -nr -- '~ qk '; pfn ${v:-"$@"} 4592 nqk=${v:-$@} 4593 print -nr -- '=nqk '; pfn "$nqk" 4594 print -nr -- '~nqk '; pfn ${v:-$@} 4595 expected-stdout: 4596 = qs <spacedivdedargument 4597 here> 4598 ~ qs <spacedivdedargument 4599 here> 4600 =nqs <spacedivdedargument 4601 here> 4602 ~nqs <space> 4603 <divded> 4604 <argument 4605 here> 4606 = qk <space divded argument 4607 here> 4608 ~ qk <space> 4609 <divded> 4610 <argument 4611 here> 4612 =nqk <space divded argument 4613 here> 4614 ~nqk <space> 4615 <divded> 4616 <argument 4617 here> 4618 --- 4619 name: IFS-subst-4-5 4620 description: 4621 extended testsuite based on problem by mikeserv 4622 stdin: 4623 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; } 4624 a='space divded argument 4625 here' 4626 IFS=\ ; set -- $a; IFS=, 4627 qs="$*" 4628 print -nr -- '= qs '; pfn "$qs" 4629 print -nr -- '~ qs '; pfn "$*" 4630 nqs=$* 4631 print -nr -- '=nqs '; pfn "$nqs" 4632 print -nr -- '~nqs '; pfn $* 4633 qk="$@" 4634 print -nr -- '= qk '; pfn "$qk" 4635 print -nr -- '~ qk '; pfn "$@" 4636 nqk=$@ 4637 print -nr -- '=nqk '; pfn "$nqk" 4638 print -nr -- '~nqk '; pfn $@ 4639 expected-stdout: 4640 = qs <space,divded,argument 4641 here> 4642 ~ qs <space,divded,argument 4643 here> 4644 =nqs <space,divded,argument 4645 here> 4646 ~nqs <space> 4647 <divded> 4648 <argument 4649 here> 4650 = qk <space divded argument 4651 here> 4652 ~ qk <space> 4653 <divded> 4654 <argument 4655 here> 4656 =nqk <space divded argument 4657 here> 4658 ~nqk <space> 4659 <divded> 4660 <argument 4661 here> 4662 --- 4663 name: IFS-subst-4-5p 4664 description: 4665 extended testsuite based on problem by mikeserv 4666 stdin: 4667 pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; } 4668 a='space divded argument 4669 here' 4670 IFS=\ ; set -- $a; IFS=, 4671 unset v 4672 qs=${v:-"$*"} 4673 print -nr -- '= qs '; pfn "$qs" 4674 print -nr -- '~ qs '; pfn ${v:-"$*"} 4675 nqs=${v:-$*} 4676 print -nr -- '=nqs '; pfn "$nqs" 4677 print -nr -- '~nqs '; pfn ${v:-$*} 4678 qk=${v:-"$@"} 4679 print -nr -- '= qk '; pfn "$qk" 4680 print -nr -- '~ qk '; pfn ${v:-"$@"} 4681 nqk=${v:-$@} 4682 print -nr -- '=nqk '; pfn "$nqk" 4683 print -nr -- '~nqk '; pfn ${v:-$@} 4684 expected-stdout: 4685 = qs <space,divded,argument 4686 here> 4687 ~ qs <space,divded,argument 4688 here> 4689 =nqs <space,divded,argument 4690 here> 4691 ~nqs <space> 4692 <divded> 4693 <argument 4694 here> 4695 = qk <space divded argument 4696 here> 4697 ~ qk <space> 4698 <divded> 4699 <argument 4700 here> 4701 =nqk <space divded argument 4702 here> 4703 ~nqk <space> 4704 <divded> 4705 <argument 4706 here> 4707 --- 4708 name: IFS-subst-5 4709 description: 4710 extended testsuite based on IFS-subst-3 4711 differs slightly from ksh93: 4712 - omit trailing field in a3zna, a7ina (unquoted $@ expansion) 4713 - has extra middle fields in b5ins, b7ina (IFS_NWS unquoted expansion) 4714 differs slightly from bash: 4715 - omit leading field in a5ins, a7ina (IFS_NWS unquoted expansion) 4716 differs slightly from zsh: 4717 - differs in assignment, not expansion; probably zsh bug 4718 - has extra middle fields in b5ins, b7ina (IFS_NWS unquoted expansion) 4719 'emulate sh' zsh has extra fields in 4720 - a5ins (IFS_NWS unquoted $*) 4721 - b5ins, matching mkshs 4722 !!WARNING!! more to come: http://austingroupbugs.net/view.php?id=888 4723 stdin: 4724 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; 4725 IFS=; set -- "" 2 ""; pfb $*; x=$*; pfn "$x"' 4726 echo '=a1zns' 4727 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; 4728 IFS=; set -- "" 2 ""; pfb "$*"; x="$*"; pfn "$x"' 4729 echo '=a2zqs' 4730 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; 4731 IFS=; set -- "" 2 ""; pfb $@; x=$@; pfn "$x"' 4732 echo '=a3zna' 4733 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; 4734 IFS=; set -- "" 2 ""; pfb "$@"; x="$@"; pfn "$x"' 4735 echo '=a4zqa' 4736 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; 4737 IFS=,; set -- "" 2 ""; pfb $*; x=$*; pfn "$x"' 4738 echo '=a5ins' 4739 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; 4740 IFS=,; set -- "" 2 ""; pfb "$*"; x="$*"; pfn "$x"' 4741 echo '=a6iqs' 4742 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; 4743 IFS=,; set -- "" 2 ""; pfb $@; x=$@; pfn "$x"' 4744 echo '=a7ina' 4745 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; 4746 IFS=,; set -- "" 2 ""; pfb "$@"; x="$@"; pfn "$x"' 4747 echo '=a8iqa' 4748 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; 4749 IFS=; set -- A B "" "" C; pfb $*; x=$*; pfn "$x"' 4750 echo '=b1zns' 4751 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; 4752 IFS=; set -- A B "" "" C; pfb "$*"; x="$*"; pfn "$x"' 4753 echo '=b2zqs' 4754 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; 4755 IFS=; set -- A B "" "" C; pfb $@; x=$@; pfn "$x"' 4756 echo '=b3zna' 4757 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; 4758 IFS=; set -- A B "" "" C; pfb "$@"; x="$@"; pfn "$x"' 4759 echo '=b4zqa' 4760 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; 4761 IFS=,; set -- A B "" "" C; pfb $*; x=$*; pfn "$x"' 4762 echo '=b5ins' 4763 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; 4764 IFS=,; set -- A B "" "" C; pfb "$*"; x="$*"; pfn "$x"' 4765 echo '=b6iqs' 4766 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; 4767 IFS=,; set -- A B "" "" C; pfb $@; x=$@; pfn "$x"' 4768 echo '=b7ina' 4769 "$__progname" -c 'pfb() { for s_arg in "$@"; do print -r -- "[$s_arg]"; done; }; pfn() { for s_arg in "$@"; do print -r -- "<$s_arg>"; done; }; 4770 IFS=,; set -- A B "" "" C; pfb "$@"; x="$@"; pfn "$x"' 4771 echo '=b8iqa' 4772 expected-stdout: 4773 [2] 4774 <2> 4775 =a1zns 4776 [2] 4777 <2> 4778 =a2zqs 4779 [2] 4780 < 2 > 4781 =a3zna 4782 [] 4783 [2] 4784 [] 4785 < 2 > 4786 =a4zqa 4787 [2] 4788 <,2,> 4789 =a5ins 4790 [,2,] 4791 <,2,> 4792 =a6iqs 4793 [2] 4794 < 2 > 4795 =a7ina 4796 [] 4797 [2] 4798 [] 4799 < 2 > 4800 =a8iqa 4801 [A] 4802 [B] 4803 [C] 4804 <ABC> 4805 =b1zns 4806 [ABC] 4807 <ABC> 4808 =b2zqs 4809 [A] 4810 [B] 4811 [C] 4812 <A B C> 4813 =b3zna 4814 [A] 4815 [B] 4816 [] 4817 [] 4818 [C] 4819 <A B C> 4820 =b4zqa 4821 [A] 4822 [B] 4823 [] 4824 [] 4825 [C] 4826 <A,B,,,C> 4827 =b5ins 4828 [A,B,,,C] 4829 <A,B,,,C> 4830 =b6iqs 4831 [A] 4832 [B] 4833 [] 4834 [] 4835 [C] 4836 <A B C> 4837 =b7ina 4838 [A] 4839 [B] 4840 [] 4841 [] 4842 [C] 4843 <A B C> 4844 =b8iqa 4845 --- 4846 name: IFS-subst-6 4847 description: 4848 Regression wrt. vector expansion in trim 4849 stdin: 4850 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } 4851 IFS= 4852 x=abc 4853 set -- a b 4854 showargs ${x#$*} 4855 expected-stdout: 4856 <c> . 4857 --- 4858 name: IFS-subst-7 4859 description: 4860 ksh93 bug wrt. vector expansion in trim 4861 stdin: 4862 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } 4863 IFS="*" 4864 a=abcd 4865 set -- '' c 4866 showargs "$*" ${a##"$*"} 4867 expected-stdout: 4868 <*c> <abcd> . 4869 --- 4870 name: IFS-subst-8 4871 description: 4872 http://austingroupbugs.net/view.php?id=221 4873 stdin: 4874 n() { echo "$#"; }; n "${foo-$@}" 4875 expected-stdout: 4876 1 4877 --- 4878 name: IFS-subst-9 4879 description: 4880 Scalar context for $*/$@ in [[ and case 4881 stdin: 4882 "$__progname" -c 'IFS=; set a b; [[ $* = "$1$2" ]]; echo 1 $?' sh a b 4883 "$__progname" -c 'IFS=; [[ $* = ab ]]; echo 2 "$?"' sh a b 4884 "$__progname" -c 'IFS=; [[ "$*" = ab ]]; echo 3 "$?"' sh a b 4885 "$__progname" -c 'IFS=; [[ $* = a ]]; echo 4 "$?"' sh a b 4886 "$__progname" -c 'IFS=; [[ "$*" = a ]]; echo 5 "$?"' sh a b 4887 "$__progname" -c 'IFS=; [[ "$@" = a ]]; echo 6 "$?"' sh a b 4888 "$__progname" -c 'IFS=; case "$@" in a) echo 7 a;; ab) echo 7 b;; a\ b) echo 7 ok;; esac' sh a b 4889 "$__progname" -c 'IFS=; case $* in a) echo 8 a;; ab) echo 8 ok;; esac' sh a b 4890 "$__progname" -c 'pfsp() { for s_arg in "$@"; do print -nr -- "<$s_arg> "; done; print .; }; IFS=; star=$* at="$@"; pfsp 9 "$star" "$at"' sh a b 4891 expected-stdout: 4892 1 0 4893 2 0 4894 3 0 4895 4 1 4896 5 1 4897 6 1 4898 7 ok 4899 8 ok 4900 <9> <ab> <a b> . 4901 --- 4902 name: IFS-subst-10 4903 description: 4904 Scalar context in ${var=$subst} 4905 stdin: 4906 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } 4907 set -- one "two three" four 4908 unset -v var 4909 save_IFS=$IFS 4910 IFS= 4911 set -- ${var=$*} 4912 IFS=$save_IFS 4913 echo "var=$var" 4914 showargs "$@" 4915 expected-stdout: 4916 var=onetwo threefour 4917 <onetwo threefour> . 4918 --- 4919 name: IFS-arith-1 4920 description: 4921 http://austingroupbugs.net/view.php?id=832 4922 stdin: 4923 ${ZSH_VERSION+false} || emulate sh 4924 ${BASH_VERSION+set -o posix} 4925 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } 4926 IFS=0 4927 showargs $((1230456)) 4928 expected-stdout: 4929 <123> <456> . 4930 --- 4931 name: integer-base-err-1 4932 description: 4933 Can't have 0 base (causes shell to exit) 4934 expected-exit: e != 0 4935 stdin: 4936 typeset -i i 4937 i=3 4938 i=0#4 4939 echo $i 4940 expected-stderr-pattern: 4941 /^.*:.*0#4.*\n$/ 4942 --- 4943 name: integer-base-err-2 4944 description: 4945 Can't have multiple bases in a 'constant' (causes shell to exit) 4946 (ksh88 fails this test) 4947 expected-exit: e != 0 4948 stdin: 4949 typeset -i i 4950 i=3 4951 i=2#110#11 4952 echo $i 4953 expected-stderr-pattern: 4954 /^.*:.*2#110#11.*\n$/ 4955 --- 4956 name: integer-base-err-3 4957 description: 4958 Syntax errors in expressions and effects on bases 4959 (interactive so errors don't cause exits) 4960 (ksh88 fails this test - shell exits, even with -i) 4961 need-ctty: yes 4962 arguments: !-i! 4963 stdin: 4964 PS1= # minimise prompt hassles 4965 typeset -i4 a=10 4966 typeset -i a=2+ 4967 echo $a 4968 typeset -i4 a=10 4969 typeset -i2 a=2+ 4970 echo $a 4971 expected-stderr-pattern: 4972 /^([#\$] )?.*:.*2+.*\n.*:.*2+.*\n$/ 4973 expected-stdout: 4974 4#22 4975 4#22 4976 --- 4977 name: integer-base-err-4 4978 description: 4979 Are invalid digits (according to base) errors? 4980 (ksh93 fails this test) 4981 expected-exit: e != 0 4982 stdin: 4983 typeset -i i; 4984 i=3#4 4985 expected-stderr-pattern: 4986 /^([#\$] )?.*:.*3#4.*\n$/ 4987 --- 4988 name: integer-base-1 4989 description: 4990 Missing number after base is treated as 0. 4991 stdin: 4992 typeset -i i 4993 i=3 4994 i=2# 4995 echo $i 4996 expected-stdout: 4997 0 4998 --- 4999 name: integer-base-2 5000 description: 5001 Check 'stickyness' of base in various situations 5002 stdin: 5003 typeset -i i=8 5004 echo $i 5005 echo ---------- A 5006 typeset -i4 j=8 5007 echo $j 5008 echo ---------- B 5009 typeset -i k=8 5010 typeset -i4 k=8 5011 echo $k 5012 echo ---------- C 5013 typeset -i4 l 5014 l=3#10 5015 echo $l 5016 echo ---------- D 5017 typeset -i m 5018 m=3#10 5019 echo $m 5020 echo ---------- E 5021 n=2#11 5022 typeset -i n 5023 echo $n 5024 n=10 5025 echo $n 5026 echo ---------- F 5027 typeset -i8 o=12 5028 typeset -i4 o 5029 echo $o 5030 echo ---------- G 5031 typeset -i p 5032 let p=8#12 5033 echo $p 5034 expected-stdout: 5035 8 5036 ---------- A 5037 4#20 5038 ---------- B 5039 4#20 5040 ---------- C 5041 4#3 5042 ---------- D 5043 3#10 5044 ---------- E 5045 2#11 5046 2#1010 5047 ---------- F 5048 4#30 5049 ---------- G 5050 8#12 5051 --- 5052 name: integer-base-3 5053 description: 5054 More base parsing (hmm doesn't test much..) 5055 stdin: 5056 typeset -i aa 5057 aa=1+12#10+2 5058 echo $aa 5059 typeset -i bb 5060 bb=1+$aa 5061 echo $bb 5062 typeset -i bb 5063 bb=$aa 5064 echo $bb 5065 typeset -i cc 5066 cc=$aa 5067 echo $cc 5068 expected-stdout: 5069 15 5070 16 5071 15 5072 15 5073 --- 5074 name: integer-base-4 5075 description: 5076 Check that things not declared as integers are not made integers, 5077 also, check if base is not reset by -i with no arguments. 5078 (ksh93 fails - prints 10#20 - go figure) 5079 stdin: 5080 xx=20 5081 let xx=10 5082 typeset -i | grep '^xx=' 5083 typeset -i4 a=10 5084 typeset -i a=20 5085 echo $a 5086 expected-stdout: 5087 4#110 5088 --- 5089 name: integer-base-5 5090 description: 5091 More base stuff 5092 stdin: 5093 typeset -i4 a=3#10 5094 echo $a 5095 echo -- 5096 typeset -i j=3 5097 j='~3' 5098 echo $j 5099 echo -- 5100 typeset -i k=1 5101 x[k=k+1]=3 5102 echo $k 5103 echo -- 5104 typeset -i l 5105 for l in 1 2+3 4; do echo $l; done 5106 expected-stdout: 5107 4#3 5108 -- 5109 -4 5110 -- 5111 2 5112 -- 5113 1 5114 5 5115 4 5116 --- 5117 name: integer-base-6 5118 description: 5119 Even more base stuff 5120 (ksh93 fails this test - prints 0) 5121 stdin: 5122 typeset -i7 i 5123 i= 5124 echo $i 5125 expected-stdout: 5126 7#0 5127 --- 5128 name: integer-base-7 5129 description: 5130 Check that non-integer parameters don't get bases assigned 5131 stdin: 5132 echo $(( zz = 8#100 )) 5133 echo $zz 5134 expected-stdout: 5135 64 5136 64 5137 --- 5138 name: integer-base-8 5139 description: 5140 Check that base-36 works (full span) 5141 stdin: 5142 echo 1:$((36#109AZ)). 5143 typeset -i36 x=1691675 5144 echo 2:$x. 5145 typeset -Uui36 x 5146 echo 3:$x. 5147 expected-stdout: 5148 1:1691675. 5149 2:36#109az. 5150 3:36#109AZ. 5151 --- 5152 name: integer-base-check-flat 5153 description: 5154 Check behaviour does not match POSuX (except if set -o posix), 5155 because a not type-safe scripting language has *no* business 5156 interpreting the string "010" as octal number eight (dangerous). 5157 stdin: 5158 echo 1 "$("$__progname" -c 'echo :$((10))/$((010)),$((0x10)):')" . 5159 echo 2 "$("$__progname" -o posix -c 'echo :$((10))/$((010)),$((0x10)):')" . 5160 echo 3 "$("$__progname" -o sh -c 'echo :$((10))/$((010)),$((0x10)):')" . 5161 expected-stdout: 5162 1 :10/10,16: . 5163 2 :10/8,16: . 5164 3 :10/10,16: . 5165 --- 5166 name: integer-base-check-numeric-from-1 5167 description: 5168 Check behaviour for base one 5169 category: !shell:ebcdic-yes 5170 stdin: 5171 echo 1:$((1#1))0. 5172 expected-stdout: 5173 1:490. 5174 --- 5175 name: integer-base-check-numeric-from-1-ebcdic 5176 description: 5177 Check behaviour for base one 5178 category: !shell:ebcdic-no 5179 stdin: 5180 echo 1:$((1#1))0. 5181 expected-stdout: 5182 1:2410. 5183 --- 5184 name: integer-base-check-numeric-from-2 5185 description: 5186 Check behaviour for base two to 36, and that 37 degrades to 10 5187 stdin: 5188 i=1 5189 while (( ++i <= 37 )); do 5190 eval 'echo '$i':$(('$i'#10)).' 5191 done 5192 echo 37:$($__progname -c 'echo $((37#10))').$?: 5193 expected-stdout: 5194 2:2. 5195 3:3. 5196 4:4. 5197 5:5. 5198 6:6. 5199 7:7. 5200 8:8. 5201 9:9. 5202 10:10. 5203 11:11. 5204 12:12. 5205 13:13. 5206 14:14. 5207 15:15. 5208 16:16. 5209 17:17. 5210 18:18. 5211 19:19. 5212 20:20. 5213 21:21. 5214 22:22. 5215 23:23. 5216 24:24. 5217 25:25. 5218 26:26. 5219 27:27. 5220 28:28. 5221 29:29. 5222 30:30. 5223 31:31. 5224 32:32. 5225 33:33. 5226 34:34. 5227 35:35. 5228 36:36. 5229 37:10. 5230 37:10.0: 5231 --- 5232 name: integer-base-check-numeric-to-1 5233 description: 5234 Check behaviour for base one 5235 category: !shell:ebcdic-yes 5236 stdin: 5237 i=1 5238 typeset -Uui$i x=0x40 5239 eval "typeset -i10 y=$x" 5240 print $i:$x.$y. 5241 expected-stdout: 5242 1:1#@.64. 5243 --- 5244 name: integer-base-check-numeric-to-1-ebcdic 5245 description: 5246 Check behaviour for base one 5247 category: !shell:ebcdic-no 5248 stdin: 5249 i=1 5250 typeset -Uui$i x=0x7C 5251 eval "typeset -i10 y=$x" 5252 print $i:$x.$y. 5253 expected-stdout: 5254 1:1#@.124. 5255 --- 5256 name: integer-base-check-numeric-to-2 5257 description: 5258 Check behaviour for base two to 36, and that 37 degrades to 10 5259 stdin: 5260 i=1 5261 while (( ++i <= 37 )); do 5262 typeset -Uui$i x=0x40 5263 eval "typeset -i10 y=$x" 5264 print $i:$x.$y. 5265 done 5266 expected-stdout: 5267 2:2#1000000.64. 5268 3:3#2101.64. 5269 4:4#1000.64. 5270 5:5#224.64. 5271 6:6#144.64. 5272 7:7#121.64. 5273 8:8#100.64. 5274 9:9#71.64. 5275 10:64.64. 5276 11:11#59.64. 5277 12:12#54.64. 5278 13:13#4C.64. 5279 14:14#48.64. 5280 15:15#44.64. 5281 16:16#40.64. 5282 17:17#3D.64. 5283 18:18#3A.64. 5284 19:19#37.64. 5285 20:20#34.64. 5286 21:21#31.64. 5287 22:22#2K.64. 5288 23:23#2I.64. 5289 24:24#2G.64. 5290 25:25#2E.64. 5291 26:26#2C.64. 5292 27:27#2A.64. 5293 28:28#28.64. 5294 29:29#26.64. 5295 30:30#24.64. 5296 31:31#22.64. 5297 32:32#20.64. 5298 33:33#1V.64. 5299 34:34#1U.64. 5300 35:35#1T.64. 5301 36:36#1S.64. 5302 37:64.64. 5303 --- 5304 name: integer-arithmetic-span 5305 description: 5306 Check wraparound and size that is defined in mksh 5307 category: int:32 5308 stdin: 5309 echo s:$((2147483647+1)).$(((2147483647*2)+1)).$(((2147483647*2)+2)). 5310 echo u:$((#2147483647+1)).$((#(2147483647*2)+1)).$((#(2147483647*2)+2)). 5311 expected-stdout: 5312 s:-2147483648.-1.0. 5313 u:2147483648.4294967295.0. 5314 --- 5315 name: integer-arithmetic-span-64 5316 description: 5317 Check wraparound and size that is defined in mksh 5318 category: int:64 5319 stdin: 5320 echo s:$((9223372036854775807+1)).$(((9223372036854775807*2)+1)).$(((9223372036854775807*2)+2)). 5321 echo u:$((#9223372036854775807+1)).$((#(9223372036854775807*2)+1)).$((#(9223372036854775807*2)+2)). 5322 expected-stdout: 5323 s:-9223372036854775808.-1.0. 5324 u:9223372036854775808.18446744073709551615.0. 5325 --- 5326 name: integer-size-FAIL-to-detect 5327 description: 5328 Notify the user that their ints are not 32 or 64 bit 5329 category: int:u 5330 stdin: 5331 : 5332 --- 5333 name: lineno-stdin 5334 description: 5335 See if $LINENO is updated and can be modified. 5336 stdin: 5337 echo A $LINENO 5338 echo B $LINENO 5339 LINENO=20 5340 echo C $LINENO 5341 expected-stdout: 5342 A 1 5343 B 2 5344 C 20 5345 --- 5346 name: lineno-inc 5347 description: 5348 See if $LINENO is set for .'d files. 5349 file-setup: file 644 "dotfile" 5350 echo dot A $LINENO 5351 echo dot B $LINENO 5352 LINENO=20 5353 echo dot C $LINENO 5354 stdin: 5355 echo A $LINENO 5356 echo B $LINENO 5357 . ./dotfile 5358 expected-stdout: 5359 A 1 5360 B 2 5361 dot A 1 5362 dot B 2 5363 dot C 20 5364 --- 5365 name: lineno-func 5366 description: 5367 See if $LINENO is set for commands in a function. 5368 stdin: 5369 echo A $LINENO 5370 echo B $LINENO 5371 bar() { 5372 echo func A $LINENO 5373 echo func B $LINENO 5374 } 5375 bar 5376 echo C $LINENO 5377 expected-stdout: 5378 A 1 5379 B 2 5380 func A 4 5381 func B 5 5382 C 8 5383 --- 5384 name: lineno-unset 5385 description: 5386 See if unsetting LINENO makes it non-magic. 5387 file-setup: file 644 "dotfile" 5388 echo dot A $LINENO 5389 echo dot B $LINENO 5390 stdin: 5391 unset LINENO 5392 echo A $LINENO 5393 echo B $LINENO 5394 bar() { 5395 echo func A $LINENO 5396 echo func B $LINENO 5397 } 5398 bar 5399 . ./dotfile 5400 echo C $LINENO 5401 expected-stdout: 5402 A 5403 B 5404 func A 5405 func B 5406 dot A 5407 dot B 5408 C 5409 --- 5410 name: lineno-unset-use 5411 description: 5412 See if unsetting LINENO makes it non-magic even 5413 when it is re-used. 5414 file-setup: file 644 "dotfile" 5415 echo dot A $LINENO 5416 echo dot B $LINENO 5417 stdin: 5418 unset LINENO 5419 LINENO=3 5420 echo A $LINENO 5421 echo B $LINENO 5422 bar() { 5423 echo func A $LINENO 5424 echo func B $LINENO 5425 } 5426 bar 5427 . ./dotfile 5428 echo C $LINENO 5429 expected-stdout: 5430 A 3 5431 B 3 5432 func A 3 5433 func B 3 5434 dot A 3 5435 dot B 3 5436 C 3 5437 --- 5438 name: lineno-trap 5439 description: 5440 Check if LINENO is tracked in traps 5441 stdin: 5442 fail() { 5443 echo "line <$1>" 5444 exit 1 5445 } 5446 trap 'fail $LINENO' INT ERR 5447 false 5448 expected-stdout: 5449 line <6> 5450 expected-exit: 1 5451 --- 5452 name: lineno-eval-alias 5453 description: 5454 Check if LINENO is trapped in eval and aliases 5455 stdin: 5456 ${ZSH_VERSION+false} || emulate sh; echo $LINENO 5457 echo $LINENO 5458 eval ' echo $LINENO 5459 echo $LINENO 5460 echo $LINENO' 5461 echo $LINENO 5462 expected-stdout: 5463 1 5464 2 5465 3 5466 3 5467 3 5468 6 5469 --- 5470 name: unknown-trap 5471 description: 5472 Ensure unknown traps are not a syntax error 5473 stdin: 5474 ( 5475 trap "echo trap 1 executed" UNKNOWNSIGNAL || echo "foo" 5476 echo =1 5477 trap "echo trap 2 executed" UNKNOWNSIGNAL EXIT 999999 FNORD 5478 echo = $? 5479 ) 2>&1 | sed "s^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]PROG" 5480 expected-stdout: 5481 PROG: trap: bad signal 'UNKNOWNSIGNAL' 5482 foo 5483 =1 5484 PROG: trap: bad signal 'UNKNOWNSIGNAL' 5485 PROG: trap: bad signal '999999' 5486 PROG: trap: bad signal 'FNORD' 5487 = 1 5488 trap 2 executed 5489 --- 5490 name: read-IFS-1 5491 description: 5492 Simple test, default IFS 5493 stdin: 5494 echo "A B " > IN 5495 unset x y z 5496 read x y z < IN 5497 echo 1: "x[$x] y[$y] z[$z]" 5498 echo 1a: ${z-z not set} 5499 read x < IN 5500 echo 2: "x[$x]" 5501 expected-stdout: 5502 1: x[A] y[B] z[] 5503 1a: 5504 2: x[A B] 5505 --- 5506 name: read-IFS-2 5507 description: 5508 Complex tests, IFS either colon (IFS-NWS) or backslash (tricky) 5509 stdin: 5510 n=0 5511 showargs() { print -nr "$1"; shift; for s_arg in "$@"; do print -nr -- " [$s_arg]"; done; print; } 5512 (IFS=\\ a=\<\\\>; showargs 3 $a) 5513 (IFS=: b=\<:\>; showargs 4 $b) 5514 print -r '<\>' | (IFS=\\ read f g; showargs 5 "$f" "$g") 5515 print -r '<\\>' | (IFS=\\ read f g; showargs 6 "$f" "$g") 5516 print '<\\\n>' | (IFS=\\ read f g; showargs 7 "$f" "$g") 5517 print -r '<\>' | (IFS=\\ read f; showargs 8 "$f") 5518 print -r '<\\>' | (IFS=\\ read f; showargs 9 "$f") 5519 print '<\\\n>' | (IFS=\\ read f; showargs 10 "$f") 5520 print -r '<\>' | (IFS=\\ read -r f g; showargs 11 "$f" "$g") 5521 print -r '<\\>' | (IFS=\\ read -r f g; showargs 12 "$f" "$g") 5522 print '<\\\n>' | (IFS=\\ read -r f g; showargs 13 "$f" "$g") 5523 print -r '<\>' | (IFS=\\ read -r f; showargs 14 "$f") 5524 print -r '<\\>' | (IFS=\\ read -r f; showargs 15 "$f") 5525 print '<\\\n>' | (IFS=\\ read -r f; showargs 16 "$f") 5526 print -r '<:>' | (IFS=: read f g; showargs 17 "$f" "$g") 5527 print -r '<::>' | (IFS=: read f g; showargs 18 "$f" "$g") 5528 print '<:\n>' | (IFS=: read f g; showargs 19 "$f" "$g") 5529 print -r '<:>' | (IFS=: read f; showargs 20 "$f") 5530 print -r '<::>' | (IFS=: read f; showargs 21 "$f") 5531 print '<:\n>' | (IFS=: read f; showargs 22 "$f") 5532 print -r '<:>' | (IFS=: read -r f g; showargs 23 "$f" "$g") 5533 print -r '<::>' | (IFS=: read -r f g; showargs 24 "$f" "$g") 5534 print '<:\n>' | (IFS=: read -r f g; showargs 25 "$f" "$g") 5535 print -r '<:>' | (IFS=: read -r f; showargs 26 "$f") 5536 print -r '<::>' | (IFS=: read -r f; showargs 27 "$f") 5537 print '<:\n>' | (IFS=: read -r f; showargs 28 "$f") 5538 expected-stdout: 5539 3 [<] [>] 5540 4 [<] [>] 5541 5 [<] [>] 5542 6 [<] [>] 5543 7 [<>] [] 5544 8 [<>] 5545 9 [<\>] 5546 10 [<>] 5547 11 [<] [>] 5548 12 [<] [\>] 5549 13 [<] [] 5550 14 [<\>] 5551 15 [<\\>] 5552 16 [<] 5553 17 [<] [>] 5554 18 [<] [:>] 5555 19 [<] [] 5556 20 [<:>] 5557 21 [<::>] 5558 22 [<] 5559 23 [<] [>] 5560 24 [<] [:>] 5561 25 [<] [] 5562 26 [<:>] 5563 27 [<::>] 5564 28 [<] 5565 --- 5566 name: read-ksh-1 5567 description: 5568 If no var specified, REPLY is used 5569 stdin: 5570 echo "abc" > IN 5571 read < IN 5572 echo "[$REPLY]"; 5573 expected-stdout: 5574 [abc] 5575 --- 5576 name: read-regress-1 5577 description: 5578 Check a regression of read 5579 file-setup: file 644 "foo" 5580 foo bar 5581 baz 5582 blah 5583 stdin: 5584 while read a b c; do 5585 read d 5586 break 5587 done <foo 5588 echo "<$a|$b|$c><$d>" 5589 expected-stdout: 5590 <foo|bar|><baz> 5591 --- 5592 name: read-delim-1 5593 description: 5594 Check read with delimiters 5595 stdin: 5596 emit() { 5597 print -n 'foo bar\tbaz\nblah \0blub\tblech\nmyok meck \0' 5598 } 5599 emit | while IFS= read -d "" foo; do print -r -- "<$foo>"; done 5600 emit | while read -d "" foo; do print -r -- "<$foo>"; done 5601 emit | while read -d "eh?" foo; do print -r -- "<$foo>"; done 5602 expected-stdout: 5603 <foo bar baz 5604 blah > 5605 <blub blech 5606 myok meck > 5607 <foo bar baz 5608 blah> 5609 <blub blech 5610 myok meck> 5611 <foo bar baz 5612 blah blub bl> 5613 <ch 5614 myok m> 5615 --- 5616 name: read-ext-1 5617 description: 5618 Check read with number of bytes specified, and -A 5619 stdin: 5620 print 'foo\nbar' >x1 5621 print -n x >x2 5622 print 'foo\\ bar baz' >x3 5623 x1a=u; read x1a <x1 5624 x1b=u; read -N-1 x1b <x1 5625 x2a=u; read x2a <x2; r2a=$? 5626 x2b=u; read -N2 x2c <x2; r2b=$? 5627 x2c=u; read -n2 x2c <x2; r2c=$? 5628 x3a=u; read -A x3a <x3 5629 print -r "x1a=<$x1a>" 5630 print -r "x1b=<$x1b>" 5631 print -r "x2a=$r2a<$x2a>" 5632 print -r "x2b=$r2b<$x2b>" 5633 print -r "x2c=$r2c<$x2c>" 5634 print -r "x3a=<${x3a[0]}|${x3a[1]}|${x3a[2]}>" 5635 expected-stdout: 5636 x1a=<foo> 5637 x1b=<foo 5638 bar> 5639 x2a=1<x> 5640 x2b=1<u> 5641 x2c=0<x> 5642 x3a=<foo bar|baz|> 5643 --- 5644 name: regression-1 5645 description: 5646 Lex array code had problems with this. 5647 stdin: 5648 echo foo[ 5649 n=bar 5650 echo "hi[ $n ]=1" 5651 expected-stdout: 5652 foo[ 5653 hi[ bar ]=1 5654 --- 5655 name: regression-2 5656 description: 5657 When PATH is set before running a command, the new path is 5658 not used in doing the path search 5659 $ echo echo hi > /tmp/q ; chmod a+rx /tmp/q 5660 $ PATH=/tmp q 5661 q: not found 5662 $ 5663 in comexec() the two lines 5664 while (*vp != NULL) 5665 (void) typeset(*vp++, xxx, 0); 5666 need to be moved out of the switch to before findcom() is 5667 called - I don't know what this will break. 5668 stdin: 5669 : "${PWD:-`pwd 2> /dev/null`}" 5670 : "${PWD:?"PWD not set - cannot do test"}" 5671 mkdir Y 5672 cat > Y/xxxscript << EOF 5673 #!/bin/sh 5674 # Need to restore path so echo can be found (some shells don't have 5675 # it as a built-in) 5676 PATH=\$OLDPATH 5677 echo hi 5678 exit 0 5679 EOF 5680 chmod a+rx Y/xxxscript 5681 export OLDPATH="$PATH" 5682 PATH=$PWD/Y xxxscript 5683 exit $? 5684 expected-stdout: 5685 hi 5686 --- 5687 name: regression-6 5688 description: 5689 Parsing of $(..) expressions is non-optimal. It is 5690 impossible to have any parentheses inside the expression. 5691 I.e., 5692 $ ksh -c 'echo $(echo \( )' 5693 no closing quote 5694 $ ksh -c 'echo $(echo "(" )' 5695 no closing quote 5696 $ 5697 The solution is to hack the parsing clode in lex.c, the 5698 question is how to hack it: should any parentheses be 5699 escaped by a backslash, or should recursive parsing be done 5700 (so quotes could also be used to hide hem). The former is 5701 easier, the later better... 5702 stdin: 5703 echo $(echo \( ) 5704 echo $(echo "(" ) 5705 expected-stdout: 5706 ( 5707 ( 5708 --- 5709 name: regression-9 5710 description: 5711 Continue in a for loop does not work right: 5712 for i in a b c ; do 5713 if [ $i = b ] ; then 5714 continue 5715 fi 5716 echo $i 5717 done 5718 Prints a forever... 5719 stdin: 5720 first=yes 5721 for i in a b c ; do 5722 if [ $i = b ] ; then 5723 if [ $first = no ] ; then 5724 echo 'continue in for loop broken' 5725 break # hope break isn't broken too :-) 5726 fi 5727 first=no 5728 continue 5729 fi 5730 done 5731 echo bye 5732 expected-stdout: 5733 bye 5734 --- 5735 name: regression-10 5736 description: 5737 The following: 5738 set -- `false` 5739 echo $? 5740 should print 0 according to POSIX (dash, bash, ksh93, posh) 5741 but not 0 according to the getopt(1) manual page, ksh88, and 5742 Bourne sh (such as /bin/sh on Solaris). 5743 We honour POSIX except when -o sh is set. 5744 category: shell:legacy-no 5745 stdin: 5746 showf() { 5747 [[ -o posix ]]; FPOSIX=$((1-$?)) 5748 [[ -o sh ]]; FSH=$((1-$?)) 5749 echo -n "FPOSIX=$FPOSIX FSH=$FSH " 5750 } 5751 set +o posix +o sh 5752 showf 5753 set -- `false` 5754 echo rv=$? 5755 set -o sh 5756 showf 5757 set -- `false` 5758 echo rv=$? 5759 set -o posix 5760 showf 5761 set -- `false` 5762 echo rv=$? 5763 set -o posix -o sh 5764 showf 5765 set -- `false` 5766 echo rv=$? 5767 expected-stdout: 5768 FPOSIX=0 FSH=0 rv=0 5769 FPOSIX=0 FSH=1 rv=1 5770 FPOSIX=1 FSH=0 rv=0 5771 FPOSIX=1 FSH=1 rv=0 5772 --- 5773 name: regression-10-legacy 5774 description: 5775 The following: 5776 set -- `false` 5777 echo $? 5778 should print 0 according to POSIX (dash, bash, ksh93, posh) 5779 but not 0 according to the getopt(1) manual page, ksh88, and 5780 Bourne sh (such as /bin/sh on Solaris). 5781 category: shell:legacy-yes 5782 stdin: 5783 showf() { 5784 [[ -o posix ]]; FPOSIX=$((1-$?)) 5785 [[ -o sh ]]; FSH=$((1-$?)) 5786 echo -n "FPOSIX=$FPOSIX FSH=$FSH " 5787 } 5788 set +o posix +o sh 5789 showf 5790 set -- `false` 5791 echo rv=$? 5792 set -o sh 5793 showf 5794 set -- `false` 5795 echo rv=$? 5796 set -o posix 5797 showf 5798 set -- `false` 5799 echo rv=$? 5800 set -o posix -o sh 5801 showf 5802 set -- `false` 5803 echo rv=$? 5804 expected-stdout: 5805 FPOSIX=0 FSH=0 rv=1 5806 FPOSIX=0 FSH=1 rv=1 5807 FPOSIX=1 FSH=0 rv=0 5808 FPOSIX=1 FSH=1 rv=0 5809 --- 5810 name: regression-11 5811 description: 5812 The following: 5813 x=/foo/bar/blah 5814 echo ${x##*/} 5815 should echo blah but on some machines echos /foo/bar/blah. 5816 stdin: 5817 x=/foo/bar/blah 5818 echo ${x##*/} 5819 expected-stdout: 5820 blah 5821 --- 5822 name: regression-12 5823 description: 5824 Both of the following echos produce the same output under sh/ksh.att: 5825 #!/bin/sh 5826 x="foo bar" 5827 echo "`echo \"$x\"`" 5828 echo "`echo "$x"`" 5829 pdksh produces different output for the former (foo instead of foo\tbar) 5830 stdin: 5831 x="foo bar" 5832 echo "`echo \"$x\"`" 5833 echo "`echo "$x"`" 5834 expected-stdout: 5835 foo bar 5836 foo bar 5837 --- 5838 name: regression-13 5839 description: 5840 The following command hangs forever: 5841 $ (: ; cat /etc/termcap) | sleep 2 5842 This is because the shell forks a shell to run the (..) command 5843 and this shell has the pipe open. When the sleep dies, the cat 5844 doesn't get a SIGPIPE 'cause a process (ie, the second shell) 5845 still has the pipe open. 5846 5847 NOTE: this test provokes a bizarre bug in ksh93 (shell starts reading 5848 commands from /etc/termcap..) 5849 time-limit: 10 5850 stdin: 5851 echo A line of text that will be duplicated quite a number of times.> t1 5852 cat t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 t1 > t2 5853 cat t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 t2 > t1 5854 cat t1 t1 t1 t1 > t2 5855 (: ; cat t2 2>/dev/null) | sleep 1 5856 --- 5857 name: regression-14 5858 description: 5859 The command 5860 $ (foobar) 2> /dev/null 5861 generates no output under /bin/sh, but pdksh produces the error 5862 foobar: not found 5863 Also, the command 5864 $ foobar 2> /dev/null 5865 generates an error under /bin/sh and pdksh, but AT&T ksh88 produces 5866 no error (redirected to /dev/null). 5867 stdin: 5868 (you/should/not/see/this/error/1) 2> /dev/null 5869 you/should/not/see/this/error/2 2> /dev/null 5870 true 5871 --- 5872 name: regression-15 5873 description: 5874 The command 5875 $ whence foobar 5876 generates a blank line under pdksh and sets the exit status to 0. 5877 AT&T ksh88 generates no output and sets the exit status to 1. Also, 5878 the command 5879 $ whence foobar cat 5880 generates no output under AT&T ksh88 (pdksh generates a blank line 5881 and /bin/cat). 5882 stdin: 5883 whence does/not/exist > /dev/null 5884 echo 1: $? 5885 echo 2: $(whence does/not/exist | wc -l) 5886 echo 3: $(whence does/not/exist cat | wc -l) 5887 expected-stdout: 5888 1: 1 5889 2: 0 5890 3: 0 5891 --- 5892 name: regression-16 5893 description: 5894 ${var%%expr} seems to be broken in many places. On the mips 5895 the commands 5896 $ read line < /etc/passwd 5897 $ echo $line 5898 root:0:1:... 5899 $ echo ${line%%:*} 5900 root 5901 $ echo $line 5902 root 5903 $ 5904 change the value of line. On sun4s & pas, the echo ${line%%:*} doesn't 5905 work. Haven't checked elsewhere... 5906 script: 5907 read x 5908 y=$x 5909 echo ${x%%:*} 5910 echo $x 5911 stdin: 5912 root:asdjhasdasjhs:0:1:Root:/:/bin/sh 5913 expected-stdout: 5914 root 5915 root:asdjhasdasjhs:0:1:Root:/:/bin/sh 5916 --- 5917 name: regression-17 5918 description: 5919 The command 5920 . /foo/bar 5921 should set the exit status to non-zero (sh and AT&T ksh88 do). 5922 XXX doting a non existent file is a fatal error for a script 5923 stdin: 5924 . does/not/exist 5925 expected-exit: e != 0 5926 expected-stderr-pattern: /.?/ 5927 --- 5928 name: regression-19 5929 description: 5930 Both of the following echos should produce the same thing, but don't: 5931 $ x=foo/bar 5932 $ echo ${x%/*} 5933 foo 5934 $ echo "${x%/*}" 5935 foo/bar 5936 stdin: 5937 x=foo/bar 5938 echo "${x%/*}" 5939 expected-stdout: 5940 foo 5941 --- 5942 name: regression-21 5943 description: 5944 backslash does not work as expected in case labels: 5945 $ x='-x' 5946 $ case $x in 5947 -\?) echo hi 5948 esac 5949 hi 5950 $ x='-?' 5951 $ case $x in 5952 -\\?) echo hi 5953 esac 5954 hi 5955 $ 5956 stdin: 5957 case -x in 5958 -\?) echo fail 5959 esac 5960 --- 5961 name: regression-22 5962 description: 5963 Quoting backquotes inside backquotes doesn't work: 5964 $ echo `echo hi \`echo there\` folks` 5965 asks for more info. sh and AT&T ksh88 both echo 5966 hi there folks 5967 stdin: 5968 echo `echo hi \`echo there\` folks` 5969 expected-stdout: 5970 hi there folks 5971 --- 5972 name: regression-23 5973 description: 5974 )) is not treated `correctly': 5975 $ (echo hi ; (echo there ; echo folks)) 5976 missing (( 5977 $ 5978 instead of (as sh and ksh.att) 5979 $ (echo hi ; (echo there ; echo folks)) 5980 hi 5981 there 5982 folks 5983 $ 5984 stdin: 5985 ( : ; ( : ; echo hi)) 5986 expected-stdout: 5987 hi 5988 --- 5989 name: regression-25 5990 description: 5991 Check reading stdin in a while loop. The read should only read 5992 a single line, not a whole stdio buffer; the cat should get 5993 the rest. 5994 stdin: 5995 (echo a; echo b) | while read x ; do 5996 echo $x 5997 cat > /dev/null 5998 done 5999 expected-stdout: 6000 a 6001 --- 6002 name: regression-26 6003 description: 6004 Check reading stdin in a while loop. The read should read both 6005 lines, not just the first. 6006 script: 6007 a= 6008 while [ "$a" != xxx ] ; do 6009 last=$x 6010 read x 6011 cat /dev/null | sed 's/x/y/' 6012 a=x$a 6013 done 6014 echo $last 6015 stdin: 6016 a 6017 b 6018 expected-stdout: 6019 b 6020 --- 6021 name: regression-27 6022 description: 6023 The command 6024 . /does/not/exist 6025 should cause a script to exit. 6026 stdin: 6027 . does/not/exist 6028 echo hi 6029 expected-exit: e != 0 6030 expected-stderr-pattern: /does\/not\/exist/ 6031 --- 6032 name: regression-28 6033 description: 6034 variable assignements not detected well 6035 stdin: 6036 a.x=1 echo hi 6037 expected-exit: e != 0 6038 expected-stderr-pattern: /a\.x=1/ 6039 --- 6040 name: regression-29 6041 description: 6042 alias expansion different from AT&T ksh88 6043 stdin: 6044 alias a='for ' b='i in' 6045 a b hi ; do echo $i ; done 6046 expected-stdout: 6047 hi 6048 --- 6049 name: regression-30 6050 description: 6051 strange characters allowed inside ${...} 6052 stdin: 6053 echo ${a{b}} 6054 expected-exit: e != 0 6055 expected-stderr-pattern: /.?/ 6056 --- 6057 name: regression-31 6058 description: 6059 Does read handle partial lines correctly 6060 script: 6061 a= ret= 6062 while [ "$a" != xxx ] ; do 6063 read x y z 6064 ret=$? 6065 a=x$a 6066 done 6067 echo "[$x]" 6068 echo $ret 6069 stdin: ! 6070 a A aA 6071 b B Bb 6072 c 6073 expected-stdout: 6074 [c] 6075 1 6076 --- 6077 name: regression-32 6078 description: 6079 Does read set variables to null at eof? 6080 script: 6081 a= 6082 while [ "$a" != xxx ] ; do 6083 read x y z 6084 a=x$a 6085 done 6086 echo 1: ${x-x not set} ${y-y not set} ${z-z not set} 6087 echo 2: ${x:+x not null} ${y:+y not null} ${z:+z not null} 6088 stdin: 6089 a A Aa 6090 b B Bb 6091 expected-stdout: 6092 1: 6093 2: 6094 --- 6095 name: regression-33 6096 description: 6097 Does umask print a leading 0 when umask is 3 digits? 6098 stdin: 6099 # on MiNT, the first umask call seems to fail 6100 umask 022 6101 # now, the test proper 6102 umask 222 6103 umask 6104 expected-stdout: 6105 0222 6106 --- 6107 name: regression-35 6108 description: 6109 Tempory files used for here-docs in functions get trashed after 6110 the function is parsed (before it is executed) 6111 stdin: 6112 f1() { 6113 cat <<- EOF 6114 F1 6115 EOF 6116 f2() { 6117 cat <<- EOF 6118 F2 6119 EOF 6120 } 6121 } 6122 f1 6123 f2 6124 unset -f f1 6125 f2 6126 expected-stdout: 6127 F1 6128 F2 6129 F2 6130 --- 6131 name: regression-36 6132 description: 6133 Command substitution breaks reading in while loop 6134 (test from <sjg (a] void.zen.oz.au>) 6135 stdin: 6136 (echo abcdef; echo; echo 123) | 6137 while read line 6138 do 6139 # the following line breaks it 6140 c=`echo $line | wc -c` 6141 echo $c 6142 done 6143 expected-stdout: 6144 7 6145 1 6146 4 6147 --- 6148 name: regression-37 6149 description: 6150 Machines with broken times() (reported by <sjg (a] void.zen.oz.au>) 6151 time does not report correct real time 6152 stdin: 6153 time sleep 1 6154 expected-stderr-pattern: !/^\s*0\.0[\s\d]+real|^\s*real[\s]+0+\.0/ 6155 --- 6156 name: regression-38 6157 description: 6158 set -e doesn't ignore exit codes for if/while/until/&&/||/!. 6159 arguments: !-e! 6160 stdin: 6161 if false; then echo hi ; fi 6162 false || true 6163 false && true 6164 while false; do echo hi; done 6165 echo ok 6166 expected-stdout: 6167 ok 6168 --- 6169 name: regression-39 6170 description: 6171 Only posh and oksh(2013-07) say hi below; FreeBSD sh, 6172 GNU bash in POSIX mode, dash, ksh93, mksh dont. All of 6173 them exit 0. The POSIX behaviour is needed by BSD make. 6174 stdin: 6175 set -e 6176 echo `false; echo hi` $(<this-file-does-not-exist) 6177 echo $? 6178 expected-stdout: 6179 6180 0 6181 expected-stderr-pattern: /this-file-does-not-exist/ 6182 --- 6183 name: regression-40 6184 description: 6185 This used to cause a core dump 6186 env-setup: !RANDOM=12! 6187 stdin: 6188 echo hi 6189 expected-stdout: 6190 hi 6191 --- 6192 name: regression-41 6193 description: 6194 foo should be set to bar (should not be empty) 6195 stdin: 6196 foo=` 6197 echo bar` 6198 echo "($foo)" 6199 expected-stdout: 6200 (bar) 6201 --- 6202 name: regression-42 6203 description: 6204 Can't use command line assignments to assign readonly parameters. 6205 stdin: 6206 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \ 6207 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \ 6208 done >env; chmod +x env; PATH=.$PATHSEP$PATH 6209 foo=bar 6210 readonly foo 6211 foo=stuff env | grep '^foo' 6212 expected-exit: e != 0 6213 expected-stderr-pattern: 6214 /read-only/ 6215 --- 6216 name: regression-43 6217 description: 6218 Can subshells be prefixed by redirections (historical shells allow 6219 this) 6220 stdin: 6221 < /dev/null (sed 's/^/X/') 6222 --- 6223 name: regression-45 6224 description: 6225 Parameter assignments with [] recognised correctly 6226 stdin: 6227 FOO=*[12] 6228 BAR=abc[ 6229 MORE=[abc] 6230 JUNK=a[bc 6231 echo "<$FOO>" 6232 echo "<$BAR>" 6233 echo "<$MORE>" 6234 echo "<$JUNK>" 6235 expected-stdout: 6236 <*[12]> 6237 <abc[> 6238 <[abc]> 6239 <a[bc> 6240 --- 6241 name: regression-46 6242 description: 6243 Check that alias expansion works in command substitutions and 6244 at the end of file. 6245 stdin: 6246 alias x='echo hi' 6247 FOO="`x` " 6248 echo "[$FOO]" 6249 x 6250 expected-stdout: 6251 [hi ] 6252 hi 6253 --- 6254 name: regression-47 6255 description: 6256 Check that aliases are fully read. 6257 stdin: 6258 alias x='echo hi; 6259 echo there' 6260 x 6261 echo done 6262 expected-stdout: 6263 hi 6264 there 6265 done 6266 --- 6267 name: regression-48 6268 description: 6269 Check that (here doc) temp files are not left behind after an exec. 6270 stdin: 6271 mkdir foo || exit 1 6272 TMPDIR=$PWD/foo "$__progname" <<- 'EOF' 6273 x() { 6274 sed 's/^/X /' << E_O_F 6275 hi 6276 there 6277 folks 6278 E_O_F 6279 echo "done ($?)" 6280 } 6281 echo=echo; [ -x /bin/echo ] && echo=/bin/echo 6282 exec $echo subtest-1 hi 6283 EOF 6284 echo subtest-1 foo/* 6285 TMPDIR=$PWD/foo "$__progname" <<- 'EOF' 6286 echo=echo; [ -x /bin/echo ] && echo=/bin/echo 6287 sed 's/^/X /' << E_O_F; exec $echo subtest-2 hi 6288 a 6289 few 6290 lines 6291 E_O_F 6292 EOF 6293 echo subtest-2 foo/* 6294 expected-stdout: 6295 subtest-1 hi 6296 subtest-1 foo/* 6297 X a 6298 X few 6299 X lines 6300 subtest-2 hi 6301 subtest-2 foo/* 6302 --- 6303 name: regression-49 6304 description: 6305 Check that unset params with attributes are reported by set, those 6306 sans attributes are not. 6307 stdin: 6308 unset FOO BAR 6309 echo X$FOO 6310 export BAR 6311 typeset -i BLAH 6312 set | grep FOO 6313 set | grep BAR 6314 set | grep BLAH 6315 expected-stdout: 6316 X 6317 BAR 6318 BLAH 6319 --- 6320 name: regression-50 6321 description: 6322 Check that aliases do not use continuation prompt after trailing 6323 semi-colon. 6324 file-setup: file 644 "envf" 6325 PS1=Y 6326 PS2=X 6327 env-setup: !ENV=./envf! 6328 need-ctty: yes 6329 arguments: !-i! 6330 stdin: 6331 alias foo='echo hi ; ' 6332 foo 6333 foo echo there 6334 expected-stdout: 6335 hi 6336 hi 6337 there 6338 expected-stderr: ! 6339 YYYY 6340 --- 6341 name: regression-51 6342 description: 6343 Check that set allows both +o and -o options on same command line. 6344 stdin: 6345 set a b c 6346 set -o noglob +o allexport 6347 echo A: $*, * 6348 expected-stdout: 6349 A: a b c, * 6350 --- 6351 name: regression-52 6352 description: 6353 Check that globbing works in pipelined commands 6354 file-setup: file 644 "envf" 6355 PS1=P 6356 file-setup: file 644 "abc" 6357 stuff 6358 env-setup: !ENV=./envf! 6359 need-ctty: yes 6360 arguments: !-i! 6361 stdin: 6362 sed 's/^/X /' < ab* 6363 echo mark 1 6364 sed 's/^/X /' < ab* | sed 's/^/Y /' 6365 echo mark 2 6366 expected-stdout: 6367 X stuff 6368 mark 1 6369 Y X stuff 6370 mark 2 6371 expected-stderr: ! 6372 PPPPP 6373 --- 6374 name: regression-53 6375 description: 6376 Check that getopts works in functions 6377 stdin: 6378 bfunc() { 6379 echo bfunc: enter "(args: $*; OPTIND=$OPTIND)" 6380 while getopts B oc; do 6381 case $oc in 6382 (B) 6383 echo bfunc: B option 6384 ;; 6385 (*) 6386 echo bfunc: odd option "($oc)" 6387 ;; 6388 esac 6389 done 6390 echo bfunc: leave 6391 } 6392 6393 function kfunc { 6394 echo kfunc: enter "(args: $*; OPTIND=$OPTIND)" 6395 while getopts K oc; do 6396 case $oc in 6397 (K) 6398 echo kfunc: K option 6399 ;; 6400 (*) 6401 echo bfunc: odd option "($oc)" 6402 ;; 6403 esac 6404 done 6405 echo kfunc: leave 6406 } 6407 6408 set -- -f -b -k -l 6409 echo "line 1: OPTIND=$OPTIND" 6410 getopts kbfl optc 6411 echo "line 2: ret=$?, optc=$optc, OPTIND=$OPTIND" 6412 bfunc -BBB blah 6413 echo "line 3: OPTIND=$OPTIND" 6414 getopts kbfl optc 6415 echo "line 4: ret=$?, optc=$optc, OPTIND=$OPTIND" 6416 kfunc -KKK blah 6417 echo "line 5: OPTIND=$OPTIND" 6418 getopts kbfl optc 6419 echo "line 6: ret=$?, optc=$optc, OPTIND=$OPTIND" 6420 echo 6421 6422 OPTIND=1 6423 set -- -fbkl 6424 echo "line 10: OPTIND=$OPTIND" 6425 getopts kbfl optc 6426 echo "line 20: ret=$?, optc=$optc, OPTIND=$OPTIND" 6427 bfunc -BBB blah 6428 echo "line 30: OPTIND=$OPTIND" 6429 getopts kbfl optc 6430 echo "line 40: ret=$?, optc=$optc, OPTIND=$OPTIND" 6431 kfunc -KKK blah 6432 echo "line 50: OPTIND=$OPTIND" 6433 getopts kbfl optc 6434 echo "line 60: ret=$?, optc=$optc, OPTIND=$OPTIND" 6435 expected-stdout: 6436 line 1: OPTIND=1 6437 line 2: ret=0, optc=f, OPTIND=2 6438 bfunc: enter (args: -BBB blah; OPTIND=2) 6439 bfunc: B option 6440 bfunc: B option 6441 bfunc: leave 6442 line 3: OPTIND=2 6443 line 4: ret=0, optc=b, OPTIND=3 6444 kfunc: enter (args: -KKK blah; OPTIND=1) 6445 kfunc: K option 6446 kfunc: K option 6447 kfunc: K option 6448 kfunc: leave 6449 line 5: OPTIND=3 6450 line 6: ret=0, optc=k, OPTIND=4 6451 6452 line 10: OPTIND=1 6453 line 20: ret=0, optc=f, OPTIND=2 6454 bfunc: enter (args: -BBB blah; OPTIND=2) 6455 bfunc: B option 6456 bfunc: B option 6457 bfunc: leave 6458 line 30: OPTIND=2 6459 line 40: ret=1, optc=?, OPTIND=2 6460 kfunc: enter (args: -KKK blah; OPTIND=1) 6461 kfunc: K option 6462 kfunc: K option 6463 kfunc: K option 6464 kfunc: leave 6465 line 50: OPTIND=2 6466 line 60: ret=1, optc=?, OPTIND=2 6467 --- 6468 name: regression-54 6469 description: 6470 Check that ; is not required before the then in if (( ... )) then ... 6471 stdin: 6472 if (( 1 )) then 6473 echo ok dparen 6474 fi 6475 if [[ -n 1 ]] then 6476 echo ok dbrackets 6477 fi 6478 expected-stdout: 6479 ok dparen 6480 ok dbrackets 6481 --- 6482 name: regression-55 6483 description: 6484 Check ${foo:%bar} is allowed (ksh88 allows it...) 6485 stdin: 6486 x=fooXbarXblah 6487 echo 1 ${x%X*} 6488 echo 2 ${x:%X*} 6489 echo 3 ${x%%X*} 6490 echo 4 ${x:%%X*} 6491 echo 5 ${x#*X} 6492 echo 6 ${x:#*X} 6493 echo 7 ${x##*X} 6494 echo 8 ${x:##*X} 6495 expected-stdout: 6496 1 fooXbar 6497 2 fooXbar 6498 3 foo 6499 4 foo 6500 5 barXblah 6501 6 barXblah 6502 7 blah 6503 8 blah 6504 --- 6505 name: regression-57 6506 description: 6507 Check if typeset output is correct for 6508 uninitialised array elements. 6509 stdin: 6510 typeset -i xxx[4] 6511 echo A 6512 typeset -i | grep xxx | sed 's/^/ /' 6513 echo B 6514 typeset | grep xxx | sed 's/^/ /' 6515 6516 xxx[1]=2+5 6517 echo M 6518 typeset -i | grep xxx | sed 's/^/ /' 6519 echo N 6520 typeset | grep xxx | sed 's/^/ /' 6521 expected-stdout: 6522 A 6523 xxx 6524 B 6525 typeset -i xxx 6526 M 6527 xxx[1]=7 6528 N 6529 set -A xxx 6530 typeset -i xxx[1] 6531 --- 6532 name: regression-58 6533 description: 6534 Check if trap exit is ok (exit not mistaken for signal name) 6535 stdin: 6536 trap 'echo hi' exit 6537 trap exit 1 6538 expected-stdout: 6539 hi 6540 --- 6541 name: regression-59 6542 description: 6543 Check if ${#array[*]} is calculated correctly. 6544 stdin: 6545 a[12]=hi 6546 a[8]=there 6547 echo ${#a[*]} 6548 expected-stdout: 6549 2 6550 --- 6551 name: regression-60 6552 description: 6553 Check if default exit status is previous command 6554 stdin: 6555 (true; exit) 6556 echo A $? 6557 (false; exit) 6558 echo B $? 6559 ( (exit 103) ; exit) 6560 echo C $? 6561 expected-stdout: 6562 A 0 6563 B 1 6564 C 103 6565 --- 6566 name: regression-61 6567 description: 6568 Check if EXIT trap is executed for sub shells. 6569 stdin: 6570 trap 'echo parent exit' EXIT 6571 echo start 6572 (echo A; echo A last) 6573 echo B 6574 (echo C; trap 'echo sub exit' EXIT; echo C last) 6575 echo parent last 6576 expected-stdout: 6577 start 6578 A 6579 A last 6580 B 6581 C 6582 C last 6583 sub exit 6584 parent last 6585 parent exit 6586 --- 6587 name: regression-62 6588 description: 6589 Check if test -nt/-ot succeeds if second(first) file is missing. 6590 stdin: 6591 :>a 6592 test a -nt b && echo nt OK || echo nt BAD 6593 test b -ot a && echo ot OK || echo ot BAD 6594 expected-stdout: 6595 nt OK 6596 ot OK 6597 --- 6598 name: regression-63 6599 description: 6600 Check if typeset, export, and readonly work 6601 stdin: 6602 { 6603 echo FNORD-0 6604 FNORD_A=1 6605 FNORD_B=2 6606 FNORD_C=3 6607 FNORD_D=4 6608 FNORD_E=5 6609 FNORD_F=6 6610 FNORD_G=7 6611 FNORD_H=8 6612 integer FNORD_E FNORD_F FNORD_G FNORD_H 6613 export FNORD_C FNORD_D FNORD_G FNORD_H 6614 readonly FNORD_B FNORD_D FNORD_F FNORD_H 6615 echo FNORD-1 6616 export 6617 echo FNORD-2 6618 export -p 6619 echo FNORD-3 6620 readonly 6621 echo FNORD-4 6622 readonly -p 6623 echo FNORD-5 6624 typeset 6625 echo FNORD-6 6626 typeset -p 6627 echo FNORD-7 6628 typeset - 6629 echo FNORD-8 6630 } | fgrep FNORD 6631 fnord=(42 23) 6632 typeset -p fnord 6633 echo FNORD-9 6634 expected-stdout: 6635 FNORD-0 6636 FNORD-1 6637 FNORD_C 6638 FNORD_D 6639 FNORD_G 6640 FNORD_H 6641 FNORD-2 6642 export FNORD_C=3 6643 export FNORD_D=4 6644 export FNORD_G=7 6645 export FNORD_H=8 6646 FNORD-3 6647 FNORD_B 6648 FNORD_D 6649 FNORD_F 6650 FNORD_H 6651 FNORD-4 6652 readonly FNORD_B=2 6653 readonly FNORD_D=4 6654 readonly FNORD_F=6 6655 readonly FNORD_H=8 6656 FNORD-5 6657 typeset FNORD_A 6658 typeset -r FNORD_B 6659 typeset -x FNORD_C 6660 typeset -x -r FNORD_D 6661 typeset -i FNORD_E 6662 typeset -i -r FNORD_F 6663 typeset -i -x FNORD_G 6664 typeset -i -x -r FNORD_H 6665 FNORD-6 6666 typeset FNORD_A=1 6667 typeset -r FNORD_B=2 6668 typeset -x FNORD_C=3 6669 typeset -x -r FNORD_D=4 6670 typeset -i FNORD_E=5 6671 typeset -i -r FNORD_F=6 6672 typeset -i -x FNORD_G=7 6673 typeset -i -x -r FNORD_H=8 6674 FNORD-7 6675 FNORD_A=1 6676 FNORD_B=2 6677 FNORD_C=3 6678 FNORD_D=4 6679 FNORD_E=5 6680 FNORD_F=6 6681 FNORD_G=7 6682 FNORD_H=8 6683 FNORD-8 6684 set -A fnord 6685 typeset fnord[0]=42 6686 typeset fnord[1]=23 6687 FNORD-9 6688 --- 6689 name: regression-64 6690 description: 6691 Check that we can redefine functions calling time builtin 6692 stdin: 6693 t() { 6694 time >/dev/null 6695 } 6696 t 2>/dev/null 6697 t() { 6698 time 6699 } 6700 --- 6701 name: regression-65 6702 description: 6703 check for a regression with sleep builtin and signal mask 6704 category: !nojsig 6705 time-limit: 5 6706 stdin: 6707 sleep 1 6708 echo blub |& 6709 while read -p line; do :; done 6710 echo ok 6711 expected-stdout: 6712 ok 6713 --- 6714 name: regression-66 6715 description: 6716 Check that quoting is sane 6717 category: !nojsig 6718 stdin: 6719 ac_space=' ' 6720 ac_newline=' 6721 ' 6722 set | grep ^ac_ |& 6723 set -A lines 6724 while IFS= read -pr line; do 6725 if [[ $line = *space* ]]; then 6726 lines[0]=$line 6727 else 6728 lines[1]=$line 6729 fi 6730 done 6731 for line in "${lines[@]}"; do 6732 print -r -- "$line" 6733 done 6734 expected-stdout: 6735 ac_space=' ' 6736 ac_newline=$'\n' 6737 --- 6738 name: regression-67 6739 description: 6740 Check that we can both break and use source on the same line 6741 stdin: 6742 for s in s; do break; done; print -s s 6743 --- 6744 name: regression-68 6745 description: 6746 Check that all common arithmetic operators work as expected 6747 stdin: 6748 echo 1 $(( a = 5 )) . 6749 echo 2 $(( ++a )) , $(( a++ )) , $(( a )) . 6750 echo 3 $(( --a )) , $(( a-- )) , $(( a )) . 6751 echo 4 $(( a == 5 )) , $(( a == 6 )) . 6752 echo 5 $(( a != 5 )) , $(( a != 6 )) . 6753 echo 6 $(( a *= 3 )) . 6754 echo 7 $(( a /= 5 )) . 6755 echo 8 $(( a %= 2 )) . 6756 echo 9 $(( a += 9 )) . 6757 echo 10 $(( a -= 4 )) . 6758 echo 11 $(( a <<= 1 )) . 6759 echo 12 $(( a >>= 1 )) . 6760 echo 13 $(( a &= 4 )) . 6761 echo 14 $(( a ^= a )) . 6762 echo 15 $(( a |= 5 )) . 6763 echo 16 $(( 5 << 1 )) . 6764 echo 17 $(( 5 >> 1 )) . 6765 echo 18 $(( 5 <= 6 )) , $(( 5 <= 5 )) , $(( 5 <= 4 )) . 6766 echo 19 $(( 5 >= 6 )) , $(( 5 >= 5 )) , $(( 5 >= 4 )) . 6767 echo 20 $(( 5 < 6 )) , $(( 5 < 5 )) , $(( 5 < 4 )) . 6768 echo 21 $(( 5 > 6 )) , $(( 5 > 5 )) , $(( 5 > 4 )) . 6769 echo 22 $(( 0 && 0 )) , $(( 0 && 1 )) , $(( 1 && 0 )) , $(( 1 && 1 )) . 6770 echo 23 $(( 0 || 0 )) , $(( 0 || 1 )) , $(( 1 || 0 )) , $(( 1 || 1 )) . 6771 echo 24 $(( 5 * 3 )) . 6772 echo 25 $(( 7 / 2 )) . 6773 echo 26 $(( 5 % 5 )) , $(( 5 % 4 )) , $(( 5 % 1 )) , $(( 5 % -1 )) , $(( 5 % -2 )) . 6774 echo 27 $(( 5 + 2 )) , $(( 5 + 0 )) , $(( 5 + -2 )) . 6775 echo 28 $(( 5 - 2 )) , $(( 5 - 0 )) , $(( 5 - -2 )) . 6776 echo 29 $(( 6 & 4 )) , $(( 6 & 8 )) . 6777 echo 30 $(( 4 ^ 2 )) , $(( 4 ^ 4 )) . 6778 echo 31 $(( 4 | 2 )) , $(( 4 | 4 )) , $(( 4 | 0 )) . 6779 echo 32 $(( 0 ? 1 : 2 )) , $(( 3 ? 4 : 5 )) . 6780 echo 33 $(( 5 , 2 , 3 )) . 6781 echo 34 $(( ~0 )) , $(( ~1 )) , $(( ~~1 )) , $(( ~~2 )) . 6782 echo 35 $(( !0 )) , $(( !1 )) , $(( !!1 )) , $(( !!2 )) . 6783 echo 36 $(( (5) )) . 6784 expected-stdout: 6785 1 5 . 6786 2 6 , 6 , 7 . 6787 3 6 , 6 , 5 . 6788 4 1 , 0 . 6789 5 0 , 1 . 6790 6 15 . 6791 7 3 . 6792 8 1 . 6793 9 10 . 6794 10 6 . 6795 11 12 . 6796 12 6 . 6797 13 4 . 6798 14 0 . 6799 15 5 . 6800 16 10 . 6801 17 2 . 6802 18 1 , 1 , 0 . 6803 19 0 , 1 , 1 . 6804 20 1 , 0 , 0 . 6805 21 0 , 0 , 1 . 6806 22 0 , 0 , 0 , 1 . 6807 23 0 , 1 , 1 , 1 . 6808 24 15 . 6809 25 3 . 6810 26 0 , 1 , 0 , 0 , 1 . 6811 27 7 , 5 , 3 . 6812 28 3 , 5 , 7 . 6813 29 4 , 0 . 6814 30 6 , 0 . 6815 31 6 , 4 , 4 . 6816 32 2 , 4 . 6817 33 3 . 6818 34 -1 , -2 , 1 , 2 . 6819 35 1 , 0 , 1 , 1 . 6820 36 5 . 6821 --- 6822 name: regression-69 6823 description: 6824 Check that all non-lksh arithmetic operators work as expected 6825 category: shell:legacy-no 6826 stdin: 6827 a=5 b=0x80000005 6828 echo 1 $(( a ^<= 1 )) , $(( b ^<= 1 )) . 6829 echo 2 $(( a ^>= 2 )) , $(( b ^>= 2 )) . 6830 echo 3 $(( 5 ^< 1 )) . 6831 echo 4 $(( 5 ^> 1 )) . 6832 expected-stdout: 6833 1 10 , 11 . 6834 2 -2147483646 , -1073741822 . 6835 3 10 . 6836 4 -2147483646 . 6837 --- 6838 name: readonly-0 6839 description: 6840 Ensure readonly is honoured for assignments and unset 6841 stdin: 6842 "$__progname" -c 'u=x; echo $? $u .' || echo aborted, $? 6843 echo = 6844 "$__progname" -c 'readonly u; u=x; echo $? $u .' || echo aborted, $? 6845 echo = 6846 "$__progname" -c 'u=x; readonly u; unset u; echo $? $u .' || echo aborted, $? 6847 expected-stdout: 6848 0 x . 6849 = 6850 aborted, 2 6851 = 6852 1 x . 6853 expected-stderr-pattern: 6854 /read-only/ 6855 --- 6856 name: readonly-1 6857 description: 6858 http://austingroupbugs.net/view.php?id=367 for export 6859 stdin: 6860 "$__progname" -c 'readonly foo; export foo=a; echo $?' || echo aborted, $? 6861 expected-stdout: 6862 aborted, 2 6863 expected-stderr-pattern: 6864 /read-only/ 6865 --- 6866 name: readonly-2a 6867 description: 6868 Check that getopts works as intended, for readonly-2b to be valid 6869 stdin: 6870 "$__progname" -c 'set -- -a b; getopts a c; echo $? $c .; getopts a c; echo $? $c .' || echo aborted, $? 6871 expected-stdout: 6872 0 a . 6873 1 ? . 6874 --- 6875 name: readonly-2b 6876 description: 6877 http://austingroupbugs.net/view.php?id=367 for getopts 6878 stdin: 6879 "$__progname" -c 'readonly c; set -- -a b; getopts a c; echo $? $c .' || echo aborted, $? 6880 expected-stdout: 6881 2 . 6882 expected-stderr-pattern: 6883 /read-only/ 6884 --- 6885 name: readonly-3 6886 description: 6887 http://austingroupbugs.net/view.php?id=367 for read 6888 stdin: 6889 echo x | "$__progname" -c 'read s; echo $? $s .' || echo aborted, $? 6890 echo y | "$__progname" -c 'readonly s; read s; echo $? $s .' || echo aborted, $? 6891 expected-stdout: 6892 0 x . 6893 2 . 6894 expected-stderr-pattern: 6895 /read-only/ 6896 --- 6897 name: readonly-4 6898 description: 6899 Do not permit bypassing readonly for first array item 6900 stdin: 6901 set -A arr -- foo bar 6902 readonly arr 6903 arr=baz 6904 print -r -- "${arr[@]}" 6905 expected-exit: e != 0 6906 expected-stderr-pattern: 6907 /read[ -]?only/ 6908 --- 6909 name: readonly-5 6910 description: 6911 Ensure readonly is idempotent 6912 stdin: 6913 readonly x=1 6914 readonly x 6915 --- 6916 name: syntax-1 6917 description: 6918 Check that lone ampersand is a syntax error 6919 stdin: 6920 & 6921 expected-exit: e != 0 6922 expected-stderr-pattern: 6923 /syntax error/ 6924 --- 6925 name: xxx-quoted-newline-1 6926 description: 6927 Check that \<newline> works inside of ${} 6928 stdin: 6929 abc=2 6930 echo ${ab\ 6931 c} 6932 expected-stdout: 6933 2 6934 --- 6935 name: xxx-quoted-newline-2 6936 description: 6937 Check that \<newline> works at the start of a here document 6938 stdin: 6939 cat << EO\ 6940 F 6941 hi 6942 EOF 6943 expected-stdout: 6944 hi 6945 --- 6946 name: xxx-quoted-newline-3 6947 description: 6948 Check that \<newline> works at the end of a here document 6949 stdin: 6950 cat << EOF 6951 hi 6952 EO\ 6953 F 6954 expected-stdout: 6955 hi 6956 --- 6957 name: xxx-multi-assignment-cmd 6958 description: 6959 Check that assignments in a command affect subsequent assignments 6960 in the same command 6961 stdin: 6962 FOO=abc 6963 FOO=123 BAR=$FOO 6964 echo $BAR 6965 expected-stdout: 6966 123 6967 --- 6968 name: xxx-multi-assignment-posix-cmd 6969 description: 6970 Check that the behaviour for multiple assignments with a 6971 command name matches POSIX. See: 6972 http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925 6973 stdin: 6974 X=a Y=b; X=$Y Y=$X "$__progname" -c 'echo 1 $X $Y .'; echo 2 $X $Y . 6975 unset X Y Z 6976 X=a Y=${X=b} Z=$X "$__progname" -c 'echo 3 $Z .' 6977 unset X Y Z 6978 X=a Y=${X=b} Z=$X; echo 4 $Z . 6979 expected-stdout: 6980 1 b a . 6981 2 a b . 6982 3 b . 6983 4 a . 6984 --- 6985 name: xxx-multi-assignment-posix-nocmd 6986 description: 6987 Check that the behaviour for multiple assignments with no 6988 command name matches POSIX (Debian #334182). See: 6989 http://thread.gmane.org/gmane.comp.standards.posix.austin.general/1925 6990 stdin: 6991 X=a Y=b; X=$Y Y=$X; echo 1 $X $Y . 6992 expected-stdout: 6993 1 b b . 6994 --- 6995 name: xxx-multi-assignment-posix-subassign 6996 description: 6997 Check that the behaviour for multiple assignments matches POSIX: 6998 - The assignment words shall be expanded in the current execution 6999 environment. 7000 - The assignments happen in the temporary execution environment. 7001 stdin: 7002 unset X Y Z 7003 Z=a Y=${X:=b} sh -c 'echo +$X+ +$Y+ +$Z+' 7004 echo /$X/ 7005 # Now for the special case: 7006 unset X Y Z 7007 X= Y=${X:=b} sh -c 'echo +$X+ +$Y+' 7008 echo /$X/ 7009 expected-stdout: 7010 ++ +b+ +a+ 7011 /b/ 7012 ++ +b+ 7013 /b/ 7014 --- 7015 name: xxx-exec-environment-1 7016 description: 7017 Check to see if exec sets it's environment correctly 7018 stdin: 7019 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \ 7020 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \ 7021 done >env; chmod +x env; PATH=.$PATHSEP$PATH 7022 FOO=bar exec env 7023 expected-stdout-pattern: 7024 /(^|.*\n)FOO=bar\n/ 7025 --- 7026 name: xxx-exec-environment-2 7027 description: 7028 Check to make sure exec doesn't change environment if a program 7029 isn't exec-ed 7030 stdin: 7031 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \ 7032 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \ 7033 done >env; chmod +x env; PATH=.$PATHSEP$PATH 7034 env >bar1 7035 FOO=bar exec; env >bar2 7036 cmp -s bar1 bar2 7037 --- 7038 name: exec-function-environment-1 7039 description: 7040 Check assignments in function calls and whether they affect 7041 the current execution environment (ksh93, SUSv4) 7042 stdin: 7043 f() { a=2; }; g() { b=3; echo y$c-; }; a=1 f; b=2; c=1 g 7044 echo x$a-$b- z$c- 7045 expected-stdout: 7046 y1- 7047 x2-3- z1- 7048 --- 7049 name: exec-modern-korn-shell 7050 description: 7051 Check that exec can execute any command that makes it 7052 through syntax and parser 7053 stdin: 7054 print '#!'"$__progname"'\necho tf' >lq 7055 chmod +x lq 7056 PATH=$PWD 7057 exec 2>&1 7058 foo() { print two; } 7059 print =1 7060 (exec print one) 7061 print =2 7062 (exec foo) 7063 print =3 7064 (exec ls) 7065 print =4 7066 (exec lq) 7067 expected-stdout-pattern: 7068 /=1\none\n=2\ntwo\n=3\n.*: ls: not found\n=4\ntf\n/ 7069 --- 7070 name: exec-ksh88 7071 description: 7072 Check that exec only executes after a PATH search 7073 arguments: !-o!posix! 7074 stdin: 7075 print '#!'"$__progname"'\necho tf' >lq 7076 chmod +x lq 7077 PATH=$PWD 7078 exec 2>&1 7079 foo() { print two; } 7080 print =1 7081 (exec print one) 7082 print =2 7083 (exec foo) 7084 print =3 7085 (exec ls) 7086 print =4 7087 (exec lq) 7088 expected-stdout-pattern: 7089 /=1\n.*: print: not found\n=2\n.*: foo: not found\n=3\n.*: ls: not found\n=4\ntf\n/ 7090 --- 7091 name: xxx-what-do-you-call-this-1 7092 stdin: 7093 echo "${foo:-"a"}*" 7094 expected-stdout: 7095 a* 7096 --- 7097 name: xxx-prefix-strip-1 7098 stdin: 7099 foo='a cdef' 7100 echo ${foo#a c} 7101 expected-stdout: 7102 def 7103 --- 7104 name: xxx-prefix-strip-2 7105 stdin: 7106 set a c 7107 x='a cdef' 7108 echo ${x#$*} 7109 expected-stdout: 7110 def 7111 --- 7112 name: xxx-variable-syntax-1 7113 stdin: 7114 echo ${:} 7115 expected-stderr-pattern: 7116 /bad substitution/ 7117 expected-exit: 1 7118 --- 7119 name: xxx-variable-syntax-2 7120 stdin: 7121 set 0 7122 echo ${*:0} 7123 expected-stderr-pattern: 7124 /bad substitution/ 7125 expected-exit: 1 7126 --- 7127 name: xxx-variable-syntax-3 7128 stdin: 7129 set -A foo 0 7130 echo ${foo[*]:0} 7131 expected-stderr-pattern: 7132 /bad substitution/ 7133 expected-exit: 1 7134 --- 7135 name: xxx-variable-syntax-4 7136 description: 7137 Not all kinds of trims are currently impossible, check those who do 7138 stdin: 7139 foo() { 7140 echo "<$*> X${*:+ }X" 7141 } 7142 foo a b 7143 foo "" c 7144 foo "" 7145 foo "" "" 7146 IFS=: 7147 foo a b 7148 foo "" c 7149 foo "" 7150 foo "" "" 7151 IFS= 7152 foo a b 7153 foo "" c 7154 foo "" 7155 foo "" "" 7156 expected-stdout: 7157 <a b> X X 7158 < c> X X 7159 <> XX 7160 < > X X 7161 <a:b> X X 7162 <:c> X X 7163 <> XX 7164 <:> X X 7165 <ab> X X 7166 <c> X X 7167 <> XX 7168 <> XX 7169 --- 7170 name: xxx-substitution-eval-order 7171 description: 7172 Check order of evaluation of expressions 7173 stdin: 7174 i=1 x= y= 7175 set -A A abc def GHI j G k 7176 echo ${A[x=(i+=1)]#${A[y=(i+=2)]}} 7177 echo $x $y 7178 expected-stdout: 7179 HI 7180 2 4 7181 --- 7182 name: xxx-set-option-1 7183 description: 7184 Check option parsing in set 7185 stdin: 7186 set -vsA foo -- A 1 3 2 7187 echo ${foo[*]} 7188 expected-stderr: 7189 echo ${foo[*]} 7190 expected-stdout: 7191 1 2 3 A 7192 --- 7193 name: xxx-exec-1 7194 description: 7195 Check that exec exits for built-ins 7196 need-ctty: yes 7197 arguments: !-i! 7198 stdin: 7199 exec echo hi 7200 echo still herre 7201 expected-stdout: 7202 hi 7203 expected-stderr-pattern: /.*/ 7204 --- 7205 name: xxx-while-1 7206 description: 7207 Check the return value of while loops 7208 XXX need to do same for for/select/until loops 7209 stdin: 7210 i=x 7211 while [ $i != xxx ] ; do 7212 i=x$i 7213 if [ $i = xxx ] ; then 7214 false 7215 continue 7216 fi 7217 done 7218 echo loop1=$? 7219 7220 i=x 7221 while [ $i != xxx ] ; do 7222 i=x$i 7223 if [ $i = xxx ] ; then 7224 false 7225 break 7226 fi 7227 done 7228 echo loop2=$? 7229 7230 i=x 7231 while [ $i != xxx ] ; do 7232 i=x$i 7233 false 7234 done 7235 echo loop3=$? 7236 expected-stdout: 7237 loop1=0 7238 loop2=0 7239 loop3=1 7240 --- 7241 name: xxx-status-1 7242 description: 7243 Check that blank lines don't clear $? 7244 need-ctty: yes 7245 arguments: !-i! 7246 stdin: 7247 (exit 1) 7248 echo $? 7249 (exit 1) 7250 7251 echo $? 7252 true 7253 expected-stdout: 7254 1 7255 1 7256 expected-stderr-pattern: /.*/ 7257 --- 7258 name: xxx-status-2 7259 description: 7260 Check that $? is preserved in subshells, includes, traps. 7261 stdin: 7262 (exit 1) 7263 7264 echo blank: $? 7265 7266 (exit 2) 7267 (echo subshell: $?) 7268 7269 echo 'echo include: $?' > foo 7270 (exit 3) 7271 . ./foo 7272 7273 trap 'echo trap: $?' ERR 7274 (exit 4) 7275 echo exit: $? 7276 expected-stdout: 7277 blank: 1 7278 subshell: 2 7279 include: 3 7280 trap: 4 7281 exit: 4 7282 --- 7283 name: xxx-clean-chars-1 7284 description: 7285 Check MAGIC character is stuffed correctly 7286 stdin: 7287 echo `echo [` 7288 expected-stdout: 7289 [ 7290 --- 7291 name: xxx-param-subst-qmark-1 7292 description: 7293 Check suppresion of error message with null string. According to 7294 POSIX, it shouldn't print the error as 'word' isn't ommitted. 7295 ksh88/93, Solaris /bin/sh and /usr/xpg4/bin/sh all print the error. 7296 stdin: 7297 unset foo 7298 x= 7299 echo x${foo?$x} 7300 expected-exit: 1 7301 expected-stderr-pattern: !/not set/ 7302 --- 7303 name: xxx-param-subst-qmark-namespec 7304 description: 7305 Check special names are output correctly 7306 stdin: 7307 doit() { 7308 "$__progname" -c "$@" >o1 2>o2 7309 rv=$? 7310 echo RETVAL: $rv 7311 sed -e "s^${__progname%.exe}\.*e*x*e*: PROG: " -e 's/^/STDOUT: /g' <o1 7312 sed -e "s^${__progname%.exe}\.*e*x*e*: PROG: " -e 's/^/STDERR: /g' <o2 7313 } 7314 doit 'echo ${1x}' 7315 doit 'echo "${1x}"' 7316 doit 'echo ${1?}' 7317 doit 'echo ${19?}' 7318 doit 'echo ${!:?}' 7319 doit -u 'echo ${*:?}' foo "" 7320 expected-stdout: 7321 RETVAL: 1 7322 STDERR: PROG: ${1x}: bad substitution 7323 RETVAL: 1 7324 STDERR: PROG: ${1x}: bad substitution 7325 RETVAL: 1 7326 STDERR: PROG: 1: parameter null or not set 7327 RETVAL: 1 7328 STDERR: PROG: 19: parameter null or not set 7329 RETVAL: 1 7330 STDERR: PROG: !: parameter null or not set 7331 RETVAL: 1 7332 STDERR: foo: ${*:?}: bad substitution 7333 --- 7334 name: xxx-param-_-1 7335 # fails due to weirdness of execv stuff 7336 category: !os:uwin-nt 7337 description: 7338 Check c flag is set. 7339 arguments: !-c!echo "[$-]"! 7340 expected-stdout-pattern: /^\[.*c.*\]$/ 7341 --- 7342 name: tilde-expand-1 7343 description: 7344 Check tilde expansion after equal signs 7345 env-setup: !HOME=/sweet! 7346 stdin: 7347 echo ${A=a=}~ b=~ c=d~ ~ 7348 export e=~ f=d~ 7349 command command export g=~ h=d~ 7350 echo ". $e . $f ." 7351 echo ". $g . $h ." 7352 set -o posix 7353 unset A e f g h 7354 echo ${A=a=}~ b=~ c=d~ ~ 7355 export e=~ f=d~ 7356 command command export g=~ h=d~ 7357 echo ". $e . $f ." 7358 echo ". $g . $h ." 7359 expected-stdout: 7360 a=/sweet b=/sweet c=d~ /sweet 7361 . /sweet . d~ . 7362 . /sweet . d~ . 7363 a=~ b=~ c=d~ /sweet 7364 . /sweet . d~ . 7365 . /sweet . d~ . 7366 --- 7367 name: tilde-expand-2 7368 description: 7369 Check tilde expansion works 7370 env-setup: !HOME=/sweet! 7371 stdin: 7372 :>'c=a' 7373 typeset c=[ab] 7374 :>'d=a' 7375 x=typeset; $x d=[ab] 7376 echo "<$c>" "<$d>" 7377 wd=$PWD 7378 cd / 7379 plus=$(print -r -- ~+) 7380 minus=$(print -r -- ~-) 7381 nix=$(print -r -- ~) 7382 [[ $plus = / ]]; echo one $? . 7383 [[ $minus = "$wd" ]]; echo two $? . 7384 [[ $nix = /sweet ]]; echo nix $? . 7385 expected-stdout: 7386 <[ab]> <a> 7387 one 0 . 7388 two 0 . 7389 nix 0 . 7390 --- 7391 name: tilde-expand-3 7392 description: 7393 Check mostly Austin 351 stuff 7394 stdin: 7395 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } 7396 set "1 b=2" "3 d=4" 7397 export a=$1 \c=$2 7398 showargs 1 "$a" "$b" "$c" "$d" 7399 unset a b c d 7400 HOME=/tmp 7401 export \a=~ b=~ 7402 command export c=~ 7403 builtin export d=~ 7404 \\builtin export e=~ 7405 showargs 2 "$a" "$b" "$c" "$d" "$e" ksh 7406 unset a b c d e 7407 set -o posix 7408 export \a=~ b=~ 7409 command export c=~ 7410 builtin export d=~ 7411 \\builtin export e=~ 7412 showargs 3 "$a" "$b" "$c" "$d" "$e" posix 7413 unset a b c d e 7414 set +o posix 7415 export a=$1 7416 showargs 4 "$a" "$b" ksh 7417 unset a b 7418 showargs 5 a=$1 ksh 7419 export \a=$1 7420 showargs 6 "$a" "$b" ksh 7421 unset a b 7422 set -o posix 7423 export a=$1 7424 showargs 7 "$a" "$b" posix 7425 unset a b 7426 showargs 8 a=$1 posix 7427 export \a=$1 7428 showargs 9 "$a" "$b" posix 7429 unset a b 7430 set +o posix 7431 command echo 10 ksh a=~ 7432 command command export a=~ 7433 showargs 11 "$a" 7434 unset a 7435 set -o posix 7436 command echo 12 posix a=~ 7437 command command export a=~ 7438 showargs 13 "$a" 7439 unset a 7440 # unspecified whether /tmp or ~ 7441 var=export; command $var a=~ 7442 showargs 14 "$a" 7443 echo 'echo "<$foo>"' >bar 7444 "$__progname" bar 7445 var=foo 7446 export $var=1 7447 "$__progname" bar 7448 export $var=~ 7449 "$__progname" bar 7450 # unspecified 7451 command -- export a=~ 7452 showargs 18 "$a" 7453 set -A bla 7454 typeset bla[1]=~:~ 7455 global gbl=~ g2=$1 7456 local lcl=~ l2=$1 7457 readonly ro=~ r2=$1 7458 showargs 19 "${bla[1]}" a=~ "$gbl" "$lcl" "$ro" "$g2" "$l2" "$r2" 7459 set +o posix 7460 echo "20 some arbitrary stuff "=~ 7461 set -o posix 7462 echo "21 some arbitrary stuff "=~ 7463 expected-stdout: 7464 <1> <1 b=2> <> <3> <4> . 7465 <2> </tmp> </tmp> </tmp> </tmp> </tmp> <ksh> . 7466 <3> <~> </tmp> </tmp> <~> </tmp> <posix> . 7467 <4> <1 b=2> <> <ksh> . 7468 <5> <a=1> <b=2> <ksh> . 7469 <6> <1> <2> <ksh> . 7470 <7> <1 b=2> <> <posix> . 7471 <8> <a=1> <b=2> <posix> . 7472 <9> <1> <2> <posix> . 7473 10 ksh a=/tmp 7474 <11> </tmp> . 7475 12 posix a=~ 7476 <13> </tmp> . 7477 <14> <~> . 7478 <> 7479 <1> 7480 <~> 7481 <18> <~> . 7482 <19> </tmp:/tmp> <a=~> </tmp> </tmp> </tmp> <1 b=2> <1 b=2> <1 b=2> . 7483 20 some arbitrary stuff =/tmp 7484 21 some arbitrary stuff =~ 7485 --- 7486 name: exit-err-1 7487 description: 7488 Check some "exit on error" conditions 7489 stdin: 7490 print '#!'"$__progname"'\nexec "$1"' >env 7491 print '#!'"$__progname"'\nexit 1' >false 7492 chmod +x env false 7493 PATH=.$PATHSEP$PATH 7494 set -ex 7495 env false && echo something 7496 echo END 7497 expected-stdout: 7498 END 7499 expected-stderr: 7500 + env false 7501 + echo END 7502 --- 7503 name: exit-err-2 7504 description: 7505 Check some "exit on error" edge conditions (POSIXly) 7506 stdin: 7507 print '#!'"$__progname"'\nexec "$1"' >env 7508 print '#!'"$__progname"'\nexit 1' >false 7509 print '#!'"$__progname"'\nexit 0' >true 7510 chmod +x env false 7511 PATH=.$PATHSEP$PATH 7512 set -ex 7513 if env true; then 7514 env false && echo something 7515 fi 7516 echo END 7517 expected-stdout: 7518 END 7519 expected-stderr: 7520 + env true 7521 + env false 7522 + echo END 7523 --- 7524 name: exit-err-3 7525 description: 7526 pdksh regression which AT&T ksh does right 7527 TFM says: [set] -e | errexit 7528 Exit (after executing the ERR trap) ... 7529 stdin: 7530 trap 'echo EXIT' EXIT 7531 trap 'echo ERR' ERR 7532 set -e 7533 cd /XXXXX 2>/dev/null 7534 echo DONE 7535 exit 0 7536 expected-stdout: 7537 ERR 7538 EXIT 7539 expected-exit: e != 0 7540 --- 7541 name: exit-err-4 7542 description: 7543 "set -e" test suite (POSIX) 7544 stdin: 7545 set -e 7546 echo pre 7547 if true ; then 7548 false && echo foo 7549 fi 7550 echo bar 7551 expected-stdout: 7552 pre 7553 bar 7554 --- 7555 name: exit-err-5 7556 description: 7557 "set -e" test suite (POSIX) 7558 stdin: 7559 set -e 7560 foo() { 7561 while [ "$1" ]; do 7562 for E in $x; do 7563 [ "$1" = "$E" ] && { shift ; continue 2 ; } 7564 done 7565 x="$x $1" 7566 shift 7567 done 7568 echo $x 7569 } 7570 echo pre 7571 foo a b b c 7572 echo post 7573 expected-stdout: 7574 pre 7575 a b c 7576 post 7577 --- 7578 name: exit-err-6 7579 description: 7580 "set -e" test suite (BSD make) 7581 category: os:mirbsd 7582 stdin: 7583 mkdir zd zd/a zd/b 7584 print 'all:\n\t@echo eins\n\t@exit 42\n' >zd/a/Makefile 7585 print 'all:\n\t@echo zwei\n' >zd/b/Makefile 7586 wd=$(pwd) 7587 set -e 7588 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" 7589 expected-stdout: 7590 ===> a 7591 eins 7592 *** Error code 42 7593 7594 Stop in WD/zd/a (line 2 of Makefile). 7595 --- 7596 name: exit-err-7 7597 description: 7598 "set -e" regression (LP#1104543) 7599 stdin: 7600 set -e 7601 bla() { 7602 [ -x $PWD/nonexistant ] && $PWD/nonexistant 7603 } 7604 echo x 7605 bla 7606 echo y$? 7607 expected-stdout: 7608 x 7609 expected-exit: 1 7610 --- 7611 name: exit-err-8 7612 description: 7613 "set -e" regression (Debian #700526) 7614 stdin: 7615 set -e 7616 _db_cmd() { return $1; } 7617 db_input() { _db_cmd 30; } 7618 db_go() { _db_cmd 0; } 7619 db_input || : 7620 db_go 7621 exit 0 7622 --- 7623 name: exit-err-9 7624 description: 7625 "set -e" versus bang pipelines 7626 stdin: 7627 set -e 7628 ! false | false 7629 echo 1 ok 7630 ! false && false 7631 echo 2 wrong 7632 expected-stdout: 7633 1 ok 7634 expected-exit: 1 7635 --- 7636 name: exit-enoent-1 7637 description: 7638 SUSv4 says that the shell should exit with 126/127 in some situations 7639 stdin: 7640 i=0 7641 (echo; echo :) >x 7642 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r . 7643 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r . 7644 echo exit 42 >x 7645 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r . 7646 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r . 7647 rm -f x 7648 "$__progname" ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r . 7649 "$__progname" -c ./x >/dev/null 2>&1; r=$?; echo $((i++)) $r . 7650 expected-stdout: 7651 0 0 . 7652 1 126 . 7653 2 42 . 7654 3 126 . 7655 4 127 . 7656 5 127 . 7657 --- 7658 name: exit-eval-1 7659 description: 7660 Check eval vs substitution exit codes (ksh93 alike) 7661 stdin: 7662 (exit 12) 7663 eval $(false) 7664 echo A $? 7665 (exit 12) 7666 eval ' $(false)' 7667 echo B $? 7668 (exit 12) 7669 eval " $(false)" 7670 echo C $? 7671 (exit 12) 7672 eval "eval $(false)" 7673 echo D $? 7674 (exit 12) 7675 eval 'eval '"$(false)" 7676 echo E $? 7677 IFS="$IFS:" 7678 (exit 12) 7679 eval $(echo :; false) 7680 echo F $? 7681 echo -n "G " 7682 (exit 12) 7683 eval 'echo $?' 7684 echo H $? 7685 expected-stdout: 7686 A 0 7687 B 1 7688 C 0 7689 D 0 7690 E 0 7691 F 0 7692 G 12 7693 H 0 7694 --- 7695 name: exit-trap-1 7696 description: 7697 Check that "exit" with no arguments behaves SUSv4 conformant. 7698 stdin: 7699 trap 'echo hi; exit' EXIT 7700 exit 9 7701 expected-stdout: 7702 hi 7703 expected-exit: 9 7704 --- 7705 name: exit-trap-2 7706 description: 7707 Check that ERR and EXIT traps are run just like ksh93 does. 7708 GNU bash does not run ERtrap in e eval-undef but runs it 7709 twice (bug?) in +e eval-false, so does ksh93 (bug?), which 7710 also has a bug to continue execution (echoing "and out" and 7711 returning 0) in +e eval-undef. 7712 file-setup: file 644 "x" 7713 v=; unset v 7714 trap 'echo EXtrap' EXIT 7715 trap 'echo ERtrap' ERR 7716 set $1 7717 echo "and run $2" 7718 eval $2 7719 echo and out 7720 file-setup: file 644 "xt" 7721 v=; unset v 7722 trap 'echo EXtrap' EXIT 7723 trap 'echo ERtrap' ERR 7724 set $1 7725 echo 'and run true' 7726 true 7727 echo and out 7728 file-setup: file 644 "xf" 7729 v=; unset v 7730 trap 'echo EXtrap' EXIT 7731 trap 'echo ERtrap' ERR 7732 set $1 7733 echo 'and run false' 7734 false 7735 echo and out 7736 file-setup: file 644 "xu" 7737 v=; unset v 7738 trap 'echo EXtrap' EXIT 7739 trap 'echo ERtrap' ERR 7740 set $1 7741 echo 'and run ${v?}' 7742 ${v?} 7743 echo and out 7744 stdin: 7745 runtest() { 7746 rm -f rc 7747 ( 7748 "$__progname" "$@" 7749 echo $? >rc 7750 ) 2>&1 | sed \ 7751 -e 's/parameter not set/parameter null or not set/' \ 7752 -e 's/[[]6]//' -e 's/: eval: line 1//' -e 's/: line 6//' \ 7753 -e "s^${__progname%.exe}\.*e*x*e*: <stdin>\[[0-9]*]PROG" 7754 } 7755 xe=-e 7756 echo : $xe 7757 runtest x $xe true 7758 echo = eval-true $(<rc) . 7759 runtest x $xe false 7760 echo = eval-false $(<rc) . 7761 runtest x $xe '${v?}' 7762 echo = eval-undef $(<rc) . 7763 runtest xt $xe 7764 echo = noeval-true $(<rc) . 7765 runtest xf $xe 7766 echo = noeval-false $(<rc) . 7767 runtest xu $xe 7768 echo = noeval-undef $(<rc) . 7769 xe=+e 7770 echo : $xe 7771 runtest x $xe true 7772 echo = eval-true $(<rc) . 7773 runtest x $xe false 7774 echo = eval-false $(<rc) . 7775 runtest x $xe '${v?}' 7776 echo = eval-undef $(<rc) . 7777 runtest xt $xe 7778 echo = noeval-true $(<rc) . 7779 runtest xf $xe 7780 echo = noeval-false $(<rc) . 7781 runtest xu $xe 7782 echo = noeval-undef $(<rc) . 7783 expected-stdout: 7784 : -e 7785 and run true 7786 and out 7787 EXtrap 7788 = eval-true 0 . 7789 and run false 7790 ERtrap 7791 EXtrap 7792 = eval-false 1 . 7793 and run ${v?} 7794 x: v: parameter null or not set 7795 ERtrap 7796 EXtrap 7797 = eval-undef 1 . 7798 and run true 7799 and out 7800 EXtrap 7801 = noeval-true 0 . 7802 and run false 7803 ERtrap 7804 EXtrap 7805 = noeval-false 1 . 7806 and run ${v?} 7807 xu: v: parameter null or not set 7808 EXtrap 7809 = noeval-undef 1 . 7810 : +e 7811 and run true 7812 and out 7813 EXtrap 7814 = eval-true 0 . 7815 and run false 7816 ERtrap 7817 and out 7818 EXtrap 7819 = eval-false 0 . 7820 and run ${v?} 7821 x: v: parameter null or not set 7822 ERtrap 7823 EXtrap 7824 = eval-undef 1 . 7825 and run true 7826 and out 7827 EXtrap 7828 = noeval-true 0 . 7829 and run false 7830 ERtrap 7831 and out 7832 EXtrap 7833 = noeval-false 0 . 7834 and run ${v?} 7835 xu: v: parameter null or not set 7836 EXtrap 7837 = noeval-undef 1 . 7838 --- 7839 name: exit-trap-interactive 7840 description: 7841 Check that interactive shell doesn't exit via EXIT trap on syntax error 7842 arguments: !-i! 7843 stdin: 7844 trap -- EXIT 7845 echo Syntax error < 7846 echo 'After error 1' 7847 trap 'echo Exit trap' EXIT 7848 echo Syntax error < 7849 echo 'After error 2' 7850 trap 'echo Exit trap' EXIT 7851 exit 7852 echo 'After exit' 7853 expected-stdout: 7854 After error 1 7855 After error 2 7856 Exit trap 7857 expected-stderr-pattern: 7858 /syntax error: unexpected 'newline'/ 7859 --- 7860 name: test-stlt-1 7861 description: 7862 Check that test also can handle string1 < string2 etc. 7863 stdin: 7864 test 2005/10/08 '<' 2005/08/21 && echo ja || echo nein 7865 test 2005/08/21 \< 2005/10/08 && echo ja || echo nein 7866 test 2005/10/08 '>' 2005/08/21 && echo ja || echo nein 7867 test 2005/08/21 \> 2005/10/08 && echo ja || echo nein 7868 expected-stdout: 7869 nein 7870 ja 7871 ja 7872 nein 7873 expected-stderr-pattern: !/unexpected op/ 7874 --- 7875 name: test-precedence-1 7876 description: 7877 Check a weird precedence case (and POSIX echo) 7878 stdin: 7879 test \( -f = -f \) 7880 rv=$? 7881 echo $rv 7882 expected-stdout: 7883 0 7884 --- 7885 name: test-option-1 7886 description: 7887 Test the test -o operator 7888 stdin: 7889 runtest() { 7890 test -o $1; echo $? 7891 [ -o $1 ]; echo $? 7892 [[ -o $1 ]]; echo $? 7893 } 7894 if_test() { 7895 test -o $1 -o -o !$1; echo $? 7896 [ -o $1 -o -o !$1 ]; echo $? 7897 [[ -o $1 || -o !$1 ]]; echo $? 7898 test -o ?$1; echo $? 7899 } 7900 echo 0y $(if_test utf8-mode) = 7901 echo 0n $(if_test utf8-hack) = 7902 echo 1= $(runtest utf8-hack) = 7903 echo 2= $(runtest !utf8-hack) = 7904 echo 3= $(runtest ?utf8-hack) = 7905 set +U 7906 echo 1+ $(runtest utf8-mode) = 7907 echo 2+ $(runtest !utf8-mode) = 7908 echo 3+ $(runtest ?utf8-mode) = 7909 set -U 7910 echo 1- $(runtest utf8-mode) = 7911 echo 2- $(runtest !utf8-mode) = 7912 echo 3- $(runtest ?utf8-mode) = 7913 echo = short flags = 7914 echo 0y $(if_test -U) = 7915 echo 0y $(if_test +U) = 7916 echo 0n $(if_test -_) = 7917 echo 0n $(if_test -U-) = 7918 echo 1= $(runtest -_) = 7919 echo 2= $(runtest !-_) = 7920 echo 3= $(runtest ?-_) = 7921 set +U 7922 echo 1+ $(runtest -U) = 7923 echo 2+ $(runtest !-U) = 7924 echo 3+ $(runtest ?-U) = 7925 echo 1+ $(runtest +U) = 7926 echo 2+ $(runtest !+U) = 7927 echo 3+ $(runtest ?+U) = 7928 set -U 7929 echo 1- $(runtest -U) = 7930 echo 2- $(runtest !-U) = 7931 echo 3- $(runtest ?-U) = 7932 echo 1- $(runtest +U) = 7933 echo 2- $(runtest !+U) = 7934 echo 3- $(runtest ?+U) = 7935 expected-stdout: 7936 0y 0 0 0 0 = 7937 0n 1 1 1 1 = 7938 1= 1 1 1 = 7939 2= 1 1 1 = 7940 3= 1 1 1 = 7941 1+ 1 1 1 = 7942 2+ 0 0 0 = 7943 3+ 0 0 0 = 7944 1- 0 0 0 = 7945 2- 1 1 1 = 7946 3- 0 0 0 = 7947 = short flags = 7948 0y 0 0 0 0 = 7949 0y 0 0 0 0 = 7950 0n 1 1 1 1 = 7951 0n 1 1 1 1 = 7952 1= 1 1 1 = 7953 2= 1 1 1 = 7954 3= 1 1 1 = 7955 1+ 1 1 1 = 7956 2+ 0 0 0 = 7957 3+ 0 0 0 = 7958 1+ 1 1 1 = 7959 2+ 0 0 0 = 7960 3+ 0 0 0 = 7961 1- 0 0 0 = 7962 2- 1 1 1 = 7963 3- 0 0 0 = 7964 1- 0 0 0 = 7965 2- 1 1 1 = 7966 3- 0 0 0 = 7967 --- 7968 name: test-varset-1 7969 description: 7970 Test the test -v operator 7971 stdin: 7972 [[ -v a ]] 7973 rv=$?; echo $((++i)) $rv 7974 a= 7975 [[ -v a ]] 7976 rv=$?; echo $((++i)) $rv 7977 unset a 7978 [[ -v a ]] 7979 rv=$?; echo $((++i)) $rv 7980 a=x 7981 [[ -v a ]] 7982 rv=$?; echo $((++i)) $rv 7983 nameref b=a 7984 [[ -v b ]] 7985 rv=$?; echo $((++i)) $rv 7986 unset a 7987 [[ -v b ]] 7988 rv=$?; echo $((++i)) $rv 7989 x[1]=y 7990 [[ -v x ]] 7991 rv=$?; echo $((++i)) $rv 7992 [[ -v x[0] ]] 7993 rv=$?; echo $((++i)) $rv 7994 [[ -v x[1] ]] 7995 rv=$?; echo $((++i)) $rv 7996 [[ -v x[2] ]] 7997 rv=$?; echo $((++i)) $rv 7998 expected-stdout: 7999 1 1 8000 2 0 8001 3 1 8002 4 0 8003 5 0 8004 6 1 8005 7 1 8006 8 1 8007 9 0 8008 10 1 8009 --- 8010 name: test-varset-2 8011 description: 8012 test -v works only on scalars 8013 stdin: 8014 [[ -v x[*] ]] 8015 echo ok 8016 expected-exit: e != 0 8017 expected-stderr-pattern: 8018 /unexpected '\*'/ 8019 --- 8020 name: test-stnze-1 8021 description: 8022 Check that the short form [ $x ] works 8023 stdin: 8024 i=0 8025 [ -n $x ] 8026 rv=$?; echo $((++i)) $rv 8027 [ $x ] 8028 rv=$?; echo $((++i)) $rv 8029 [ -n "$x" ] 8030 rv=$?; echo $((++i)) $rv 8031 [ "$x" ] 8032 rv=$?; echo $((++i)) $rv 8033 x=0 8034 [ -n $x ] 8035 rv=$?; echo $((++i)) $rv 8036 [ $x ] 8037 rv=$?; echo $((++i)) $rv 8038 [ -n "$x" ] 8039 rv=$?; echo $((++i)) $rv 8040 [ "$x" ] 8041 rv=$?; echo $((++i)) $rv 8042 x='1 -a 1 = 2' 8043 [ -n $x ] 8044 rv=$?; echo $((++i)) $rv 8045 [ $x ] 8046 rv=$?; echo $((++i)) $rv 8047 [ -n "$x" ] 8048 rv=$?; echo $((++i)) $rv 8049 [ "$x" ] 8050 rv=$?; echo $((++i)) $rv 8051 expected-stdout: 8052 1 0 8053 2 1 8054 3 1 8055 4 1 8056 5 0 8057 6 0 8058 7 0 8059 8 0 8060 9 1 8061 10 1 8062 11 0 8063 12 0 8064 --- 8065 name: test-stnze-2 8066 description: 8067 Check that the short form [[ $x ]] works (ksh93 extension) 8068 stdin: 8069 i=0 8070 [[ -n $x ]] 8071 rv=$?; echo $((++i)) $rv 8072 [[ $x ]] 8073 rv=$?; echo $((++i)) $rv 8074 [[ -n "$x" ]] 8075 rv=$?; echo $((++i)) $rv 8076 [[ "$x" ]] 8077 rv=$?; echo $((++i)) $rv 8078 x=0 8079 [[ -n $x ]] 8080 rv=$?; echo $((++i)) $rv 8081 [[ $x ]] 8082 rv=$?; echo $((++i)) $rv 8083 [[ -n "$x" ]] 8084 rv=$?; echo $((++i)) $rv 8085 [[ "$x" ]] 8086 rv=$?; echo $((++i)) $rv 8087 x='1 -a 1 = 2' 8088 [[ -n $x ]] 8089 rv=$?; echo $((++i)) $rv 8090 [[ $x ]] 8091 rv=$?; echo $((++i)) $rv 8092 [[ -n "$x" ]] 8093 rv=$?; echo $((++i)) $rv 8094 [[ "$x" ]] 8095 rv=$?; echo $((++i)) $rv 8096 expected-stdout: 8097 1 1 8098 2 1 8099 3 1 8100 4 1 8101 5 0 8102 6 0 8103 7 0 8104 8 0 8105 9 0 8106 10 0 8107 11 0 8108 12 0 8109 --- 8110 name: test-numeq 8111 description: 8112 Check numeric -eq works (R40d regression); spotted by Martijn Dekker 8113 stdin: 8114 tst() { 8115 eval "$2" 8116 case $? in 8117 (0) echo yepp 0 \#"$*" ;; 8118 (1) echo nope 1 \#"$*" ;; 8119 (2) echo terr 2 \#"$*" ;; 8120 (*) echo wtf\? $? \#"$*" ;; 8121 esac 8122 } 8123 tst 1 'test 2 -eq 2' 8124 tst 2 'test 2 -eq 2a' 8125 tst 3 'test 2 -eq 3' 8126 tst 4 'test 2 -ne 2' 8127 tst 5 'test 2 -ne 2a' 8128 tst 6 'test 2 -ne 3' 8129 tst 7 'test \! 2 -eq 2' 8130 tst 8 'test \! 2 -eq 2a' 8131 tst 9 'test \! 2 -eq 3' 8132 expected-stdout: 8133 yepp 0 #1 test 2 -eq 2 8134 terr 2 #2 test 2 -eq 2a 8135 nope 1 #3 test 2 -eq 3 8136 nope 1 #4 test 2 -ne 2 8137 terr 2 #5 test 2 -ne 2a 8138 yepp 0 #6 test 2 -ne 3 8139 nope 1 #7 test \! 2 -eq 2 8140 terr 2 #8 test \! 2 -eq 2a 8141 yepp 0 #9 test \! 2 -eq 3 8142 expected-stderr-pattern: 8143 /bad number/ 8144 --- 8145 name: mkshrc-1 8146 description: 8147 Check that ~/.mkshrc works correctly. 8148 Part 1: verify user environment is not read (internal) 8149 stdin: 8150 echo x $FNORD 8151 expected-stdout: 8152 x 8153 --- 8154 name: mkshrc-2a 8155 description: 8156 Check that ~/.mkshrc works correctly. 8157 Part 2: verify mkshrc is not read (non-interactive shells) 8158 file-setup: file 644 ".mkshrc" 8159 FNORD=42 8160 env-setup: !HOME=.!ENV=! 8161 stdin: 8162 echo x $FNORD 8163 expected-stdout: 8164 x 8165 --- 8166 name: mkshrc-2b 8167 description: 8168 Check that ~/.mkshrc works correctly. 8169 Part 2: verify mkshrc can be read (interactive shells) 8170 file-setup: file 644 ".mkshrc" 8171 FNORD=42 8172 need-ctty: yes 8173 arguments: !-i! 8174 env-setup: !HOME=.!ENV=!PS1=! 8175 stdin: 8176 echo x $FNORD 8177 expected-stdout: 8178 x 42 8179 expected-stderr-pattern: 8180 /(# )*/ 8181 --- 8182 name: mkshrc-3 8183 description: 8184 Check that ~/.mkshrc works correctly. 8185 Part 3: verify mkshrc can be turned off 8186 file-setup: file 644 ".mkshrc" 8187 FNORD=42 8188 env-setup: !HOME=.!ENV=nonexistant! 8189 stdin: 8190 echo x $FNORD 8191 expected-stdout: 8192 x 8193 --- 8194 name: sh-mode-1 8195 description: 8196 Check that sh mode turns braceexpand off 8197 and that that works correctly 8198 stdin: 8199 set -o braceexpand 8200 set +o sh 8201 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh 8202 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex 8203 echo {a,b,c} 8204 set +o braceexpand 8205 echo {a,b,c} 8206 set -o braceexpand 8207 echo {a,b,c} 8208 set -o sh 8209 echo {a,b,c} 8210 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh 8211 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex 8212 set -o braceexpand 8213 echo {a,b,c} 8214 [[ $(set +o) == *@(-o sh)@(| *) ]] && echo sh || echo nosh 8215 [[ $(set +o) == *@(-o braceexpand)@(| *) ]] && echo brex || echo nobrex 8216 expected-stdout: 8217 nosh 8218 brex 8219 a b c 8220 {a,b,c} 8221 a b c 8222 {a,b,c} 8223 sh 8224 nobrex 8225 a b c 8226 sh 8227 brex 8228 --- 8229 name: sh-mode-2a 8230 description: 8231 Check that posix or sh mode is *not* automatically turned on 8232 category: !binsh 8233 stdin: 8234 ln -s "$__progname" ksh || cp "$__progname" ksh 8235 ln -s "$__progname" sh || cp "$__progname" sh 8236 ln -s "$__progname" ./-ksh || cp "$__progname" ./-ksh 8237 ln -s "$__progname" ./-sh || cp "$__progname" ./-sh 8238 for shell in {,-}{,k}sh; do 8239 print -- $shell $(./$shell +l -c \ 8240 '[[ $(set +o) == *"-o "@(sh|posix)@(| *) ]] && echo sh || echo nosh') 8241 done 8242 expected-stdout: 8243 sh nosh 8244 ksh nosh 8245 -sh nosh 8246 -ksh nosh 8247 --- 8248 name: sh-mode-2b 8249 description: 8250 Check that posix or sh mode *is* automatically turned on 8251 category: binsh 8252 stdin: 8253 ln -s "$__progname" ksh || cp "$__progname" ksh 8254 ln -s "$__progname" sh || cp "$__progname" sh 8255 ln -s "$__progname" ./-ksh || cp "$__progname" ./-ksh 8256 ln -s "$__progname" ./-sh || cp "$__progname" ./-sh 8257 for shell in {,-}{,k}sh; do 8258 print -- $shell $(./$shell +l -c \ 8259 '[[ $(set +o) == *"-o "@(sh|posix)@(| *) ]] && echo sh || echo nosh') 8260 done 8261 expected-stdout: 8262 sh sh 8263 ksh nosh 8264 -sh sh 8265 -ksh nosh 8266 --- 8267 name: pipeline-1 8268 description: 8269 pdksh bug: last command of a pipeline is executed in a 8270 subshell - make sure it still is, scripts depend on it 8271 file-setup: file 644 "abcx" 8272 file-setup: file 644 "abcy" 8273 stdin: 8274 echo * 8275 echo a | while read d; do 8276 echo $d 8277 echo $d* 8278 echo * 8279 set -o noglob 8280 echo $d* 8281 echo * 8282 done 8283 echo * 8284 expected-stdout: 8285 abcx abcy 8286 a 8287 abcx abcy 8288 abcx abcy 8289 a* 8290 * 8291 abcx abcy 8292 --- 8293 name: pipeline-2 8294 description: 8295 check that co-processes work with TCOMs, TPIPEs and TPARENs 8296 category: !nojsig 8297 stdin: 8298 "$__progname" -c 'i=100; echo hi |& while read -p line; do echo "$((i++)) $line"; done' 8299 "$__progname" -c 'i=200; echo hi | cat |& while read -p line; do echo "$((i++)) $line"; done' 8300 "$__progname" -c 'i=300; (echo hi | cat) |& while read -p line; do echo "$((i++)) $line"; done' 8301 expected-stdout: 8302 100 hi 8303 200 hi 8304 300 hi 8305 --- 8306 name: pipeline-3 8307 description: 8308 Check that PIPESTATUS does what it's supposed to 8309 stdin: 8310 echo 1 $PIPESTATUS . 8311 echo 2 ${PIPESTATUS[0]} . 8312 echo 3 ${PIPESTATUS[1]} . 8313 (echo x; exit 12) | (cat; exit 23) | (cat; exit 42) 8314 echo 5 $? , $PIPESTATUS , ${PIPESTATUS[0]} , ${PIPESTATUS[1]} , ${PIPESTATUS[2]} , ${PIPESTATUS[3]} . 8315 echo 6 ${PIPESTATUS[0]} . 8316 set | fgrep PIPESTATUS 8317 echo 8 $(set | fgrep PIPESTATUS) . 8318 expected-stdout: 8319 1 0 . 8320 2 0 . 8321 3 . 8322 x 8323 5 42 , 12 , 12 , 23 , 42 , . 8324 6 0 . 8325 PIPESTATUS[0]=0 8326 8 PIPESTATUS[0]=0 PIPESTATUS[1]=0 . 8327 --- 8328 name: pipeline-4 8329 description: 8330 Check that "set -o pipefail" does what it's supposed to 8331 stdin: 8332 echo 1 "$("$__progname" -c '(exit 12) | (exit 23) | (exit 42); echo $?')" . 8333 echo 2 "$("$__progname" -c '! (exit 12) | (exit 23) | (exit 42); echo $?')" . 8334 echo 3 "$("$__progname" -o pipefail -c '(exit 12) | (exit 23) | (exit 42); echo $?')" . 8335 echo 4 "$("$__progname" -o pipefail -c '! (exit 12) | (exit 23) | (exit 42); echo $?')" . 8336 echo 5 "$("$__progname" -c '(exit 23) | (exit 42) | :; echo $?')" . 8337 echo 6 "$("$__progname" -c '! (exit 23) | (exit 42) | :; echo $?')" . 8338 echo 7 "$("$__progname" -o pipefail -c '(exit 23) | (exit 42) | :; echo $?')" . 8339 echo 8 "$("$__progname" -o pipefail -c '! (exit 23) | (exit 42) | :; echo $?')" . 8340 echo 9 "$("$__progname" -o pipefail -c 'x=$( (exit 23) | (exit 42) | :); echo $?')" . 8341 expected-stdout: 8342 1 42 . 8343 2 0 . 8344 3 42 . 8345 4 0 . 8346 5 0 . 8347 6 1 . 8348 7 42 . 8349 8 0 . 8350 9 42 . 8351 --- 8352 name: persist-history-1 8353 description: 8354 Check if persistent history saving works 8355 category: !no-histfile 8356 need-ctty: yes 8357 arguments: !-i! 8358 env-setup: !ENV=./Env!HISTFILE=hist.file! 8359 file-setup: file 644 "Env" 8360 PS1=X 8361 stdin: 8362 cat hist.file 8363 expected-stdout-pattern: 8364 /cat hist.file/ 8365 expected-stderr-pattern: 8366 /^X*$/ 8367 --- 8368 name: typeset-1 8369 description: 8370 Check that typeset -g works correctly 8371 stdin: 8372 set -A arrfoo 65 8373 foo() { 8374 typeset -g -Uui16 arrfoo[*] 8375 } 8376 echo before ${arrfoo[0]} . 8377 foo 8378 echo after ${arrfoo[0]} . 8379 set -A arrbar 65 8380 bar() { 8381 echo inside before ${arrbar[0]} . 8382 arrbar[0]=97 8383 echo inside changed ${arrbar[0]} . 8384 typeset -g -Uui16 arrbar[*] 8385 echo inside typeset ${arrbar[0]} . 8386 arrbar[0]=48 8387 echo inside changed ${arrbar[0]} . 8388 } 8389 echo before ${arrbar[0]} . 8390 bar 8391 echo after ${arrbar[0]} . 8392 expected-stdout: 8393 before 65 . 8394 after 16#41 . 8395 before 65 . 8396 inside before 65 . 8397 inside changed 97 . 8398 inside typeset 16#61 . 8399 inside changed 16#30 . 8400 after 16#30 . 8401 --- 8402 name: typeset-2 8403 description: 8404 Check that typeset -p on arrays works correctly 8405 stdin: 8406 set -A x -- a b c 8407 echo = 8408 typeset -p x 8409 echo = 8410 typeset -p x[1] 8411 expected-stdout: 8412 = 8413 set -A x 8414 typeset x[0]=a 8415 typeset x[1]=b 8416 typeset x[2]=c 8417 = 8418 typeset x[1]=b 8419 --- 8420 name: typeset-padding-1 8421 description: 8422 Check if left/right justification works as per TFM 8423 stdin: 8424 typeset -L10 ln=0hall0 8425 typeset -R10 rn=0hall0 8426 typeset -ZL10 lz=0hall0 8427 typeset -ZR10 rz=0hall0 8428 typeset -Z10 rx=" hallo " 8429 echo "<$ln> <$rn> <$lz> <$rz> <$rx>" 8430 expected-stdout: 8431 <0hall0 > < 0hall0> <hall0 > <00000hall0> <0000 hallo> 8432 --- 8433 name: typeset-padding-2 8434 description: 8435 Check if base-!10 integers are padded right 8436 stdin: 8437 typeset -Uui16 -L9 ln=16#1 8438 typeset -Uui16 -R9 rn=16#1 8439 typeset -Uui16 -Z9 zn=16#1 8440 typeset -L9 ls=16#1 8441 typeset -R9 rs=16#1 8442 typeset -Z9 zs=16#1 8443 echo "<$ln> <$rn> <$zn> <$ls> <$rs> <$zs>" 8444 expected-stdout: 8445 <16#1 > < 16#1> <16#000001> <16#1 > < 16#1> <0000016#1> 8446 --- 8447 name: utf8bom-1 8448 description: 8449 Check that the UTF-8 Byte Order Mark is ignored as the first 8450 multibyte character of the shell input (with -c, from standard 8451 input, as file, or as eval argument), but nowhere else 8452 # breaks on Mac OSX (HFS+ non-standard Unicode canonical decomposition) 8453 category: !os:darwin,!shell:ebcdic-yes 8454 stdin: 8455 mkdir foo 8456 print '#!/bin/sh\necho ohne' >foo/fnord 8457 print '#!/bin/sh\necho mit' >foo/fnord 8458 print 'fnord\nfnord\nfnord\nfnord' >foo/bar 8459 print eval \''fnord\nfnord\nfnord\nfnord'\' >foo/zoo 8460 set -A anzahl -- foo/* 8461 echo got ${#anzahl[*]} files 8462 chmod +x foo/* 8463 export PATH=$(pwd)/foo$PATHSEP$PATH 8464 "$__progname" -c 'fnord' 8465 echo = 8466 "$__progname" -c 'fnord; fnord; fnord; fnord' 8467 echo = 8468 "$__progname" foo/bar 8469 echo = 8470 "$__progname" <foo/bar 8471 echo = 8472 "$__progname" foo/zoo 8473 echo = 8474 "$__progname" -c 'echo : $(fnord)' 8475 rm -rf foo 8476 expected-stdout: 8477 got 4 files 8478 ohne 8479 = 8480 ohne 8481 ohne 8482 mit 8483 ohne 8484 = 8485 ohne 8486 ohne 8487 mit 8488 ohne 8489 = 8490 ohne 8491 ohne 8492 mit 8493 ohne 8494 = 8495 ohne 8496 ohne 8497 mit 8498 ohne 8499 = 8500 : ohne 8501 --- 8502 name: utf8bom-2 8503 description: 8504 Check that we can execute BOM-shebangs (failures not fatal) 8505 XXX if the OS can already execute them, we lose 8506 note: cygwin execve(2) doesn't return to us with ENOEXEC, we lose 8507 note: Ultrix perl5 t4 returns 65280 (exit-code 255) and no text 8508 XXX fails when LD_PRELOAD is set with -e and Perl chokes it (ASan) 8509 need-pass: no 8510 category: !os:cygwin,!os:msys,!os:ultrix,!os:uwin-nt,!smksh 8511 env-setup: !FOO=BAR! 8512 stdin: 8513 print '#!'"$__progname"'\nprint "1 a=$ENV{FOO}";' >t1 8514 print '#!'"$__progname"'\nprint "2 a=$ENV{FOO}";' >t2 8515 print '#!'"$__perlname"'\nprint "3 a=$ENV{FOO}\n";' >t3 8516 print '#!'"$__perlname"'\nprint "4 a=$ENV{FOO}\n";' >t4 8517 chmod +x t? 8518 ./t1 8519 ./t2 8520 ./t3 8521 ./t4 8522 expected-stdout: 8523 1 a=/nonexistant{FOO} 8524 2 a=/nonexistant{FOO} 8525 3 a=BAR 8526 4 a=BAR 8527 expected-stderr-pattern: 8528 /(Unrecognized character .... ignored at \..t4 line 1)*/ 8529 --- 8530 name: utf8opt-1 8531 description: 8532 Check that the utf8-mode flag is not set at non-interactive startup 8533 env-setup: !PS1=!PS2=!LC_CTYPE=@utflocale@! 8534 stdin: 8535 if [[ $- = *U* ]]; then 8536 echo is set 8537 else 8538 echo is not set 8539 fi 8540 expected-stdout: 8541 is not set 8542 --- 8543 name: utf8opt-2 8544 description: 8545 Check that the utf8-mode flag is set at interactive startup. 8546 If your OS is old, try passing HAVE_SETLOCALE_CTYPE=0 to Build.sh 8547 need-pass: no 8548 category: !noutf8 8549 need-ctty: yes 8550 arguments: !-i! 8551 env-setup: !PS1=!PS2=!LC_CTYPE=@utflocale@! 8552 stdin: 8553 if [[ $- = *U* ]]; then 8554 echo is set 8555 else 8556 echo is not set 8557 fi 8558 expected-stdout: 8559 is set 8560 expected-stderr-pattern: 8561 /(# )*/ 8562 --- 8563 name: utf8opt-3a 8564 description: 8565 Ensure U on the command line is honoured 8566 (these two tests may pass falsely depending on CPPFLAGS) 8567 stdin: 8568 export i=0 8569 code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi' 8570 let i++; "$__progname" -U -c "$code" 8571 let i++; "$__progname" +U -c "$code" 8572 echo $((++i)) done 8573 expected-stdout: 8574 1 on 8575 2 off 8576 3 done 8577 --- 8578 name: utf8opt-3b 8579 description: 8580 Ensure U on the command line is honoured, interactive shells 8581 need-ctty: yes 8582 stdin: 8583 export i=0 8584 code='if [[ $- = *U* ]]; then echo $i on; else echo $i off; fi' 8585 let i++; "$__progname" -U -ic "$code" 8586 let i++; "$__progname" +U -ic "$code" 8587 echo $((++i)) done 8588 expected-stdout: 8589 1 on 8590 2 off 8591 3 done 8592 --- 8593 name: utf8bug-1 8594 description: 8595 Ensure trailing combining characters are not lost 8596 stdin: 8597 set -U 8598 a=a 8599 b=$'\u0301' 8600 x=$a$b 8601 print -r -- "<e$x>" 8602 x=$a 8603 x+=$b 8604 print -r -- "<e$x>" 8605 b=$'\u0301'b 8606 x=$a 8607 x+=$b 8608 print -r -- "<e$x>" 8609 expected-stdout: 8610 <ea> 8611 <ea> 8612 <eab> 8613 --- 8614 name: aliases-1 8615 description: 8616 Check if built-in shell aliases are okay 8617 stdin: 8618 alias 8619 typeset -f 8620 expected-stdout: 8621 autoload='\\builtin typeset -fu' 8622 functions='\\builtin typeset -f' 8623 hash='\\builtin alias -t' 8624 history='\\builtin fc -l' 8625 integer='\\builtin typeset -i' 8626 local='\\builtin typeset' 8627 login='\\builtin exec login' 8628 nameref='\\builtin typeset -n' 8629 nohup='nohup ' 8630 r='\\builtin fc -e -' 8631 type='\\builtin whence -v' 8632 --- 8633 name: aliases-2b 8634 description: 8635 Check if set -o sh does not influence built-in aliases 8636 arguments: !-o!sh! 8637 stdin: 8638 alias 8639 typeset -f 8640 expected-stdout: 8641 autoload='\\builtin typeset -fu' 8642 functions='\\builtin typeset -f' 8643 hash='\\builtin alias -t' 8644 history='\\builtin fc -l' 8645 integer='\\builtin typeset -i' 8646 local='\\builtin typeset' 8647 login='\\builtin exec login' 8648 nameref='\\builtin typeset -n' 8649 nohup='nohup ' 8650 r='\\builtin fc -e -' 8651 type='\\builtin whence -v' 8652 --- 8653 name: aliases-3b 8654 description: 8655 Check if running as sh does not influence built-in aliases 8656 stdin: 8657 cp "$__progname" sh 8658 ./sh -c 'alias; typeset -f' 8659 rm -f sh 8660 expected-stdout: 8661 autoload='\\builtin typeset -fu' 8662 functions='\\builtin typeset -f' 8663 hash='\\builtin alias -t' 8664 history='\\builtin fc -l' 8665 integer='\\builtin typeset -i' 8666 local='\\builtin typeset' 8667 login='\\builtin exec login' 8668 nameref='\\builtin typeset -n' 8669 nohup='nohup ' 8670 r='\\builtin fc -e -' 8671 type='\\builtin whence -v' 8672 --- 8673 name: aliases-cmdline 8674 description: 8675 Check that aliases work from the command line (Debian #517009) 8676 Note that due to the nature of the lexing process, defining 8677 aliases in COMSUBs then immediately using them, and things 8678 like 'alias foo=bar && foo', still fail. 8679 stdin: 8680 "$__progname" -c $'alias a="echo OK"\na' 8681 expected-stdout: 8682 OK 8683 --- 8684 name: aliases-funcdef-1 8685 description: 8686 Check if POSIX functions take precedences over aliases 8687 stdin: 8688 alias foo='echo makro' 8689 foo() { 8690 echo funktion 8691 } 8692 foo 8693 expected-stdout: 8694 makro 8695 --- 8696 name: aliases-funcdef-2 8697 description: 8698 Check if POSIX functions take precedences over aliases 8699 stdin: 8700 alias foo='echo makro' 8701 foo () { 8702 echo funktion 8703 } 8704 foo 8705 expected-stdout: 8706 makro 8707 --- 8708 name: aliases-funcdef-3 8709 description: 8710 Check if aliases take precedences over Korn functions 8711 stdin: 8712 alias foo='echo makro' 8713 function foo { 8714 echo funktion 8715 } 8716 foo 8717 expected-stdout: 8718 makro 8719 --- 8720 name: aliases-funcdef-4 8721 description: 8722 Functions should only take over if actually being defined 8723 stdin: 8724 alias local 8725 :|| local() { :; } 8726 alias local 8727 expected-stdout: 8728 local='\\builtin typeset' 8729 local='\\builtin typeset' 8730 --- 8731 name: arrays-1 8732 description: 8733 Check if Korn Shell arrays work as expected 8734 stdin: 8735 v="c d" 8736 set -A foo -- a \$v "$v" '$v' b 8737 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|" 8738 expected-stdout: 8739 5|a|$v|c d|$v|b| 8740 --- 8741 name: arrays-2a 8742 description: 8743 Check if bash-style arrays work as expected 8744 stdin: 8745 v="c d" 8746 foo=(a \$v "$v" '$v' b) 8747 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|" 8748 expected-stdout: 8749 5|a|$v|c d|$v|b| 8750 --- 8751 name: arrays-2b 8752 description: 8753 Check if bash-style arrays work as expected, with newlines 8754 stdin: 8755 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "$x|"; done' >pfp 8756 chmod +x pfp 8757 test -n "$ZSH_VERSION" && setopt KSH_ARRAYS 8758 v="e f" 8759 foo=(a 8760 bc 8761 d \$v "$v" '$v' g 8762 ) 8763 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo 8764 foo=(a\ 8765 bc 8766 d \$v "$v" '$v' g 8767 ) 8768 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo 8769 foo=(a\ 8770 bc\\ 8771 d \$v "$v" '$v' 8772 g) 8773 ./pfp "${#foo[*]}" "${foo[0]}" "${foo[1]}" "${foo[2]}" "${foo[3]}" "${foo[4]}" "${foo[5]}" "${foo[6]}"; echo 8774 expected-stdout: 8775 7|a|bc|d|$v|e f|$v|g| 8776 7|a|bc|d|$v|e f|$v|g| 8777 6|abc\|d|$v|e f|$v|g|| 8778 --- 8779 name: arrays-3 8780 description: 8781 Check if array bounds are uint32_t 8782 stdin: 8783 set -A foo a b c 8784 foo[4097]=d 8785 foo[2147483637]=e 8786 echo ${foo[*]} 8787 foo[-1]=f 8788 echo ${foo[4294967295]} g ${foo[*]} 8789 expected-stdout: 8790 a b c d e 8791 f g a b c d e f 8792 --- 8793 name: arrays-4 8794 description: 8795 Check if Korn Shell arrays with specified indices work as expected 8796 stdin: 8797 v="c d" 8798 set -A foo -- [1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b 8799 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|" 8800 # we don't want this at all: 8801 # 5|a|$v|c d||$v|b| 8802 set -A arr "[5]=meh" 8803 echo "<${arr[0]}><${arr[5]}>" 8804 expected-stdout: 8805 5|[1]=$v|[2]=c d|[4]=$v|[0]=a|[5]=b|| 8806 <[5]=meh><> 8807 --- 8808 name: arrays-5 8809 description: 8810 Check if bash-style arrays with specified indices work as expected 8811 (taken out temporarily to fix arrays-4; see also arrays-9a comment) 8812 category: disabled 8813 stdin: 8814 v="c d" 8815 foo=([1]=\$v [2]="$v" [4]='$v' [0]=a [5]=b) 8816 echo "${#foo[*]}|${foo[0]}|${foo[1]}|${foo[2]}|${foo[3]}|${foo[4]}|${foo[5]}|" 8817 x=([128]=foo bar baz) 8818 echo k= ${!x[*]} . 8819 echo v= ${x[*]} . 8820 # Check that we do not break this by globbing 8821 :>b=blah 8822 bleh=5 8823 typeset -a arr 8824 arr+=([bleh]=blah) 8825 echo "<${arr[0]}><${arr[5]}>" 8826 expected-stdout: 8827 5|a|$v|c d||$v|b| 8828 k= 128 129 130 . 8829 v= foo bar baz . 8830 <><blah> 8831 --- 8832 name: arrays-6 8833 description: 8834 Check if we can get the array keys (indices) for indexed arrays, 8835 Korn shell style 8836 stdin: 8837 of() { 8838 i=0 8839 for x in "$@"; do 8840 echo -n "$((i++))<$x>" 8841 done 8842 echo 8843 } 8844 foo[1]=eins 8845 set | grep '^foo' 8846 echo = 8847 foo[0]=zwei 8848 foo[4]=drei 8849 set | grep '^foo' 8850 echo = 8851 echo a $(of ${foo[*]}) = $(of ${bar[*]}) a 8852 echo b $(of "${foo[*]}") = $(of "${bar[*]}") b 8853 echo c $(of ${foo[@]}) = $(of ${bar[@]}) c 8854 echo d $(of "${foo[@]}") = $(of "${bar[@]}") d 8855 echo e $(of ${!foo[*]}) = $(of ${!bar[*]}) e 8856 echo f $(of "${!foo[*]}") = $(of "${!bar[*]}") f 8857 echo g $(of ${!foo[@]}) = $(of ${!bar[@]}) g 8858 echo h $(of "${!foo[@]}") = $(of "${!bar[@]}") h 8859 expected-stdout: 8860 foo[1]=eins 8861 = 8862 foo[0]=zwei 8863 foo[1]=eins 8864 foo[4]=drei 8865 = 8866 a 0<zwei>1<eins>2<drei> = a 8867 b 0<zwei eins drei> = 0<> b 8868 c 0<zwei>1<eins>2<drei> = c 8869 d 0<zwei>1<eins>2<drei> = d 8870 e 0<0>1<1>2<4> = e 8871 f 0<0 1 4> = 0<> f 8872 g 0<0>1<1>2<4> = g 8873 h 0<0>1<1>2<4> = h 8874 --- 8875 name: arrays-7 8876 description: 8877 Check if we can get the array keys (indices) for indexed arrays, 8878 Korn shell style, in some corner cases 8879 stdin: 8880 echo !arz: ${!arz} 8881 echo !arz[0]: ${!arz[0]} 8882 echo !arz[1]: ${!arz[1]} 8883 arz=foo 8884 echo !arz: ${!arz} 8885 echo !arz[0]: ${!arz[0]} 8886 echo !arz[1]: ${!arz[1]} 8887 unset arz 8888 echo !arz: ${!arz} 8889 echo !arz[0]: ${!arz[0]} 8890 echo !arz[1]: ${!arz[1]} 8891 expected-stdout: 8892 !arz: arz 8893 !arz[0]: arz[0] 8894 !arz[1]: arz[1] 8895 !arz: arz 8896 !arz[0]: arz[0] 8897 !arz[1]: arz[1] 8898 !arz: arz 8899 !arz[0]: arz[0] 8900 !arz[1]: arz[1] 8901 --- 8902 name: arrays-8 8903 description: 8904 Check some behavioural rules for arrays. 8905 stdin: 8906 fna() { 8907 set -A aa 9 8908 } 8909 fnb() { 8910 typeset ab 8911 set -A ab 9 8912 } 8913 fnc() { 8914 typeset ac 8915 set -A ac 91 8916 unset ac 8917 set -A ac 92 8918 } 8919 fnd() { 8920 set +A ad 9 8921 } 8922 fne() { 8923 unset ae 8924 set +A ae 9 8925 } 8926 fnf() { 8927 unset af[0] 8928 set +A af 9 8929 } 8930 fng() { 8931 unset ag[*] 8932 set +A ag 9 8933 } 8934 set -A aa 1 2 8935 set -A ab 1 2 8936 set -A ac 1 2 8937 set -A ad 1 2 8938 set -A ae 1 2 8939 set -A af 1 2 8940 set -A ag 1 2 8941 set -A ah 1 2 8942 typeset -Z3 aa ab ac ad ae af ag 8943 print 1a ${aa[*]} . 8944 print 1b ${ab[*]} . 8945 print 1c ${ac[*]} . 8946 print 1d ${ad[*]} . 8947 print 1e ${ae[*]} . 8948 print 1f ${af[*]} . 8949 print 1g ${ag[*]} . 8950 print 1h ${ah[*]} . 8951 fna 8952 fnb 8953 fnc 8954 fnd 8955 fne 8956 fnf 8957 fng 8958 typeset -Z5 ah[*] 8959 print 2a ${aa[*]} . 8960 print 2b ${ab[*]} . 8961 print 2c ${ac[*]} . 8962 print 2d ${ad[*]} . 8963 print 2e ${ae[*]} . 8964 print 2f ${af[*]} . 8965 print 2g ${ag[*]} . 8966 print 2h ${ah[*]} . 8967 expected-stdout: 8968 1a 001 002 . 8969 1b 001 002 . 8970 1c 001 002 . 8971 1d 001 002 . 8972 1e 001 002 . 8973 1f 001 002 . 8974 1g 001 002 . 8975 1h 1 2 . 8976 2a 9 . 8977 2b 001 002 . 8978 2c 92 . 8979 2d 009 002 . 8980 2e 9 . 8981 2f 9 002 . 8982 2g 009 . 8983 2h 00001 00002 . 8984 --- 8985 name: arrays-9a 8986 description: 8987 Check that we can concatenate arrays 8988 stdin: 8989 unset foo; foo=(bar); foo+=(baz); echo 1 ${!foo[*]} : ${foo[*]} . 8990 unset foo; foo=(foo bar); foo+=(baz); echo 2 ${!foo[*]} : ${foo[*]} . 8991 # unset foo; foo=([2]=foo [0]=bar); foo+=(baz [5]=quux); echo 3 ${!foo[*]} : ${foo[*]} . 8992 expected-stdout: 8993 1 0 1 : bar baz . 8994 2 0 1 2 : foo bar baz . 8995 # 3 0 2 3 5 : bar foo baz quux . 8996 --- 8997 name: arrays-9b 8998 description: 8999 Check that we can concatenate parameters too 9000 stdin: 9001 unset foo; foo=bar; foo+=baz; echo 1 $foo . 9002 unset foo; typeset -i16 foo=10; foo+=20; echo 2 $foo . 9003 expected-stdout: 9004 1 barbaz . 9005 2 16#a20 . 9006 --- 9007 name: arrassign-basic 9008 description: 9009 Check basic whitespace conserving properties of wdarrassign 9010 stdin: 9011 a=($(echo a b)) 9012 b=($(echo "a b")) 9013 c=("$(echo "a b")") 9014 d=("$(echo a b)") 9015 a+=($(echo c d)) 9016 b+=($(echo "c d")) 9017 c+=("$(echo "c d")") 9018 d+=("$(echo c d)") 9019 echo ".a:${a[0]}.${a[1]}.${a[2]}.${a[3]}:" 9020 echo ".b:${b[0]}.${b[1]}.${b[2]}.${b[3]}:" 9021 echo ".c:${c[0]}.${c[1]}.${c[2]}.${c[3]}:" 9022 echo ".d:${d[0]}.${d[1]}.${d[2]}.${d[3]}:" 9023 expected-stdout: 9024 .a:a.b.c.d: 9025 .b:a.b.c.d: 9026 .c:a b.c d..: 9027 .d:a b.c d..: 9028 --- 9029 name: arrassign-eol 9030 description: 9031 Commands after array assignments are not permitted 9032 stdin: 9033 foo=(a b) env 9034 expected-exit: e != 0 9035 expected-stderr-pattern: 9036 /syntax error: unexpected 'env'/ 9037 --- 9038 name: arrassign-fnc-none 9039 description: 9040 Check locality of array access inside a function 9041 stdin: 9042 function fn { 9043 x+=(f) 9044 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:" 9045 } 9046 function rfn { 9047 if [[ -n $BASH_VERSION ]]; then 9048 y=() 9049 else 9050 set -A y 9051 fi 9052 y+=(f) 9053 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:" 9054 } 9055 x=(m m) 9056 y=(m m) 9057 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:" 9058 fn 9059 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:" 9060 fn 9061 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:" 9062 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:" 9063 rfn 9064 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:" 9065 rfn 9066 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:" 9067 expected-stdout: 9068 .f0:m.m..: 9069 .fn:m.m.f.: 9070 .f1:m.m.f.: 9071 .fn:m.m.f.f: 9072 .f2:m.m.f.f: 9073 .rf0:m.m..: 9074 .rfn:f...: 9075 .rf1:f...: 9076 .rfn:f...: 9077 .rf2:f...: 9078 --- 9079 name: arrassign-fnc-local 9080 description: 9081 Check locality of array access inside a function 9082 with the bash/mksh/ksh93 local/typeset keyword 9083 (note: ksh93 has no local; typeset works only in FKSH) 9084 stdin: 9085 function fn { 9086 typeset x 9087 x+=(f) 9088 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:" 9089 } 9090 function rfn { 9091 if [[ -n $BASH_VERSION ]]; then 9092 y=() 9093 else 9094 set -A y 9095 fi 9096 typeset y 9097 y+=(f) 9098 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:" 9099 } 9100 function fnr { 9101 typeset z 9102 if [[ -n $BASH_VERSION ]]; then 9103 z=() 9104 else 9105 set -A z 9106 fi 9107 z+=(f) 9108 echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:" 9109 } 9110 x=(m m) 9111 y=(m m) 9112 z=(m m) 9113 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:" 9114 fn 9115 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:" 9116 fn 9117 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:" 9118 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:" 9119 rfn 9120 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:" 9121 rfn 9122 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:" 9123 echo ".f0r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:" 9124 fnr 9125 echo ".f1r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:" 9126 fnr 9127 echo ".f2r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:" 9128 expected-stdout: 9129 .f0:m.m..: 9130 .fn:f...: 9131 .f1:m.m..: 9132 .fn:f...: 9133 .f2:m.m..: 9134 .rf0:m.m..: 9135 .rfn:f...: 9136 .rf1:...: 9137 .rfn:f...: 9138 .rf2:...: 9139 .f0r:m.m..: 9140 .fnr:f...: 9141 .f1r:m.m..: 9142 .fnr:f...: 9143 .f2r:m.m..: 9144 --- 9145 name: arrassign-fnc-global 9146 description: 9147 Check locality of array access inside a function 9148 with the bash4/mksh/yash/zsh typeset -g keyword 9149 stdin: 9150 function fn { 9151 typeset -g x 9152 x+=(f) 9153 echo ".fn:${x[0]}.${x[1]}.${x[2]}.${x[3]}:" 9154 } 9155 function rfn { 9156 set -A y 9157 typeset -g y 9158 y+=(f) 9159 echo ".rfn:${y[0]}.${y[1]}.${y[2]}.${y[3]}:" 9160 } 9161 function fnr { 9162 typeset -g z 9163 set -A z 9164 z+=(f) 9165 echo ".fnr:${z[0]}.${z[1]}.${z[2]}.${z[3]}:" 9166 } 9167 x=(m m) 9168 y=(m m) 9169 z=(m m) 9170 echo ".f0:${x[0]}.${x[1]}.${x[2]}.${x[3]}:" 9171 fn 9172 echo ".f1:${x[0]}.${x[1]}.${x[2]}.${x[3]}:" 9173 fn 9174 echo ".f2:${x[0]}.${x[1]}.${x[2]}.${x[3]}:" 9175 echo ".rf0:${y[0]}.${y[1]}.${y[2]}.${y[3]}:" 9176 rfn 9177 echo ".rf1:${y[0]}.${y[1]}.${y[2]}.${y[3]}:" 9178 rfn 9179 echo ".rf2:${y[0]}.${y[1]}.${y[2]}.${y[3]}:" 9180 echo ".f0r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:" 9181 fnr 9182 echo ".f1r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:" 9183 fnr 9184 echo ".f2r:${z[0]}.${z[1]}.${z[2]}.${z[3]}:" 9185 expected-stdout: 9186 .f0:m.m..: 9187 .fn:m.m.f.: 9188 .f1:m.m.f.: 9189 .fn:m.m.f.f: 9190 .f2:m.m.f.f: 9191 .rf0:m.m..: 9192 .rfn:f...: 9193 .rf1:f...: 9194 .rfn:f...: 9195 .rf2:f...: 9196 .f0r:m.m..: 9197 .fnr:f...: 9198 .f1r:f...: 9199 .fnr:f...: 9200 .f2r:f...: 9201 --- 9202 name: strassign-fnc-none 9203 description: 9204 Check locality of string access inside a function 9205 stdin: 9206 function fn { 9207 x+=f 9208 echo ".fn:$x:" 9209 } 9210 function rfn { 9211 y= 9212 y+=f 9213 echo ".rfn:$y:" 9214 } 9215 x=m 9216 y=m 9217 echo ".f0:$x:" 9218 fn 9219 echo ".f1:$x:" 9220 fn 9221 echo ".f2:$x:" 9222 echo ".rf0:$y:" 9223 rfn 9224 echo ".rf1:$y:" 9225 rfn 9226 echo ".rf2:$y:" 9227 expected-stdout: 9228 .f0:m: 9229 .fn:mf: 9230 .f1:mf: 9231 .fn:mff: 9232 .f2:mff: 9233 .rf0:m: 9234 .rfn:f: 9235 .rf1:f: 9236 .rfn:f: 9237 .rf2:f: 9238 --- 9239 name: strassign-fnc-local 9240 description: 9241 Check locality of string access inside a function 9242 with the bash/mksh/ksh93 local/typeset keyword 9243 (note: ksh93 has no local; typeset works only in FKSH) 9244 stdin: 9245 function fn { 9246 typeset x 9247 x+=f 9248 echo ".fn:$x:" 9249 } 9250 function rfn { 9251 y= 9252 typeset y 9253 y+=f 9254 echo ".rfn:$y:" 9255 } 9256 function fnr { 9257 typeset z 9258 z= 9259 z+=f 9260 echo ".fnr:$z:" 9261 } 9262 x=m 9263 y=m 9264 z=m 9265 echo ".f0:$x:" 9266 fn 9267 echo ".f1:$x:" 9268 fn 9269 echo ".f2:$x:" 9270 echo ".rf0:$y:" 9271 rfn 9272 echo ".rf1:$y:" 9273 rfn 9274 echo ".rf2:$y:" 9275 echo ".f0r:$z:" 9276 fnr 9277 echo ".f1r:$z:" 9278 fnr 9279 echo ".f2r:$z:" 9280 expected-stdout: 9281 .f0:m: 9282 .fn:f: 9283 .f1:m: 9284 .fn:f: 9285 .f2:m: 9286 .rf0:m: 9287 .rfn:f: 9288 .rf1:: 9289 .rfn:f: 9290 .rf2:: 9291 .f0r:m: 9292 .fnr:f: 9293 .f1r:m: 9294 .fnr:f: 9295 .f2r:m: 9296 --- 9297 name: strassign-fnc-global 9298 description: 9299 Check locality of string access inside a function 9300 with the bash4/mksh/yash/zsh typeset -g keyword 9301 stdin: 9302 function fn { 9303 typeset -g x 9304 x+=f 9305 echo ".fn:$x:" 9306 } 9307 function rfn { 9308 y= 9309 typeset -g y 9310 y+=f 9311 echo ".rfn:$y:" 9312 } 9313 function fnr { 9314 typeset -g z 9315 z= 9316 z+=f 9317 echo ".fnr:$z:" 9318 } 9319 x=m 9320 y=m 9321 z=m 9322 echo ".f0:$x:" 9323 fn 9324 echo ".f1:$x:" 9325 fn 9326 echo ".f2:$x:" 9327 echo ".rf0:$y:" 9328 rfn 9329 echo ".rf1:$y:" 9330 rfn 9331 echo ".rf2:$y:" 9332 echo ".f0r:$z:" 9333 fnr 9334 echo ".f1r:$z:" 9335 fnr 9336 echo ".f2r:$z:" 9337 expected-stdout: 9338 .f0:m: 9339 .fn:mf: 9340 .f1:mf: 9341 .fn:mff: 9342 .f2:mff: 9343 .rf0:m: 9344 .rfn:f: 9345 .rf1:f: 9346 .rfn:f: 9347 .rf2:f: 9348 .f0r:m: 9349 .fnr:f: 9350 .f1r:f: 9351 .fnr:f: 9352 .f2r:f: 9353 --- 9354 name: unset-fnc-local-ksh 9355 description: 9356 Check that unset removes a previous local 9357 (ksh93 syntax compatible version); apparently, 9358 there are shells which fail this? 9359 stdin: 9360 function f { 9361 echo f0: $x 9362 typeset x 9363 echo f1: $x 9364 x=fa 9365 echo f2: $x 9366 unset x 9367 echo f3: $x 9368 x=fb 9369 echo f4: $x 9370 } 9371 x=o 9372 echo before: $x 9373 f 9374 echo after: $x 9375 expected-stdout: 9376 before: o 9377 f0: o 9378 f1: 9379 f2: fa 9380 f3: o 9381 f4: fb 9382 after: fb 9383 --- 9384 name: unset-fnc-local-sh 9385 description: 9386 Check that unset removes a previous local 9387 (Debian Policy 10.4 sh version); apparently, 9388 there are shells which fail this? 9389 stdin: 9390 f() { 9391 echo f0: $x 9392 local x 9393 echo f1: $x 9394 x=fa 9395 echo f2: $x 9396 unset x 9397 echo f3: $x 9398 x=fb 9399 echo f4: $x 9400 } 9401 x=o 9402 echo before: $x 9403 f 9404 echo after: $x 9405 expected-stdout: 9406 before: o 9407 f0: o 9408 f1: 9409 f2: fa 9410 f3: o 9411 f4: fb 9412 after: fb 9413 --- 9414 name: varexpand-substr-1 9415 description: 9416 Check if bash-style substring expansion works 9417 when using positive numerics 9418 stdin: 9419 x=abcdefghi 9420 typeset -i y=123456789 9421 typeset -i 16 z=123456789 # 16#75bcd15 9422 echo a t${x:2:2} ${y:2:3} ${z:2:3} a 9423 echo b ${x::3} ${y::3} ${z::3} b 9424 echo c ${x:2:} ${y:2:} ${z:2:} c 9425 echo d ${x:2} ${y:2} ${z:2} d 9426 echo e ${x:2:6} ${y:2:6} ${z:2:7} e 9427 echo f ${x:2:7} ${y:2:7} ${z:2:8} f 9428 echo g ${x:2:8} ${y:2:8} ${z:2:9} g 9429 expected-stdout: 9430 a tcd 345 #75 a 9431 b abc 123 16# b 9432 c c 9433 d cdefghi 3456789 #75bcd15 d 9434 e cdefgh 345678 #75bcd1 e 9435 f cdefghi 3456789 #75bcd15 f 9436 g cdefghi 3456789 #75bcd15 g 9437 --- 9438 name: varexpand-substr-2 9439 description: 9440 Check if bash-style substring expansion works 9441 when using negative numerics or expressions 9442 stdin: 9443 x=abcdefghi 9444 typeset -i y=123456789 9445 typeset -i 16 z=123456789 # 16#75bcd15 9446 n=2 9447 echo a ${x:$n:3} ${y:$n:3} ${z:$n:3} a 9448 echo b ${x:(n):3} ${y:(n):3} ${z:(n):3} b 9449 echo c ${x:(-2):1} ${y:(-2):1} ${z:(-2):1} c 9450 echo d t${x: n:2} ${y: n:3} ${z: n:3} d 9451 expected-stdout: 9452 a cde 345 #75 a 9453 b cde 345 #75 b 9454 c h 8 1 c 9455 d tcd 345 #75 d 9456 --- 9457 name: varexpand-substr-3 9458 description: 9459 Check that some things that work in bash fail. 9460 This is by design. Oh and vice versa, nowadays. 9461 stdin: 9462 export x=abcdefghi n=2 9463 "$__progname" -c 'echo v${x:(n)}x' 9464 "$__progname" -c 'echo w${x: n}x' 9465 "$__progname" -c 'echo x${x:n}x' 9466 "$__progname" -c 'echo y${x:}x' 9467 "$__progname" -c 'echo z${x}x' 9468 # next fails only in bash 9469 "$__progname" -c 'x=abcdef;y=123;echo ${x:${y:2:1}:2}' >/dev/null 2>&1; echo $? 9470 expected-stdout: 9471 vcdefghix 9472 wcdefghix 9473 zabcdefghix 9474 0 9475 expected-stderr-pattern: 9476 /x:n.*bad substitution.*\n.*bad substitution/ 9477 --- 9478 name: varexpand-substr-4 9479 description: 9480 Check corner cases for substring expansion 9481 stdin: 9482 x=abcdefghi 9483 integer y=2 9484 echo a ${x:(y == 1 ? 2 : 3):4} a 9485 expected-stdout: 9486 a defg a 9487 --- 9488 name: varexpand-substr-5A 9489 description: 9490 Check that substring expansions work on characters 9491 stdin: 9492 set +U 9493 x=mh 9494 echo a ${x::1} ${x: -1} a 9495 echo b ${x::3} ${x: -3} b 9496 echo c ${x:1:2} ${x: -3:2} c 9497 echo d ${#x} d 9498 expected-stdout: 9499 a m h a 9500 b m h b 9501 c c 9502 d 4 d 9503 --- 9504 name: varexpand-substr-5W 9505 description: 9506 Check that substring expansions work on characters 9507 stdin: 9508 set -U 9509 x=mh 9510 echo a ${x::1} ${x: -1} a 9511 echo b ${x::2} ${x: -2} b 9512 echo c ${x:1:1} ${x: -2:1} c 9513 echo d ${#x} d 9514 expected-stdout: 9515 a m h a 9516 b m h b 9517 c c 9518 d 3 d 9519 --- 9520 name: varexpand-substr-6 9521 description: 9522 Check that string substitution works correctly 9523 stdin: 9524 foo=1 9525 bar=2 9526 baz=qwertyuiop 9527 echo a ${baz: foo: bar} 9528 echo b ${baz: foo: $bar} 9529 echo c ${baz: $foo: bar} 9530 echo d ${baz: $foo: $bar} 9531 expected-stdout: 9532 a we 9533 b we 9534 c we 9535 d we 9536 --- 9537 name: varexpand-special-hash 9538 description: 9539 Check special ${var@x} expansion for x=hash 9540 category: !shell:ebcdic-yes 9541 stdin: 9542 typeset -i8 foo=10 9543 bar=baz 9544 unset baz 9545 print ${foo@#} ${bar@#} ${baz@#} . 9546 expected-stdout: 9547 9B15FBFB CFBDD32B 00000000 . 9548 --- 9549 name: varexpand-special-hash-ebcdic 9550 description: 9551 Check special ${var@x} expansion for x=hash 9552 category: !shell:ebcdic-no 9553 stdin: 9554 typeset -i8 foo=10 9555 bar=baz 9556 unset baz 9557 print ${foo@#} ${bar@#} ${baz@#} . 9558 expected-stdout: 9559 016AE33D 9769C4AF 00000000 . 9560 --- 9561 name: varexpand-special-quote 9562 description: 9563 Check special ${var@Q} expansion for quoted strings 9564 category: !shell:faux-ebcdic 9565 stdin: 9566 set +U 9567 i=x 9568 j=a\ b 9569 k=$'c 9570 d\xA0''ef' 9571 print -r -- "<i=$i j=$j k=$k>" 9572 s="u=${i@Q} v=${j@Q} w=${k@Q}" 9573 print -r -- "s=\"$s\"" 9574 eval "$s" 9575 typeset -p u v w 9576 expected-stdout: 9577 <i=x j=a b k=c 9578 def> 9579 s="u=x v='a b' w=$'c\nd\240e\u20ACf'" 9580 typeset u=x 9581 typeset v='a b' 9582 typeset w=$'c\nd\240e\u20ACf' 9583 --- 9584 name: varexpand-special-quote-faux-EBCDIC 9585 description: 9586 Check special ${var@Q} expansion for quoted strings 9587 category: shell:faux-ebcdic 9588 stdin: 9589 set +U 9590 i=x 9591 j=a\ b 9592 k=$'c 9593 d\xA0''ef' 9594 print -r -- "<i=$i j=$j k=$k>" 9595 s="u=${i@Q} v=${j@Q} w=${k@Q}" 9596 print -r -- "s=\"$s\"" 9597 eval "$s" 9598 typeset -p u v w 9599 expected-stdout: 9600 <i=x j=a b k=c 9601 def> 9602 s="u=x v='a b' w=$'c\nde\u20ACf'" 9603 typeset u=x 9604 typeset v='a b' 9605 typeset w=$'c\nde\u20ACf' 9606 --- 9607 name: varexpand-null-1 9608 description: 9609 Ensure empty strings expand emptily 9610 stdin: 9611 print s ${a} . ${b} S 9612 print t ${a#?} . ${b%?} T 9613 print r ${a=} . ${b/c/d} R 9614 print q 9615 print s "${a}" . "${b}" S 9616 print t "${a#?}" . "${b%?}" T 9617 print r "${a=}" . "${b/c/d}" R 9618 expected-stdout: 9619 s . S 9620 t . T 9621 r . R 9622 q 9623 s . S 9624 t . T 9625 r . R 9626 --- 9627 name: varexpand-null-2 9628 description: 9629 Ensure empty strings, when quoted, are expanded as empty strings 9630 stdin: 9631 print '#!'"$__progname"'\nfor x in "$@"; do print -nr -- "<$x> "; done' >pfs 9632 chmod +x pfs 9633 ./pfs 1 "${a}" 2 "${a#?}" + "${b%?}" 3 "${a=}" + "${b/c/d}" 9634 echo . 9635 expected-stdout: 9636 <1> <> <2> <> <+> <> <3> <> <+> <> . 9637 --- 9638 name: varexpand-null-3 9639 description: 9640 Ensure concatenating behaviour matches other shells 9641 stdin: 9642 showargs() { for s_arg in "$@"; do echo -n "<$s_arg> "; done; echo .; } 9643 showargs 0 ""$@ 9644 x=; showargs 1 "$x"$@ 9645 set A; showargs 2 "${@:+}" 9646 n() { echo "$#"; } 9647 unset e 9648 set -- a b 9649 n """$@" 9650 n "$@" 9651 n "$@""" 9652 n "$e""$@" 9653 n "$@" 9654 n "$@""$e" 9655 set -- 9656 n """$@" 9657 n "$@" 9658 n "$@""" 9659 n "$e""$@" 9660 n "$@" 9661 n "$@""$e" 9662 expected-stdout: 9663 <0> <> . 9664 <1> <> . 9665 <2> <> . 9666 2 9667 2 9668 2 9669 2 9670 2 9671 2 9672 1 9673 0 9674 1 9675 1 9676 0 9677 1 9678 --- 9679 name: varexpand-funny-chars 9680 description: 9681 Check some characters 9682 XXX \uEF80 is asymmetric, possibly buggy so we dont check this 9683 stdin: 9684 x=$'<\x00>'; typeset -p x 9685 x=$'<\x01>'; typeset -p x 9686 x=$'<\u0000>'; typeset -p x 9687 x=$'<\u0001>'; typeset -p x 9688 expected-stdout: 9689 typeset x='<' 9690 typeset x=$'<\001>' 9691 typeset x='<' 9692 typeset x=$'<\001>' 9693 --- 9694 name: print-funny-chars 9695 description: 9696 Check print builtin's capability to output designated characters 9697 stdin: 9698 { 9699 print '<\0144\0344\xDB\u00DB\u20AC\uDB\x40>' 9700 print '<\x00>' 9701 print '<\x01>' 9702 print '<\u0000>' 9703 print '<\u0001>' 9704 } | { 9705 # integer-base-one-3Ar 9706 typeset -Uui16 -Z11 pos=0 9707 typeset -Uui16 -Z5 hv=2147483647 9708 dasc= 9709 if read -arN -1 line; then 9710 typeset -i1 line 9711 i=0 9712 while (( i < ${#line[*]} )); do 9713 hv=${line[i++]} 9714 if (( (pos & 15) == 0 )); then 9715 (( pos )) && print -r -- "$dasc|" 9716 print -n "${pos#16#} " 9717 dasc=' |' 9718 fi 9719 print -n "${hv#16#} " 9720 if (( (hv < 32) || (hv > 126) )); then 9721 dasc=$dasc. 9722 else 9723 dasc=$dasc${line[i-1]#1#} 9724 fi 9725 (( (pos++ & 15) == 7 )) && print -n -- '- ' 9726 done 9727 fi 9728 while (( pos & 15 )); do 9729 print -n ' ' 9730 (( (pos++ & 15) == 7 )) && print -n -- '- ' 9731 done 9732 (( hv == 2147483647 )) || print -r -- "$dasc|" 9733 } 9734 expected-stdout: 9735 00000000 3C 64 E4 DB C3 9B E2 82 - AC C3 9B 40 3E 0A 3C 00 |<d.........@>.<.| 9736 00000010 3E 0A 3C 01 3E 0A 3C 00 - 3E 0A 3C 01 3E 0A |>.<.>.<.>.<.>.| 9737 --- 9738 name: print-bksl-c 9739 description: 9740 Check print builtin's \c escape 9741 stdin: 9742 print '\ca'; print b 9743 expected-stdout: 9744 ab 9745 --- 9746 name: print-cr 9747 description: 9748 Check that CR+LF is not collapsed into LF as some MSYS shells wrongly do 9749 stdin: 9750 echo '#!'"$__progname" >foo 9751 cat >>foo <<-'EOF' 9752 print -n -- '220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT\r\n220->> Bitte keine Werbung einwerfen! <<\r\r\n220 Who do you wanna pretend to be today' 9753 print \? 9754 EOF 9755 chmod +x foo 9756 echo "[$(./foo)]" 9757 ./foo | while IFS= read -r line; do 9758 print -r -- "{$line}" 9759 done 9760 expected-stdout: 9761 [220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT 9762 220->> Bitte keine Werbung einwerfen! << 9764 220 Who do you wanna pretend to be today? ] 9766 {220-blau.mirbsd.org ESMTP ready at Thu, 25 Jul 2013 15:57:57 GMT } 9768 {220->> Bitte keine Werbung einwerfen! << } 9771 {220 Who do you wanna pretend to be today? } 9773 --- 9774 name: print-crlf 9775 description: 9776 Check that CR+LF is shown and read as-is 9777 category: shell:textmode-no 9778 stdin: 9779 cat >foo <<-'EOF' 9780 x='bar 9781 ' # 9782 echo .${#x} # 9783 if test x"$KSH_VERSION" = x""; then # 9784 printf '<%s>' "$x" # 9785 else # 9786 print -nr -- "<$x>" # 9787 fi # 9788 EOF 9789 echo "[$("$__progname" foo)]" 9790 "$__progname" foo | while IFS= read -r line; do 9791 print -r -- "{$line}" 9792 done 9793 expected-stdout: 9794 [.5 9795 <bar 9796 >] 9797 {.5} 9798 {<bar } 9800 --- 9801 name: print-crlf-textmode 9802 description: 9803 Check that CR+LF is treated as newline 9804 category: shell:textmode-yes 9805 stdin: 9806 cat >foo <<-'EOF' 9807 x='bar 9808 ' # 9809 echo .${#x} # 9810 if test x"$KSH_VERSION" = x""; then # 9811 printf '<%s>' "$x" # 9812 else # 9813 print -nr -- "<$x>" # 9814 fi # 9815 EOF 9816 echo "[$("$__progname" foo)]" 9817 "$__progname" foo | while IFS= read -r line; do 9818 print -r -- "{$line}" 9819 done 9820 expected-stdout: 9821 [.4 9822 <bar 9823 >] 9824 {.4} 9825 {<bar} 9826 --- 9827 name: print-lf 9828 description: 9829 Check that LF-only is shown and read as-is 9830 stdin: 9831 cat >foo <<-'EOF' 9832 x='bar 9833 ' # 9834 echo .${#x} # 9835 if test x"$KSH_VERSION" = x""; then # 9836 printf '<%s>' "$x" # 9837 else # 9838 print -nr -- "<$x>" # 9839 fi # 9840 EOF 9841 echo "[$("$__progname" foo)]" 9842 "$__progname" foo | while IFS= read -r line; do 9843 print -r -- "{$line}" 9844 done 9845 expected-stdout: 9846 [.4 9847 <bar 9848 >] 9849 {.4} 9850 {<bar} 9851 --- 9852 name: print-nul-chars 9853 description: 9854 Check handling of NUL characters for print and COMSUB 9855 stdin: 9856 x=$(print '<\0>') 9857 print $(($(print '<\0>' | wc -c))) $(($(print "$x" | wc -c))) \ 9858 ${#x} "$x" '<\0>' 9859 expected-stdout-pattern: 9860 /^4 3 2 <> <\0>$/ 9861 --- 9862 name: print-array 9863 description: 9864 Check that print -A works as expected 9865 stdin: 9866 print -An 0x20AC 0xC3 0xBC 8#101 9867 set -U 9868 print -A 0x20AC 0xC3 0xBC 8#102 9869 expected-stdout: 9870 AB 9871 --- 9872 name: print-escapes 9873 description: 9874 Check backslash expansion by the print builtin 9875 stdin: 9876 print '\ \!\"\#\$\%\&'\\\''\(\)\*\+\,\-\.\/\0\1\2\3\4\5\6\7\8' \ 9877 '\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T' \ 9878 '\U\V\W\X\Y\Z\[\\\]\^\_\`\a\b \d\e\f\g\h\i\j\k\l\m\n\o\p' \ 9879 '\q\r\s\t\u\v\w\x\y\z\{\|\}\~' '\u20acd' '\U20acd' '\x123' \ 9880 '\0x' '\0123' '\01234' | { 9881 # integer-base-one-3As 9882 typeset -Uui16 -Z11 pos=0 9883 typeset -Uui16 -Z5 hv=2147483647 9884 typeset -i1 wc=0x0A 9885 dasc= 9886 nl=${wc#1#} 9887 while IFS= read -r line; do 9888 line=$line$nl 9889 while [[ -n $line ]]; do 9890 hv=1#${line::1} 9891 if (( (pos & 15) == 0 )); then 9892 (( pos )) && print -r -- "$dasc|" 9893 print -n "${pos#16#} " 9894 dasc=' |' 9895 fi 9896 print -n "${hv#16#} " 9897 if (( (hv < 32) || (hv > 126) )); then 9898 dasc=$dasc. 9899 else 9900 dasc=$dasc${line::1} 9901 fi 9902 (( (pos++ & 15) == 7 )) && print -n -- '- ' 9903 line=${line:1} 9904 done 9905 done 9906 while (( pos & 15 )); do 9907 print -n ' ' 9908 (( (pos++ & 15) == 7 )) && print -n -- '- ' 9909 done 9910 (( hv == 2147483647 )) || print -r -- "$dasc|" 9911 } 9912 expected-stdout: 9913 00000000 5C 20 5C 21 5C 22 5C 23 - 5C 24 5C 25 5C 26 5C 27 |\ \!\"\#\$\%\&\'| 9914 00000010 5C 28 5C 29 5C 2A 5C 2B - 5C 2C 5C 2D 5C 2E 5C 2F |\(\)\*\+\,\-\.\/| 9915 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| 9916 00000030 20 5C 39 5C 3A 5C 3B 5C - 3C 5C 3D 5C 3E 5C 3F 5C | \9\:\;\<\=\>\?\| 9917 00000040 40 5C 41 5C 42 5C 43 5C - 44 1B 5C 46 5C 47 5C 48 |@\A\B\C\D.\F\G\H| 9918 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| 9919 00000060 5C 51 5C 52 5C 53 5C 54 - 20 5C 55 5C 56 5C 57 5C |\Q\R\S\T \U\V\W\| 9920 00000070 58 5C 59 5C 5A 5C 5B 5C - 5C 5D 5C 5E 5C 5F 5C 60 |X\Y\Z\[\\]\^\_\`| 9921 00000080 07 08 20 20 5C 64 1B 0C - 5C 67 5C 68 5C 69 5C 6A |.. \d..\g\h\i\j| 9922 00000090 5C 6B 5C 6C 5C 6D 0A 5C - 6F 5C 70 20 5C 71 0D 5C |\k\l\m.\o\p \q.\| 9923 000000A0 73 09 5C 75 0B 5C 77 5C - 78 5C 79 5C 7A 5C 7B 5C |s.\u.\w\x\y\z\{\| 9924 000000B0 7C 5C 7D 5C 7E 20 E2 82 - AC 64 20 EF BF BD 20 12 ||\}\~ ...d ... .| 9925 000000C0 33 20 78 20 53 20 53 34 - 0A |3 x S S4.| 9926 --- 9927 name: dollar-doublequoted-strings 9928 description: 9929 Check that a $ preceding "" is ignored 9930 stdin: 9931 echo $"Localise me!" 9932 cat <<<$"Me too!" 9933 V=X 9934 aol=aol 9935 cat <<-$"aol" 9936 I do not take a $V for a V! 9937 aol 9938 expected-stdout: 9939 Localise me! 9940 Me too! 9941 I do not take a $V for a V! 9942 --- 9943 name: dollar-quoted-strings 9944 description: 9945 Check backslash expansion by $'' strings 9946 stdin: 9947 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn 9948 chmod +x pfn 9949 ./pfn $'\ \!\"\#\$\%\&\'\(\)\*\+\,\-\.\/ \1\2\3\4\5\6' \ 9950 $'a\0b' $'a\01b' $'\7\8\9\:\;\<\=\>\?\@\A\B\C\D\E\F\G\H\I' \ 9951 $'\J\K\L\M\N\O\P\Q\R\S\T\U1\V\W\X\Y\Z\[\\\]\^\_\`\a\b\d\e' \ 9952 $'\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u1\v\w\x1\y\z\{\|\}\~ $x' \ 9953 $'\u20acd' $'\U20acd' $'\x123' $'fn\x0rd' $'\0234' $'\234' \ 9954 $'\2345' $'\ca' $'\c!' $'\c?' $'\c' $'a\ 9955 b' | { 9956 # integer-base-one-3As 9957 typeset -Uui16 -Z11 pos=0 9958 typeset -Uui16 -Z5 hv=2147483647 9959 typeset -i1 wc=0x0A 9960 dasc= 9961 nl=${wc#1#} 9962 while IFS= read -r line; do 9963 line=$line$nl 9964 while [[ -n $line ]]; do 9965 hv=1#${line::1} 9966 if (( (pos & 15) == 0 )); then 9967 (( pos )) && print -r -- "$dasc|" 9968 print -n "${pos#16#} " 9969 dasc=' |' 9970 fi 9971 print -n "${hv#16#} " 9972 if (( (hv < 32) || (hv > 126) )); then 9973 dasc=$dasc. 9974 else 9975 dasc=$dasc${line::1} 9976 fi 9977 (( (pos++ & 15) == 7 )) && print -n -- '- ' 9978 line=${line:1} 9979 done 9980 done 9981 while (( pos & 15 )); do 9982 print -n ' ' 9983 (( (pos++ & 15) == 7 )) && print -n -- '- ' 9984 done 9985 (( hv == 2147483647 )) || print -r -- "$dasc|" 9986 } 9987 expected-stdout: 9988 00000000 20 21 22 23 24 25 26 27 - 28 29 2A 2B 2C 2D 2E 2F | !"#$%&'()*+,-./| 9989 00000010 20 01 02 03 04 05 06 0A - 61 0A 61 01 62 0A 07 38 | .......a.a.b..8| 9990 00000020 39 3A 3B 3C 3D 3E 3F 40 - 41 42 43 44 1B 46 47 48 |9:;<=>?@ABCD.FGH| 9991 00000030 49 0A 4A 4B 4C 4D 4E 4F - 50 51 52 53 54 01 56 57 |I.JKLMNOPQRST.VW| 9992 00000040 58 59 5A 5B 5C 5D 5E 5F - 60 07 08 64 1B 0A 0C 67 |XYZ[\]^_`..d...g| 9993 00000050 68 69 6A 6B 6C 6D 0A 6F - 70 71 0D 73 09 01 0B 77 |hijklm.opq.s...w| 9994 00000060 01 79 7A 7B 7C 7D 7E 20 - 24 78 0A E2 82 AC 64 0A |.yz{|}~ $x....d.| 9995 00000070 EF BF BD 0A C4 A3 0A 66 - 6E 0A 13 34 0A 9C 0A 9C |.......fn..4....| 9996 00000080 35 0A 01 0A 01 0A 7F 0A - 82 80 A6 0A 61 0A 62 0A |5...........a.b.| 9997 --- 9998 name: dollar-quotes-in-heredocs-strings 9999 description: 10000 They are, however, not parsed in here documents, here strings 10001 (outside of string delimiters) or regular strings, but in 10002 parameter substitutions. 10003 stdin: 10004 cat <<EOF 10005 dollar = strchr(s, '$'); /* ' */ 10006 foo " bar \" baz 10007 EOF 10008 cat <<$'a\tb' 10009 a\tb 10010 a b 10011 cat <<<"dollar = strchr(s, '$'); /* ' */" 10012 cat <<<'dollar = strchr(s, '\''$'\''); /* '\'' */' 10013 x="dollar = strchr(s, '$'); /* ' */" 10014 cat <<<"$x" 10015 cat <<<$'a\E[0m\tb' 10016 unset nl; print -r -- "x${nl:=$'\n'}y" 10017 echo "1 foo\"bar" 10018 # cf & HEREDOC 10019 cat <<EOF 10020 2 foo\"bar 10021 EOF 10022 # probably never reached for here strings? 10023 cat <<<"3 foo\"bar" 10024 cat <<<"4 foo\\\"bar" 10025 cat <<<'5 foo\"bar' 10026 # old scripts use this (e.g. ncurses) 10027 echo "^$" 10028 # make sure this works, outside of quotes 10029 cat <<<'7'$'\t''.' 10030 expected-stdout: 10031 dollar = strchr(s, '$'); /* ' */ 10032 foo " bar \" baz 10033 a\tb 10034 dollar = strchr(s, '$'); /* ' */ 10035 dollar = strchr(s, '$'); /* ' */ 10036 dollar = strchr(s, '$'); /* ' */ 10037 a[0m b 10038 x 10039 y 10040 1 foo"bar 10041 2 foo\"bar 10042 3 foo"bar 10043 4 foo\"bar 10044 5 foo\"bar 10045 ^$ 10046 7 . 10047 --- 10048 name: dot-needs-argument 10049 description: 10050 check Debian #415167 solution: '.' without arguments should fail 10051 stdin: 10052 "$__progname" -c . 10053 "$__progname" -c source 10054 expected-exit: e != 0 10055 expected-stderr-pattern: 10056 /\.: missing argument.*\n.*source: missing argument/ 10057 --- 10058 name: dot-errorlevel 10059 description: 10060 Ensure dot resets $? 10061 stdin: 10062 :>dotfile 10063 (exit 42) 10064 . ./dotfile 10065 echo 1 $? . 10066 expected-stdout: 10067 1 0 . 10068 --- 10069 name: alias-function-no-conflict 10070 description: 10071 make aliases not conflict with function definitions 10072 stdin: 10073 # POSIX function can be defined, but alias overrides it 10074 alias foo='echo bar' 10075 foo 10076 foo() { 10077 echo baz 10078 } 10079 foo 10080 unset -f foo 10081 foo 2>/dev/null || echo rab 10082 # alias overrides ksh function 10083 alias korn='echo bar' 10084 korn 10085 function korn { 10086 echo baz 10087 } 10088 korn 10089 # alias temporarily overrides POSIX function 10090 bla() { 10091 echo bfn 10092 } 10093 bla 10094 alias bla='echo bal' 10095 bla 10096 unalias bla 10097 bla 10098 expected-stdout: 10099 bar 10100 bar 10101 bar 10102 bar 10103 bar 10104 bfn 10105 bal 10106 bfn 10107 --- 10108 name: bash-function-parens 10109 description: 10110 ensure the keyword function is ignored when preceding 10111 POSIX style function declarations (bashism) 10112 stdin: 10113 mk() { 10114 echo '#!'"$__progname" 10115 echo "$1 {" 10116 echo ' echo "bar='\''$0'\'\" 10117 echo '}' 10118 print -r -- "${2:-foo}" 10119 } 10120 mk 'function foo' >f-korn 10121 mk 'foo ()' >f-dash 10122 mk 'function foo ()' >f-bash 10123 print '#!'"$__progname"'\nprint -r -- "${0%/f-argh}"' >f-argh 10124 chmod +x f-* 10125 u=$(./f-argh) 10126 x="korn: $(./f-korn)"; echo "${x/@("$u")/.}" 10127 x="dash: $(./f-dash)"; echo "${x/@("$u")/.}" 10128 x="bash: $(./f-bash)"; echo "${x/@("$u")/.}" 10129 expected-stdout: 10130 korn: bar='foo' 10131 dash: bar='./f-dash' 10132 bash: bar='./f-bash' 10133 --- 10134 name: integer-base-one-1 10135 description: 10136 check if the use of fake integer base 1 works 10137 stdin: 10138 set -U 10139 typeset -Uui16 i0=1# i1=1# 10140 typeset -i1 o0a=64 10141 typeset -i1 o1a=0x263A 10142 typeset -Uui1 o0b=0x7E 10143 typeset -Uui1 o1b=0xFDD0 10144 integer px=0xCAFE 'p0=1# ' p1=1# pl=1#f 10145 echo "in <$i0> <$i1>" 10146 echo "out <${o0a#1#}|${o0b#1#}> <${o1a#1#}|${o1b#1#}>" 10147 typeset -Uui1 i0 i1 10148 echo "pass <$px> <$p0> <$p1> <$pl> <${i0#1#}|${i1#1#}>" 10149 typeset -Uui16 tv1=1#~ tv2=1# tv3=1# tv4=1# tv5=1# tv6=1# tv7=1# tv8=1# 10150 echo "specX <${tv1#16#}> <${tv2#16#}> <${tv3#16#}> <${tv4#16#}> <${tv5#16#}> <${tv6#16#}> <${tv7#16#}> <${tv8#16#}>" 10151 typeset -i1 tv1 tv2 tv3 tv4 tv5 tv6 tv7 tv8 10152 echo "specW <${tv1#1#}> <${tv2#1#}> <${tv3#1#}> <${tv4#1#}> <${tv5#1#}> <${tv6#1#}> <${tv7#1#}> <${tv8#1#}>" 10153 typeset -i1 xs1=0xEF7F xs2=0xEF80 xs3=0xFDD0 10154 echo "specU <${xs1#1#}> <${xs2#1#}> <${xs3#1#}>" 10155 expected-stdout: 10156 in <16#EFEF> <16#20AC> 10157 out <@|~> <|> 10158 pass <16#cafe> <1# > <1#> <1#f> <|> 10159 specX <7E> <7F> <EF80> <EF81> <EFC0> <EFC1> <A0> <80> 10160 specW <~> <> <> <> <> <> <> <> 10161 specU <> <> <> 10162 --- 10163 name: integer-base-one-2a 10164 description: 10165 check if the use of fake integer base 1 stops at correct characters 10166 stdin: 10167 set -U 10168 integer x=1#foo 10169 echo /$x/ 10170 expected-stderr-pattern: 10171 /1#foo: unexpected 'oo'/ 10172 expected-exit: e != 0 10173 --- 10174 name: integer-base-one-2b 10175 description: 10176 check if the use of fake integer base 1 stops at correct characters 10177 stdin: 10178 set -U 10179 integer x=1# 10180 echo /$x/ 10181 expected-stderr-pattern: 10182 /1#: unexpected ''/ 10183 expected-exit: e != 0 10184 --- 10185 name: integer-base-one-2c1 10186 description: 10187 check if the use of fake integer base 1 stops at correct characters 10188 stdin: 10189 set -U 10190 integer x=1# 10191 echo /$x/ 10192 expected-stdout: 10193 /1#/ 10194 --- 10195 name: integer-base-one-2c2 10196 description: 10197 check if the use of fake integer base 1 stops at correct characters 10198 stdin: 10199 set +U 10200 integer x=1# 10201 echo /$x/ 10202 expected-stderr-pattern: 10203 /1#: unexpected ''/ 10204 expected-exit: e != 0 10205 --- 10206 name: integer-base-one-2d1 10207 description: 10208 check if the use of fake integer base 1 handles octets okay 10209 stdin: 10210 set -U 10211 typeset -i16 x=1# 10212 echo /$x/ # invalid utf-8 10213 expected-stdout: 10214 /16#efff/ 10215 --- 10216 name: integer-base-one-2d2 10217 description: 10218 check if the use of fake integer base 1 handles octets 10219 stdin: 10220 set -U 10221 typeset -i16 x=1# 10222 echo /$x/ # invalid 2-byte 10223 expected-stdout: 10224 /16#efc2/ 10225 --- 10226 name: integer-base-one-2d3 10227 description: 10228 check if the use of fake integer base 1 handles octets 10229 stdin: 10230 set -U 10231 typeset -i16 x=1# 10232 echo /$x/ # invalid 2-byte 10233 expected-stdout: 10234 /16#efef/ 10235 --- 10236 name: integer-base-one-2d4 10237 description: 10238 check if the use of fake integer base 1 stops at invalid input 10239 stdin: 10240 set -U 10241 typeset -i16 x=1# 10242 echo /$x/ # invalid 3-byte 10243 expected-stderr-pattern: 10244 /1#: unexpected ''/ 10245 expected-exit: e != 0 10246 --- 10247 name: integer-base-one-2d5 10248 description: 10249 check if the use of fake integer base 1 stops at invalid input 10250 stdin: 10251 set -U 10252 typeset -i16 x=1# 10253 echo /$x/ # non-minimalistic 10254 expected-stderr-pattern: 10255 /1#: unexpected ''/ 10256 expected-exit: e != 0 10257 --- 10258 name: integer-base-one-2d6 10259 description: 10260 check if the use of fake integer base 1 stops at invalid input 10261 stdin: 10262 set -U 10263 typeset -i16 x=1# 10264 echo /$x/ # non-minimalistic 10265 expected-stderr-pattern: 10266 /1#: unexpected ''/ 10267 expected-exit: e != 0 10268 --- 10269 name: integer-base-one-3As 10270 description: 10271 some sample code for hexdumping 10272 not NUL safe; input lines must be NL terminated 10273 stdin: 10274 { 10275 print 'Hello, World!\\\n' 10276 typeset -Uui16 i=0x100 10277 # change that to 0xFF once we can handle embedded 10278 # NUL characters in strings / here documents 10279 while (( i++ < 0x1FF )); do 10280 print -n "\x${i#16#1}" 10281 done 10282 print '\0z' 10283 } | { 10284 # integer-base-one-3As 10285 typeset -Uui16 -Z11 pos=0 10286 typeset -Uui16 -Z5 hv=2147483647 10287 typeset -i1 wc=0x0A 10288 dasc= 10289 nl=${wc#1#} 10290 while IFS= read -r line; do 10291 line=$line$nl 10292 while [[ -n $line ]]; do 10293 hv=1#${line::1} 10294 if (( (pos & 15) == 0 )); then 10295 (( pos )) && print -r -- "$dasc|" 10296 print -n "${pos#16#} " 10297 dasc=' |' 10298 fi 10299 print -n "${hv#16#} " 10300 if (( (hv < 32) || (hv > 126) )); then 10301 dasc=$dasc. 10302 else 10303 dasc=$dasc${line::1} 10304 fi 10305 (( (pos++ & 15) == 7 )) && print -n -- '- ' 10306 line=${line:1} 10307 done 10308 done 10309 while (( pos & 15 )); do 10310 print -n ' ' 10311 (( (pos++ & 15) == 7 )) && print -n -- '- ' 10312 done 10313 (( hv == 2147483647 )) || print -r -- "$dasc|" 10314 } 10315 expected-stdout: 10316 00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..| 10317 00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................| 10318 00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................| 10319 00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................| 10320 00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.| 10321 00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>| 10322 00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN| 10323 00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^| 10324 00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn| 10325 00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~| 10326 000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................| 10327 000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................| 10328 000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................| 10329 000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................| 10330 000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................| 10331 000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................| 10332 00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................| 10333 00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................| 10334 00000120 FF 7A 0A - |.z.| 10335 --- 10336 name: integer-base-one-3Ws 10337 description: 10338 some sample code for hexdumping Unicode 10339 not NUL safe; input lines must be NL terminated 10340 stdin: 10341 set -U 10342 { 10343 print 'Hello, World!\\\n' 10344 typeset -Uui16 i=0x100 10345 # change that to 0xFF once we can handle embedded 10346 # NUL characters in strings / here documents 10347 while (( i++ < 0x1FF )); do 10348 print -n "\u${i#16#1}" 10349 done 10350 print 10351 print \\xff # invalid utf-8 10352 print \\xc2 # invalid 2-byte 10353 print \\xef\\xbf\\xc0 # invalid 3-byte 10354 print \\xc0\\x80 # non-minimalistic 10355 print \\xe0\\x80\\x80 # non-minimalistic 10356 print '' # end of range 10357 print '\0z' # embedded NUL 10358 } | { 10359 # integer-base-one-3Ws 10360 typeset -Uui16 -Z11 pos=0 10361 typeset -Uui16 -Z7 hv 10362 typeset -i1 wc=0x0A 10363 typeset -i lpos 10364 dasc= 10365 nl=${wc#1#} 10366 while IFS= read -r line; do 10367 line=$line$nl 10368 lpos=0 10369 while (( lpos < ${#line} )); do 10370 wc=1#${line:(lpos++):1} 10371 if (( (wc < 32) || \ 10372 ((wc > 126) && (wc < 160)) )); then 10373 dch=. 10374 elif (( (wc & 0xFF80) == 0xEF80 )); then 10375 dch= 10376 else 10377 dch=${wc#1#} 10378 fi 10379 if (( (pos & 7) == 7 )); then 10380 dasc=$dasc$dch 10381 dch= 10382 elif (( (pos & 7) == 0 )); then 10383 (( pos )) && print -r -- "$dasc|" 10384 print -n "${pos#16#} " 10385 dasc=' |' 10386 fi 10387 let hv=wc 10388 print -n "${hv#16#} " 10389 (( (pos++ & 7) == 3 )) && \ 10390 print -n -- '- ' 10391 dasc=$dasc$dch 10392 done 10393 done 10394 while (( pos & 7 )); do 10395 print -n ' ' 10396 (( (pos++ & 7) == 3 )) && print -n -- '- ' 10397 done 10398 (( hv == 2147483647 )) || print -r -- "$dasc|" 10399 } 10400 expected-stdout: 10401 00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W| 10402 00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.| 10403 00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |...| 10404 00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........| 10405 00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........| 10406 00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........| 10407 00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"| 10408 00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*| 10409 00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012| 10410 00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:| 10411 00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB| 10412 00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ| 10413 00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR| 10414 00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ| 10415 00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab| 10416 00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij| 10417 00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr| 10418 00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz| 10419 00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....| 10420 00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........| 10421 000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........| 10422 000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........| 10423 000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |.....| 10424 000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA || 10425 000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 || 10426 000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA || 10427 000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 || 10428 000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA || 10429 000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 || 10430 000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA || 10431 000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 || 10432 000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA || 10433 00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 || 10434 00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA || 10435 00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |..| 10436 00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |..| 10437 00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |..| 10438 00000128 EFBE EFEF EFBF EFBF - 000A 007A 000A |.z.| 10439 --- 10440 name: integer-base-one-3Ar 10441 description: 10442 some sample code for hexdumping; NUL and binary safe 10443 stdin: 10444 { 10445 print 'Hello, World!\\\n' 10446 typeset -Uui16 i=0x100 10447 # change that to 0xFF once we can handle embedded 10448 # NUL characters in strings / here documents 10449 while (( i++ < 0x1FF )); do 10450 print -n "\x${i#16#1}" 10451 done 10452 print '\0z' 10453 } | { 10454 # integer-base-one-3Ar 10455 typeset -Uui16 -Z11 pos=0 10456 typeset -Uui16 -Z5 hv=2147483647 10457 dasc= 10458 if read -arN -1 line; then 10459 typeset -i1 line 10460 i=0 10461 while (( i < ${#line[*]} )); do 10462 hv=${line[i++]} 10463 if (( (pos & 15) == 0 )); then 10464 (( pos )) && print -r -- "$dasc|" 10465 print -n "${pos#16#} " 10466 dasc=' |' 10467 fi 10468 print -n "${hv#16#} " 10469 if (( (hv < 32) || (hv > 126) )); then 10470 dasc=$dasc. 10471 else 10472 dasc=$dasc${line[i-1]#1#} 10473 fi 10474 (( (pos++ & 15) == 7 )) && print -n -- '- ' 10475 done 10476 fi 10477 while (( pos & 15 )); do 10478 print -n ' ' 10479 (( (pos++ & 15) == 7 )) && print -n -- '- ' 10480 done 10481 (( hv == 2147483647 )) || print -r -- "$dasc|" 10482 } 10483 expected-stdout: 10484 00000000 48 65 6C 6C 6F 2C 20 57 - 6F 72 6C 64 21 5C 0A E3 |Hello, World!\..| 10485 00000010 81 93 E3 82 93 E3 81 AB - E3 81 A1 E3 81 AF EF BC |................| 10486 00000020 81 0A 01 02 03 04 05 06 - 07 08 09 0A 0B 0C 0D 0E |................| 10487 00000030 0F 10 11 12 13 14 15 16 - 17 18 19 1A 1B 1C 1D 1E |................| 10488 00000040 1F 20 21 22 23 24 25 26 - 27 28 29 2A 2B 2C 2D 2E |. !"#$%&'()*+,-.| 10489 00000050 2F 30 31 32 33 34 35 36 - 37 38 39 3A 3B 3C 3D 3E |/0123456789:;<=>| 10490 00000060 3F 40 41 42 43 44 45 46 - 47 48 49 4A 4B 4C 4D 4E |?@ABCDEFGHIJKLMN| 10491 00000070 4F 50 51 52 53 54 55 56 - 57 58 59 5A 5B 5C 5D 5E |OPQRSTUVWXYZ[\]^| 10492 00000080 5F 60 61 62 63 64 65 66 - 67 68 69 6A 6B 6C 6D 6E |_`abcdefghijklmn| 10493 00000090 6F 70 71 72 73 74 75 76 - 77 78 79 7A 7B 7C 7D 7E |opqrstuvwxyz{|}~| 10494 000000A0 7F 80 81 82 83 84 85 86 - 87 88 89 8A 8B 8C 8D 8E |................| 10495 000000B0 8F 90 91 92 93 94 95 96 - 97 98 99 9A 9B 9C 9D 9E |................| 10496 000000C0 9F A0 A1 A2 A3 A4 A5 A6 - A7 A8 A9 AA AB AC AD AE |................| 10497 000000D0 AF B0 B1 B2 B3 B4 B5 B6 - B7 B8 B9 BA BB BC BD BE |................| 10498 000000E0 BF C0 C1 C2 C3 C4 C5 C6 - C7 C8 C9 CA CB CC CD CE |................| 10499 000000F0 CF D0 D1 D2 D3 D4 D5 D6 - D7 D8 D9 DA DB DC DD DE |................| 10500 00000100 DF E0 E1 E2 E3 E4 E5 E6 - E7 E8 E9 EA EB EC ED EE |................| 10501 00000110 EF F0 F1 F2 F3 F4 F5 F6 - F7 F8 F9 FA FB FC FD FE |................| 10502 00000120 FF 00 7A 0A - |..z.| 10503 --- 10504 name: integer-base-one-3Wr 10505 description: 10506 some sample code for hexdumping Unicode; NUL and binary safe 10507 stdin: 10508 set -U 10509 { 10510 print 'Hello, World!\\\n' 10511 typeset -Uui16 i=0x100 10512 # change that to 0xFF once we can handle embedded 10513 # NUL characters in strings / here documents 10514 while (( i++ < 0x1FF )); do 10515 print -n "\u${i#16#1}" 10516 done 10517 print 10518 print \\xff # invalid utf-8 10519 print \\xc2 # invalid 2-byte 10520 print \\xef\\xbf\\xc0 # invalid 3-byte 10521 print \\xc0\\x80 # non-minimalistic 10522 print \\xe0\\x80\\x80 # non-minimalistic 10523 print '' # end of range 10524 print '\0z' # embedded NUL 10525 } | { 10526 # integer-base-one-3Wr 10527 typeset -Uui16 -Z11 pos=0 10528 typeset -Uui16 -Z7 hv=2147483647 10529 dasc= 10530 if read -arN -1 line; then 10531 typeset -i1 line 10532 i=0 10533 while (( i < ${#line[*]} )); do 10534 hv=${line[i++]} 10535 if (( (hv < 32) || \ 10536 ((hv > 126) && (hv < 160)) )); then 10537 dch=. 10538 elif (( (hv & 0xFF80) == 0xEF80 )); then 10539 dch= 10540 else 10541 dch=${line[i-1]#1#} 10542 fi 10543 if (( (pos & 7) == 7 )); then 10544 dasc=$dasc$dch 10545 dch= 10546 elif (( (pos & 7) == 0 )); then 10547 (( pos )) && print -r -- "$dasc|" 10548 print -n "${pos#16#} " 10549 dasc=' |' 10550 fi 10551 print -n "${hv#16#} " 10552 (( (pos++ & 7) == 3 )) && \ 10553 print -n -- '- ' 10554 dasc=$dasc$dch 10555 done 10556 fi 10557 while (( pos & 7 )); do 10558 print -n ' ' 10559 (( (pos++ & 7) == 3 )) && print -n -- '- ' 10560 done 10561 (( hv == 2147483647 )) || print -r -- "$dasc|" 10562 } 10563 expected-stdout: 10564 00000000 0048 0065 006C 006C - 006F 002C 0020 0057 |Hello, W| 10565 00000008 006F 0072 006C 0064 - 0021 005C 000A 3053 |orld!\.| 10566 00000010 3093 306B 3061 306F - FF01 000A 0001 0002 |...| 10567 00000018 0003 0004 0005 0006 - 0007 0008 0009 000A |........| 10568 00000020 000B 000C 000D 000E - 000F 0010 0011 0012 |........| 10569 00000028 0013 0014 0015 0016 - 0017 0018 0019 001A |........| 10570 00000030 001B 001C 001D 001E - 001F 0020 0021 0022 |..... !"| 10571 00000038 0023 0024 0025 0026 - 0027 0028 0029 002A |#$%&'()*| 10572 00000040 002B 002C 002D 002E - 002F 0030 0031 0032 |+,-./012| 10573 00000048 0033 0034 0035 0036 - 0037 0038 0039 003A |3456789:| 10574 00000050 003B 003C 003D 003E - 003F 0040 0041 0042 |;<=>?@AB| 10575 00000058 0043 0044 0045 0046 - 0047 0048 0049 004A |CDEFGHIJ| 10576 00000060 004B 004C 004D 004E - 004F 0050 0051 0052 |KLMNOPQR| 10577 00000068 0053 0054 0055 0056 - 0057 0058 0059 005A |STUVWXYZ| 10578 00000070 005B 005C 005D 005E - 005F 0060 0061 0062 |[\]^_`ab| 10579 00000078 0063 0064 0065 0066 - 0067 0068 0069 006A |cdefghij| 10580 00000080 006B 006C 006D 006E - 006F 0070 0071 0072 |klmnopqr| 10581 00000088 0073 0074 0075 0076 - 0077 0078 0079 007A |stuvwxyz| 10582 00000090 007B 007C 007D 007E - 007F 0080 0081 0082 |{|}~....| 10583 00000098 0083 0084 0085 0086 - 0087 0088 0089 008A |........| 10584 000000A0 008B 008C 008D 008E - 008F 0090 0091 0092 |........| 10585 000000A8 0093 0094 0095 0096 - 0097 0098 0099 009A |........| 10586 000000B0 009B 009C 009D 009E - 009F 00A0 00A1 00A2 |.....| 10587 000000B8 00A3 00A4 00A5 00A6 - 00A7 00A8 00A9 00AA || 10588 000000C0 00AB 00AC 00AD 00AE - 00AF 00B0 00B1 00B2 || 10589 000000C8 00B3 00B4 00B5 00B6 - 00B7 00B8 00B9 00BA || 10590 000000D0 00BB 00BC 00BD 00BE - 00BF 00C0 00C1 00C2 || 10591 000000D8 00C3 00C4 00C5 00C6 - 00C7 00C8 00C9 00CA || 10592 000000E0 00CB 00CC 00CD 00CE - 00CF 00D0 00D1 00D2 || 10593 000000E8 00D3 00D4 00D5 00D6 - 00D7 00D8 00D9 00DA || 10594 000000F0 00DB 00DC 00DD 00DE - 00DF 00E0 00E1 00E2 || 10595 000000F8 00E3 00E4 00E5 00E6 - 00E7 00E8 00E9 00EA || 10596 00000100 00EB 00EC 00ED 00EE - 00EF 00F0 00F1 00F2 || 10597 00000108 00F3 00F4 00F5 00F6 - 00F7 00F8 00F9 00FA || 10598 00000110 00FB 00FC 00FD 00FE - 00FF 000A EFFF 000A |..| 10599 00000118 EFC2 000A EFEF EFBF - EFC0 000A EFC0 EF80 |..| 10600 00000120 000A EFE0 EF80 EF80 - 000A FFFD EFEF EFBF |..| 10601 00000128 EFBE EFEF EFBF EFBF - 000A 0000 007A 000A |..z.| 10602 --- 10603 name: integer-base-one-4 10604 description: 10605 Check if ksh93-style base-one integers work 10606 category: !smksh 10607 stdin: 10608 set -U 10609 echo 1 $(('a')) 10610 (echo 2f $(('aa'))) 2>&1 | sed "s/^[^']*'/2p '/" 10611 echo 3 $(('')) 10612 x="'a'" 10613 echo "4 <$x>" 10614 echo 5 $(($x)) 10615 echo 6 $((x)) 10616 expected-stdout: 10617 1 97 10618 2p 'aa': multi-character character constant 10619 3 8230 10620 4 <'a'> 10621 5 97 10622 6 97 10623 --- 10624 name: integer-base-one-5A 10625 description: 10626 Check to see that were NUL and Unicode safe 10627 category: !shell:ebcdic-yes 10628 stdin: 10629 set +U 10630 print 'a\0b\xfdz' >x 10631 read -a y <x 10632 set -U 10633 typeset -Uui16 y 10634 print ${y[*]} . 10635 expected-stdout: 10636 16#61 16#0 16#62 16#FD 16#7A . 10637 --- 10638 name: integer-base-one-5E 10639 description: 10640 Check to see that were NUL and Unicode safe 10641 category: !shell:ebcdic-no 10642 stdin: 10643 set +U 10644 print 'a\0b\xfdz' >x 10645 read -a y <x 10646 set -U 10647 typeset -Uui16 y 10648 print ${y[*]} . 10649 expected-stdout: 10650 16#81 16#0 16#82 16#FD 16#A9 . 10651 --- 10652 name: integer-base-one-5W 10653 description: 10654 Check to see that were NUL and Unicode safe 10655 stdin: 10656 set -U 10657 print 'a\0bc' >x 10658 read -a y <x 10659 set +U 10660 typeset -Uui16 y 10661 print ${y[*]} . 10662 expected-stdout: 10663 16#61 16#0 16#62 16#20AC 16#63 . 10664 --- 10665 name: ulimit-1 10666 description: 10667 Check that ulimit as used in dot.mksh works or is stubbed 10668 stdin: 10669 ulimit -c 0 10670 --- 10671 name: ulimit-2 10672 description: 10673 Check if we can use a specific syntax idiom for ulimit 10674 XXX Haiku works, but only for -n and -V 10675 category: !os:haiku,!os:syllable 10676 stdin: 10677 if ! x=$(ulimit -d) || [[ $x = unknown ]]; then 10678 #echo expected to fail on this OS 10679 echo okay 10680 else 10681 ulimit -dS $x && echo okay 10682 fi 10683 expected-stdout: 10684 okay 10685 --- 10686 name: redir-1 10687 description: 10688 Check some of the most basic invariants of I/O redirection 10689 stdin: 10690 i=0 10691 function d { 10692 print o$i. 10693 print -u2 e$((i++)). 10694 } 10695 d >a 2>b 10696 echo =1= 10697 cat a 10698 echo =2= 10699 cat b 10700 echo =3= 10701 d 2>&1 >c 10702 echo =4= 10703 cat c 10704 echo =5= 10705 expected-stdout: 10706 =1= 10707 o0. 10708 =2= 10709 e0. 10710 =3= 10711 e1. 10712 =4= 10713 o1. 10714 =5= 10715 --- 10716 name: bashiop-1 10717 description: 10718 Check if GNU bash-like I/O redirection works 10719 Part 1: this is also supported by GNU bash 10720 stdin: 10721 exec 3>&1 10722 function threeout { 10723 echo ras 10724 echo dwa >&2 10725 echo tri >&3 10726 } 10727 threeout &>foo 10728 echo === 10729 cat foo 10730 expected-stdout: 10731 tri 10732 === 10733 ras 10734 dwa 10735 --- 10736 name: bashiop-2a 10737 description: 10738 Check if GNU bash-like I/O redirection works 10739 Part 2: this is *not* supported by GNU bash 10740 stdin: 10741 exec 3>&1 10742 function threeout { 10743 echo ras 10744 echo dwa >&2 10745 echo tri >&3 10746 } 10747 threeout 3&>foo 10748 echo === 10749 cat foo 10750 expected-stdout: 10751 ras 10752 === 10753 dwa 10754 tri 10755 --- 10756 name: bashiop-2b 10757 description: 10758 Check if GNU bash-like I/O redirection works 10759 Part 2: this is *not* supported by GNU bash 10760 stdin: 10761 exec 3>&1 10762 function threeout { 10763 echo ras 10764 echo dwa >&2 10765 echo tri >&3 10766 } 10767 threeout 3>foo &>&3 10768 echo === 10769 cat foo 10770 expected-stdout: 10771 === 10772 ras 10773 dwa 10774 tri 10775 --- 10776 name: bashiop-2c 10777 description: 10778 Check if GNU bash-like I/O redirection works 10779 Part 2: this is supported by GNU bash 4 only 10780 stdin: 10781 echo mir >foo 10782 set -o noclobber 10783 exec 3>&1 10784 function threeout { 10785 echo ras 10786 echo dwa >&2 10787 echo tri >&3 10788 } 10789 threeout &>>foo 10790 echo === 10791 cat foo 10792 expected-stdout: 10793 tri 10794 === 10795 mir 10796 ras 10797 dwa 10798 --- 10799 name: bashiop-3a 10800 description: 10801 Check if GNU bash-like I/O redirection fails correctly 10802 Part 1: this is also supported by GNU bash 10803 stdin: 10804 echo mir >foo 10805 set -o noclobber 10806 exec 3>&1 10807 function threeout { 10808 echo ras 10809 echo dwa >&2 10810 echo tri >&3 10811 } 10812 threeout &>foo 10813 echo === 10814 cat foo 10815 expected-stdout: 10816 === 10817 mir 10818 expected-stderr-pattern: /.*: can't (create|overwrite) .*/ 10819 --- 10820 name: bashiop-3b 10821 description: 10822 Check if GNU bash-like I/O redirection fails correctly 10823 Part 2: this is *not* supported by GNU bash 10824 stdin: 10825 echo mir >foo 10826 set -o noclobber 10827 exec 3>&1 10828 function threeout { 10829 echo ras 10830 echo dwa >&2 10831 echo tri >&3 10832 } 10833 threeout &>|foo 10834 echo === 10835 cat foo 10836 expected-stdout: 10837 tri 10838 === 10839 ras 10840 dwa 10841 --- 10842 name: bashiop-4 10843 description: 10844 Check if GNU bash-like I/O redirection works 10845 Part 4: this is also supported by GNU bash, 10846 but failed in some mksh versions 10847 stdin: 10848 exec 3>&1 10849 function threeout { 10850 echo ras 10851 echo dwa >&2 10852 echo tri >&3 10853 } 10854 function blubb { 10855 [[ -e bar ]] && threeout "$bf" &>foo 10856 } 10857 blubb 10858 echo -n >bar 10859 blubb 10860 echo === 10861 cat foo 10862 expected-stdout: 10863 tri 10864 === 10865 ras 10866 dwa 10867 --- 10868 name: bashiop-5 10869 description: 10870 Check if GNU bash-like I/O redirection is only supported 10871 in !POSIX !sh mode as it breaks existing scripts' syntax 10872 stdin: 10873 :>x; echo 1 "$("$__progname" -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" . 10874 :>x; echo 2 "$("$__progname" -o posix -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" . 10875 :>x; echo 3 "$("$__progname" -o sh -c 'echo foo>/dev/null&>x echo bar')" = "$(<x)" . 10876 expected-stdout: 10877 1 = foo echo bar . 10878 2 = bar . 10879 3 = bar . 10880 --- 10881 name: oksh-eval 10882 description: 10883 Check expansions. 10884 stdin: 10885 a= 10886 for n in ${a#*=}; do echo 1hu ${n} .; done 10887 for n in "${a#*=}"; do echo 1hq ${n} .; done 10888 for n in ${a##*=}; do echo 2hu ${n} .; done 10889 for n in "${a##*=}"; do echo 2hq ${n} .; done 10890 for n in ${a%=*}; do echo 1pu ${n} .; done 10891 for n in "${a%=*}"; do echo 1pq ${n} .; done 10892 for n in ${a%%=*}; do echo 2pu ${n} .; done 10893 for n in "${a%%=*}"; do echo 2pq ${n} .; done 10894 expected-stdout: 10895 1hq . 10896 2hq . 10897 1pq . 10898 2pq . 10899 --- 10900 name: oksh-and-list-error-1 10901 description: 10902 Test exit status of rightmost element in 2 element && list in -e mode 10903 stdin: 10904 true && false 10905 echo "should not print" 10906 arguments: !-e! 10907 expected-exit: e != 0 10908 --- 10909 name: oksh-and-list-error-2 10910 description: 10911 Test exit status of rightmost element in 3 element && list in -e mode 10912 stdin: 10913 true && true && false 10914 echo "should not print" 10915 arguments: !-e! 10916 expected-exit: e != 0 10917 --- 10918 name: oksh-or-list-error-1 10919 description: 10920 Test exit status of || list in -e mode 10921 stdin: 10922 false || false 10923 echo "should not print" 10924 arguments: !-e! 10925 expected-exit: e != 0 10926 --- 10927 name: oksh-longline-crash 10928 description: 10929 This used to cause a core dump 10930 stdin: 10931 ulimit -c 0 10932 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" 10933 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" 10934 for deplib in $deplibs; do 10935 case $deplib in 10936 -L*) 10937 new_libs="$deplib $new_libs" 10938 ;; 10939 *) 10940 case " $specialdeplibs " in 10941 *" $deplib "*) 10942 new_libs="$deplib $new_libs";; 10943 esac 10944 ;; 10945 esac 10946 done 10947 --- 10948 name: oksh-seterror-1 10949 description: 10950 The -e flag should be ignored when executing a compound list 10951 followed by an if statement. 10952 stdin: 10953 if true; then false && false; fi 10954 true 10955 arguments: !-e! 10956 expected-exit: e == 0 10957 --- 10958 name: oksh-seterror-2 10959 description: 10960 The -e flag should be ignored when executing a compound list 10961 followed by an if statement. 10962 stdin: 10963 if true; then if true; then false && false; fi; fi 10964 true 10965 arguments: !-e! 10966 expected-exit: e == 0 10967 --- 10968 name: oksh-seterror-3 10969 description: 10970 The -e flag should be ignored when executing a compound list 10971 followed by an elif statement. 10972 stdin: 10973 if true; then :; elif true; then false && false; fi 10974 arguments: !-e! 10975 expected-exit: e == 0 10976 --- 10977 name: oksh-seterror-4 10978 description: 10979 The -e flag should be ignored when executing a pipeline 10980 beginning with '!' 10981 stdin: 10982 for i in 1 2 3 10983 do 10984 false && false 10985 true || false 10986 done 10987 arguments: !-e! 10988 expected-exit: e == 0 10989 --- 10990 name: oksh-seterror-5 10991 description: 10992 The -e flag should be ignored when executing a pipeline 10993 beginning with '!' 10994 stdin: 10995 ! true | false 10996 true 10997 arguments: !-e! 10998 expected-exit: e == 0 10999 --- 11000 name: oksh-seterror-6 11001 description: 11002 When trapping ERR and EXIT, both traps should run in -e mode 11003 when an error occurs. 11004 stdin: 11005 trap 'echo EXIT' EXIT 11006 trap 'echo ERR' ERR 11007 set -e 11008 false 11009 echo DONE 11010 exit 0 11011 arguments: !-e! 11012 expected-exit: e != 0 11013 expected-stdout: 11014 ERR 11015 EXIT 11016 --- 11017 name: oksh-seterror-7 11018 description: 11019 The -e flag within a command substitution should be honored 11020 stdin: 11021 echo $( set -e; false; echo foo ) 11022 arguments: !-e! 11023 expected-stdout: 11024 11025 --- 11026 name: oksh-input-comsub 11027 description: 11028 A command substitution using input redirection should exit with 11029 failure if the input file does not exist. 11030 stdin: 11031 var=$(< non-existent) 11032 expected-exit: e != 0 11033 expected-stderr-pattern: /non-existent/ 11034 --- 11035 name: oksh-empty-for-list 11036 description: 11037 A for list which expands to zero items should not execute the body. 11038 stdin: 11039 set foo bar baz ; for out in ; do echo $out ; done 11040 --- 11041 name: oksh-varfunction-mod1 11042 description: 11043 (Inspired by PR 2450 on OpenBSD.) Calling 11044 FOO=bar f 11045 where f is a ksh style function, should not set FOO in the current 11046 env. If f is a Bourne style function, FOO should be set. Furthermore, 11047 the function should receive a correct value of FOO. However, differing 11048 from oksh, setting FOO in the function itself must change the value in 11049 setting FOO in the function itself should not change the value in 11050 global environment. 11051 stdin: 11052 print '#!'"$__progname"'\nunset RANDOM\nexport | while IFS= read -r' \ 11053 'RANDOM; do eval '\''print -r -- "$RANDOM=$'\''"$RANDOM"'\'\"\'\; \ 11054 done >env; chmod +x env; PATH=.$PATHSEP$PATH 11055 function k { 11056 if [ x$FOO != xbar ]; then 11057 echo 1 11058 return 1 11059 fi 11060 x=$(env | grep FOO) 11061 if [ "x$x" != "xFOO=bar" ]; then 11062 echo 2 11063 return 1; 11064 fi 11065 FOO=foo 11066 return 0 11067 } 11068 b () { 11069 if [ x$FOO != xbar ]; then 11070 echo 3 11071 return 1 11072 fi 11073 x=$(env | grep FOO) 11074 if [ "x$x" != "xFOO=bar" ]; then 11075 echo 4 11076 return 1; 11077 fi 11078 FOO=foo 11079 return 0 11080 } 11081 FOO=bar k 11082 if [ $? != 0 ]; then 11083 exit 1 11084 fi 11085 if [ x$FOO != x ]; then 11086 exit 1 11087 fi 11088 FOO=bar b 11089 if [ $? != 0 ]; then 11090 exit 1 11091 fi 11092 if [ x$FOO != xfoo ]; then 11093 exit 1 11094 fi 11095 FOO=barbar 11096 FOO=bar k 11097 if [ $? != 0 ]; then 11098 exit 1 11099 fi 11100 if [ x$FOO != xbarbar ]; then 11101 exit 1 11102 fi 11103 FOO=bar b 11104 if [ $? != 0 ]; then 11105 exit 1 11106 fi 11107 if [ x$FOO != xfoo ]; then 11108 exit 1 11109 fi 11110 --- 11111 name: fd-cloexec-1 11112 description: 11113 Verify that file descriptors > 2 are private for Korn shells 11114 AT&T ksh93 does this still, which means we must keep it as well 11115 XXX fails on some old Perl installations 11116 need-pass: no 11117 stdin: 11118 cat >cld <<-EOF 11119 #!$__perlname 11120 open(my \$fh, ">&", 9) or die "E: open \$!"; 11121 syswrite(\$fh, "Fowl\\n", 5) or die "E: write \$!"; 11122 EOF 11123 chmod +x cld 11124 exec 9>&1 11125 ./cld 11126 expected-exit: e != 0 11127 expected-stderr-pattern: 11128 /E: open / 11129 --- 11130 name: fd-cloexec-2 11131 description: 11132 Verify that file descriptors > 2 are not private for POSIX shells 11133 See Debian Bug #154540, Closes: #499139 11134 XXX fails on some old Perl installations 11135 need-pass: no 11136 stdin: 11137 cat >cld <<-EOF 11138 #!$__perlname 11139 open(my \$fh, ">&", 9) or die "E: open \$!"; 11140 syswrite(\$fh, "Fowl\\n", 5) or die "E: write \$!"; 11141 EOF 11142 chmod +x cld 11143 test -n "$POSH_VERSION" || set -o posix 11144 exec 9>&1 11145 ./cld 11146 expected-stdout: 11147 Fowl 11148 --- 11149 name: comsub-1a 11150 description: 11151 COMSUB are now parsed recursively, so this works 11152 see also regression-6: matching parenthess bug 11153 Fails on: pdksh bash2 bash3 zsh 11154 Passes on: bash4 ksh93 mksh(20110313+) 11155 stdin: 11156 echo 1 $(case 1 in (1) echo yes;; (2) echo no;; esac) . 11157 echo 2 $(case 1 in 1) echo yes;; 2) echo no;; esac) . 11158 TEST=1234; echo 3 ${TEST: $(case 1 in (1) echo 1;; (*) echo 2;; esac)} . 11159 TEST=5678; echo 4 ${TEST: $(case 1 in 1) echo 1;; *) echo 2;; esac)} . 11160 a=($(case 1 in (1) echo 1;; (*) echo 2;; esac)); echo 5 ${a[0]} . 11161 a=($(case 1 in 1) echo 1;; *) echo 2;; esac)); echo 6 ${a[0]} . 11162 expected-stdout: 11163 1 yes . 11164 2 yes . 11165 3 234 . 11166 4 678 . 11167 5 1 . 11168 6 1 . 11169 --- 11170 name: comsub-1b 11171 description: 11172 COMSUB are now parsed recursively, so this works 11173 Fails on: pdksh bash2 bash3 bash4 zsh 11174 Passes on: ksh93 mksh(20110313+) 11175 stdin: 11176 echo 1 $(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10)) . 11177 echo 2 $(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20)) . 11178 (( a = $(case 1 in (1) echo 1;; (*) echo 2;; esac) )); echo 3 $a . 11179 (( a = $(case 1 in 1) echo 1;; *) echo 2;; esac) )); echo 4 $a . 11180 a=($(($(case 1 in (1) echo 1;; (*) echo 2;; esac)+10))); echo 5 ${a[0]} . 11181 a=($(($(case 1 in 1) echo 1;; *) echo 2;; esac)+20))); echo 6 ${a[0]} . 11182 expected-stdout: 11183 1 11 . 11184 2 21 . 11185 3 1 . 11186 4 1 . 11187 5 11 . 11188 6 21 . 11189 --- 11190 name: comsub-2 11191 description: 11192 RedHat BZ#496791 another case of missing recursion 11193 in parsing COMSUB expressions 11194 Fails on: pdksh bash2 bash3 bash4 zsh 11195 Passes on: ksh93 mksh(20110305+) 11196 bash[34] seem to choke on comment ending with backslash-newline 11197 stdin: 11198 # a comment with " ' \ 11199 x=$( 11200 echo yes 11201 # a comment with " ' \ 11202 ) 11203 echo $x 11204 expected-stdout: 11205 yes 11206 --- 11207 name: comsub-3 11208 description: 11209 Extended test for COMSUB explaining why a recursive parser 11210 is a must (a non-recursive parser cannot pass all three of 11211 these test cases, especially the # is difficult) 11212 stdin: 11213 print '#!'"$__progname"'\necho 1234' >id; chmod +x id; PATH=.$PATHSEP$PATH 11214 echo $(typeset -i10 x=16#20; echo $x) 11215 echo $(typeset -Uui16 x=16#$(id -u) 11216 ) . 11217 echo $(c=1; d=1 11218 typeset -Uui16 a=36#foo; c=2 11219 typeset -Uui16 b=36 #foo; d=2 11220 echo $a $b $c $d) 11221 expected-stdout: 11222 32 11223 . 11224 16#4F68 16#24 2 1 11225 --- 11226 name: comsub-4 11227 description: 11228 Check the tree dump functions for !MKSH_SMALL functionality 11229 category: !smksh 11230 stdin: 11231 x() { case $1 in u) echo x ;;& *) echo $1 ;; esac; } 11232 typeset -f x 11233 expected-stdout: 11234 x() { 11235 case $1 in 11236 (u) 11237 \echo x 11238 ;| 11239 (*) 11240 \echo $1 11241 ;; 11242 esac 11243 } 11244 --- 11245 name: comsub-5 11246 description: 11247 Check COMSUB works with aliases (does not expand them twice) 11248 and reentrancy safety 11249 stdin: 11250 print '#!'"$__progname"'\nfor x in "$@"; do print -r -- "$x"; done' >pfn 11251 chmod +x pfn 11252 alias echo='echo a' 11253 foo() { 11254 echo moo 11255 ./pfn "$(echo foo)" 11256 } 11257 ./pfn "$(echo b)" 11258 typeset -f foo >x 11259 cat x 11260 foo 11261 . ./x 11262 typeset -f foo 11263 foo 11264 expected-stdout: 11265 a b 11266 foo() { 11267 \echo a moo 11268 ./pfn "$(\echo a foo )" 11269 } 11270 a moo 11271 a foo 11272 foo() { 11273 \echo a moo 11274 ./pfn "$(\echo a foo )" 11275 } 11276 a moo 11277 a foo 11278 --- 11279 name: comsub-torture 11280 description: 11281 Check the tree dump functions work correctly 11282 stdin: 11283 if [[ -z $__progname ]]; then echo >&2 call me with __progname; exit 1; fi 11284 while IFS= read -r line; do 11285 if [[ $line = '#1' ]]; then 11286 lastf=0 11287 continue 11288 elif [[ $line = EOFN* ]]; then 11289 fbody=$fbody$'\n'$line 11290 continue 11291 elif [[ $line != '#'* ]]; then 11292 fbody=$fbody$'\n\t'$line 11293 continue 11294 fi 11295 if (( lastf )); then 11296 x="inline_${nextf}() {"$fbody$'\n}\n' 11297 print -nr -- "$x" 11298 print -r -- "${x}typeset -f inline_$nextf" | "$__progname" 11299 x="function comsub_$nextf { x=\$("$fbody$'\n); }\n' 11300 print -nr -- "$x" 11301 print -r -- "${x}typeset -f comsub_$nextf" | "$__progname" 11302 x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n' 11303 print -nr -- "$x" 11304 print -r -- "${x}typeset -f reread_$nextf" | "$__progname" 11305 fi 11306 lastf=1 11307 fbody= 11308 nextf=${line#?} 11309 done <<'EOD' 11310 #1 11311 #TCOM 11312 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" 11313 #TPAREN_TPIPE_TLIST 11314 (echo $foo | tr -dc 0-9; echo) 11315 #TAND_TOR 11316 cmd && echo ja || echo nein 11317 #TSELECT 11318 select file in *; do echo "<$file>" ; break ; done 11319 #TFOR_TTIME 11320 time for i in {1,2,3} ; do echo $i ; done 11321 #TCASE 11322 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zhlen;; esac 11323 #TIF_TBANG_TDBRACKET_TELIF 11324 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi 11325 #TWHILE 11326 i=1; while (( i < 10 )); do echo $i; let ++i; done 11327 #TUNTIL 11328 i=10; until (( !--i )) ; do echo $i; done 11329 #TCOPROC 11330 cat * |& ls 11331 #TFUNCT_TBRACE_TASYNC 11332 function korn { echo eins; echo zwei ; } 11333 bourne () { logger * & } 11334 #IOREAD_IOCAT 11335 tr x u 0<foo >>bar 11336 #IOWRITE_IOCLOB_IOHERE_noIOSKIP 11337 cat >|bar <<'EOFN' 11338 foo 11339 EOFN 11340 #IOWRITE_noIOCLOB_IOHERE_IOSKIP 11341 cat 1>bar <<-EOFI 11342 foo 11343 EOFI 11344 #IORDWR_IODUP 11345 sh 1<>/dev/console 0<&1 2>&1 11346 #COMSUB_EXPRSUB_FUNSUB_VALSUB 11347 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;} 11348 #QCHAR_OQUOTE_CQUOTE 11349 echo fo\ob\"a\`r\'b\$az 11350 echo "fo\ob\"a\`r\'b\$az" 11351 echo 'fo\ob\"a\`r'\''b\$az' 11352 #OSUBST_CSUBST_OPAT_SPAT_CPAT 11353 [[ ${foo#bl\(u\)b} = @(bar|baz) ]] 11354 #heredoc_closed 11355 x=$(cat <<EOFN 11356 note there must be no space between EOFN and ) 11357 EOFN); echo $x 11358 #heredoc_space 11359 x=$(cat <<EOFN\ 11360 note the space between EOFN and ) is actually part of the here document marker 11361 EOFN ); echo $x 11362 #patch_motd 11363 x=$(sysctl -n kern.version | sed 1q) 11364 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \ 11365 ed -s /etc/motd 2>&1 <<-EOF 11366 1,/^\$/d 11367 0a 11368 $x 11369 11370 . 11371 wq 11372 EOF)" = @(?) ]] && rm -f /etc/motd 11373 if [[ ! -s /etc/motd ]]; then 11374 install -c -o root -g wheel -m 664 /dev/null /etc/motd 11375 print -- "$x\n" >/etc/motd 11376 fi 11377 #wdarrassign 11378 case x in 11379 x) a+=b; c+=(d e) 11380 esac 11381 #0 11382 EOD 11383 expected-stdout: 11384 inline_TCOM() { 11385 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" 11386 } 11387 inline_TCOM() { 11388 vara=1 varb="2 3" \cmd arg1 $arg2 "$arg3 4" 11389 } 11390 function comsub_TCOM { x=$( 11391 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" 11392 ); } 11393 function comsub_TCOM { 11394 x=$(vara=1 varb="2 3" \cmd arg1 $arg2 "$arg3 4" ) 11395 } 11396 function reread_TCOM { x=$(( 11397 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" 11398 )|tr u x); } 11399 function reread_TCOM { 11400 x=$( ( vara=1 varb="2 3" \cmd arg1 $arg2 "$arg3 4" ) | \tr u x ) 11401 } 11402 inline_TPAREN_TPIPE_TLIST() { 11403 (echo $foo | tr -dc 0-9; echo) 11404 } 11405 inline_TPAREN_TPIPE_TLIST() { 11406 ( \echo $foo | \tr -dc 0-9 11407 \echo ) 11408 } 11409 function comsub_TPAREN_TPIPE_TLIST { x=$( 11410 (echo $foo | tr -dc 0-9; echo) 11411 ); } 11412 function comsub_TPAREN_TPIPE_TLIST { 11413 x=$( ( \echo $foo | \tr -dc 0-9 ; \echo ) ) 11414 } 11415 function reread_TPAREN_TPIPE_TLIST { x=$(( 11416 (echo $foo | tr -dc 0-9; echo) 11417 )|tr u x); } 11418 function reread_TPAREN_TPIPE_TLIST { 11419 x=$( ( ( \echo $foo | \tr -dc 0-9 ; \echo ) ) | \tr u x ) 11420 } 11421 inline_TAND_TOR() { 11422 cmd && echo ja || echo nein 11423 } 11424 inline_TAND_TOR() { 11425 \cmd && \echo ja || \echo nein 11426 } 11427 function comsub_TAND_TOR { x=$( 11428 cmd && echo ja || echo nein 11429 ); } 11430 function comsub_TAND_TOR { 11431 x=$(\cmd && \echo ja || \echo nein ) 11432 } 11433 function reread_TAND_TOR { x=$(( 11434 cmd && echo ja || echo nein 11435 )|tr u x); } 11436 function reread_TAND_TOR { 11437 x=$( ( \cmd && \echo ja || \echo nein ) | \tr u x ) 11438 } 11439 inline_TSELECT() { 11440 select file in *; do echo "<$file>" ; break ; done 11441 } 11442 inline_TSELECT() { 11443 select file in * 11444 do 11445 \echo "<$file>" 11446 \break 11447 done 11448 } 11449 function comsub_TSELECT { x=$( 11450 select file in *; do echo "<$file>" ; break ; done 11451 ); } 11452 function comsub_TSELECT { 11453 x=$(select file in * ; do \echo "<$file>" ; \break ; done ) 11454 } 11455 function reread_TSELECT { x=$(( 11456 select file in *; do echo "<$file>" ; break ; done 11457 )|tr u x); } 11458 function reread_TSELECT { 11459 x=$( ( select file in * ; do \echo "<$file>" ; \break ; done ) | \tr u x ) 11460 } 11461 inline_TFOR_TTIME() { 11462 time for i in {1,2,3} ; do echo $i ; done 11463 } 11464 inline_TFOR_TTIME() { 11465 time for i in {1,2,3} 11466 do 11467 \echo $i 11468 done 11469 } 11470 function comsub_TFOR_TTIME { x=$( 11471 time for i in {1,2,3} ; do echo $i ; done 11472 ); } 11473 function comsub_TFOR_TTIME { 11474 x=$(time for i in {1,2,3} ; do \echo $i ; done ) 11475 } 11476 function reread_TFOR_TTIME { x=$(( 11477 time for i in {1,2,3} ; do echo $i ; done 11478 )|tr u x); } 11479 function reread_TFOR_TTIME { 11480 x=$( ( time for i in {1,2,3} ; do \echo $i ; done ) | \tr u x ) 11481 } 11482 inline_TCASE() { 11483 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zhlen;; esac 11484 } 11485 inline_TCASE() { 11486 case $foo in 11487 (1) 11488 \echo eins 11489 ;& 11490 (2) 11491 \echo zwei 11492 ;| 11493 (*) 11494 \echo kann net bis drei zhlen 11495 ;; 11496 esac 11497 } 11498 function comsub_TCASE { x=$( 11499 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zhlen;; esac 11500 ); } 11501 function comsub_TCASE { 11502 x=$(case $foo in (1) \echo eins ;& (2) \echo zwei ;| (*) \echo kann net bis drei zhlen ;; esac ) 11503 } 11504 function reread_TCASE { x=$(( 11505 case $foo in 1) echo eins;& 2) echo zwei ;| *) echo kann net bis drei zhlen;; esac 11506 )|tr u x); } 11507 function reread_TCASE { 11508 x=$( ( case $foo in (1) \echo eins ;& (2) \echo zwei ;| (*) \echo kann net bis drei zhlen ;; esac ) | \tr u x ) 11509 } 11510 inline_TIF_TBANG_TDBRACKET_TELIF() { 11511 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi 11512 } 11513 inline_TIF_TBANG_TDBRACKET_TELIF() { 11514 if ! [[ 1 = 1 ]] 11515 then 11516 \echo eins 11517 elif [[ 1 = 2 ]] 11518 then 11519 \echo zwei 11520 else 11521 \echo drei 11522 fi 11523 } 11524 function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$( 11525 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi 11526 ); } 11527 function comsub_TIF_TBANG_TDBRACKET_TELIF { 11528 x=$(if ! [[ 1 = 1 ]] ; then \echo eins ; elif [[ 1 = 2 ]] ; then \echo zwei ; else \echo drei ; fi ) 11529 } 11530 function reread_TIF_TBANG_TDBRACKET_TELIF { x=$(( 11531 if ! [[ 1 = 1 ]] ; then echo eins; elif [[ 1 = 2 ]]; then echo zwei ;else echo drei; fi 11532 )|tr u x); } 11533 function reread_TIF_TBANG_TDBRACKET_TELIF { 11534 x=$( ( if ! [[ 1 = 1 ]] ; then \echo eins ; elif [[ 1 = 2 ]] ; then \echo zwei ; else \echo drei ; fi ) | \tr u x ) 11535 } 11536 inline_TWHILE() { 11537 i=1; while (( i < 10 )); do echo $i; let ++i; done 11538 } 11539 inline_TWHILE() { 11540 i=1 11541 while { 11542 \\builtin let " i < 10 " 11543 } 11544 do 11545 \echo $i 11546 \let ++i 11547 done 11548 } 11549 function comsub_TWHILE { x=$( 11550 i=1; while (( i < 10 )); do echo $i; let ++i; done 11551 ); } 11552 function comsub_TWHILE { 11553 x=$(i=1 ; while { \\builtin let " i < 10 " ; } ; do \echo $i ; \let ++i ; done ) 11554 } 11555 function reread_TWHILE { x=$(( 11556 i=1; while (( i < 10 )); do echo $i; let ++i; done 11557 )|tr u x); } 11558 function reread_TWHILE { 11559 x=$( ( i=1 ; while { \\builtin let " i < 10 " ; } ; do \echo $i ; \let ++i ; done ) | \tr u x ) 11560 } 11561 inline_TUNTIL() { 11562 i=10; until (( !--i )) ; do echo $i; done 11563 } 11564 inline_TUNTIL() { 11565 i=10 11566 until { 11567 \\builtin let " !--i " 11568 } 11569 do 11570 \echo $i 11571 done 11572 } 11573 function comsub_TUNTIL { x=$( 11574 i=10; until (( !--i )) ; do echo $i; done 11575 ); } 11576 function comsub_TUNTIL { 11577 x=$(i=10 ; until { \\builtin let " !--i " ; } ; do \echo $i ; done ) 11578 } 11579 function reread_TUNTIL { x=$(( 11580 i=10; until (( !--i )) ; do echo $i; done 11581 )|tr u x); } 11582 function reread_TUNTIL { 11583 x=$( ( i=10 ; until { \\builtin let " !--i " ; } ; do \echo $i ; done ) | \tr u x ) 11584 } 11585 inline_TCOPROC() { 11586 cat * |& ls 11587 } 11588 inline_TCOPROC() { 11589 \cat * |& 11590 \ls 11591 } 11592 function comsub_TCOPROC { x=$( 11593 cat * |& ls 11594 ); } 11595 function comsub_TCOPROC { 11596 x=$(\cat * |& \ls ) 11597 } 11598 function reread_TCOPROC { x=$(( 11599 cat * |& ls 11600 )|tr u x); } 11601 function reread_TCOPROC { 11602 x=$( ( \cat * |& \ls ) | \tr u x ) 11603 } 11604 inline_TFUNCT_TBRACE_TASYNC() { 11605 function korn { echo eins; echo zwei ; } 11606 bourne () { logger * & } 11607 } 11608 inline_TFUNCT_TBRACE_TASYNC() { 11609 function korn { 11610 \echo eins 11611 \echo zwei 11612 } 11613 bourne() { 11614 \logger * & 11615 } 11616 } 11617 function comsub_TFUNCT_TBRACE_TASYNC { x=$( 11618 function korn { echo eins; echo zwei ; } 11619 bourne () { logger * & } 11620 ); } 11621 function comsub_TFUNCT_TBRACE_TASYNC { 11622 x=$(function korn { \echo eins ; \echo zwei ; } ; bourne() { \logger * & } ) 11623 } 11624 function reread_TFUNCT_TBRACE_TASYNC { x=$(( 11625 function korn { echo eins; echo zwei ; } 11626 bourne () { logger * & } 11627 )|tr u x); } 11628 function reread_TFUNCT_TBRACE_TASYNC { 11629 x=$( ( function korn { \echo eins ; \echo zwei ; } ; bourne() { \logger * & } ) | \tr u x ) 11630 } 11631 inline_IOREAD_IOCAT() { 11632 tr x u 0<foo >>bar 11633 } 11634 inline_IOREAD_IOCAT() { 11635 \tr x u <foo >>bar 11636 } 11637 function comsub_IOREAD_IOCAT { x=$( 11638 tr x u 0<foo >>bar 11639 ); } 11640 function comsub_IOREAD_IOCAT { 11641 x=$(\tr x u <foo >>bar ) 11642 } 11643 function reread_IOREAD_IOCAT { x=$(( 11644 tr x u 0<foo >>bar 11645 )|tr u x); } 11646 function reread_IOREAD_IOCAT { 11647 x=$( ( \tr x u <foo >>bar ) | \tr u x ) 11648 } 11649 inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() { 11650 cat >|bar <<'EOFN' 11651 foo 11652 EOFN 11653 } 11654 inline_IOWRITE_IOCLOB_IOHERE_noIOSKIP() { 11655 \cat >|bar <<"EOFN" 11656 foo 11657 EOFN 11658 11659 } 11660 function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$( 11661 cat >|bar <<'EOFN' 11662 foo 11663 EOFN 11664 ); } 11665 function comsub_IOWRITE_IOCLOB_IOHERE_noIOSKIP { 11666 x=$(\cat >|bar <<"EOFN" 11667 foo 11668 EOFN 11669 ) 11670 } 11671 function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP { x=$(( 11672 cat >|bar <<'EOFN' 11673 foo 11674 EOFN 11675 )|tr u x); } 11676 function reread_IOWRITE_IOCLOB_IOHERE_noIOSKIP { 11677 x=$( ( \cat >|bar <<"EOFN" 11678 foo 11679 EOFN 11680 ) | \tr u x ) 11681 } 11682 inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() { 11683 cat 1>bar <<-EOFI 11684 foo 11685 EOFI 11686 } 11687 inline_IOWRITE_noIOCLOB_IOHERE_IOSKIP() { 11688 \cat >bar <<-EOFI 11689 foo 11690 EOFI 11691 11692 } 11693 function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$( 11694 cat 1>bar <<-EOFI 11695 foo 11696 EOFI 11697 ); } 11698 function comsub_IOWRITE_noIOCLOB_IOHERE_IOSKIP { 11699 x=$(\cat >bar <<-EOFI 11700 foo 11701 EOFI 11702 ) 11703 } 11704 function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP { x=$(( 11705 cat 1>bar <<-EOFI 11706 foo 11707 EOFI 11708 )|tr u x); } 11709 function reread_IOWRITE_noIOCLOB_IOHERE_IOSKIP { 11710 x=$( ( \cat >bar <<-EOFI 11711 foo 11712 EOFI 11713 ) | \tr u x ) 11714 } 11715 inline_IORDWR_IODUP() { 11716 sh 1<>/dev/console 0<&1 2>&1 11717 } 11718 inline_IORDWR_IODUP() { 11719 \sh 1<>/dev/console <&1 2>&1 11720 } 11721 function comsub_IORDWR_IODUP { x=$( 11722 sh 1<>/dev/console 0<&1 2>&1 11723 ); } 11724 function comsub_IORDWR_IODUP { 11725 x=$(\sh 1<>/dev/console <&1 2>&1 ) 11726 } 11727 function reread_IORDWR_IODUP { x=$(( 11728 sh 1<>/dev/console 0<&1 2>&1 11729 )|tr u x); } 11730 function reread_IORDWR_IODUP { 11731 x=$( ( \sh 1<>/dev/console <&1 2>&1 ) | \tr u x ) 11732 } 11733 inline_COMSUB_EXPRSUB_FUNSUB_VALSUB() { 11734 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;} 11735 } 11736 inline_COMSUB_EXPRSUB_FUNSUB_VALSUB() { 11737 \echo $(\true ) $((1+ 2)) ${ \: ;} ${|REPLY=x ;} 11738 } 11739 function comsub_COMSUB_EXPRSUB_FUNSUB_VALSUB { x=$( 11740 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;} 11741 ); } 11742 function comsub_COMSUB_EXPRSUB_FUNSUB_VALSUB { 11743 x=$(\echo $(\true ) $((1+ 2)) ${ \: ;} ${|REPLY=x ;} ) 11744 } 11745 function reread_COMSUB_EXPRSUB_FUNSUB_VALSUB { x=$(( 11746 echo $(true) $((1+ 2)) ${ :;} ${| REPLY=x;} 11747 )|tr u x); } 11748 function reread_COMSUB_EXPRSUB_FUNSUB_VALSUB { 11749 x=$( ( \echo $(\true ) $((1+ 2)) ${ \: ;} ${|REPLY=x ;} ) | \tr u x ) 11750 } 11751 inline_QCHAR_OQUOTE_CQUOTE() { 11752 echo fo\ob\"a\`r\'b\$az 11753 echo "fo\ob\"a\`r\'b\$az" 11754 echo 'fo\ob\"a\`r'\''b\$az' 11755 } 11756 inline_QCHAR_OQUOTE_CQUOTE() { 11757 \echo fo\ob\"a\`r\'b\$az 11758 \echo "fo\ob\"a\`r\'b\$az" 11759 \echo "fo\\ob\\\"a\\\`r"\'"b\\\$az" 11760 } 11761 function comsub_QCHAR_OQUOTE_CQUOTE { x=$( 11762 echo fo\ob\"a\`r\'b\$az 11763 echo "fo\ob\"a\`r\'b\$az" 11764 echo 'fo\ob\"a\`r'\''b\$az' 11765 ); } 11766 function comsub_QCHAR_OQUOTE_CQUOTE { 11767 x=$(\echo fo\ob\"a\`r\'b\$az ; \echo "fo\ob\"a\`r\'b\$az" ; \echo "fo\\ob\\\"a\\\`r"\'"b\\\$az" ) 11768 } 11769 function reread_QCHAR_OQUOTE_CQUOTE { x=$(( 11770 echo fo\ob\"a\`r\'b\$az 11771 echo "fo\ob\"a\`r\'b\$az" 11772 echo 'fo\ob\"a\`r'\''b\$az' 11773 )|tr u x); } 11774 function reread_QCHAR_OQUOTE_CQUOTE { 11775 x=$( ( \echo fo\ob\"a\`r\'b\$az ; \echo "fo\ob\"a\`r\'b\$az" ; \echo "fo\\ob\\\"a\\\`r"\'"b\\\$az" ) | \tr u x ) 11776 } 11777 inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() { 11778 [[ ${foo#bl\(u\)b} = @(bar|baz) ]] 11779 } 11780 inline_OSUBST_CSUBST_OPAT_SPAT_CPAT() { 11781 [[ ${foo#bl\(u\)b} = @(bar|baz) ]] 11782 } 11783 function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$( 11784 [[ ${foo#bl\(u\)b} = @(bar|baz) ]] 11785 ); } 11786 function comsub_OSUBST_CSUBST_OPAT_SPAT_CPAT { 11787 x=$([[ ${foo#bl\(u\)b} = @(bar|baz) ]] ) 11788 } 11789 function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT { x=$(( 11790 [[ ${foo#bl\(u\)b} = @(bar|baz) ]] 11791 )|tr u x); } 11792 function reread_OSUBST_CSUBST_OPAT_SPAT_CPAT { 11793 x=$( ( [[ ${foo#bl\(u\)b} = @(bar|baz) ]] ) | \tr u x ) 11794 } 11795 inline_heredoc_closed() { 11796 x=$(cat <<EOFN 11797 note there must be no space between EOFN and ) 11798 EOFN); echo $x 11799 } 11800 inline_heredoc_closed() { 11801 x=$(\cat <<EOFN 11802 note there must be no space between EOFN and ) 11803 EOFN 11804 ) 11805 \echo $x 11806 } 11807 function comsub_heredoc_closed { x=$( 11808 x=$(cat <<EOFN 11809 note there must be no space between EOFN and ) 11810 EOFN); echo $x 11811 ); } 11812 function comsub_heredoc_closed { 11813 x=$(x=$(\cat <<EOFN 11814 note there must be no space between EOFN and ) 11815 EOFN 11816 ) ; \echo $x ) 11817 } 11818 function reread_heredoc_closed { x=$(( 11819 x=$(cat <<EOFN 11820 note there must be no space between EOFN and ) 11821 EOFN); echo $x 11822 )|tr u x); } 11823 function reread_heredoc_closed { 11824 x=$( ( x=$(\cat <<EOFN 11825 note there must be no space between EOFN and ) 11826 EOFN 11827 ) ; \echo $x ) | \tr u x ) 11828 } 11829 inline_heredoc_space() { 11830 x=$(cat <<EOFN\ 11831 note the space between EOFN and ) is actually part of the here document marker 11832 EOFN ); echo $x 11833 } 11834 inline_heredoc_space() { 11835 x=$(\cat <<EOFN\ 11836 note the space between EOFN and ) is actually part of the here document marker 11837 EOFN 11838 ) 11839 \echo $x 11840 } 11841 function comsub_heredoc_space { x=$( 11842 x=$(cat <<EOFN\ 11843 note the space between EOFN and ) is actually part of the here document marker 11844 EOFN ); echo $x 11845 ); } 11846 function comsub_heredoc_space { 11847 x=$(x=$(\cat <<EOFN\ 11848 note the space between EOFN and ) is actually part of the here document marker 11849 EOFN 11850 ) ; \echo $x ) 11851 } 11852 function reread_heredoc_space { x=$(( 11853 x=$(cat <<EOFN\ 11854 note the space between EOFN and ) is actually part of the here document marker 11855 EOFN ); echo $x 11856 )|tr u x); } 11857 function reread_heredoc_space { 11858 x=$( ( x=$(\cat <<EOFN\ 11859 note the space between EOFN and ) is actually part of the here document marker 11860 EOFN 11861 ) ; \echo $x ) | \tr u x ) 11862 } 11863 inline_patch_motd() { 11864 x=$(sysctl -n kern.version | sed 1q) 11865 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \ 11866 ed -s /etc/motd 2>&1 <<-EOF 11867 1,/^\$/d 11868 0a 11869 $x 11870 11871 . 11872 wq 11873 EOF)" = @(?) ]] && rm -f /etc/motd 11874 if [[ ! -s /etc/motd ]]; then 11875 install -c -o root -g wheel -m 664 /dev/null /etc/motd 11876 print -- "$x\n" >/etc/motd 11877 fi 11878 } 11879 inline_patch_motd() { 11880 x=$(\sysctl -n kern.version | \sed 1q ) 11881 [[ -s /etc/motd && "$([[ "$(\head -1 /etc/motd )" != $x ]] && \ed -s /etc/motd 2>&1 <<-EOF 11882 1,/^\$/d 11883 0a 11884 $x 11885 11886 . 11887 wq 11888 EOF 11889 )" = @(?) ]] && \rm -f /etc/motd 11890 if [[ ! -s /etc/motd ]] 11891 then 11892 \install -c -o root -g wheel -m 664 /dev/null /etc/motd 11893 \print -- "$x\n" >/etc/motd 11894 fi 11895 } 11896 function comsub_patch_motd { x=$( 11897 x=$(sysctl -n kern.version | sed 1q) 11898 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \ 11899 ed -s /etc/motd 2>&1 <<-EOF 11900 1,/^\$/d 11901 0a 11902 $x 11903 11904 . 11905 wq 11906 EOF)" = @(?) ]] && rm -f /etc/motd 11907 if [[ ! -s /etc/motd ]]; then 11908 install -c -o root -g wheel -m 664 /dev/null /etc/motd 11909 print -- "$x\n" >/etc/motd 11910 fi 11911 ); } 11912 function comsub_patch_motd { 11913 x=$(x=$(\sysctl -n kern.version | \sed 1q ) ; [[ -s /etc/motd && "$([[ "$(\head -1 /etc/motd )" != $x ]] && \ed -s /etc/motd 2>&1 <<-EOF 11914 1,/^\$/d 11915 0a 11916 $x 11917 11918 . 11919 wq 11920 EOF 11921 )" = @(?) ]] && \rm -f /etc/motd ; if [[ ! -s /etc/motd ]] ; then \install -c -o root -g wheel -m 664 /dev/null /etc/motd ; \print -- "$x\n" >/etc/motd ; fi ) 11922 } 11923 function reread_patch_motd { x=$(( 11924 x=$(sysctl -n kern.version | sed 1q) 11925 [[ -s /etc/motd && "$([[ "$(head -1 /etc/motd)" != $x ]] && \ 11926 ed -s /etc/motd 2>&1 <<-EOF 11927 1,/^\$/d 11928 0a 11929 $x 11930 11931 . 11932 wq 11933 EOF)" = @(?) ]] && rm -f /etc/motd 11934 if [[ ! -s /etc/motd ]]; then 11935 install -c -o root -g wheel -m 664 /dev/null /etc/motd 11936 print -- "$x\n" >/etc/motd 11937 fi 11938 )|tr u x); } 11939 function reread_patch_motd { 11940 x=$( ( x=$(\sysctl -n kern.version | \sed 1q ) ; [[ -s /etc/motd && "$([[ "$(\head -1 /etc/motd )" != $x ]] && \ed -s /etc/motd 2>&1 <<-EOF 11941 1,/^\$/d 11942 0a 11943 $x 11944 11945 . 11946 wq 11947 EOF 11948 )" = @(?) ]] && \rm -f /etc/motd ; if [[ ! -s /etc/motd ]] ; then \install -c -o root -g wheel -m 664 /dev/null /etc/motd ; \print -- "$x\n" >/etc/motd ; fi ) | \tr u x ) 11949 } 11950 inline_wdarrassign() { 11951 case x in 11952 x) a+=b; c+=(d e) 11953 esac 11954 } 11955 inline_wdarrassign() { 11956 case x in 11957 (x) 11958 a+=b 11959 \\builtin set -A c+ -- d e 11960 ;; 11961 esac 11962 } 11963 function comsub_wdarrassign { x=$( 11964 case x in 11965 x) a+=b; c+=(d e) 11966 esac 11967 ); } 11968 function comsub_wdarrassign { 11969 x=$(case x in (x) a+=b ; \\builtin set -A c+ -- d e ;; esac ) 11970 } 11971 function reread_wdarrassign { x=$(( 11972 case x in 11973 x) a+=b; c+=(d e) 11974 esac 11975 )|tr u x); } 11976 function reread_wdarrassign { 11977 x=$( ( case x in (x) a+=b ; \\builtin set -A c+ -- d e ;; esac ) | \tr u x ) 11978 } 11979 --- 11980 name: comsub-torture-io 11981 description: 11982 Check the tree dump functions work correctly with I/O redirection 11983 stdin: 11984 if [[ -z $__progname ]]; then echo >&2 call me with __progname; exit 1; fi 11985 while IFS= read -r line; do 11986 if [[ $line = '#1' ]]; then 11987 lastf=0 11988 continue 11989 elif [[ $line = EOFN* ]]; then 11990 fbody=$fbody$'\n'$line 11991 continue 11992 elif [[ $line != '#'* ]]; then 11993 fbody=$fbody$'\n\t'$line 11994 continue 11995 fi 11996 if (( lastf )); then 11997 x="inline_${nextf}() {"$fbody$'\n}\n' 11998 print -nr -- "$x" 11999 print -r -- "${x}typeset -f inline_$nextf" | "$__progname" 12000 x="function comsub_$nextf { x=\$("$fbody$'\n); }\n' 12001 print -nr -- "$x" 12002 print -r -- "${x}typeset -f comsub_$nextf" | "$__progname" 12003 x="function reread_$nextf { x=\$(("$fbody$'\n)|tr u x); }\n' 12004 print -nr -- "$x" 12005 print -r -- "${x}typeset -f reread_$nextf" | "$__progname" 12006 fi 12007 lastf=1 12008 fbody= 12009 nextf=${line#?} 12010 done <<'EOD' 12011 #1 12012 #TCOM 12013 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3 12014 #TPAREN_TPIPE_TLIST 12015 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3 12016 #TAND_TOR 12017 cmd >&3 && >&3 echo ja || echo >&3 nein 12018 #TSELECT 12019 select file in *; do echo "<$file>" ; break >&3 ; done >&3 12020 #TFOR_TTIME 12021 for i in {1,2,3} ; do time >&3 echo $i ; done >&3 12022 #TCASE 12023 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zhlen >&3;; esac >&3 12024 #TIF_TBANG_TDBRACKET_TELIF 12025 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3 12026 #TWHILE 12027 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3 12028 #TUNTIL 12029 i=10; until (( !--i )) >&3 ; do echo $i; done >&3 12030 #TCOPROC 12031 cat * >&3 |& >&3 ls 12032 #TFUNCT_TBRACE_TASYNC 12033 function korn { echo eins; echo >&3 zwei ; } 12034 bourne () { logger * >&3 & } 12035 #COMSUB_EXPRSUB 12036 echo $(true >&3) $((1+ 2)) 12037 #0 12038 EOD 12039 expected-stdout: 12040 inline_TCOM() { 12041 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3 12042 } 12043 inline_TCOM() { 12044 vara=1 varb="2 3" \cmd arg1 $arg2 "$arg3 4" >&3 12045 } 12046 function comsub_TCOM { x=$( 12047 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3 12048 ); } 12049 function comsub_TCOM { 12050 x=$(vara=1 varb="2 3" \cmd arg1 $arg2 "$arg3 4" >&3 ) 12051 } 12052 function reread_TCOM { x=$(( 12053 vara=1 varb='2 3' cmd arg1 $arg2 "$arg3 4" >&3 12054 )|tr u x); } 12055 function reread_TCOM { 12056 x=$( ( vara=1 varb="2 3" \cmd arg1 $arg2 "$arg3 4" >&3 ) | \tr u x ) 12057 } 12058 inline_TPAREN_TPIPE_TLIST() { 12059 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3 12060 } 12061 inline_TPAREN_TPIPE_TLIST() { 12062 ( \echo $foo | \tr -dc 0-9 >&3 12063 \echo >&3 ) >&3 12064 } 12065 function comsub_TPAREN_TPIPE_TLIST { x=$( 12066 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3 12067 ); } 12068 function comsub_TPAREN_TPIPE_TLIST { 12069 x=$( ( \echo $foo | \tr -dc 0-9 >&3 ; \echo >&3 ) >&3 ) 12070 } 12071 function reread_TPAREN_TPIPE_TLIST { x=$(( 12072 (echo $foo | tr -dc 0-9 >&3; echo >&3) >&3 12073 )|tr u x); } 12074 function reread_TPAREN_TPIPE_TLIST { 12075 x=$( ( ( \echo $foo | \tr -dc 0-9 >&3 ; \echo >&3 ) >&3 ) | \tr u x ) 12076 } 12077 inline_TAND_TOR() { 12078 cmd >&3 && >&3 echo ja || echo >&3 nein 12079 } 12080 inline_TAND_TOR() { 12081 \cmd >&3 && \echo ja >&3 || \echo nein >&3 12082 } 12083 function comsub_TAND_TOR { x=$( 12084 cmd >&3 && >&3 echo ja || echo >&3 nein 12085 ); } 12086 function comsub_TAND_TOR { 12087 x=$(\cmd >&3 && \echo ja >&3 || \echo nein >&3 ) 12088 } 12089 function reread_TAND_TOR { x=$(( 12090 cmd >&3 && >&3 echo ja || echo >&3 nein 12091 )|tr u x); } 12092 function reread_TAND_TOR { 12093 x=$( ( \cmd >&3 && \echo ja >&3 || \echo nein >&3 ) | \tr u x ) 12094 } 12095 inline_TSELECT() { 12096 select file in *; do echo "<$file>" ; break >&3 ; done >&3 12097 } 12098 inline_TSELECT() { 12099 select file in * 12100 do 12101 \echo "<$file>" 12102 \break >&3 12103 done >&3 12104 } 12105 function comsub_TSELECT { x=$( 12106 select file in *; do echo "<$file>" ; break >&3 ; done >&3 12107 ); } 12108 function comsub_TSELECT { 12109 x=$(select file in * ; do \echo "<$file>" ; \break >&3 ; done >&3 ) 12110 } 12111 function reread_TSELECT { x=$(( 12112 select file in *; do echo "<$file>" ; break >&3 ; done >&3 12113 )|tr u x); } 12114 function reread_TSELECT { 12115 x=$( ( select file in * ; do \echo "<$file>" ; \break >&3 ; done >&3 ) | \tr u x ) 12116 } 12117 inline_TFOR_TTIME() { 12118 for i in {1,2,3} ; do time >&3 echo $i ; done >&3 12119 } 12120 inline_TFOR_TTIME() { 12121 for i in {1,2,3} 12122 do 12123 time \echo $i >&3 12124 done >&3 12125 } 12126 function comsub_TFOR_TTIME { x=$( 12127 for i in {1,2,3} ; do time >&3 echo $i ; done >&3 12128 ); } 12129 function comsub_TFOR_TTIME { 12130 x=$(for i in {1,2,3} ; do time \echo $i >&3 ; done >&3 ) 12131 } 12132 function reread_TFOR_TTIME { x=$(( 12133 for i in {1,2,3} ; do time >&3 echo $i ; done >&3 12134 )|tr u x); } 12135 function reread_TFOR_TTIME { 12136 x=$( ( for i in {1,2,3} ; do time \echo $i >&3 ; done >&3 ) | \tr u x ) 12137 } 12138 inline_TCASE() { 12139 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zhlen >&3;; esac >&3 12140 } 12141 inline_TCASE() { 12142 case $foo in 12143 (1) 12144 \echo eins >&3 12145 ;& 12146 (2) 12147 \echo zwei >&3 12148 ;| 12149 (*) 12150 \echo kann net bis drei zhlen >&3 12151 ;; 12152 esac >&3 12153 } 12154 function comsub_TCASE { x=$( 12155 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zhlen >&3;; esac >&3 12156 ); } 12157 function comsub_TCASE { 12158 x=$(case $foo in (1) \echo eins >&3 ;& (2) \echo zwei >&3 ;| (*) \echo kann net bis drei zhlen >&3 ;; esac >&3 ) 12159 } 12160 function reread_TCASE { x=$(( 12161 case $foo in 1) echo eins >&3;& 2) echo zwei >&3 ;| *) echo kann net bis drei zhlen >&3;; esac >&3 12162 )|tr u x); } 12163 function reread_TCASE { 12164 x=$( ( case $foo in (1) \echo eins >&3 ;& (2) \echo zwei >&3 ;| (*) \echo kann net bis drei zhlen >&3 ;; esac >&3 ) | \tr u x ) 12165 } 12166 inline_TIF_TBANG_TDBRACKET_TELIF() { 12167 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3 12168 } 12169 inline_TIF_TBANG_TDBRACKET_TELIF() { 12170 if ! [[ 1 = 1 ]] >&3 12171 then 12172 \echo eins 12173 elif [[ 1 = 2 ]] >&3 12174 then 12175 \echo zwei 12176 else 12177 \echo drei 12178 fi >&3 12179 } 12180 function comsub_TIF_TBANG_TDBRACKET_TELIF { x=$( 12181 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3 12182 ); } 12183 function comsub_TIF_TBANG_TDBRACKET_TELIF { 12184 x=$(if ! [[ 1 = 1 ]] >&3 ; then \echo eins ; elif [[ 1 = 2 ]] >&3 ; then \echo zwei ; else \echo drei ; fi >&3 ) 12185 } 12186 function reread_TIF_TBANG_TDBRACKET_TELIF { x=$(( 12187 if ! [[ 1 = 1 ]] >&3 ; then echo eins; elif [[ 1 = 2 ]] >&3; then echo zwei ;else echo drei; fi >&3 12188 )|tr u x); } 12189 function reread_TIF_TBANG_TDBRACKET_TELIF { 12190 x=$( ( if ! [[ 1 = 1 ]] >&3 ; then \echo eins ; elif [[ 1 = 2 ]] >&3 ; then \echo zwei ; else \echo drei ; fi >&3 ) | \tr u x ) 12191 } 12192 inline_TWHILE() { 12193 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3 12194 } 12195 inline_TWHILE() { 12196 i=1 12197 while { 12198 \\builtin let " i < 10 " 12199 } >&3 12200 do 12201 \echo $i 12202 \let ++i 12203 done >&3 12204 } 12205 function comsub_TWHILE { x=$( 12206 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3 12207 ); } 12208 function comsub_TWHILE { 12209 x=$(i=1 ; while { \\builtin let " i < 10 " ; } >&3 ; do \echo $i ; \let ++i ; done >&3 ) 12210 } 12211 function reread_TWHILE { x=$(( 12212 i=1; while (( i < 10 )) >&3; do echo $i; let ++i; done >&3 12213 )|tr u x); } 12214 function reread_TWHILE { 12215 x=$( ( i=1 ; while { \\builtin let " i < 10 " ; } >&3 ; do \echo $i ; \let ++i ; done >&3 ) | \tr u x ) 12216 } 12217 inline_TUNTIL() { 12218 i=10; until (( !--i )) >&3 ; do echo $i; done >&3 12219 } 12220 inline_TUNTIL() { 12221 i=10 12222 until { 12223 \\builtin let " !--i " 12224 } >&3 12225 do 12226 \echo $i 12227 done >&3 12228 } 12229 function comsub_TUNTIL { x=$( 12230 i=10; until (( !--i )) >&3 ; do echo $i; done >&3 12231 ); } 12232 function comsub_TUNTIL { 12233 x=$(i=10 ; until { \\builtin let " !--i " ; } >&3 ; do \echo $i ; done >&3 ) 12234 } 12235 function reread_TUNTIL { x=$(( 12236 i=10; until (( !--i )) >&3 ; do echo $i; done >&3 12237 )|tr u x); } 12238 function reread_TUNTIL { 12239 x=$( ( i=10 ; until { \\builtin let " !--i " ; } >&3 ; do \echo $i ; done >&3 ) | \tr u x ) 12240 } 12241 inline_TCOPROC() { 12242 cat * >&3 |& >&3 ls 12243 } 12244 inline_TCOPROC() { 12245 \cat * >&3 |& 12246 \ls >&3 12247 } 12248 function comsub_TCOPROC { x=$( 12249 cat * >&3 |& >&3 ls 12250 ); } 12251 function comsub_TCOPROC { 12252 x=$(\cat * >&3 |& \ls >&3 ) 12253 } 12254 function reread_TCOPROC { x=$(( 12255 cat * >&3 |& >&3 ls 12256 )|tr u x); } 12257 function reread_TCOPROC { 12258 x=$( ( \cat * >&3 |& \ls >&3 ) | \tr u x ) 12259 } 12260 inline_TFUNCT_TBRACE_TASYNC() { 12261 function korn { echo eins; echo >&3 zwei ; } 12262 bourne () { logger * >&3 & } 12263 } 12264 inline_TFUNCT_TBRACE_TASYNC() { 12265 function korn { 12266 \echo eins 12267 \echo zwei >&3 12268 } 12269 bourne() { 12270 \logger * >&3 & 12271 } 12272 } 12273 function comsub_TFUNCT_TBRACE_TASYNC { x=$( 12274 function korn { echo eins; echo >&3 zwei ; } 12275 bourne () { logger * >&3 & } 12276 ); } 12277 function comsub_TFUNCT_TBRACE_TASYNC { 12278 x=$(function korn { \echo eins ; \echo zwei >&3 ; } ; bourne() { \logger * >&3 & } ) 12279 } 12280 function reread_TFUNCT_TBRACE_TASYNC { x=$(( 12281 function korn { echo eins; echo >&3 zwei ; } 12282 bourne () { logger * >&3 & } 12283 )|tr u x); } 12284 function reread_TFUNCT_TBRACE_TASYNC { 12285 x=$( ( function korn { \echo eins ; \echo zwei >&3 ; } ; bourne() { \logger * >&3 & } ) | \tr u x ) 12286 } 12287 inline_COMSUB_EXPRSUB() { 12288 echo $(true >&3) $((1+ 2)) 12289 } 12290 inline_COMSUB_EXPRSUB() { 12291 \echo $(\true >&3 ) $((1+ 2)) 12292 } 12293 function comsub_COMSUB_EXPRSUB { x=$( 12294 echo $(true >&3) $((1+ 2)) 12295 ); } 12296 function comsub_COMSUB_EXPRSUB { 12297 x=$(\echo $(\true >&3 ) $((1+ 2)) ) 12298 } 12299 function reread_COMSUB_EXPRSUB { x=$(( 12300 echo $(true >&3) $((1+ 2)) 12301 )|tr u x); } 12302 function reread_COMSUB_EXPRSUB { 12303 x=$( ( \echo $(\true >&3 ) $((1+ 2)) ) | \tr u x ) 12304 } 12305 --- 12306 name: funsub-1 12307 description: 12308 Check that non-subenvironment command substitution works 12309 stdin: 12310 set -e 12311 foo=bar 12312 echo "ob $foo ." 12313 echo "${ 12314 echo "ib $foo :" 12315 foo=baz 12316 echo "ia $foo :" 12317 false 12318 }" . 12319 echo "oa $foo ." 12320 expected-stdout: 12321 ob bar . 12322 ib bar : 12323 ia baz : . 12324 oa baz . 12325 --- 12326 name: funsub-2 12327 description: 12328 You can now reliably use local and return in funsubs 12329 (not exit though) 12330 stdin: 12331 x=q; e=1; x=${ echo a; e=2; echo x$e;}; echo 1:y$x,$e,$?. 12332 x=q; e=1; x=${ echo a; typeset e=2; echo x$e;}; echo 2:y$x,$e,$?. 12333 x=q; e=1; x=${ echo a; typeset e=2; return 3; echo x$e;}; echo 3:y$x,$e,$?. 12334 expected-stdout: 12335 1:ya x2,2,0. 12336 2:ya x2,1,0. 12337 3:ya,1,3. 12338 --- 12339 name: valsub-1 12340 description: 12341 Check that "value substitutions" work as advertised 12342 stdin: 12343 x=1 12344 y=2 12345 z=3 12346 REPLY=4 12347 echo "before: x<$x> y<$y> z<$z> R<$REPLY>" 12348 x=${| 12349 local y 12350 echo "start: x<$x> y<$y> z<$z> R<$REPLY>" 12351 x=5 12352 y=6 12353 z=7 12354 REPLY=8 12355 echo "end: x<$x> y<$y> z<$z> R<$REPLY>" 12356 } 12357 echo "after: x<$x> y<$y> z<$z> R<$REPLY>" 12358 # ensure trailing newlines are kept 12359 t=${|REPLY=$'foo\n\n';} 12360 typeset -p t 12361 echo -n this used to segfault 12362 echo ${|true;}$(true). 12363 expected-stdout: 12364 before: x<1> y<2> z<3> R<4> 12365 start: x<1> y<> z<3> R<> 12366 end: x<5> y<6> z<7> R<8> 12367 after: x<8> y<2> z<7> R<4> 12368 typeset t=$'foo\n\n' 12369 this used to segfault. 12370 --- 12371 name: event-subst-3 12372 description: 12373 Check that '!' substitution in noninteractive mode is ignored 12374 file-setup: file 755 "falsetto" 12375 #! /bin/sh 12376 echo molto bene 12377 exit 42 12378 file-setup: file 755 "!false" 12379 #! /bin/sh 12380 echo si 12381 stdin: 12382 export PATH=.$PATHSEP$PATH 12383 falsetto 12384 echo yeap 12385 !false 12386 echo meow 12387 ! false 12388 echo = $? 12389 if 12390 ! false; then echo foo; else echo bar; fi 12391 expected-stdout: 12392 molto bene 12393 yeap 12394 si 12395 meow 12396 = 0 12397 foo 12398 --- 12399 name: event-subst-0 12400 description: 12401 Check that '!' substitution in interactive mode is ignored 12402 need-ctty: yes 12403 arguments: !-i! 12404 file-setup: file 755 "falsetto" 12405 #! /bin/sh 12406 echo molto bene 12407 exit 42 12408 file-setup: file 755 "!false" 12409 #! /bin/sh 12410 echo si 12411 stdin: 12412 export PATH=.$PATHSEP$PATH 12413 falsetto 12414 echo yeap 12415 !false 12416 echo meow 12417 ! false 12418 echo = $? 12419 if 12420 ! false; then echo foo; else echo bar; fi 12421 expected-stdout: 12422 molto bene 12423 yeap 12424 si 12425 meow 12426 = 0 12427 foo 12428 expected-stderr-pattern: 12429 /.*/ 12430 --- 12431 name: nounset-1 12432 description: 12433 Check that "set -u" matches (future) SUSv4 requirement 12434 stdin: 12435 (set -u 12436 try() { 12437 local v 12438 eval v=\$$1 12439 if [[ -n $v ]]; then 12440 echo $1=nz 12441 else 12442 echo $1=zf 12443 fi 12444 } 12445 x=y 12446 (echo $x) 12447 echo =1 12448 (echo $y) 12449 echo =2 12450 (try x) 12451 echo =3 12452 (try y) 12453 echo =4 12454 (try 0) 12455 echo =5 12456 (try 2) 12457 echo =6 12458 (try) 12459 echo =7 12460 (echo at=$@) 12461 echo =8 12462 (echo asterisk=$*) 12463 echo =9 12464 (echo $?) 12465 echo =10 12466 (echo $!) 12467 echo =11 12468 (echo $-) 12469 echo =12 12470 #(echo $_) 12471 #echo =13 12472 (echo $#) 12473 echo =14 12474 (mypid=$$; try mypid) 12475 echo =15 12476 ) 2>&1 | sed -e 's/^[^]]*]//' -e 's/^[^:]*: *//' 12477 exit ${PIPESTATUS[0]} 12478 expected-stdout: 12479 y 12480 =1 12481 y: parameter not set 12482 =2 12483 x=nz 12484 =3 12485 y: parameter not set 12486 =4 12487 0=nz 12488 =5 12489 2: parameter not set 12490 =6 12491 1: parameter not set 12492 =7 12493 at= 12494 =8 12495 asterisk= 12496 =9 12497 0 12498 =10 12499 !: parameter not set 12500 =11 12501 ush 12502 =12 12503 0 12504 =14 12505 mypid=nz 12506 =15 12507 --- 12508 name: nameref-1 12509 description: 12510 Testsuite for nameref (bound variables) 12511 stdin: 12512 bar=global 12513 typeset -n ir2=bar 12514 typeset -n ind=ir2 12515 echo !ind: ${!ind} 12516 echo ind: $ind 12517 echo !ir2: ${!ir2} 12518 echo ir2: $ir2 12519 typeset +n ind 12520 echo !ind: ${!ind} 12521 echo ind: $ind 12522 typeset -n ir2=ind 12523 echo !ir2: ${!ir2} 12524 echo ir2: $ir2 12525 set|grep ^ir2|sed 's/^/s1: /' 12526 typeset|grep ' ir2'|sed -e 's/^/s2: /' -e 's/nameref/typeset -n/' 12527 set -A blub -- e1 e2 e3 12528 typeset -n ind=blub 12529 typeset -n ir2=blub[2] 12530 echo !ind[1]: ${!ind[1]} 12531 echo !ir2: $!ir2 12532 echo ind[1]: ${ind[1]} 12533 echo ir2: $ir2 12534 expected-stdout: 12535 !ind: bar 12536 ind: global 12537 !ir2: bar 12538 ir2: global 12539 !ind: ind 12540 ind: ir2 12541 !ir2: ind 12542 ir2: ir2 12543 s1: ir2=ind 12544 s2: typeset -n ir2 12545 !ind[1]: blub[1] 12546 !ir2: ir2 12547 ind[1]: e2 12548 ir2: e3 12549 --- 12550 name: nameref-2da 12551 description: 12552 Testsuite for nameref (bound variables) 12553 Functions, argument given directly, after local 12554 stdin: 12555 function foo { 12556 typeset bar=lokal baz=auch 12557 typeset -n v=bar 12558 echo entering 12559 echo !v: ${!v} 12560 echo !bar: ${!bar} 12561 echo !baz: ${!baz} 12562 echo bar: $bar 12563 echo v: $v 12564 v=123 12565 echo bar: $bar 12566 echo v: $v 12567 echo exiting 12568 } 12569 bar=global 12570 echo bar: $bar 12571 foo bar 12572 echo bar: $bar 12573 expected-stdout: 12574 bar: global 12575 entering 12576 !v: bar 12577 !bar: bar 12578 !baz: baz 12579 bar: lokal 12580 v: lokal 12581 bar: 123 12582 v: 123 12583 exiting 12584 bar: global 12585 --- 12586 name: nameref-3 12587 description: 12588 Advanced testsuite for bound variables (ksh93 fails this) 12589 stdin: 12590 typeset -n foo=bar[i] 12591 set -A bar -- b c a 12592 for i in 0 1 2 3; do 12593 print $i $foo . 12594 done 12595 expected-stdout: 12596 0 b . 12597 1 c . 12598 2 a . 12599 3 . 12600 --- 12601 name: nameref-4 12602 description: 12603 Ensure we don't run in an infinite loop 12604 time-limit: 3 12605 stdin: 12606 baz() { 12607 typeset -n foo=fnord fnord=foo 12608 foo[0]=bar 12609 } 12610 set -A foo bad 12611 echo sind $foo . 12612 baz 12613 echo blah $foo . 12614 expected-stdout: 12615 sind bad . 12616 blah bad . 12617 expected-stderr-pattern: 12618 /fnord: expression recurses on parameter/ 12619 --- 12620 name: better-parens-1a 12621 description: 12622 Check support for (()) and $(()) vs () and $() 12623 stdin: 12624 if ( (echo fubar)|tr u x); then 12625 echo ja 12626 else 12627 echo nein 12628 fi 12629 expected-stdout: 12630 fxbar 12631 ja 12632 --- 12633 name: better-parens-1b 12634 description: 12635 Check support for (()) and $(()) vs () and $() 12636 stdin: 12637 echo $( (echo fubar)|tr u x) $? 12638 expected-stdout: 12639 fxbar 0 12640 --- 12641 name: better-parens-1c 12642 description: 12643 Check support for (()) and $(()) vs () and $() 12644 stdin: 12645 x=$( (echo fubar)|tr u x); echo $x $? 12646 expected-stdout: 12647 fxbar 0 12648 --- 12649 name: better-parens-2a 12650 description: 12651 Check support for (()) and $(()) vs () and $() 12652 stdin: 12653 if ((echo fubar)|tr u x); then 12654 echo ja 12655 else 12656 echo nein 12657 fi 12658 expected-stdout: 12659 fxbar 12660 ja 12661 --- 12662 name: better-parens-2b 12663 description: 12664 Check support for (()) and $(()) vs () and $() 12665 stdin: 12666 echo $((echo fubar)|tr u x) $? 12667 expected-stdout: 12668 fxbar 0 12669 --- 12670 name: better-parens-2c 12671 description: 12672 Check support for (()) and $(()) vs () and $() 12673 stdin: 12674 x=$((echo fubar)|tr u x); echo $x $? 12675 expected-stdout: 12676 fxbar 0 12677 --- 12678 name: better-parens-3a 12679 description: 12680 Check support for (()) and $(()) vs () and $() 12681 stdin: 12682 if ( (echo fubar)|(tr u x)); then 12683 echo ja 12684 else 12685 echo nein 12686 fi 12687 expected-stdout: 12688 fxbar 12689 ja 12690 --- 12691 name: better-parens-3b 12692 description: 12693 Check support for (()) and $(()) vs () and $() 12694 stdin: 12695 echo $( (echo fubar)|(tr u x)) $? 12696 expected-stdout: 12697 fxbar 0 12698 --- 12699 name: better-parens-3c 12700 description: 12701 Check support for (()) and $(()) vs () and $() 12702 stdin: 12703 x=$( (echo fubar)|(tr u x)); echo $x $? 12704 expected-stdout: 12705 fxbar 0 12706 --- 12707 name: better-parens-4a 12708 description: 12709 Check support for (()) and $(()) vs () and $() 12710 stdin: 12711 if ((echo fubar)|(tr u x)); then 12712 echo ja 12713 else 12714 echo nein 12715 fi 12716 expected-stdout: 12717 fxbar 12718 ja 12719 --- 12720 name: better-parens-4b 12721 description: 12722 Check support for (()) and $(()) vs () and $() 12723 stdin: 12724 echo $((echo fubar)|(tr u x)) $? 12725 expected-stdout: 12726 fxbar 0 12727 --- 12728 name: better-parens-4c 12729 description: 12730 Check support for (()) and $(()) vs () and $() 12731 stdin: 12732 x=$((echo fubar)|(tr u x)); echo $x $? 12733 expected-stdout: 12734 fxbar 0 12735 --- 12736 name: better-parens-5 12737 description: 12738 Another corner case 12739 stdin: 12740 ( (echo 'fo o$bar' "baz\$bla\"" m\$eh) | tr a A) 12741 ((echo 'fo o$bar' "baz\$bla\"" m\$eh) | tr a A) 12742 expected-stdout: 12743 fo o$bAr bAz$blA" m$eh 12744 fo o$bAr bAz$blA" m$eh 12745 --- 12746 name: echo-test-1 12747 description: 12748 Test what the echo builtin does (mksh) 12749 category: !shell:ebcdic-yes 12750 stdin: 12751 echo -n 'foo\x40bar' 12752 echo -e '\tbaz' 12753 expected-stdout: 12754 foo@bar baz 12755 --- 12756 name: echo-test-1-ebcdic 12757 description: 12758 Test what the echo builtin does (mksh) 12759 category: !shell:ebcdic-no 12760 stdin: 12761 echo -n 'foo\x7Cbar' 12762 echo -e '\tbaz' 12763 expected-stdout: 12764 foo@bar baz 12765 --- 12766 name: echo-test-2 12767 description: 12768 Test what the echo builtin does (POSIX) 12769 Note: this follows Debian Policy 10.4 which mandates 12770 that -n shall be treated as an option, not XSI which 12771 mandates it shall be treated as string but escapes 12772 shall be expanded. 12773 stdin: 12774 test -n "$POSH_VERSION" || set -o posix 12775 echo -n 'foo\x40bar' 12776 echo -e '\tbaz' 12777 expected-stdout: 12778 foo\x40bar-e \tbaz 12779 --- 12780 name: echo-test-3-mnbsd 12781 description: 12782 Test what the echo builtin does, and test a compatibility flag. 12783 category: mnbsdash 12784 stdin: 12785 "$__progname" -c 'echo -n 1=\\x40$1; echo -e \\x2E' -- foo bar 12786 "$__progname" -o posix -c 'echo -n 2=\\x40$1; echo -e \\x2E' -- foo bar 12787 "$__progname" -o sh -c 'echo -n 3=\\x40$1; echo -e \\x2E' -- foo bar 12788 expected-stdout: 12789 1=@foo. 12790 2=\x40foo-e \x2E 12791 3=\x40bar. 12792 --- 12793 name: echo-test-3-normal 12794 description: 12795 Test what the echo builtin does, and test a compatibility flag. 12796 category: !mnbsdash,!shell:ebcdic-yes 12797 stdin: 12798 "$__progname" -c 'echo -n 1=\\x40$1; echo -e \\x2E' -- foo bar 12799 "$__progname" -o posix -c 'echo -n 2=\\x40$1; echo -e \\x2E' -- foo bar 12800 "$__progname" -o sh -c 'echo -n 3=\\x40$1; echo -e \\x2E' -- foo bar 12801 expected-stdout: 12802 1=@foo. 12803 2=\x40foo-e \x2E 12804 3=\x40foo-e \x2E 12805 --- 12806 name: echo-test-3-ebcdic 12807 description: 12808 Test what the echo builtin does, and test a compatibility flag. 12809 category: !mnbsdash,!shell:ebcdic-no 12810 stdin: 12811 "$__progname" -c 'echo -n 1=\\x7C$1; echo -e \\x4B' -- foo bar 12812 "$__progname" -o posix -c 'echo -n 2=\\x7C$1; echo -e \\x4B' -- foo bar 12813 "$__progname" -o sh -c 'echo -n 3=\\x7C$1; echo -e \\x4B' -- foo bar 12814 expected-stdout: 12815 1=@foo. 12816 2=\x7Cfoo-e \x4B 12817 3=\x7Cfoo-e \x4B 12818 --- 12819 name: utilities-getopts-1 12820 description: 12821 getopts sets OPTIND correctly for unparsed option 12822 stdin: 12823 set -- -a -a -x 12824 while getopts :a optc; do 12825 echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc." 12826 done 12827 echo done 12828 expected-stdout: 12829 OPTARG=, OPTIND=2, optc=a. 12830 OPTARG=, OPTIND=3, optc=a. 12831 OPTARG=x, OPTIND=4, optc=?. 12832 done 12833 --- 12834 name: utilities-getopts-2 12835 description: 12836 Check OPTARG 12837 stdin: 12838 set -- -a Mary -x 12839 while getopts a: optc; do 12840 echo "OPTARG=$OPTARG, OPTIND=$OPTIND, optc=$optc." 12841 done 12842 echo done 12843 expected-stdout: 12844 OPTARG=Mary, OPTIND=3, optc=a. 12845 OPTARG=, OPTIND=4, optc=?. 12846 done 12847 expected-stderr-pattern: /.*-x.*option/ 12848 --- 12849 name: utilities-getopts-3 12850 description: 12851 Check unsetting OPTARG 12852 stdin: 12853 set -- -x arg -y 12854 getopts x:y opt && echo "${OPTARG-unset}" 12855 getopts x:y opt && echo "${OPTARG-unset}" 12856 expected-stdout: 12857 arg 12858 unset 12859 --- 12860 name: wcswidth-1 12861 description: 12862 Check the new wcswidth feature 12863 stdin: 12864 s= 12865 set +U 12866 print octets: ${#s} . 12867 print 8-bit width: ${%s} . 12868 set -U 12869 print characters: ${#s} . 12870 print columns: ${%s} . 12871 s= 12872 set +U 12873 print octets: ${#s} . 12874 print 8-bit width: ${%s} . 12875 set -U 12876 print characters: ${#s} . 12877 print columns: ${%s} . 12878 expected-stdout: 12879 octets: 3 . 12880 8-bit width: -1 . 12881 characters: 1 . 12882 columns: 2 . 12883 octets: 3 . 12884 8-bit width: 3 . 12885 characters: 1 . 12886 columns: 1 . 12887 --- 12888 name: wcswidth-2 12889 description: 12890 Check some corner cases 12891 stdin: 12892 print % $% . 12893 set -U 12894 x='a b' 12895 print c ${%x} . 12896 set +U 12897 x='a b' 12898 print d ${%x} . 12899 expected-stdout: 12900 % $% . 12901 c -1 . 12902 d -1 . 12903 --- 12904 name: wcswidth-3 12905 description: 12906 Check some corner cases 12907 stdin: 12908 print ${%} . 12909 expected-stderr-pattern: 12910 /bad substitution/ 12911 expected-exit: 1 12912 --- 12913 name: wcswidth-4a 12914 description: 12915 Check some corner cases 12916 stdin: 12917 print ${%*} . 12918 expected-stderr-pattern: 12919 /bad substitution/ 12920 expected-exit: 1 12921 --- 12922 name: wcswidth-4b 12923 description: 12924 Check some corner cases 12925 stdin: 12926 print ${%@} . 12927 expected-stderr-pattern: 12928 /bad substitution/ 12929 expected-exit: 1 12930 --- 12931 name: wcswidth-4c 12932 description: 12933 Check some corner cases 12934 stdin: 12935 : 12936 print ${%?} . 12937 expected-stdout: 12938 1 . 12939 --- 12940 name: realpath-1 12941 description: 12942 Check proper return values for realpath 12943 category: os:mirbsd 12944 stdin: 12945 wd=$(realpath .) 12946 mkdir dir 12947 :>file 12948 :>dir/file 12949 ln -s dir lndir 12950 ln -s file lnfile 12951 ln -s nix lnnix 12952 ln -s . lnself 12953 i=0 12954 chk() { 12955 typeset x y 12956 x=$(realpath "$wd/$1" 2>&1); y=$? 12957 print $((++i)) "?$1" =${x##*$wd/} !$y 12958 } 12959 chk dir 12960 chk dir/ 12961 chk dir/file 12962 chk dir/nix 12963 chk file 12964 chk file/ 12965 chk file/file 12966 chk file/nix 12967 chk nix 12968 chk nix/ 12969 chk nix/file 12970 chk nix/nix 12971 chk lndir 12972 chk lndir/ 12973 chk lndir/file 12974 chk lndir/nix 12975 chk lnfile 12976 chk lnfile/ 12977 chk lnfile/file 12978 chk lnfile/nix 12979 chk lnnix 12980 chk lnnix/ 12981 chk lnnix/file 12982 chk lnnix/nix 12983 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 12984 rm lnself 12985 expected-stdout: 12986 1 ?dir =dir !0 12987 2 ?dir/ =dir !0 12988 3 ?dir/file =dir/file !0 12989 4 ?dir/nix =dir/nix !0 12990 5 ?file =file !0 12991 6 ?file/ =file/: Not a directory !20 12992 7 ?file/file =file/file: Not a directory !20 12993 8 ?file/nix =file/nix: Not a directory !20 12994 9 ?nix =nix !0 12995 10 ?nix/ =nix !0 12996 11 ?nix/file =nix/file: No such file or directory !2 12997 12 ?nix/nix =nix/nix: No such file or directory !2 12998 13 ?lndir =dir !0 12999 14 ?lndir/ =dir !0 13000 15 ?lndir/file =dir/file !0 13001 16 ?lndir/nix =dir/nix !0 13002 17 ?lnfile =file !0 13003 18 ?lnfile/ =lnfile/: Not a directory !20 13004 19 ?lnfile/file =lnfile/file: Not a directory !20 13005 20 ?lnfile/nix =lnfile/nix: Not a directory !20 13006 21 ?lnnix =nix !0 13007 22 ?lnnix/ =nix !0 13008 23 ?lnnix/file =lnnix/file: No such file or directory !2 13009 24 ?lnnix/nix =lnnix/nix: No such file or directory !2 13010 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 13011 --- 13012 name: realpath-2 13013 description: 13014 Ensure that exactly two leading slashes are not collapsed 13015 POSIX guarantees this exception, e.g. for UNC paths on Cygwin 13016 category: os:mirbsd 13017 stdin: 13018 ln -s /bin t1 13019 ln -s //bin t2 13020 ln -s ///bin t3 13021 realpath /bin 13022 realpath //bin 13023 realpath ///bin 13024 realpath /usr/bin 13025 realpath /usr//bin 13026 realpath /usr///bin 13027 realpath t1 13028 realpath t2 13029 realpath t3 13030 rm -f t1 t2 t3 13031 cd //usr/bin 13032 pwd 13033 cd ../lib 13034 pwd 13035 realpath //usr/include/../bin 13036 expected-stdout: 13037 /bin 13038 //bin 13039 /bin 13040 /usr/bin 13041 /usr/bin 13042 /usr/bin 13043 /bin 13044 //bin 13045 /bin 13046 //usr/bin 13047 //usr/lib 13048 //usr/bin 13049 --- 13050 name: crash-1 13051 description: 13052 Crashed during March 2011, fixed on vernal equinx 13053 category: os:mirbsd,os:openbsd 13054 stdin: 13055 export MALLOC_OPTIONS=FGJPRSX 13056 "$__progname" -c 'x=$(tr z r <<<baz); echo $x' 13057 expected-stdout: 13058 bar 13059 --- 13060 name: debian-117-1 13061 description: 13062 Check test - bug#465250 13063 stdin: 13064 test \( ! -e \) ; echo $? 13065 expected-stdout: 13066 1 13067 --- 13068 name: debian-117-2 13069 description: 13070 Check test - bug#465250 13071 stdin: 13072 test \( -e \) ; echo $? 13073 expected-stdout: 13074 0 13075 --- 13076 name: debian-117-3 13077 description: 13078 Check test - bug#465250 13079 stdin: 13080 test ! -e ; echo $? 13081 expected-stdout: 13082 1 13083 --- 13084 name: debian-117-4 13085 description: 13086 Check test - bug#465250 13087 stdin: 13088 test -e ; echo $? 13089 expected-stdout: 13090 0 13091 --- 13092 name: case-zsh 13093 description: 13094 Check that zsh case variants work 13095 stdin: 13096 case 'b' in 13097 a) echo a ;; 13098 b) echo b ;; 13099 c) echo c ;; 13100 *) echo x ;; 13101 esac 13102 echo = 13103 case 'b' in 13104 a) echo a ;& 13105 b) echo b ;& 13106 c) echo c ;& 13107 *) echo x ;& 13108 esac 13109 echo = 13110 case 'b' in 13111 a) echo a ;| 13112 b) echo b ;| 13113 c) echo c ;| 13114 *) echo x ;| 13115 esac 13116 expected-stdout: 13117 b 13118 = 13119 b 13120 c 13121 x 13122 = 13123 b 13124 x 13125 --- 13126 name: case-braces 13127 description: 13128 Check that case end tokens are not mixed up (Debian #220272) 13129 stdin: 13130 i=0 13131 for value in 'x' '}' 'esac'; do 13132 print -n "$((++i))($value)bourne " 13133 case $value in 13134 }) echo brace ;; 13135 *) echo no ;; 13136 esac 13137 print -n "$((++i))($value)korn " 13138 case $value { 13139 esac) echo esac ;; 13140 *) echo no ;; 13141 } 13142 done 13143 expected-stdout: 13144 1(x)bourne no 13145 2(x)korn no 13146 3(})bourne brace 13147 4(})korn no 13148 5(esac)bourne no 13149 6(esac)korn esac 13150 --- 13151 name: command-shift 13152 description: 13153 Check that 'command shift' works 13154 stdin: 13155 function snc { 13156 echo "before 0='$0' 1='$1' 2='$2'" 13157 shift 13158 echo "after 0='$0' 1='$1' 2='$2'" 13159 } 13160 function swc { 13161 echo "before 0='$0' 1='$1' 2='$2'" 13162 command shift 13163 echo "after 0='$0' 1='$1' 2='$2'" 13164 } 13165 echo = without command 13166 snc 13167 echo = with command 13168 swc 13169 echo = done 13170 expected-stdout: 13171 = without command 13172 before 0='snc' 1='' 2='' 13173 after 0='snc' 1='' 2='' 13174 = with command 13175 before 0='swc' 1='' 2='' 13176 after 0='swc' 1='' 2='' 13177 = done 13178 --- 13179 name: command-pvV-posix-priorities 13180 description: 13181 For POSIX compatibility, command -v should find aliases and reserved 13182 words, and command -p[vV] should find aliases, reserved words, and 13183 builtins over external commands. 13184 stdin: 13185 PATH=/bin:/usr/bin 13186 alias foo="bar baz" 13187 bar() { :; } 13188 for word in 'if' 'foo' 'bar' 'set' 'true'; do 13189 command -v "$word" 13190 command -pv "$word" 13191 command -V "$word" 13192 command -pV "$word" 13193 done 13194 expected-stdout: 13195 if 13196 if 13197 if is a reserved word 13198 if is a reserved word 13199 alias foo='bar baz' 13200 alias foo='bar baz' 13201 foo is an alias for 'bar baz' 13202 foo is an alias for 'bar baz' 13203 bar 13204 bar 13205 bar is a function 13206 bar is a function 13207 set 13208 set 13209 set is a special shell builtin 13210 set is a special shell builtin 13211 true 13212 true 13213 true is a shell builtin 13214 true is a shell builtin 13215 --- 13216 name: whence-preserve-tradition 13217 description: 13218 This regression test is to ensure that the POSIX compatibility 13219 changes for 'command' (see previous test) do not affect traditional 13220 'whence' behaviour. 13221 category: os:mirbsd 13222 stdin: 13223 PATH=/bin:/usr/bin 13224 alias foo="bar baz" 13225 bar() { :; } 13226 for word in 'if' 'foo' 'bar' 'set' 'true'; do 13227 whence "$word" 13228 whence -p "$word" 13229 whence -v "$word" 13230 whence -pv "$word" 13231 done 13232 expected-stdout: 13233 if 13234 if is a reserved word 13235 if not found 13236 'bar baz' 13237 foo is an alias for 'bar baz' 13238 foo not found 13239 bar 13240 bar is a function 13241 bar not found 13242 set 13243 set is a special shell builtin 13244 set not found 13245 true 13246 /bin/true 13247 true is a shell builtin 13248 true is a tracked alias for /bin/true 13249 --- 13250 name: duffs-device 13251 description: 13252 Check that the compiler did not optimise-break them 13253 (lex.c has got a similar one in SHEREDELIM) 13254 category: !shell:faux-ebcdic,!shell:ebcdic-yes 13255 stdin: 13256 set +U 13257 s= 13258 typeset -i1 i=0 13259 while (( ++i < 256 )); do 13260 s+=${i#1#} 13261 done 13262 s+=$'\xC2\xA0\xE2\x82\xAC\xEF\xBF\xBD\xEF\xBF\xBE\xEF\xBF\xBF\xF0\x90\x80\x80.' 13263 typeset -p s 13264 expected-stdout: 13265 typeset s=$'\001\002\003\004\005\006\a\b\t\n\v\f\r\016\017\020\021\022\023\024\025\026\027\030\031\032\E\034\035\036\037 !"#$%&\047()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317\320\321\322\323\324\325\326\327\330\331\332\333\334\335\336\337\340\341\342\343\344\345\346\347\350\351\352\353\354\355\356\357\360\361\362\363\364\365\366\367\370\371\372\373\374\375\376\377\u00A0\u20AC\uFFFD\357\277\276\357\277\277\360\220\200\200.' 13266 --- 13267 name: duffs-device-ebcdic 13268 description: 13269 Check that the compiler did not optimise-break them 13270 category: !shell:ebcdic-no 13271 stdin: 13272 set +U 13273 s= 13274 typeset -i1 i=0 13275 while (( ++i < 256 )); do 13276 s+=${i#1#} 13277 done 13278 #s+=$'\xC2\xA0\xE2\x82\xAC\xEF\xBF\xBD\xEF\xBF\xBE\xEF\xBF\xBF\xF0\x90\x80\x80.' #XXX 13279 typeset -p s 13280 expected-stdout: 13281 typeset s=$'\001\002\003\004\t\006\007\010\011\012\v\f\r\016\017\020\021\022\023\024\n\b\027\030\031\032\033\034\035\036\037\040\041\042\043\044\045\046\E\050\051\052\053\054\055\056\a\060\061\062\063\064\065\066\067\070\071\072\073\074\075\076\077 .<(+|&!$*);^-/,%_>?`:#@\175="abcdefghijklmnopqr~stuvwxyz[]{ABCDEFGHI}JKLMNOPQR\\STUVWXYZ0123456789\377' 13282 --- 13283 name: duffs-device-faux-EBCDIC 13284 description: 13285 Check that the compiler did not optimise-break them 13286 category: shell:faux-ebcdic 13287 stdin: 13288 set +U 13289 s= 13290 typeset -i1 i=0 13291 while (( ++i < 256 )); do 13292 s+=${i#1#} 13293 done 13294 s+=$'\xC2\xA0\xE2\x82\xAC\xEF\xBF\xBD\xEF\xBF\xBE\xEF\xBF\xBF\xF0\x90\x80\x80.' 13295 typeset -p s 13296 expected-stdout: 13297 typeset s=$'\001\002\003\004\005\006\a\b\t\n\v\f\r\016\017\020\021\022\023\024\025\026\027\030\031\032\E\034\035\036\037 !"#$%&\047()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~\177\200\201\202\203\204\205\206\207\210\211\212\213\214\215\216\217\220\221\222\223\224\225\226\227\230\231\232\233\234\235\236\237\u00A0\u20AC\uFFFD\220\200\200.' 13298 --- 13299 name: stateptr-underflow 13300 description: 13301 This check overflows an Xrestpos stored in a short in R40 13302 category: fastbox 13303 stdin: 13304 function Lb64decode { 13305 [[ -o utf8-mode ]]; local u=$? 13306 set +U 13307 local c s="$*" t= 13308 [[ -n $s ]] || { s=$(cat;print x); s=${s%x}; } 13309 local -i i=0 n=${#s} p=0 v x 13310 local -i16 o 13311 13312 while (( i < n )); do 13313 c=${s:(i++):1} 13314 case $c { 13315 (=) break ;; 13316 ([A-Z]) (( v = 1#$c - 65 )) ;; 13317 ([a-z]) (( v = 1#$c - 71 )) ;; 13318 ([0-9]) (( v = 1#$c + 4 )) ;; 13319 (+) v=62 ;; 13320 (/) v=63 ;; 13321 (*) continue ;; 13322 } 13323 (( x = (x << 6) | v )) 13324 case $((p++)) { 13325 (0) continue ;; 13326 (1) (( o = (x >> 4) & 255 )) ;; 13327 (2) (( o = (x >> 2) & 255 )) ;; 13328 (3) (( o = x & 255 )) 13329 p=0 13330 ;; 13331 } 13332 t=$t\\x${o#16#} 13333 done 13334 print -n $t 13335 (( u )) || set -U 13336 } 13337 13338 i=-1 13339 s= 13340 while (( ++i < 12120 )); do 13341 s+=a 13342 done 13343 Lb64decode $s >/dev/null 13344 --- 13345 name: xtrace-1 13346 description: 13347 Check that "set -x" doesn't redirect too quickly 13348 stdin: 13349 print '#!'"$__progname" >bash 13350 cat >>bash <<'EOF' 13351 echo 'GNU bash, version 2.05b.0(1)-release (i386-ecce-mirbsd10) 13352 Copyright (C) 2002 Free Software Foundation, Inc.' 13353 EOF 13354 chmod +x bash 13355 "$__progname" -xc 'foo=$(./bash --version 2>&1 | sed q); echo "=$foo="' 13356 expected-stdout: 13357 =GNU bash, version 2.05b.0(1)-release (i386-ecce-mirbsd10)= 13358 expected-stderr-pattern: 13359 /.*/ 13360 --- 13361 name: xtrace-2 13362 description: 13363 Check that "set -x" is off during PS4 expansion 13364 stdin: 13365 f() { 13366 print -n "(f1:$-)" 13367 set -x 13368 print -n "(f2:$-)" 13369 } 13370 PS4='[(p:$-)$(f)] ' 13371 print "(o0:$-)" 13372 set -x -o inherit-xtrace 13373 print "(o1:$-)" 13374 set +x 13375 print "(o2:$-)" 13376 expected-stdout: 13377 (o0:sh) 13378 (o1:shx) 13379 (o2:sh) 13380 expected-stderr: 13381 [(p:sh)(f1:sh)(f2:sh)] print '(o1:shx)' 13382 [(p:sh)(f1:sh)(f2:sh)] set +x 13383 --- 13384 name: fksh-flags 13385 description: 13386 Check that FKSH functions have their own shell flags 13387 category: shell:legacy-no 13388 stdin: 13389 [[ $KSH_VERSION = Version* ]] && set +B 13390 function foo { 13391 set +f 13392 set -e 13393 echo 2 "${-/s}" . 13394 } 13395 set -fh 13396 echo 1 "${-/s}" . 13397 foo 13398 echo 3 "${-/s}" . 13399 expected-stdout: 13400 1 fh . 13401 2 eh . 13402 3 fh . 13403 --- 13404 name: fksh-flags-legacy 13405 description: 13406 Check that even FKSH functions share the shell flags 13407 category: shell:legacy-yes 13408 stdin: 13409 [[ $KSH_VERSION = Version* ]] && set +B 13410 foo() { 13411 set +f 13412 set -e 13413 echo 2 "${-/s}" . 13414 } 13415 set -fh 13416 echo 1 "${-/s}" . 13417 foo 13418 echo 3 "${-/s}" . 13419 expected-stdout: 13420 1 fh . 13421 2 eh . 13422 3 eh . 13423 --- 13424 name: fsh-flags 13425 description: 13426 Check that !FKSH functions share the shell flags 13427 stdin: 13428 [[ $KSH_VERSION = Version* ]] && set +B 13429 foo() { 13430 set +f 13431 set -e 13432 echo 2 "${-/s}" . 13433 } 13434 set -fh 13435 echo 1 "${-/s}" . 13436 foo 13437 echo 3 "${-/s}" . 13438 expected-stdout: 13439 1 fh . 13440 2 eh . 13441 3 eh . 13442 --- 13443