1# Special shell variables 2 3# The space after $ is to avoid expanding the variables in testsuite output, 4# to work-around a bug in autotest 5 6# Not testing any functionality 7m4_define([VAR_UNSET], 8[AT_SETUP([$ $1]) 9AT_CHECK([tcsh -f -c 'echo $?$1'], , 10[0 11]) 12AT_CLEANUP 13]) 14m4_define([ENV_SET], 15[AT_SETUP([$ $1]) 16AT_CHECK([tcsh -f -c 'printenv $1'], 0, [ignore]) 17AT_CLEANUP 18]) 19m4_define([ENV_UNSET], 20[AT_SETUP([$ $1]) 21AT_CHECK([tcsh -f -c 'printenv $1'], 1, 22[0 23]) 24AT_CLEANUP 25]) 26 27 28AT_SETUP([$ addsuffix]) 29 30AT_CHECK([tcsh -f -c 'echo $?addsuffix'], , 31[1 32]) 33# Nothing more 34 35AT_CLEANUP 36 37 38VAR_UNSET([afsuser]) 39VAR_UNSET([ampm]) 40 41 42AT_SETUP([$ argv]) 43 44AT_CHECK([tcsh -f -c 'echo $argv; echo $2' foo bar baz], , 45[foo bar baz 46bar 47]) 48 49AT_CLEANUP 50 51 52VAR_UNSET([autocorrect]) 53VAR_UNSET([autoexpand]) 54VAR_UNSET([autolist]) 55TCSH_UNTESTED([$ autologout]) 56 57 58AT_SETUP([$ backslash_quote]) 59 60AT_DATA([backslash.csh], 61[[echo $?backslash_quote 62set echo_style=none 63echo 'foo\\bar' 64echo "foo\\bar" 65echo 'foo\bar' 66echo "foo\bar" 67set backslash_quote 68echo 'foo\\bar' 69echo "foo\\bar" 70echo 'foo\'bar' 71echo 'foo\"bar' 72echo "foo\"bar" 73echo "foo\'bar" 74echo 'foo\bar' 75echo "foo\bar" 76]]) 77AT_CHECK([tcsh -f backslash.csh], , 78[0 79foo\\bar 80foo\\bar 81foo\bar 82foo\bar 83foo\bar 84foo\bar 85foo'bar 86foo"bar 87foo"bar 88foo'bar 89foo\bar 90foo\bar 91]) 92 93AT_CLEANUP 94 95 96VAR_UNSET([catalog]) 97 98 99AT_SETUP([$ cdpath]) 100 101AT_DATA([cdpath.csh], 102[[echo $?cdpath 103set cdpath=($cwd /) 104set home=$cwd 105mkdir tcsh_test_dir 106cd dev 107cd tcsh_test_dir 108]]) 109AT_CHECK([tcsh -f cdpath.csh], , 110[0 111/dev @&t@ 112~/tcsh_test_dir @&t@ 113]) 114 115AT_CLEANUP 116 117 118VAR_UNSET([color]) 119VAR_UNSET([colorcat]) 120 121 122AT_SETUP([$ command]) 123 124AT_CHECK([tcsh -f -c 'echo $command'], , 125[echo $command 126]) 127 128AT_DATA([command.csh], 129[[echo $?command 130]]) 131AT_CHECK([tcsh -f command.csh], , 132[0 133]) 134 135AT_CLEANUP 136 137 138VAR_UNSET([complete]) 139VAR_UNSET([continue]) 140VAR_UNSET([continue_args]) 141VAR_UNSET([correct]) 142 143 144AT_SETUP([$ csubstnonl]) 145 146touch test_file 147 148AT_DATA([csubstnonl.csh], 149[[echo $?csubstnonl 150echo `echo fail \ 151| sed 's/fail/OK/'` 152sh -c 'echo 1 >&2' 153(echo `echo fail | \\ 154sed 's/fail/OK/'`) 155sh -c 'echo 2 >&2' 156echo `echo a\ 157b` 158unset csubstnonl 159sh -c 'echo 3 >&2' 160(echo `echo fail \ 161| sed 's/fail/OK/'`) 162sh -c 'echo 4 >&2' 163echo `echo fail | \\ 164sed 's/fail/OK/'` 165echo `echo \\ 166?est_file` 167echo `cat << END\ 168OK\ 169END` 170]]) 171AT_CHECK([tcsh -f csubstnonl.csh], , 172[1 173OK 174 175a b 176fail 177OK 178test_file 179OK 180], 181[1 182 sed: Command not found. 1832 1843 185Invalid null command. 1864 187]) 188 189AT_CLEANUP 190 191 192AT_SETUP([$ cwd]) 193 194AT_DATA([cwd.csh], 195[[echo $?cwd 196printenv PWD 197cd / 198echo $cwd 199pushd /dev 200echo $cwd 201popd 202echo $cwd 203printenv PWD 204setenv PWD foo 205echo $cwd 206set cwd=bar 207printenv PWD 208]]) 209AT_CHECK([tcsh -f cwd.csh | sed "s,$PWD,CWD,"], , 210[1 211CWD 212/ 213/dev / @&t@ 214/dev 215/ @&t@ 216/ 217/ 218/ 219foo 220]) 221 222AT_CLEANUP 223 224 225VAR_UNSET([dextract]) # Behavior tested with pushd 226VAR_UNSET([dirsfile]) 227 228 229AT_SETUP([$ dirstack]) 230 231AT_DATA([dirstack.csh], 232[[echo $dirstack 233set home=$cwd 234pushd / 235echo $dirstack 236set dirstack=(/ /dev $home) 237# The first popd does nothing, looks like a bug 238popd 239popd 240echo $dirstack 241]]) 242AT_CHECK([tcsh -f dirstack.csh | sed "s,$PWD,CWD,g"], , 243[CWD 244/ ~ @&t@ 245/ CWD 246/ /dev ~ @&t@ 247/dev ~ @&t@ 248/dev CWD 249]) 250 251AT_CLEANUP 252 253 254TCSH_UNTESTED([$ dspmbyte]) 255VAR_UNSET([dunique]) # Behavior tested with pushd 256 257 258AT_SETUP([$ echo]) 259 260touch some_file; 261 262AT_CHECK([tcsh -f -c 'echo $?echo'], , 263[0 264]) 265 266AT_CHECK([tcsh -f -x -c 'echo $?echo'], , 267[1 268], 269[echo 1 270]) 271 272AT_DATA([echo.csh], 273[[ls some_* 274set echo 275ls some_* $echo 276echo some_* $echo 277]]) 278AT_CHECK([tcsh -f echo.csh], , 279[some_file 280some_file 281some_file 282], 283[ls some_file 284echo some_* 285]) 286 287AT_CLEANUP 288 289 290AT_SETUP([$ echo_style]) 291 292AT_DATA([echo_style.csh], 293[[echo $?echo_style 294set echo_style=bsd 295echo -n foo 296echo 'b\tr' 297set echo_style=sysv 298echo -n foo 299echo 'b\tr' 300set echo_style=both 301echo -n foo 302echo 'b\tr' 303set echo_style=none 304echo -n foo 305echo 'b\tr' 306]]) 307AT_CHECK([tcsh -f echo_style.csh], , 308[1 309foob\tr 310-n foo 311b r 312foob r 313-n foo 314b\tr 315]) 316 317AT_CLEANUP 318 319 320AT_SETUP([$ edit]) 321 322AT_CHECK([TERM=something tcsh -f -c 'echo $?edit'], , 323[1 324]) 325 326AT_CHECK([TERM=dumb tcsh -f -c 'echo $?edit'], , 327[0 328]) 329 330AT_CLEANUP 331 332 333AT_SETUP([$ ellipsis]) 334 335AT_DATA([ellipsis0.csh], 336[[echo $?ellipsis 337set home=$cwd 338mkdir -p a/b 339cd a/b 340set prompt='%c01 ' 341]]) 342AT_CHECK([tcsh -f -i -q < ellipsis0.csh], , 343[> 0 344~/<1>b exit 345]) 346 347AT_DATA([ellipsis0.csh], 348[[set ellipsis 349set home=$cwd 350mkdir -p a/b 351cd a/b 352set prompt='%c01 ' 353]]) 354AT_CHECK([tcsh -f -i -q < ellipsis0.csh], , 355[> ~...b exit 356]) 357 358AT_CLEANUP 359 360 361VAR_UNSET([fignore]) 362VAR_UNSET([filec]) 363 364 365AT_SETUP([$ gid]) 366 367AT_CHECK([(tcsh -f -c 'echo $gid'; id -gr) | uniq | wc -l | tr -d ' \t'], , 368[1 369]) 370 371AT_CLEANUP 372 373 374AT_SETUP([$ group]) 375 376AT_DATA([group.csh], 377[[echo $?group 378set group=foo 379printenv GROUP 380setenv GROUP bar 381echo $group 382]]) 383AT_CHECK([tcsh -f group.csh], , 384[1 385foo 386bar 387]) 388 389AT_CLEANUP 390 391 392AT_SETUP([$ histchars]) 393 394AT_DATA([histchars.csh], 395[[echo $?histchars 396set histchars='/+' 397echo OK 398/3 399+K+k 400]]) 401AT_CHECK([tcsh -f -q -i < histchars.csh], , 402[> 0 403OK 404OK 405Ok 406> exit 407], 408[echo OK 409echo Ok 410]) 411 412AT_CLEANUP 413 414 415AT_SETUP([$ histdup]) 416 417AT_DATA([histdup.csh], 418[[echo $?histdup 419history -c 420: 1 421: 2 422: 1 423history 424set histdup=all 425history -c 426: 1 427: 2 428: 1 429history 430set histdup=prev 431history -c 432: 1 433: 2 434: 1 435: 3 436: 3 437history 438set histdup=erase 439history -c 440: 1 441: 2 442: 1 443history 444]]) 445AT_CHECK([[tcsh -f -q -i < histdup.csh] dnl 446 [| sed 's/ [^ ]* / TIME /']], , 447[> 0 448 3 TIME : 1 449 4 TIME : 2 450 5 TIME : 1 451 6 TIME history 452 9 TIME : 1 453 10 TIME : 2 454 11 TIME history 455 14 TIME : 1 456 15 TIME : 2 457 16 TIME : 1 458 17 TIME : 3 459 18 TIME history 460 22 TIME : 2 461 23 TIME : 1 462 24 TIME history 463> exit 464]) 465 466AT_CLEANUP 467 468 469VAR_UNSET([histfile]) 470 471 472AT_SETUP([$ histlit]) 473 474AT_DATA([histlit.csh], 475[[echo $?histlit 476echo OK 477!! 478history 479history -S hist1 480set histlit 481history 482history -S hist2 483]]) 484AT_CHECK([[tcsh -f -q -i < histlit.csh] dnl 485 [| sed 's/ [^ ]* / TIME /']], , 486[> 0 487OK 488OK 489 1 TIME echo $?histlit 490 2 TIME echo OK 491 3 TIME echo OK 492 4 TIME history 493 1 TIME echo $?histlit 494 2 TIME echo OK 495 3 TIME !! 496 4 TIME history 497 5 TIME history -S hist1 498 6 TIME set histlit 499 7 TIME history 500> exit 501], 502[echo OK 503]) 504AT_CHECK([[sed 's/^#+[0123456789]*$/#+STAMP/' < hist1]], , 505[#+STAMP 506echo $?histlit 507#+STAMP 508echo OK 509#+STAMP 510echo OK 511#+STAMP 512history 513#+STAMP 514history -S hist1 515]) 516AT_CHECK([[sed 's/^#+[0123456789]*$/#+STAMP/' < hist2]], , 517[#+STAMP 518echo $?histlit 519#+STAMP 520echo OK 521#+STAMP 522!! 523#+STAMP 524history 525#+STAMP 526history -S hist1 527#+STAMP 528set histlit 529#+STAMP 530history 531#+STAMP 532history -S hist2 533]) 534 535AT_CLEANUP 536 537 538AT_SETUP([$ history]) 539 540AT_DATA([history.csh], 541[[echo $#history $history 542set home=$cwd 543set var=value 544set history=(1 '%/,%~,%h,%\!,\!,%%,%j,%$var,%#,%R\n') 545: OK 546history 547]]) 548AT_CHECK([tcsh -f -i -q < history.csh | sed "s,$PWD,CWD,"], , 549[> 1 100 550CWD,~, 6, 6, 6,%,-1,value,>,history 551> exit 552]) 553 554AT_CLEANUP 555 556 557AT_SETUP([$ home]) 558 559AT_DATA([home.csh], 560[[echo $?home 561(echo $home; echo ~) | uniq | wc -l | tr -d ' \t' 562set home=/foo 563printenv HOME 564setenv HOME /bar 565echo $home 566]]) 567AT_CHECK([tcsh -f home.csh], , 568[1 5691 570/foo 571/bar 572]) 573 574AT_CHECK([(unset HOME; tcsh -f -c 'echo $?home; printenv HOME')], 1, 575[0 576]) 577 578AT_CLEANUP 579 580 581VAR_UNSET([ignoreeof]) 582 583 584AT_SETUP([$ implicitcd]) 585 586AT_DATA([implicitcd.csh], 587[[echo $?implicitcd 588mkdir subdir 589set home=$cwd 590sh -c 'echo 1 >&2' 591(subdir) 592sh -c 'echo 2 >&2' 593(~/subdir) 594sh -c 'echo 3 >&2' 595set implicitcd 596subdir 597pwd 598.. 599~/subdir 600pwd 601cd 602set implicitcd=verbose 603subdir 604.. 605~/subdir 606]]) 607(echo 1; echo 'subdir: Command not found.'; 608 echo 2; echo "$PWD/subdir: Permission denied."; echo 3) > experr 609AT_CHECK([tcsh -f -i -q < implicitcd.csh | sed "s,$PWD,CWD,"], , 610[> 0 611CWD/subdir 612CWD/subdir 613cd subdir 614cd .. 615cd ~/subdir 616> exit 617], [experr]) 618 619AT_CLEANUP 620 621 622VAR_UNSET([inputmode]) 623VAR_UNSET([killdup]) 624 625 626AT_SETUP([$ killring]) 627 628AT_CHECK([tcsh -f -c 'echo $killring'], , 629[30 630]) 631# Nothing more 632 633AT_CLEANUP 634 635 636AT_SETUP([$ listflags]) 637 638# First word checked with ls-F 639AT_DATA([listflags.csh], 640[[echo $?listflags 641set listflags=(-xA $cwd/args.sh) 642ls-F -something . 643]]) 644AT_DATA([args.sh], 645[[echo "$@" 646]]) 647chmod a+x args.sh 648AT_CHECK([tcsh -f listflags.csh], , 649[0 650-xFA -something . 651]) 652 653AT_CLEANUP 654 655 656VAR_UNSET([listjobs]) 657VAR_UNSET([listlinks]) # Functionality tested with ls-F 658VAR_UNSET([listmax]) 659VAR_UNSET([listmaxrows]) 660VAR_UNSET([loginsh]) # Can't test the other case 661VAR_UNSET([logout]) 662 663 664AT_SETUP([$ mail]) 665 666AT_DATA([mail.csh], 667[[echo $?mail 668mkdir maildir 669touch spool 670set mail=(0 spool maildir) 671echo > maildir/1 672echo > maildir/2 673echo >> spool 674echo >> spool 675]]) 676AT_CHECK([tcsh -f mail.csh], , 677[0 678]) 679 680AT_CLEANUP 681 682 683VAR_UNSET([matchbeep]) 684VAR_UNSET([nobeep]) 685VAR_UNSET([noclobber]) # Functionality tested with "Command execution" 686VAR_UNSET([noding]) 687# Functionality tested with "Filename substitution" and 688# "Directory stack substitution" 689VAR_UNSET([noglob]) 690VAR_UNSET([nostat]) 691VAR_UNSET([notify]) 692TCSH_UNTESTED([$ oid]) 693 694 695AT_SETUP([$ owd]) 696 697AT_DATA([owd.csh], 698[[echo $owd 699cd / 700echo $owd 701pushd /bin 702echo $owd 703popd 704echo $owd 705]]) 706AT_CHECK([tcsh -f owd.csh | sed "s,$PWD,CWD,"], , 707[ 708CWD 709/bin / @&t@ 710/ 711/ @&t@ 712/bin 713]) 714 715AT_CLEANUP 716 717 718AT_SETUP([$ path]) 719 720mkdir subdir 721AT_DATA([script.sh], 722[[echo home 723]]) 724AT_DATA([subdir/script.sh], 725[[echo subdir 726]]) 727chmod a+x script.sh subdir/script.sh 728AT_DATA([path.csh], 729[[echo $?path 730set path=(. subdir) 731script.sh 732set path=(subdir .) 733script.sh 734printenv PATH 735setenv PATH :foo::bar: 736echo $path 737]]) 738AT_CHECK([tcsh -f path.csh], , 739[1 740home 741subdir 742subdir:. 743. foo . bar . 744]) 745 746AT_CLEANUP 747 748 749AT_SETUP([$ printexitvalue]) 750 751AT_DATA([printexitvalue.csh], 752[[echo $?printexitvalue 753set printexitvalue 754false 755(exit 3 >/dev/null) 756: 757]]) 758AT_CHECK([tcsh -f printexitvalue.csh], , 759[0 760Exit 1 761Exit 3 762]) 763 764AT_CLEANUP 765 766 767AT_SETUP([$ prompt]) 768 769AT_DATA([prompt.csh], 770[[echo "$prompt" 771set home=$cwd 772mkdir -p a/b 773cd a/b 774set var=value 775set prompt='%/,%~,%c,%.,%c2,%.2,%c01,%.01,%C,%h,%\!,\!,%%,%j,%$var,%#,%? ' 776(exit 50) 777]]) 778AT_CHECK([tcsh -f -i -q < prompt.csh | sed "s,$PWD,CWD,"], , 779[> %# @&t@ 780CWD/a/b,~/a/b,b,b,~/a/b,~/a/b,~/<1>b,~/<1>b,b,8,8,8,%,0,value,>,50 exit 781]) 782 783AT_CLEANUP 784 785 786AT_SETUP([$ prompt2]) 787 788AT_CHECK([echo 'echo "$prompt2"' | tcsh -f], , 789[%R? @&t@ 790]) 791 792AT_CLEANUP 793 794 795AT_SETUP([$ prompt3]) 796 797AT_CHECK([echo 'echo "$prompt3"' | tcsh -f], , 798[CORRECT>%R (y|n|e|a)? @&t@ 799]) 800 801AT_CLEANUP 802 803AT_SETUP([$ promptchars]) 804 805AT_DATA([promptchars.csh], 806[[echo $?promptchars 807set promptchars=_x 808]]) 809AT_CHECK([tcsh -f -i -q < promptchars.csh], , 810[> 0 811_ exit 812]) 813 814AT_CLEANUP 815 816 817VAR_UNSET([pushdtohome]) # Functionality tested with pushd 818VAR_UNSET([pushdsilent]) # Functionality tested with pushd 819VAR_UNSET([recexact]) 820VAR_UNSET([recognize_only_executablers]) 821VAR_UNSET([rmstar]) 822 823 824AT_SETUP([$ rprompt]) 825 826AT_DATA([rprompt.csh], 827[[echo $?rprompt 828set home=$cwd 829mkdir -p a/b 830cd a/b 831set var=value 832set rprompt='%/,%~,%c,%.,%c2,%.2,%c01,%.01,%C,%h,%\!,\!,%%,%j,%$var,%#,%?' 833(exit 50) 834]]) 835AT_CHECK([tcsh -f -i -q < rprompt.csh | sed "s,$PWD,CWD,"], , 836[> 0 837> CWD/a/b,~/a/b,b,b,~/a/b,~/a/b,~/<1>b,~/<1>b,b,8,8,8,%,0,value,>,50 exit 838]) 839 840AT_CLEANUP 841 842 843VAR_UNSET([savedirs]) 844VAR_UNSET([savehist]) 845VAR_UNSET([sched]) 846 847 848AT_SETUP([$ shell]) 849 850AT_CHECK([tcsh -f -c 'echo $?shell'], , 851[1 852]) 853 854AT_CHECK([SHELL=foo/tcsh tcsh -f -c 'echo $shell'], , 855[foo/tcsh 856]) 857 858AT_CLEANUP 859 860 861AT_SETUP([$ shlvl]) 862 863AT_DATA([shlvl.csh], 864[[echo $shlvl 865set shlvl=8 866printenv SHLVL 867setenv SHLVL 2 868echo $shlvl 869tcsh -c 'echo $shlvl' 870]]) 871AT_CHECK([SHLVL=5 tcsh -f shlvl.csh], , 872[6 8738 8742 8753 876]) 877 878AT_CLEANUP 879 880 881AT_SETUP([$ status]) 882 883AT_DATA([status.csh], 884[[echo $status 885sh -c 'kill -ABRT $$' 886if ( $status > 128 ) echo OK 887true 888echo $status 889]]) 890AT_CHECK([tcsh -f status.csh | sed 's/Abort (core dumped)/Abort/'], , 891[0 892Abort 893OK 8940 895]) 896 897AT_CLEANUP 898 899 900AT_SETUP([$ symlinks]) 901 902AT_DATA([symlinks.csh], 903[[echo $?symlinks 904set home=$cwd 905mkdir -p a/b 906ln -s a/b link 907set symlinks=chase 908cd link 909echo $cwd 910cd 911set symlinks=ignore 912cd link 913echo $cwd 914cd .. 915echo $cwd 916set symlinks=expand 917cd a 918(echo ../a; echo `pwd`) | uniq | wc -l | tr -d ' \t' 919]]) 920AT_CHECK([tcsh -f symlinks.csh | sed "s,$PWD,CWD,"], , 921[0 922CWD/a/b 923CWD/link 924CWD 9251 926]) 927 928AT_CLEANUP 929 930 931AT_SETUP([$ tcsh]) 932 933AT_CHECK([tcsh -f -c 'echo $?tcsh'], , 934[1 935]) 936 937AT_CLEANUP 938 939 940AT_SETUP([$ term]) 941 942AT_DATA([term.csh], 943[[echo $term 944set term=foo 945printenv TERM 946setenv TERM bar 947echo $term 948]]) 949AT_CHECK([TERM=something tcsh -f term.csh], , 950[something 951foo 952bar 953]) 954 955AT_CHECK([(unset TERM; tcsh -f -c 'echo $?term; printenv TERM')], 1, 956[0 957]) 958 959AT_CLEANUP 960 961 962VAR_UNSET([time]) 963VAR_UNSET([tperiod]) 964 965 966AT_SETUP([$ tty]) 967 968AT_CHECK([tcsh -f -c 'echo ">$tty<"' < /dev/null], , 969[>< 970]) 971 972AT_CLEANUP 973 974 975AT_SETUP([$ uid]) 976 977AT_CHECK([(tcsh -f -c 'echo $uid'; id -ru) | uniq | wc -l | tr -d ' \t'], , 978[1 979]) 980 981AT_CLEANUP 982 983 984AT_SETUP([$ user]) 985 986AT_DATA([user.csh], 987[[echo $?user 988set user=foo 989printenv USER 990setenv USER bar 991echo $user 992]]) 993AT_CHECK([tcsh -f user.csh], , 994[1 995foo 996bar 997]) 998 999AT_CHECK([(unset USER; LOGNAME=foo tcsh -f -c 'echo $user; printenv USER')], , 1000[foo 1001foo 1002]) 1003 1004AT_CHECK([(unset LOGNAME; USER=foo tcsh -f -c 'echo $user; printenv LOGNAME')], 1005 , 1006[foo 1007foo 1008]) 1009 1010AT_CLEANUP 1011 1012 1013AT_SETUP([$ verbose]) 1014 1015AT_CHECK([tcsh -f -v -c 'echo $verbose'], , [ 1016], 1017[echo $verbose 1018]) 1019 1020AT_DATA([verbose.csh], 1021[[echo $?verbose 1022set verbose 1023echo $verbose 1024!! 1025]]) 1026AT_CHECK([tcsh -f -i -q < verbose.csh], , 1027[> 0 1028 1029 1030> exit 1031], 1032[echo $verbose 1033echo $verbose 1034]) 1035 1036AT_CLEANUP 1037 1038 1039AT_SETUP([$ version]) 1040 1041AT_CHECK([tcsh -f -c 'echo $?version'], , 1042[1 1043]) 1044 1045AT_CLEANUP 1046 1047 1048VAR_UNSET([visiblebell]) 1049VAR_UNSET([watch]) 1050VAR_UNSET([who]) 1051VAR_UNSET([wordchars]) 1052 1053 1054# Nothing to test for environment variables, except for the synchronization 1055# above 1056