1.\" $OpenBSD: csh.1,v 1.88 2023/03/30 16:16:32 jmc Exp $ 2.\" $NetBSD: csh.1,v 1.10 1995/03/21 09:02:35 cgd Exp $ 3.\" 4.\" Copyright (c) 1980, 1990, 1993 5.\" The Regents of the University of California. All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. Neither the name of the University nor the names of its contributors 16.\" may be used to endorse or promote products derived from this software 17.\" without specific prior written permission. 18.\" 19.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29.\" SUCH DAMAGE. 30.\" 31.\" @(#)csh.1 8.2 (Berkeley) 1/21/94 32.\" 33.Dd $Mdocdate: March 30 2023 $ 34.Dt CSH 1 35.Os 36.Sh NAME 37.Nm csh 38.Nd a shell (command interpreter) with C-like syntax 39.Sh SYNOPSIS 40.Nm csh 41.Op Fl bcefimnstVvXx 42.Op Ar argument ... 43.Nm csh 44.Op Fl l 45.Sh DESCRIPTION 46.Nm 47is a command language interpreter 48incorporating a history mechanism (see 49.Sx History substitutions ) , 50job control facilities (see 51.Sx Jobs ) , 52interactive file name 53and user name completion (see 54.Sx File name completion ) , 55and a C-like syntax. 56It is used both as an interactive 57login shell and a shell script command processor. 58.Ss Argument list processing 59If the first argument (argument 0) to the shell is a dash 60.Pq Sq \- , 61then this is a login shell. 62A login shell also can be specified by invoking the shell with the 63.Fl l 64flag as the only argument. 65.Pp 66The rest of the flag arguments are interpreted as follows: 67.Bl -tag -width 5n 68.It Fl b 69This flag forces a 70.Dq break 71from option processing, causing any further 72shell arguments to be treated as non-option arguments. 73The remaining arguments will not be interpreted as shell options. 74This may be used to pass options to a shell script without confusion 75or possible subterfuge. 76The shell will not run a set-user-ID script without this option. 77.It Fl c 78Commands are read from the (single) following argument which must 79be present. 80Any remaining arguments are placed in 81.Ar argv . 82.It Fl e 83The shell exits if any invoked command terminates abnormally 84or yields a non-zero exit status. 85.It Fl f 86The shell will start faster, because it will not execute user or 87system startup files, load saved history or perform command hashing. 88Note: if the environment variable 89.Ev HOME 90is not set, fast startup is the default. 91.It Fl i 92The shell is interactive and prompts for its top-level input, 93even if it appears not to be a terminal. 94Shells are interactive without this option if their inputs 95and outputs are terminals. 96.It Fl l 97The shell is a login shell (only applicable if 98.Fl l 99is the only flag specified). 100.It Fl m 101Read 102.Pa .cshrc , 103regardless of its owner and group. 104This option is dangerous and should only be used by 105.Xr su 1 . 106.It Fl n 107Commands are parsed, but not executed. 108This aids in syntactic checking of shell scripts. 109When used interactively, the 110shell can be terminated by pressing control-D (end-of-file character), since 111.Ic exit 112will not work. 113.It Fl s 114Command input is taken from the standard input. 115.It Fl t 116A single line of input is read and executed. 117A backslash 118.Pq Ql \e 119may be used to escape the newline at the end of this 120line and continue onto another line. 121.It Fl V 122Causes the 123.Va verbose 124variable to be set even before 125.Pa .cshrc 126is executed. 127.It Fl v 128Causes the 129.Va verbose 130variable to be set, with the effect 131that command input is echoed after history substitution. 132.It Fl X 133Causes the 134.Va echo 135variable to be set even before 136.Pa .cshrc 137is executed. 138.It Fl x 139Causes the 140.Va echo 141variable to be set, so that commands are echoed immediately before execution. 142.El 143.Pp 144After processing of flag arguments, if arguments remain but none of the 145.Fl c , 146.Fl i , 147.Fl s , 148or 149.Fl t 150options were given, the first argument is taken as the name of a file of 151commands to be executed. 152The shell opens this file, and saves its name for possible resubstitution 153by 154.Sq $0 . 155Since many systems use either the standard version 6 or version 7 shells 156whose shell scripts are not compatible with this shell, the shell will 157execute such a 158.Dq standard 159shell if the first character of a script 160is not a hash mark 161.Pq Ql # ; 162i.e., if the script does not start with a comment. 163Remaining arguments initialize the variable 164.Va argv . 165.Pp 166An instance of 167.Nm 168begins by executing commands from the file 169.Pa /etc/csh.cshrc 170and, 171if this is a login shell, 172.Pa /etc/csh.login . 173It then executes 174commands from 175.Pa .cshrc 176in the home directory of the invoker, 177and, if this is a login shell, the file 178.Pa .login 179in the same location. 180It is typical for users on CRTs to put the command 181.Ic stty crt 182in their 183.Pa .login 184file, and to also invoke 185.Xr tset 1 186there. 187.Pp 188In the normal case, the shell will begin reading commands from the 189terminal, prompting with 190.Sq "% " . 191Processing of arguments and the use of the shell to process files 192containing command scripts will be described later. 193.Pp 194The shell repeatedly performs the following actions: 195a line of command input is read and broken into 196.Dq words . 197This sequence of words is placed on the command history list and parsed. 198Finally each command in the current line is executed. 199.Pp 200When a login shell terminates, it executes commands from the files 201.Pa .logout 202in the user's home directory and 203.Pa /etc/csh.logout . 204.Ss Lexical structure 205The shell splits input lines into words at blanks and tabs with the 206following exceptions. 207The characters 208.Ql & , 209.Ql | , 210.Ql \&; , 211.Ql < , 212.Ql > , 213.Ql \&( , 214and 215.Ql \&) 216form separate words. 217If doubled in 218.Ql && , 219.Ql || , 220.Ql << , 221or 222.Ql >> , 223these pairs form single words. 224These parser metacharacters may be made part of other words, or have their 225special meaning prevented, by preceding them with a backslash 226.Pq Ql \e . 227A newline preceded by a 228.Ql \e 229is equivalent to a blank. 230.Pp 231Strings enclosed in matched pairs of quotations, 232.Ql \(aq , 233.Ql \` , 234or 235.Ql \&" , 236form parts of a word; metacharacters in these strings, including blanks 237and tabs, do not form separate words. 238These quotations have semantics to be described later. 239Within pairs of 240.Ql \(aq 241or 242.Ql \&" 243characters, a newline preceded by a 244.Ql \e 245gives 246a true newline character. 247.Pp 248When the shell's input is not a terminal, 249the character 250.Ql # 251introduces a comment that continues to the end of the 252input line. 253This special meaning is prevented when preceded by 254.Ql \e 255and in quotations using 256.Ql \` , 257.Ql \(aq , 258and 259.Ql \&" . 260.Ss Commands 261A simple command is a sequence of words, the first of which 262specifies the command to be executed. 263A simple command or 264a sequence of simple commands separated by 265.Ql | 266characters forms a pipeline. 267The output of each command in a pipeline is connected to the input of the next. 268Sequences of pipelines may be separated by 269.Ql \&; , 270and are then executed sequentially. 271A sequence of pipelines may be executed without immediately 272waiting for it to terminate by following it with a 273.Ql & . 274.Pp 275Any of the above may be placed in 276.Ql \&( 277.Ql \&) 278to form a simple command (that 279may be a component of a pipeline, for example). 280It is also possible to separate pipelines with 281.Ql || 282or 283.Ql && 284showing, 285as in the C language, 286that the second is to be executed only if the first fails or succeeds, 287respectively. 288(See 289.Em Expressions . ) 290.Ss Jobs 291The shell associates a 292.Em job 293with each pipeline. 294It keeps a table of current jobs, printed by the 295.Ic jobs 296command, and assigns them small integer numbers. 297When a job is started asynchronously with 298.Ql & , 299the shell prints a line that looks 300like: 301.Bd -filled -offset indent 302.Op 1 3031234 304.Ed 305.Pp 306showing that the job which was started asynchronously was job number 3071 and had one (top-level) process, whose process ID was 1234. 308.Pp 309If you are running a job and wish to do something else you may hit 310.Ic ^Z 311(control-Z), which sends a 312.Dv SIGSTOP 313signal to the current job. 314The shell will then normally show that the job has been 315.Dq Stopped , 316and print another prompt. 317You can then manipulate the state of this job, putting it in the 318.Em background 319with the 320.Ic bg 321command, or run some other 322commands and eventually bring the job back into the 323.Em foreground 324with the 325.Ic fg 326command. 327A 328.Ic ^Z 329takes effect immediately and 330is like an interrupt in that pending output and unread input are discarded 331when it is typed. 332There is another special key 333.Ic ^Y 334that does not generate a 335.Dv SIGSTOP 336signal until a program attempts to 337.Xr read 2 338it. 339This request can usefully be typed ahead when you have prepared some commands 340for a job that you wish to stop after it has read them. 341.Pp 342A job being run in the background will stop if it tries to read 343from the terminal. 344Background jobs are normally allowed to produce output, 345but this can be disabled by giving the command 346.Ic stty tostop . 347If you set this 348tty option, then background jobs will stop when they try to produce 349output like they do when they try to read input. 350.Pp 351There are several ways to refer to jobs in the shell. 352The character 353.Ql % 354introduces a job name. 355If you wish to refer to job number 1, you can name it as 356.Ql %1 . 357Just naming a job brings it to the foreground; thus 358.Ic %1 359is a synonym for 360.Ic fg %1 , 361bringing job number 1 back into the foreground. 362Similarly, saying 363.Ic %1 & 364resumes job number 1 in the background. 365Jobs can also be named by prefixes of the string typed in to start them, 366if these prefixes are unambiguous; thus 367.Ic %ex 368would normally restart a suspended 369.Xr ex 1 370job, if there were only one suspended job whose name began with 371the string 372.Qq ex . 373It is also possible to say 374.Ic %?string , 375which specifies a job whose text contains 376.Ar string , 377if there is only one such job. 378.Pp 379The shell maintains a notion of the current and previous jobs. 380In output about jobs, the current job is marked with a 381.Ql + 382and the previous job with a 383.Ql \- . 384The abbreviation 385.Ql %+ 386refers to the current job and 387.Ql %\- 388refers to the previous job. 389For close analogy with the syntax of the 390.Ic history 391mechanism (described below), 392.Ql %% 393is also a synonym for the current job. 394.Pp 395The job control mechanism requires that the 396.Xr stty 1 397option 398.Ic new 399be set. 400It is an artifact from a 401.Em new 402implementation 403of the 404tty driver that allows generation of interrupt characters from 405the keyboard to tell jobs to stop. 406See 407.Xr stty 1 408for details 409on setting options in the new tty driver. 410.Ss Status reporting 411The shell learns immediately whenever a process changes state. 412It normally informs you whenever a job becomes blocked so that 413no further progress is possible, but only just before it prints 414a prompt. 415This is done so that it does not otherwise disturb your work. 416If, however, you set the shell variable 417.Va notify , 418the shell will notify you immediately of changes of status in background 419jobs. 420There is also a shell command 421.Ic notify 422that marks a single process so that its status changes will be immediately 423reported. 424By default 425.Ic notify 426marks the current process; 427simply say 428.Ic notify 429after starting a background job to mark it. 430.Pp 431When you try to leave the shell while jobs are stopped, you will 432be warned that 433.Dq You have stopped jobs . 434You may use the 435.Ic jobs 436command to see what they are. 437If you try to exit again immediately, 438the shell will not warn you a second time, and the suspended 439jobs will be terminated. 440.Ss File name completion 441When the file name completion feature is enabled by setting 442the shell variable 443.Va filec 444(see 445.Ic set ) , 446.Nm 447will 448interactively complete file names and user names from unique 449prefixes when they are input from the terminal followed by 450the escape character (the escape key, or control-[). 451For example, 452if the current directory looks like 453.Bd -literal -offset indent 454DSC.OLD bin cmd lib xmpl.c 455DSC.NEW chaosnet cmtest mail xmpl.o 456bench class dev mbox xmpl.out 457.Ed 458.Pp 459and the input is 460.Pp 461.Dl % vi ch<escape> 462.Pp 463.Nm 464will complete the prefix 465.Dq ch 466to the only matching file name 467.Dq chaosnet , 468changing the input line to 469.Pp 470.Dl % vi chaosnet 471.Pp 472However, given 473.Pp 474.Dl % vi D<escape> 475.Pp 476.Nm 477will only expand the input to 478.Pp 479.Dl % vi DSC. 480.Pp 481and will sound the terminal bell to indicate that the expansion is 482incomplete, since there are two file names matching the prefix 483.Ql D . 484.Pp 485If a partial file name is followed by the end-of-file character 486(usually control-D), then, instead of completing the name, 487.Nm 488will list all file names matching the prefix. 489For example, the input 490.Pp 491.Dl % vi D<control-D> 492.Pp 493causes all files beginning with 494.Ql D 495to be listed: 496.Pp 497.Dl DSC.NEW DSC.OLD 498.Pp 499while the input line remains unchanged. 500.Pp 501The same system of escape and end-of-file can also be used to 502expand partial user names, if the word to be completed 503(or listed) begins with the tilde character 504.Pq Ql ~ . 505For example, typing 506.Pp 507.Dl cd ~ro<escape> 508.Pp 509may produce the expansion 510.Pp 511.Dl cd ~root 512.Pp 513The use of the terminal bell to signal errors or multiple matches 514can be inhibited by setting the variable 515.Va nobeep . 516.Pp 517Normally, all files in the particular directory are candidates 518for name completion. 519Files with certain suffixes can be excluded 520from consideration by setting the variable 521.Va fignore 522to the 523list of suffixes to be ignored. 524Thus, if 525.Va fignore 526is set by 527the command 528.Pp 529.Dl % set fignore = (.o .out) 530.Pp 531then typing 532.Pp 533.Dl % vi x<escape> 534.Pp 535would result in the completion to 536.Pp 537.Dl % vi xmpl.c 538.Pp 539ignoring the files 540.Qq xmpl.o 541and 542.Qq xmpl.out . 543However, if the only completion possible requires not ignoring these 544suffixes, then they are not ignored. 545In addition, 546.Va fignore 547does not affect the listing of file names by control-D. 548All files are listed regardless of their suffixes. 549.Ss Substitutions 550We now describe the various transformations the shell performs on the 551input in the order in which they occur. 552.Ss History substitutions 553History substitutions place words from previous command input as portions 554of new commands, making it easy to repeat commands, repeat arguments 555of a previous command in the current command, or fix spelling mistakes 556in the previous command with little typing and a high degree of confidence. 557History substitutions begin with the character 558.Ql \&! 559and may begin 560.Em anywhere 561in the input stream (with the proviso that they do 562.Em not 563nest). 564This 565.Ql \&! 566may be preceded by a 567.Ql \e 568to prevent its special meaning; for 569convenience, a 570.Ql \&! 571character is passed unchanged when it is followed by a blank, 572tab, newline, 573.Ql = 574or 575.Ql \&( . 576(History substitutions also occur when an input line begins with 577.Ql ^ . 578This special abbreviation will be described later.) 579Any input line that contains history substitution is echoed on the terminal 580before it is executed as it would have been typed without history substitution. 581.Pp 582Commands input from the terminal that consist of one or more words 583are saved on the history list. 584The history substitutions reintroduce sequences of words from these 585saved commands into the input stream. 586The size of the history list is controlled by the 587.Va history 588variable; the previous command is always retained, 589regardless of the value of the history variable. 590Commands are numbered sequentially from 1. 591.Pp 592For definiteness, consider the following output from the 593.Ic history 594command: 595.Bd -literal -offset indent 59609 write michael 59710 ex write.c 59811 cat oldwrite.c 59912 diff *write.c 600.Ed 601.Pp 602The commands are shown with their event numbers. 603It is not usually necessary to use event numbers, but the current event 604number can be made part of the prompt by placing a 605.Ql \&! 606in the prompt string. 607.Pp 608With the current event 13 we can refer to previous events by event 609number 610.Ql !11 , 611relatively as in 612.Ql !\-2 613(referring to the same event), 614by a prefix of a command word 615as in 616.Ql !d 617for event 12 or 618.Ql !wri 619for event 9, or by a string contained in 620a word in the command as in 621.Ql !?mic? 622also referring to event 9. 623These forms, without further change, simply reintroduce the words 624of the specified events, each separated by a single blank. 625As a special case, 626.Ql !! 627refers to the previous command; thus 628.Ql !! 629alone is a 630.Em redo . 631.Pp 632To select words from an event we can follow the event specification by 633a 634.Ql \&: 635and a designator for the desired words. 636The words of an input line are numbered from 0, 637the first (usually command) word being 0, the second word (first argument) 638being 1, etc. 639The basic word designators are: 640.Pp 641.Bl -tag -width Ds -compact -offset indent 642.It \&0 643first (command) word 644.It Ar n 645.Ar n Ns 'th 646argument 647.It ^ 648first argument; i.e., 649.Ql 1 650.It $ 651last argument 652.It % 653word matched by (immediately preceding) 654.No \&? Ns Ar s Ns ?\& 655search 656.It Ar \&x\-y 657range of words 658.It Ar \&\-y 659abbreviates 660.Ql \&0\-y 661.It * 662abbreviates 663.Ql ^\-$ , 664or nothing if only 1 word in event 665.It Ar x* 666abbreviates 667.Ql x\-$ 668.It Ar x\- 669like 670.Ql x* 671but omitting word 672.Ql $ 673.El 674.Pp 675The 676.Ql \&: 677separating the event specification from the word designator 678can be omitted if the argument selector begins with a 679.Ql ^ , 680.Ql $ , 681.Ql * , 682.Ql \- , 683or 684.Ql % . 685After the optional word designator, 686a sequence of modifiers can be placed, each preceded by a 687.Ql \&: . 688The following modifiers are defined: 689.Pp 690.Bl -tag -width Ds -compact -offset indent 691.It h 692Remove a trailing pathname component, leaving the head. 693.It r 694Remove a trailing 695.Ql .xxx 696component, leaving the root name. 697.It e 698Remove all but the extension 699.Ql .xxx 700part. 701.It s Ns Ar /l/r/ 702Substitute 703.Ar l 704for 705.Ar r . 706.It t 707Remove all leading pathname components, leaving the tail. 708.It \&& 709Repeat the previous substitution. 710.It g 711Apply the change once on each word, prefixing the above; e.g., 712.Ql g& . 713.It a 714Apply the change as many times as possible on a single word, prefixing 715the above. 716It can be used together with 717.Ql g 718to apply a substitution globally. 719.It p 720Print the new command line but do not execute it. 721.It q 722Quote the substituted words, preventing further substitutions. 723.It x 724Like 725.Ql q , 726but break into words at blanks, tabs, and newlines. 727.El 728.Pp 729Unless preceded by a 730.Ql g , 731the change is applied only to the first 732modifiable word. 733With substitutions, it is an error for no word to be applicable. 734.Pp 735The left-hand side of substitutions are not regular expressions in the sense 736of the editors, but instead strings. 737Any character may be used as the delimiter in place of 738.Ql / ; 739a 740.Ql \e 741quotes the delimiter into the 742.Ar l 743and 744.Ar r 745strings. 746The character 747.Ql & 748in the right-hand side is replaced by the text from 749the left. 750A 751.Ql \e 752also quotes 753.Ql & . 754A 755.Dv NULL 756.Ar l 757.Pq Ql // 758uses the previous string either from an 759.Ar l 760or from a 761contextual scan string 762.Ar s 763in 764.Ql !? Ns Ar s Ns \e? . 765The trailing delimiter in the substitution may be omitted if a newline 766follows immediately as may the trailing 767.Ql \&? 768in a contextual scan. 769.Pp 770A history reference may be given without an event specification; e.g., 771.Ql !$ . 772Here, the reference is to the previous command unless a previous 773history reference occurred on the same line in which case this form repeats 774the previous reference. 775Thus 776.Dq !?foo?^ !$ 777gives the first and last arguments 778from the command matching 779.Dq ?foo? . 780.Pp 781A special abbreviation of a history reference occurs when the first 782non-blank character of an input line is a 783.Ql ^ . 784This is equivalent to 785.Dq !:s^ 786providing a convenient shorthand for substitutions 787on the text of the previous line. 788Thus 789.Ic ^lb^lib 790fixes the spelling of 791.Dq lib 792in the previous command. 793Finally, a history substitution may be surrounded with 794.Ql { 795and 796.Ql } 797if necessary to insulate it from the characters that follow. 798Thus, after 799.Ic ls \-ld ~paul 800we might do 801.Ic !{l}a 802to do 803.Ic ls \-ld ~paula , 804while 805.Ic !la 806would look for a command starting with 807.Dq la . 808.Ss Quotations with \(aq and \&" 809The quotation of strings by 810.Ql \(aq 811and 812.Ql \&" 813can be used 814to prevent all or some of the remaining substitutions. 815Strings enclosed in 816.Ql \(aq 817are prevented from any further interpretation. 818Strings enclosed in 819.Ql \&" 820may be expanded as described below. 821.Pp 822In both cases the resulting text becomes (all or part of) a single word; 823only in one special case (see 824.Em Command Substitution 825below) does a 826.Ql \&" 827quoted string yield parts of more than one word; 828.Ql \(aq 829quoted strings never do. 830.Ss Alias substitution 831The shell maintains a list of aliases that can be established, displayed 832and modified by the 833.Ic alias 834and 835.Ic unalias 836commands. 837After a command line is scanned, it is parsed into distinct commands and 838the first word of each command, left-to-right, is checked to see if it 839has an alias. 840If it does, then the text that is the alias for that command is reread 841with the history mechanism available 842as though that command were the previous input line. 843The resulting words replace the 844command and argument list. 845If no reference is made to the history list, then the argument list is 846left unchanged. 847.Pp 848Thus if the alias for 849.Dq ls 850is 851.Dq ls \-l , 852the command 853.Ic ls /usr 854would map to 855.Ic ls \-l /usr , 856the argument list here being undisturbed. 857Similarly, if the alias for 858.Dq lookup 859was 860.Dq grep !^ /etc/passwd 861then 862.Ic lookup bill 863would map to 864.Ic grep bill /etc/passwd . 865.Pp 866If an alias is found, the word transformation of the input text 867is performed and the aliasing process begins again on the reformed input line. 868Looping is prevented if the first word of the new text is the same as the old 869by flagging it to prevent further aliasing. 870Other loops are detected and cause an error. 871.Pp 872Note that the mechanism allows aliases to introduce parser metasyntax. 873Thus, we can 874.Ic alias print 'pr \e!* \&| lpr' 875to make a command that 876.Ic pr Ns 's 877its arguments to the line printer. 878.Ss Variable substitution 879The shell maintains a set of variables, each of which has as value a list 880of zero or more words. 881Some of these variables are set by the shell or referred to by it. 882For instance, the 883.Va argv 884variable is an image of the shell's argument list, and words of this 885variable's value are referred to in special ways. 886.Pp 887The values of variables may be displayed and changed by using the 888.Ic set 889and 890.Ic unset 891commands. 892Of the variables referred to by the shell a number are toggles; 893the shell does not care what their value is, 894only whether they are set or not. 895For instance, the 896.Va verbose 897variable is a toggle that causes command input to be echoed. 898The setting of this variable results from the 899.Fl v 900command-line option. 901.Pp 902Other operations treat variables numerically. 903The 904.Ic @ 905command permits numeric calculations to be performed and the result 906assigned to a variable. 907Variable values are, however, always represented as (zero or more) strings. 908For the purposes of numeric operations, the null string is considered to be 909zero, and the second and additional words of multiword values are ignored. 910.Pp 911After the input line is aliased and parsed, and before each command 912is executed, variable substitution 913is performed, keyed by 914.Ql $ 915characters. 916This expansion can be prevented by preceding the 917.Ql $ 918with a 919.Ql \e 920except 921within double quotes 922.Pq Ql \&" , 923where it 924.Em always 925occurs, and within single quotes 926.Pq Ql \(aq , 927where it 928.Em never 929occurs. 930Strings quoted by backticks 931.Pq \` \` 932are interpreted later (see 933.Sx Command substitution 934below), so 935.Ql $ 936substitution does not occur there until later, if at all. 937A 938.Ql $ 939is passed unchanged if followed by a blank, tab, or end-of-line. 940.Pp 941Input/output redirections are recognized before variable expansion, 942and are variable expanded separately. 943Otherwise, the command name and entire argument list are expanded together. 944It is thus possible for the first (command) word (to this point) to generate 945more than one word, the first of which becomes the command name, 946and the rest of which become arguments. 947.Pp 948Unless enclosed in 949.Ql \&" 950or given the 951.Ql :q 952modifier, the results of variable 953substitution may eventually be command and filename substituted. 954Within 955.Ql \&" , 956a variable whose value consists of multiple words expands to 957(a portion of) a single word, with the words of the variable's value 958separated by blanks. 959When the 960.Ql :q 961modifier is applied to a substitution, 962the variable will expand to multiple words with each word separated 963by a blank and quoted to prevent later command or filename substitution. 964.Pp 965The following metasequences are provided for introducing variable values into 966the shell input. 967Except as noted, it is an error to reference a variable that is not set. 968.Pp 969.Bl -tag -width Ds -compact -offset indent 970.It $name 971.It ${name} 972Are replaced by the words of the value of variable 973.Ar name , 974each separated by a blank. 975Braces insulate 976.Ar name 977from following characters that would otherwise be part of it. 978Shell variables have names consisting of up to 20 letters and digits 979starting with a letter. 980The underscore character is considered a letter. 981If 982.Ar name 983is not a shell variable, but is set in the environment, then 984that value is returned (but 985.Ql \&: 986modifiers and the other forms 987given below are not available here). 988.It $name Ns Op selector 989.It ${name Ns [ selector ] Ns } 990May be used to select only some of the words from the value of 991.Ar name . 992The selector is subjected to 993.Ql $ 994substitution and may consist of a single 995number or two numbers separated by a 996.Ql \- . 997The first word of a variable's value is numbered 998.Ql 1 . 999If the first number of a range is omitted, it defaults to 1000.Ql 1 . 1001If the last number of a range is omitted, it defaults to 1002.Ql $#name . 1003The selector 1004.Ql * 1005selects all words. 1006It is not an error for a range to be empty if the second argument is omitted 1007or in range. 1008.It $#name 1009.It ${#name} 1010Gives the number of words in the variable. 1011This is useful for later use in a 1012.Dq $argv[selector] . 1013.It $0 1014Substitutes the name of the file from which command input is being read. 1015An error occurs if the name is not known. 1016.It $number 1017.It ${number} 1018Equivalent to 1019.Dq $argv[number] . 1020.It $* 1021Equivalent to 1022.Dq $argv[*] . 1023.El 1024.Pp 1025The modifiers 1026.Ql :e , 1027.Ql :h , 1028.Ql :t , 1029.Ql :r , 1030.Ql :q , 1031and 1032.Ql :x 1033may be applied to 1034the substitutions above as may 1035.Ql :gh , 1036.Ql :gt , 1037and 1038.Ql :gr . 1039If braces 1040.Ql { 1041.Ql } 1042appear in the command form then the modifiers 1043must appear within the braces. 1044The current implementation allows only one 1045.Ql \&: 1046modifier on each 1047.Ql $ 1048expansion. 1049.Pp 1050The following substitutions may not be modified with 1051.Ql \&: 1052modifiers. 1053.Bl -tag -width Ds -compact -offset indent 1054.It $?name 1055.It ${?name} 1056Substitutes the string 1057.Dq 1 1058if name is set, 1059.Dq 0 1060if it is not. 1061.It $?0 1062Substitutes 1063.Ql 1 1064if the current input filename is known, 1065.Ql 0 1066if it is not. 1067.It \&$\&$\& 1068Substitute the (decimal) process number of the (parent) shell. 1069Do 1070.Em NOT 1071use this mechanism for generating temporary file names; see 1072.Xr mktemp 1 1073instead. 1074.It $! 1075Substitute the (decimal) process number of the last background process 1076started by this shell. 1077.It $< 1078Substitutes a line from the standard 1079input, with no further interpretation. 1080It can be used to read from the keyboard in a shell script. 1081.El 1082.Ss Command and filename substitution 1083The remaining substitutions, command and filename substitution, 1084are applied selectively to the arguments of built-in commands. 1085By selectively, we mean that portions of expressions which are 1086not evaluated are not subjected to these expansions. 1087For commands that are not internal to the shell, the command 1088name is substituted separately from the argument list. 1089This occurs very late, 1090after input-output redirection is performed, and in a child 1091of the main shell. 1092.Ss Command substitution 1093Command substitution is shown by a command enclosed in 1094.Ql \` . 1095The output from such a command is normally broken into separate words 1096at blanks, tabs, and newlines, with null words being discarded; 1097this text then replaces the original string. 1098Within double quotes 1099.Pq Ql \&" , 1100only newlines force new words; 1101blanks and tabs are preserved. 1102.Pp 1103In any case, the single final newline does not force a new word. 1104Note that it is thus possible for a command substitution to yield 1105only part of a word, even if the command outputs a complete line. 1106.Ss Filename substitution 1107If a word contains any of the characters 1108.Ql * , 1109.Ql \&? , 1110.Ql \&[ , 1111or 1112.Ql { , 1113or begins with the character 1114.Ql ~ , 1115then that word is a candidate for 1116filename substitution, also known as 1117.Dq globbing . 1118This word is then regarded as a pattern, and replaced with an alphabetically 1119sorted list of file names that match the pattern. 1120In a list of words specifying filename substitution it is an error for 1121no pattern to match an existing file name, but it is not required 1122for each pattern to match. 1123Only the metacharacters 1124.Ql * , 1125.Ql \&? , 1126and 1127.Ql \&[ 1128imply pattern matching, 1129the characters 1130.Ql ~ 1131and 1132.Ql { 1133being more akin to abbreviations. 1134.Pp 1135In matching filenames, the character 1136.Ql \&. 1137at the beginning of a filename 1138or immediately following a 1139.Ql / , 1140as well as the character 1141.Ql / 1142must be matched explicitly. 1143The character 1144.Ql * 1145matches any string of characters, including the null 1146string. 1147The character 1148.Ql \&? 1149matches any single character. 1150.Pp 1151The sequence 1152.Dq Op ... 1153matches any one of the characters enclosed. 1154Within 1155.Dq Op ... , 1156a pair of characters separated by 1157.Ql \- 1158matches any character lexically between 1159the two (inclusive). 1160Within 1161.Dq Op ... , 1162the name of a 1163.Em character class 1164enclosed in 1165.Sq [: 1166and 1167.Sq :] 1168stands for the list of all characters belonging to that class. 1169Supported character classes: 1170.Bd -literal -offset indent 1171alnum cntrl lower space 1172alpha digit print upper 1173blank graph punct xdigit 1174.Ed 1175.Pp 1176These match characters using the macros specified in 1177.Xr isalnum 3 , 1178.Xr isalpha 3 , 1179and so on. 1180A character class may not be used as an endpoint of a range. 1181.Pp 1182The character 1183.Ql ~ 1184at the beginning of a filename refers to home 1185directories. 1186Standing alone, i.e., 1187.Ql ~ , 1188it expands to the invoker's home directory as reflected 1189in the value of the variable 1190.Ar home . 1191When followed by a name consisting of letters, digits, and 1192.Ql \- 1193characters, 1194the shell searches for a user with that name and substitutes their 1195home directory; thus 1196.Dq ~ken 1197might expand to 1198.Dq /usr/ken 1199and 1200.Dq ~ken/chmach 1201to 1202.Dq /usr/ken/chmach . 1203If the character 1204.Ql ~ 1205is followed by a character other than a letter or 1206.Ql / , 1207or does not appear at the beginning of a word, 1208it is left undisturbed. 1209.Pp 1210The metanotation 1211.Dq a{b,c,d}e 1212is a shorthand for 1213.Dq abe ace ade . 1214Left to right order is preserved, with results of matches being sorted 1215separately at a low level to preserve this order. 1216This construct may be nested. 1217Thus, 1218.Dq ~source/s1/{oldls,ls}.c 1219expands to 1220.Dq /usr/source/s1/oldls.c /usr/source/s1/ls.c 1221without chance of error 1222if the home directory for 1223.Dq source 1224is 1225.Dq /usr/source . 1226Similarly 1227.Dq ../{memo,*box} 1228might expand to 1229.Dq ../memo ../box ../mbox . 1230(Note that 1231.Dq memo 1232was not sorted with the results of the match to 1233.Dq *box . ) 1234As a special case 1235.Ql { , 1236.Ql } , 1237and 1238.Ql {} 1239are passed undisturbed. 1240.Ss Input/output 1241The standard input and the standard output of a command may be redirected 1242with the following syntax: 1243.Pp 1244.Bl -tag -width Ds -compact -offset indent 1245.It < name 1246Open file 1247.Ar name 1248(which is first variable, command, and filename expanded) as the standard 1249input. 1250.It << word 1251Read the shell input up to a line that is identical to 1252.Ar word . 1253.Ar word 1254is not subjected to variable, command, or filename substitution, 1255and each input line is compared to 1256.Ar word 1257before any substitutions are done on the input line. 1258Unless a quoting 1259.Ql \e , 1260.Ql \&" , 1261.Ql \(aq 1262or 1263.Ql \` 1264appears in 1265.Ar word , 1266variable and command substitution is performed on the intervening lines, 1267allowing 1268.Ql \e 1269to quote 1270.Ql $ , 1271.Ql \e 1272and 1273.Ql \` . 1274Commands that are substituted have all blanks, tabs, and newlines 1275preserved, except for the final newline which is dropped. 1276The resultant text is placed in an anonymous temporary file that 1277is given to the command as its standard input. 1278.It > name 1279.It >! name 1280.It >& name 1281.It >&! name 1282The file 1283.Ar name 1284is used as the standard output. 1285If the file does not exist then it is created; 1286if the file exists, it is truncated; its previous contents are lost. 1287.Pp 1288If the variable 1289.Va noclobber 1290is set, then the file must not exist or be a character special file (e.g., a 1291terminal or 1292.Pa /dev/null ) 1293or an error results. 1294This helps prevent accidental destruction of files. 1295Here, the 1296.Ql \&! 1297forms can be used to suppress this check. 1298.Pp 1299The forms involving 1300.Ql & 1301route the standard error output into the specified 1302file as well as the standard output. 1303.Ar name 1304is expanded in the same way as 1305.Ql < 1306input filenames are. 1307.It >> name 1308.It >>& name 1309.It >>! name 1310.It >>&! name 1311Uses file 1312.Ar name 1313as the standard output; 1314like 1315.Ql > 1316but places output at the end of the file. 1317If the variable 1318.Va noclobber 1319is set, then it is an error for the file not to exist unless 1320one of the 1321.Ql \&! 1322forms is given. 1323Otherwise similar to 1324.Ql > . 1325.El 1326.Pp 1327A command receives the environment in which the shell was 1328invoked as modified by the input-output parameters and 1329the presence of the command in a pipeline. 1330Thus, unlike some previous shells, commands run from a file of shell commands 1331have no access to the text of the commands by default; 1332instead they receive the original standard input of the shell. 1333The 1334.Ql << 1335mechanism should be used to present inline data. 1336This permits shell command scripts to function as components of pipelines 1337and allows the shell to block read its input. 1338Note that the default standard input for a command run detached is 1339.Ar not 1340modified to be the empty file 1341.Pa /dev/null ; 1342instead the standard input 1343remains as the original standard input of the shell. 1344If this is a terminal 1345and if the process attempts to read from the terminal, then the process 1346will block and the user will be notified (see 1347.Sx Jobs 1348above). 1349.Pp 1350The standard error output may be directed through 1351a pipe with the standard output. 1352Simply use the form 1353.Ql |& 1354instead of just 1355.Ql | . 1356.Ss Expressions 1357Several of the built-in commands (to be described later) 1358take expressions, in which the operators are similar to those of C, with 1359the same precedence, but with the 1360.Em opposite grouping : 1361right to left. 1362These expressions appear in the 1363.Ic @ , 1364.Ic exit , 1365.Ic if , 1366and 1367.Ic while 1368commands. 1369The following operators are available: 1370.Bd -ragged -offset indent 1371|| && | ^ & == != =~ !~ <= >= 1372< > << >> + \- * / % ! ~ ( ) 1373.Ed 1374.Pp 1375Here the precedence increases to the right, 1376.Ql == 1377.Ql != 1378.Ql =~ 1379and 1380.Ql !~ , 1381.Ql <= 1382.Ql >= 1383.Ql < 1384and 1385.Ql > , 1386.Ql << 1387and 1388.Ql >> , 1389.Ql + 1390and 1391.Ql \- , 1392.Ql * 1393.Ql / 1394and 1395.Ql % 1396being, in groups, at the same level. 1397The 1398.Ql == 1399.Ql != 1400.Ql =~ 1401and 1402.Ql !~ 1403operators compare their arguments as strings; 1404all others operate on numbers. 1405The operators 1406.Ql =~ 1407and 1408.Ql !~ 1409are like 1410.Ql != 1411and 1412.Ql == 1413except that the right 1414hand side is a 1415.Ar pattern 1416(containing, e.g., *'s, ?'s, and instances of 1417.Dq [...] ) 1418against which the left-hand operand is matched. 1419This reduces the need for use of the 1420.Ar switch 1421statement in shell scripts when all that is really needed is pattern matching. 1422.Pp 1423Strings that begin with 1424.Ql 0 1425are considered octal numbers. 1426Null or missing arguments are considered 1427.Ql 0 . 1428The results of all expressions are strings, 1429which represent decimal numbers. 1430It is important to note that no two components of an expression can appear 1431in the same word; except when adjacent to components of expressions that 1432are syntactically significant to the parser 1433.Po 1434.Ql & , 1435.Ql | , 1436.Ql < , 1437.Ql > , 1438.Ql \&( , 1439and 1440.Ql \&) 1441.Pc , 1442they should be surrounded by spaces. 1443.Pp 1444Also available in expressions as primitive operands are command executions 1445enclosed in 1446.Ql { 1447and 1448.Ql } 1449and file enquiries of the form 1450.Fl l 1451.Ar name 1452where 1453.Ic l 1454is one of: 1455.Bd -literal -offset indent 1456r read access 1457w write access 1458x execute access 1459e existence 1460o ownership 1461z zero size 1462f plain file 1463d directory 1464p named pipe (FIFO) 1465l symbolic link 1466.\" Intentionally undocumented since it is incompatible with tcsh: 1467.\" s socket 1468.Ed 1469.Pp 1470The specified name is command and filename expanded and then tested 1471to see if it has the specified relationship to the real user. 1472If the file does not exist or is inaccessible then all enquiries return 1473false, i.e., 1474.Ql 0 . 1475Command executions succeed, returning true, i.e., 1476.Ql 1 , 1477if the command exits with status 0, otherwise they fail, returning 1478false, i.e., 1479.Ql 0 . 1480If more detailed status information is required then the command 1481should be executed outside an expression and the variable 1482.Ar status 1483examined. 1484.Ss Control flow 1485The shell contains several commands that can be used to regulate the 1486flow of control in command files (shell scripts) and 1487(in limited but useful ways) from terminal input. 1488These commands all operate by forcing the shell to reread or skip in its 1489input and, because of the implementation, restrict the placement of some 1490of the commands. 1491.Pp 1492The 1493.Ic foreach , 1494.Ic switch , 1495and 1496.Ic while 1497statements, as well as the 1498.Ic if\-then\-else 1499form of the 1500.Ic if 1501statement require that the major keywords appear in a single simple command 1502on an input line as shown below. 1503.Pp 1504If the shell's input is not seekable, 1505the shell buffers up input whenever a loop is being read 1506and performs seeks in this internal buffer to accomplish the rereading 1507implied by the loop. 1508(To the extent that this allows, backward goto's will succeed on 1509non-seekable inputs.) 1510.Ss Built-in commands 1511Built-in commands are executed within the shell. 1512If a built-in command occurs as any component of a pipeline 1513except the last then it is executed in a sub-shell. 1514.Pp 1515.Bl -tag -width Ds -compact -offset indent 1516.It Ic alias 1517.It Ic alias Ar name 1518.It Ic alias Ar name wordlist 1519The first form prints all aliases. 1520The second form prints the alias for name. 1521The final form assigns the specified 1522.Ar wordlist 1523as the alias of 1524.Ar name ; 1525.Ar wordlist 1526is command and filename substituted. 1527.Ar name 1528is not allowed to be 1529.Dq alias 1530or 1531.Dq unalias . 1532.Pp 1533.It Ic bg 1534.It Ic bg \&% Ns Ar job ... 1535Puts the current or specified jobs into the background, continuing them 1536if they were stopped. 1537.Pp 1538.It Ic break 1539Causes execution to resume after the 1540.Ic end 1541of the nearest enclosing 1542.Ic foreach 1543or 1544.Ic while . 1545The remaining commands on the current line are executed. 1546Multi-level breaks are thus possible by writing them all on one line. 1547.Pp 1548.It Ic breaksw 1549Causes a break from a 1550.Ic switch , 1551resuming after the 1552.Ic endsw . 1553.Pp 1554.It Ic case Ar label : 1555A label in a 1556.Ic switch 1557statement as discussed below. 1558.Pp 1559.It Ic cd 1560.It Ic cd Ar name 1561.It Ic chdir 1562.It Ic chdir Ar name 1563Change the shell's working directory to directory 1564.Ar name . 1565If no argument is given then change to the home directory of the user. 1566If 1567.Ar name 1568is not found as a subdirectory of the current directory (and does not begin 1569with 1570.Ql / , 1571.Ql ./ 1572or 1573.Ql ../ ) , 1574then each 1575component of the variable 1576.Va cdpath 1577is checked to see if it has a subdirectory 1578.Ar name . 1579Finally, if all else fails but 1580.Ar name 1581is a shell variable whose value begins with 1582.Ql / , 1583then this 1584is tried to see if it is a directory. 1585.Pp 1586.It Ic continue 1587Continue execution of the nearest enclosing 1588.Ic while 1589or 1590.Ic foreach . 1591The rest of the commands on the current line are executed. 1592.Pp 1593.It Ic default : 1594Labels the default case in a 1595.Ic switch 1596statement. 1597The default should come after all 1598.Ic case 1599labels. 1600.Pp 1601.It Ic dirs 1602Prints the directory stack; the top of the stack is at the left, 1603the first directory in the stack being the current directory. 1604.Pp 1605.It Ic echo Ar wordlist 1606.It Ic echo Fl n Ar wordlist 1607The specified words are written to the shell's standard output, separated 1608by spaces, and terminated with a newline unless the 1609.Fl n 1610option is specified. 1611.Pp 1612.It Ic else 1613.It Ic end 1614.It Ic endif 1615.It Ic endsw 1616See the description of the 1617.Ic foreach , 1618.Ic if , 1619.Ic switch , 1620and 1621.Ic while 1622statements below. 1623.Pp 1624.It Ic eval Ar arg ... 1625(As in 1626.Xr sh 1 . ) 1627The arguments are read as input to the shell and the resulting 1628command(s) executed in the context of the current shell. 1629This is usually used to execute commands 1630generated as the result of command or variable substitution, since 1631parsing occurs before these substitutions. 1632See 1633.Xr tset 1 1634for an example of using 1635.Ic eval . 1636.Pp 1637.It Ic exec Ar command 1638The specified command is executed in place of the current shell. 1639.Pp 1640.It Ic exit 1641.It Ic exit ( Ar expr ) 1642The shell exits either with the value of the 1643.Ic status 1644variable (first form) or with the value of the specified 1645.Ic expr 1646(second form). 1647.Pp 1648.It Ic fg 1649.It Ic fg % Ns Ar job ... 1650Brings the current or specified jobs into the foreground, continuing them if 1651they were stopped. 1652.Pp 1653.It Ic foreach Ar name ( Ar wordlist ) 1654.It ... 1655.It Ic end 1656The variable 1657.Ar name 1658is successively set to each member of 1659.Ar wordlist 1660and the sequence of commands between this command and the matching 1661.Ic end 1662are executed. 1663(Both 1664.Ic foreach 1665and 1666.Ic end 1667must appear alone on separate lines.) 1668The built-in command 1669.Ic continue 1670may be used to continue the loop prematurely and the built-in 1671command 1672.Ic break 1673to terminate it prematurely. 1674When this command is read from the terminal, the loop is read once 1675prompting with 1676.Ql \&? 1677before any statements in the loop are executed. 1678If you make a mistake typing in a loop at the terminal, you can rub it out. 1679.Pp 1680.It Ic glob Ar wordlist 1681Like 1682.Ic echo 1683but no 1684.Ql \e 1685escapes are recognized and words are delimited 1686by NUL characters in the output. 1687Useful for programs that wish to use the shell to filename expand a list 1688of words. 1689.Pp 1690.It Ic goto Ar word 1691The specified 1692.Ar word 1693is filename and command expanded to yield a string of the form 1694.Ql label . 1695The shell rewinds its input as much as possible 1696and searches for a line of the form 1697.Dq label: , 1698possibly preceded by blanks or tabs. 1699Execution continues after the specified line. 1700.Pp 1701.It Ic hashstat 1702Print a statistics line showing how effective the internal hash 1703table has been at locating commands (and avoiding 1704.Ic exec Ns 's ) . 1705An 1706.Ic exec 1707is attempted for each component of the 1708.Em path 1709where the hash function indicates a possible hit, and in each component 1710that does not begin with a 1711.Ql / . 1712.Pp 1713.It Ic history 1714.It Ic history Ar n 1715.It Ic history Fl h Ar n 1716.It Ic history Fl r Ar n 1717Displays the history event list; if 1718.Ar n 1719is given, only the 1720.Ar n 1721most recent events are printed. 1722The 1723.Fl h 1724option causes the history list to be printed without leading numbers. 1725This format produces files suitable for sourcing using the 1726.Fl h 1727option to 1728.Ic source . 1729The 1730.Fl r 1731option reverses the order of printout to be most recent first 1732instead of oldest first. 1733.Pp 1734.It Ic if ( Ar expr ) No command 1735If the specified expression evaluates to true, then the single 1736.Ar command 1737with arguments is executed. 1738Variable substitution on 1739.Ar command 1740happens early, at the same 1741time it does for the rest of the 1742.Ic if 1743command. 1744.Ar command 1745must be a simple command, not 1746a pipeline, a command list, or a parenthesized command list. 1747Input/output redirection occurs even if 1748.Ar expr 1749is false, i.e., when command is 1750.Em not 1751executed (this is a bug). 1752.Pp 1753.It Ic if ( Ar expr ) Ic then 1754.It ... 1755.It Ic else if ( Ar expr2 ) Ic then 1756.It ... 1757.It Ic else 1758.It ... 1759.It Ic endif 1760If the specified 1761.Ar expr 1762is true then the commands up to the first 1763.Ic else 1764are executed; otherwise if 1765.Ar expr2 1766is true then the commands up to the 1767second 1768.Ic else 1769are executed, etc. 1770Any number of 1771.Ic else-if 1772pairs are possible; only one 1773.Ic endif 1774is needed. 1775The 1776.Ic else 1777part is likewise optional. 1778(The words 1779.Ic else 1780and 1781.Ic endif 1782must appear at the beginning of input lines; 1783the 1784.Ic if 1785must appear alone on its input line or after an 1786.Ic else . ) 1787.Pp 1788.It Ic jobs 1789.It Ic jobs Fl l 1790Lists the active jobs; the 1791.Fl l 1792option lists process IDs in addition to the normal information. 1793.Pp 1794.It Ic kill % Ns Ar job 1795.It Ic kill Oo Fl s Ar signal_name Oc Ar pid 1796.It Ic kill Fl sig Ar pid ... 1797.It Ic kill Fl l Op exit_status 1798Sends either the 1799.Dv SIGTERM 1800(terminate) signal or the 1801specified signal to the specified jobs or processes. 1802Signals are either given by number or by names (as given in 1803.In signal.h , 1804stripped of the prefix 1805.Dq SIG ) . 1806The signal names are listed by 1807.Dq kill \-l ; 1808if an 1809.Ar exit_status 1810is specified, only the corresponding signal name will be written. 1811There is no default; just saying 1812.Dq kill 1813does not 1814send a signal to the current job. 1815If the signal being sent is 1816.Dv SIGTERM 1817(terminate) or 1818.Dv SIGHUP 1819(hangup), 1820then the job or process will be sent a 1821.Dv SIGCONT 1822(continue) signal as well. 1823.Pp 1824.It Ic limit 1825.It Ic limit Ar resource 1826.It Ic limit Ar resource maximum\-use 1827.It Ic limit Fl h 1828.It Ic limit Fl h Ar resource 1829.It Ic limit Fl h Ar resource maximum\-use 1830Limits the consumption by the current process and each process 1831it creates to not individually exceed 1832.Ar maximum\-use 1833on the 1834specified 1835.Ar resource . 1836If no 1837.Ar maximum\-use 1838is given, then 1839the current limit is printed; if no 1840.Ar resource 1841is given, then 1842all limitations are given. 1843If the 1844.Fl h 1845flag is given, the hard limits are used instead of the current limits. 1846The hard limits impose a ceiling on the values of the current limits. 1847Only the superuser may raise the hard limits, 1848but a user may lower or raise the current limits within the legal range. 1849.Pp 1850Resources controllable currently include: 1851.Bl -tag -width coredumpsize 1852.It Ar cputime 1853the maximum number of CPU-seconds to be used by each process. 1854.It Ar filesize 1855the largest single file (in bytes) that can be created. 1856.It Ar datasize 1857the maximum growth (in bytes) of the data segment. 1858.It Ar stacksize 1859the maximum 1860size of the automatically-extended stack region. 1861.It Ar coredumpsize 1862the size of the largest core dump (in bytes) that will be created. 1863.It Ar memoryuse 1864the maximum size (in bytes) to which a process's resident set 1865size (RSS) may grow. 1866Not enforced. 1867.It Ar memorylocked 1868The maximum size (in bytes) which a process may lock into memory using the 1869.Xr mlock 2 1870function. 1871.It Ar maxproc 1872The maximum number of simultaneous processes for this user ID. 1873.It Ar openfiles 1874The maximum number of simultaneous open files for this user ID. 1875.It Ar vmemoryuse 1876the maximum size (in bytes) to which a process's total size may grow. 1877.El 1878.Pp 1879The 1880.Ar maximum\-use 1881may be given as a (floating point or integer) 1882number followed by a scale factor. 1883For all limits other than 1884.Ar cputime 1885the default scale is 1886.Ql k 1887or 1888.Dq kilobytes 1889(1024 bytes); 1890a scale factor of 1891.Ql m 1892or 1893.Dq megabytes 1894may also be used. 1895For 1896.Ar cputime 1897the default scale is 1898.Dq seconds ; 1899a scale factor of 1900.Ql m 1901for minutes 1902or 1903.Ql h 1904for hours, or a time of the form 1905.Dq mm:ss 1906giving minutes 1907and seconds also may be used. 1908.Pp 1909For both 1910.Ar resource 1911names and scale factors, unambiguous prefixes 1912of the names suffice. 1913.Pp 1914.It Ic login 1915Terminate a login shell, replacing it with an instance of 1916.Pa /usr/bin/login . 1917This is one way to log off, included for compatibility with 1918.Xr sh 1 . 1919.Pp 1920.It Ic logout 1921Terminate a login shell. 1922Especially useful if 1923.Va ignoreeof 1924is set. 1925.Pp 1926.It Ic nice 1927.It Ic nice Ar +number 1928.It Ic nice Ar command 1929.It Ic nice Ar +number command 1930The first form sets the 1931scheduling priority 1932for this shell to 4. 1933The second form sets the 1934priority 1935to the given 1936.Ar number . 1937The final two forms run command at priority 4 and 1938.Ar number 1939respectively. 1940The greater the number, the less CPU the process will get. 1941The superuser may specify negative priority by using 1942.Dq nice \-number ... . 1943.Ar command 1944is always executed in a sub-shell, and the restrictions 1945placed on commands in simple 1946.Ic if 1947statements apply. 1948.Pp 1949.It Ic nohup 1950.It Ic nohup Ar command 1951The first form can be used in shell scripts to cause hangups to be 1952ignored for the remainder of the script. 1953The second form causes the specified command to be run with hangups 1954ignored. 1955All processes detached with 1956.Ql & 1957are effectively 1958.Ic nohup Ns 'ed . 1959.Pp 1960.It Ic notify 1961.It Ic notify % Ns Ar job ... 1962Causes the shell to notify the user asynchronously when the status of the 1963current or specified jobs change; normally notification is presented 1964before a prompt. 1965This is automatic if the shell variable 1966.Va notify 1967is set. 1968.Pp 1969.It Ic onintr 1970.It Ic onintr Fl 1971.It Ic onintr Ar label 1972Control the action of the shell on interrupts. 1973The first form restores the default action of the shell on interrupts, 1974which is to terminate shell scripts or to return to the terminal command 1975input level. 1976The second form 1977.Ic onintr \- 1978causes all interrupts to be ignored. 1979The final form causes the shell to execute a 1980.Ic goto label 1981when 1982an interrupt is received or a child process terminates because 1983it was interrupted. 1984.Pp 1985In any case, if the shell is running detached and interrupts are 1986being ignored, all forms of 1987.Ic onintr 1988have no meaning and interrupts 1989continue to be ignored by the shell and all invoked commands. 1990Finally, 1991.Ic onintr 1992statements are ignored in the system startup files where interrupts 1993are disabled 1994.Pq Pa /etc/csh.cshrc , /etc/csh.login . 1995.Pp 1996.It Ic popd 1997.It Ic popd Ar +n 1998Pops the directory stack, returning to the new top directory. 1999With an argument 2000.Dq + Ns Ar n 2001discards the 2002.Ar n Ns 'th 2003entry in the stack. 2004The members of the directory stack are numbered from the top starting at 0. 2005.Pp 2006.It Ic pushd 2007.It Ic pushd Ar name 2008.It Ic pushd Ar +n 2009With no arguments, 2010.Ic pushd 2011exchanges the top two elements of the directory stack. 2012Given a 2013.Ar name 2014argument, 2015.Ic pushd 2016changes to the new directory (ala 2017.Ic cd ) 2018and pushes the old current working directory 2019(as in 2020.Ic cwd ) 2021onto the directory stack. 2022With a numeric argument, 2023.Ic pushd 2024rotates the 2025.Ar n Ns 'th 2026argument of the directory 2027stack around to be the top element and changes to it. 2028The members 2029of the directory stack are numbered from the top starting at 0. 2030.Pp 2031.It Ic rehash 2032Causes the internal hash table of the contents of the directories in 2033the 2034.Va path 2035variable to be recomputed. 2036This is needed if new commands are added to directories in the 2037.Ic path 2038while you are logged in. 2039This should only be necessary if you add 2040commands to one of your own directories, or if a systems programmer 2041changes the contents of a system directory. 2042.Pp 2043.It Ic repeat Ar count command 2044The specified 2045.Ar command , 2046which is subject to the same restrictions 2047as the 2048.Ar command 2049in the one line 2050.Ic if 2051statement above, 2052is executed 2053.Ar count 2054times. 2055I/O redirections occur exactly once, even if 2056.Ar count 2057is 0. 2058.Pp 2059.It Ic set 2060.It Ic set Ar name 2061.It Ic set Ar name Ns =word 2062.It Ic set Ar name[index] Ns =word 2063.It Ic set Ar name Ns =(wordlist) 2064The first form of the command shows the value of all shell variables. 2065Variables that have other than a single word as their 2066value print as a parenthesized word list. 2067The second form sets 2068.Ar name 2069to the null string. 2070The third form sets 2071.Ar name 2072to the single 2073.Ar word . 2074The fourth form sets 2075the 2076.Ar index Ns 'th 2077component of 2078.Ar name 2079to 2080.Ar word ; 2081this component must already exist. 2082The final form sets 2083.Ar name 2084to the list of words in 2085.Ar wordlist . 2086The value is always command and filename expanded. 2087.Pp 2088These arguments may be repeated to set multiple values in a single set command. 2089Note however, that variable expansion happens for all arguments before any 2090setting occurs. 2091.Pp 2092.It Ic setenv 2093.It Ic setenv Ar name 2094.It Ic setenv Ar name value 2095The first form lists all current environment variables. 2096It is equivalent to 2097.Xr printenv 1 . 2098The last form sets the value of environment variable 2099.Ar name 2100to be 2101.Ar value , 2102a single string. 2103The second form sets 2104.Ar name 2105to an empty string. 2106The most commonly used environment variables 2107.Ev USER , 2108.Ev TERM , 2109and 2110.Ev PATH 2111are automatically imported to and exported from the 2112.Nm 2113variables 2114.Ar user , 2115.Ar term , 2116and 2117.Ar path ; 2118there is no need to use 2119.Ic setenv 2120for these. 2121.Pp 2122.It Ic shift 2123.It Ic shift Ar variable 2124The members of 2125.Ic argv 2126are shifted to the left, discarding 2127.Ic argv Ns Bq 1 . 2128It is an error for 2129.Ic argv 2130not to be set or to have less than one word as value. 2131The second form performs the same function on the specified variable. 2132.Pp 2133.It Ic source Ar name 2134.It Ic source Fl h Ar name 2135The shell reads commands from 2136.Ar name . 2137.Ic source 2138commands may be nested; if they are nested too deeply the shell may 2139run out of file descriptors. 2140An error in a 2141.Ic source 2142at any level terminates all nested 2143.Ic source 2144commands. 2145Normally input during 2146.Ic source 2147commands is not placed on the history list; 2148the 2149.Fl h 2150option causes the commands to be placed on the 2151history list without being executed. 2152.Pp 2153.It Ic stop 2154.It Ic stop % Ns Ar job ... 2155Stops the current or specified jobs that are executing in the background. 2156.Pp 2157.It Ic suspend 2158Causes the shell to stop in its tracks, much as if it had been sent a stop 2159signal with 2160.Ic ^Z . 2161This is most often used to stop shells started by 2162.Xr su 1 . 2163.Pp 2164.It Ic switch ( Ar string ) 2165.It Ic case Ar str1 : 2166.It \ \ \ \ \&... 2167.It Ic \ \ \ \ breaksw 2168.It \ \ \ \ \&... 2169.It Ic default : 2170.It \ \ \ \ \&... 2171.It Ic \ \ \ \ breaksw 2172.It Ic endsw 2173Each case label is successively matched against the specified 2174.Ar string , 2175which is first command and filename expanded. 2176The file metacharacters 2177.Ql * , 2178.Ql \&? 2179and 2180.Dq [...] 2181may be used in the case labels, 2182which are variable expanded. 2183If none of the labels match before the 2184.Dq default 2185label is found, then 2186the execution begins after the default label. 2187Each case label and the default label must appear at the beginning of a line. 2188The command 2189.Ic breaksw 2190causes execution to continue after the 2191.Ic endsw . 2192Otherwise control may fall through case labels and the default label as in C. 2193If no label matches and there is no default, execution continues after 2194the 2195.Ic endsw . 2196.Pp 2197.It Ic time 2198.It Ic time Ar command 2199With no argument, a summary of time used by this shell and its children 2200is printed. 2201If arguments are given, 2202the specified simple command is timed and a time summary 2203as described under the 2204.Ic time 2205variable is printed. 2206If necessary, an extra shell is created to print the time 2207statistic when the command completes. 2208.Pp 2209.It Ic umask 2210.It Ic umask Ar value 2211The file creation mask is displayed (first form) or set to the specified 2212value (second form). 2213The mask is given in octal. 2214Common values for 2215the mask are 002 giving all access to the group and read and execute 2216access to others or 022 giving all access except write access for 2217users in the group or others. 2218The 2219.Xr chmod 2 2220manual page provides the complete list of bits that can be set. 2221.Pp 2222.It Ic unalias Ar pattern 2223All aliases whose names match the specified pattern are discarded. 2224Thus all aliases are removed by 2225.Ic unalias * . 2226It is not an error for nothing to be 2227.Ic unalias Ns ed. 2228.Pp 2229.It Ic unhash 2230Use of the internal hash table to speed location of executed programs 2231is disabled. 2232.Pp 2233.It Ic unlimit 2234.It Ic unlimit Ar resource 2235.It Ic unlimit Fl h 2236.It Ic unlimit Fl h Ar resource 2237Removes the limitation on 2238.Ar resource . 2239If no 2240.Ar resource 2241is specified, then all 2242.Ar resource 2243limitations are removed. 2244If 2245.Fl h 2246is given, the corresponding hard limits are removed. 2247Only the superuser may do this. 2248.Pp 2249.It Ic unset Ar pattern 2250All variables whose names match the specified pattern are removed. 2251Thus all variables are removed by 2252.Ic unset * ; 2253this has noticeably 2254distasteful side-effects. 2255It is not an error for nothing to be 2256.Ic unset . 2257.Pp 2258.It Ic unsetenv Ar pattern 2259Removes all variables whose names match the specified pattern from the 2260environment. 2261See also the 2262.Ic setenv 2263command above and 2264.Xr printenv 1 . 2265.Pp 2266.It Ic wait 2267Wait for all background jobs. 2268If the shell is interactive, then an interrupt can disrupt the wait. 2269After the interrupt, the shell prints names and job numbers of all jobs 2270known to be outstanding. 2271.Pp 2272.It Ic which Ar command 2273Displays the resolved command that will be executed by the shell. 2274.Pp 2275.It Ic while ( Ar expr ) 2276.It \&... 2277.It Ic end 2278While the specified expression evaluates to non-zero, the commands between 2279the 2280.Ic while 2281and the matching 2282.Ic end 2283are evaluated. 2284.Ic break 2285and 2286.Ic continue 2287may be used to terminate or continue the loop prematurely. 2288(The 2289.Ic while 2290and 2291.Ic end 2292must appear alone on their input lines.) 2293Prompting occurs here the first time through the loop as for the 2294.Ic foreach 2295statement if the input is a terminal. 2296.Pp 2297.It Ic % Ns Ar job 2298Brings the specified job into the foreground. 2299.Pp 2300.It Ic % Ns Ar job Ic & 2301Continues the specified job in the background. 2302.Pp 2303.It Ic @ 2304.It Ic @ Ar name Ns = expr 2305.It Ic @ Ar name[index] Ns = expr 2306The first form prints the values of all the shell variables. 2307The second form sets the specified 2308.Ar name 2309to the value of 2310.Ar expr . 2311If the expression contains 2312.Ql < , 2313.Ql > , 2314.Ql & 2315or 2316.Ql | 2317then at least 2318this part of the expression must be placed within 2319.Ql \&( 2320.Ql \&) . 2321The third form assigns the value of 2322.Ar expr 2323to the 2324.Ar index Ns 'th 2325argument of 2326.Ar name . 2327Both 2328.Ar name 2329and its 2330.Ar index Ns 'th 2331component must already exist. 2332.Pp 2333The operators 2334.Ql *= , 2335.Ql += , 2336etc. are available as in C. 2337The space separating the name from the assignment operator is optional. 2338Spaces are, however, mandatory in separating components of 2339.Ar expr , 2340which would otherwise be single words. 2341.Pp 2342Special postfix 2343.Ql +\|+ 2344and 2345.Ql \-\|\- 2346operators increment and decrement 2347.Ar name 2348respectively; i.e., 2349.Dq @ i++ . 2350.El 2351.Ss Pre-defined and environment variables 2352The following variables have special meaning to the shell. 2353Of these, 2354.Va argv , 2355.Va cwd , 2356.Va home , 2357.Va path , 2358.Va prompt , 2359.Va shell 2360and 2361.Va status 2362are always set by the shell. 2363Except for 2364.Ar cwd 2365and 2366.Ar status , 2367this setting occurs only at initialization; 2368these variables will not then be modified unless done 2369explicitly by the user. 2370.Pp 2371The shell copies the environment variable 2372.Ev USER 2373into the variable 2374.Ar user , 2375.Ev TERM 2376into 2377.Ar term , 2378and 2379.Ev HOME 2380into 2381.Ar home , 2382and copies these back into the environment whenever the normal 2383shell variables are reset. 2384The environment variable 2385.Ev PATH 2386is likewise handled; it is not 2387necessary to worry about its setting other than in the file 2388.Pa .cshrc 2389as inferior 2390.Nm 2391processes will import the definition of 2392.Ar path 2393from the environment, and re-export it if you then change it. 2394.Bl -tag -width histchars 2395.It Ic argv 2396Set to the arguments to the shell, it is from this variable that 2397positional parameters are substituted; i.e., 2398.Dq $1 2399is replaced by 2400.Dq $argv[1] , 2401etc. 2402.It Ic cdpath 2403Gives a list of alternate directories searched to find subdirectories 2404in 2405.Ic chdir 2406commands. 2407.It Ic cwd 2408The full pathname of the current directory. 2409.It Ic echo 2410Set when the 2411.Fl x 2412command-line option is given. 2413Causes each command and its arguments 2414to be echoed just before it is executed. 2415For non-built-in commands all expansions occur before echoing. 2416Built-in commands are echoed before command and filename substitution, 2417since these substitutions are then done selectively. 2418.It Ic filec 2419Enable file name completion. 2420.It Ic histchars 2421Can be given a string value to change the characters used in history 2422substitution. 2423The first character of its value is used as the 2424history substitution character, replacing the default character 2425.Ql \&! . 2426The second character of its value replaces the character 2427.Ql ^ 2428in quick substitutions. 2429.It Ic histfile 2430Can be set to the pathname where history is going to be saved/restored. 2431.It Ic history 2432Can be given a numeric value to control the size of the history list. 2433Any command that has been referenced in this many events will not be 2434discarded. 2435Too large values of 2436.Va history 2437may run the shell out of memory. 2438The last executed command is always saved on the history list. 2439.It Ic home 2440The home directory of the invoker, initialized from the environment. 2441The filename expansion of 2442.Dq Pa ~ 2443refers to this variable. 2444.It Ic ignoreeof 2445If set, the shell ignores 2446end-of-file from input devices which are terminals. 2447This prevents shells from accidentally being killed by control-Ds. 2448.It Ic mail 2449The files where the shell checks for mail. 2450This checking is done after each command completion that will 2451result in a prompt, 2452if a specified interval has elapsed. 2453The shell says 2454.Dq You have new mail. 2455if the file exists with an access time not greater than its modify time. 2456.Pp 2457If the first word of the value of 2458.Ar mail 2459is numeric it specifies a different mail checking interval, in seconds, 2460than the default, which is 10 minutes. 2461.Pp 2462If multiple mail files are specified, then the shell says 2463.Dq New mail in Ar name 2464when there is mail in the file 2465.Ar name . 2466.It Ic noclobber 2467As described in the section on 2468.Sx Input/output , 2469restrictions are placed on output redirection to ensure that 2470files are not accidentally destroyed, and that 2471.Ql >> 2472redirections 2473refer to existing files. 2474.It Ic noglob 2475If set, filename expansion is inhibited. 2476This inhibition is most useful in shell scripts that 2477are not dealing with filenames, 2478or after a list of filenames has been obtained and further expansions 2479are not desirable. 2480.It Ic nonomatch 2481If set, it is not an error for a filename expansion to not match any 2482existing files; instead the primitive pattern is returned. 2483It is still an error for the primitive pattern to be malformed; i.e., 2484.Dq echo [ 2485still gives an error. 2486.It Ic notify 2487If set, the shell notifies asynchronously of job completions; 2488the default is to present job completions just before printing 2489a prompt. 2490.It Ic path 2491Each word of the 2492.Va path 2493variable specifies a directory in which 2494commands are to be sought for execution. 2495A null word specifies the current directory. 2496If there is no 2497.Ar path 2498variable then only full path names will execute. 2499The usual search path is 2500.Dq \&. , 2501.Dq /bin , 2502.Dq /usr/bin , 2503.Dq /sbin 2504and 2505.Dq /usr/sbin , 2506but this 2507may vary from system to system. 2508For the superuser the default search path is 2509.Dq /bin , 2510.Dq /usr/bin , 2511.Dq /sbin , 2512and 2513.Dq /usr/sbin . 2514A shell that is given neither the 2515.Fl c 2516nor the 2517.Fl t 2518option will normally hash the contents of the directories in the 2519.Ar path 2520variable after reading 2521.Ar \&.cshrc , 2522and each time the 2523.Ar path 2524variable is reset. 2525If new commands are added to these directories 2526while the shell is active, it may be necessary to do a 2527.Ic rehash 2528or the commands may not be found. 2529.It Ic prompt 2530The string that is printed before each command is read from 2531an interactive terminal input. 2532If a 2533.Ql \&! 2534appears in the string, it will be replaced by the current event number 2535unless a preceding 2536.Ql \e 2537is given. 2538Default is the first part of the hostname, followed by 2539.Dq % , 2540or 2541.Dq # 2542for the superuser. 2543.It Ic savehist 2544Is given a numeric value to control the number of entries of the 2545history list that are saved in 2546.Pa ~/.history 2547when the user logs out. 2548Any command that has been referenced in this many events will be saved. 2549During start up the shell sources 2550.Pa ~/.history 2551into the history list 2552enabling history to be saved across logins. 2553Too large values of 2554.Va savehist 2555will slow down the shell during start up. 2556If 2557.Va savehist 2558is just set, the shell will use the value of 2559.Va history . 2560.It Ic shell 2561The file in which the shell resides. 2562This variable is used in forking shells to interpret files that have execute 2563bits set, but which are not executable by the system. 2564(See the description of 2565.Sx Non-built-in command execution 2566below.) 2567Initialized to the (system-dependent) home of the shell. 2568.It Ic status 2569The status returned by the last command. 2570If it terminated abnormally, then 0200 is added to the status. 2571Built-in commands that fail return exit status 1, 2572all other built-in commands set status to 0. 2573.It Ic time 2574Controls automatic timing of commands. 2575If set, then any command that takes more than this many CPU seconds 2576will cause a line giving user, system, and real times, and a utilization 2577percentage which is the ratio of user plus system times to real time 2578to be printed when it terminates. 2579.It Ic verbose 2580Set by the 2581.Fl v 2582command-line option, causes the words of each command to be printed 2583after history substitution. 2584.El 2585.Ss Non-built-in command execution 2586When a command to be executed is found to not be a built-in command, 2587the shell attempts to execute the command via 2588.Xr execve 2 . 2589Each word in the variable 2590.Ar path 2591names a directory from which the shell will attempt to execute the command. 2592If it is given neither a 2593.Fl c 2594nor a 2595.Fl t 2596option, the shell will hash the names in these directories into an internal 2597table so that it will only try an 2598.Ic exec 2599in a directory if there is a possibility that the command resides there. 2600This shortcut greatly speeds command location when many directories 2601are present in the search path. 2602If this mechanism has been turned off (via 2603.Ic unhash ) , 2604or if the shell was given a 2605.Fl c 2606or 2607.Fl t 2608argument, and in any case for each directory component of 2609.Ar path 2610that does not begin with a 2611.Ql / , 2612the shell concatenates with the given command name to form a path name 2613of a file which it then attempts to execute. 2614.Pp 2615Parenthesized commands are always executed in a sub-shell. 2616Thus 2617.Pp 2618.Dl (cd ; pwd) ; pwd 2619.Pp 2620prints the 2621.Ar home 2622directory; leaving you where you were (printing this after the home directory), 2623while 2624.Pp 2625.Dl cd ; pwd 2626.Pp 2627leaves you in the 2628.Ar home 2629directory. 2630Parenthesized commands are most often used to prevent 2631.Ic chdir 2632from affecting the current shell. 2633.Pp 2634If the file has execute permissions but is not an 2635executable binary to the system, then it is assumed to be a 2636file containing shell commands and a new shell is spawned to read it. 2637.Pp 2638If there is an alias for 2639.Ic shell 2640then the words of the alias will be prepended to the argument list to form 2641the shell command. 2642The first word of the alias 2643should be the full path name of the shell 2644(e.g., 2645.Dq $shell ) . 2646Note that this is a special, late occurring, case of 2647.Ic alias 2648substitution, 2649and only allows words to be prepended to the argument list without change. 2650.Ss Signal handling 2651The shell normally ignores 2652.Dv SIGQUIT 2653signals. 2654Jobs running detached (either by 2655.Ic \&& 2656or the 2657.Ic bg 2658or 2659.Ic %... & 2660commands) are immune to signals generated from the keyboard, including 2661hangups. 2662Other signals have the values which the shell inherited from its parent. 2663The shell's handling of interrupts and terminate signals 2664in shell scripts can be controlled by 2665.Ic onintr . 2666Login shells catch the 2667.Dv SIGTERM 2668(terminate) signal; 2669otherwise this signal is passed on to children from the state in the 2670shell's parent. 2671Interrupts are not allowed when a login shell is reading the file 2672.Pa .logout . 2673.Sh LIMITATIONS 2674Word lengths: 2675Words can be no longer than 1024 characters. 2676The number of arguments to a command that involves filename expansion 2677is limited to 1/6th the number of characters allowed in an argument list. 2678Command substitutions may substitute no more characters than are 2679allowed in an argument list. 2680To detect looping, the shell restricts the number of 2681.Ic alias 2682substitutions on a single line to 20. 2683.Sh FILES 2684.Bl -tag -width /etc/passwd -compact 2685.It Pa ~/.cshrc 2686read at beginning of execution by each shell 2687.It Pa ~/.login 2688read by login shell, after 2689.Pa .cshrc 2690at login 2691.It Pa ~/.logout 2692read by login shell, at logout 2693.It Pa /bin/sh 2694standard shell, for shell scripts not starting with a 2695.Ql # 2696.It Pa /tmp/sh.* 2697temporary file for 2698.Ql << 2699.It Pa /etc/passwd 2700source of home directories for 2701.Dq ~name 2702.El 2703.Sh SEE ALSO 2704.Xr ksh 1 , 2705.Xr sh 1 , 2706.Xr tty 4 , 2707.Xr environ 7 , 2708.Xr script 7 2709.Rs 2710.\" 4.4BSD USD:4 2711.%A W. Joy 2712.%T \&An Introduction to the C shell 2713.Re 2714.Sh HISTORY 2715.Nm 2716first appeared in 2717.Bx 2 . 2718It 2719was a first implementation of a command language interpreter 2720incorporating a history mechanism (see 2721.Sx History substitutions ) , 2722job control facilities (see 2723.Sx Jobs ) , 2724interactive file name 2725and user name completion (see 2726.Sx File name completion ) , 2727and a C-like syntax. 2728There are now many shells that also have these mechanisms, plus 2729a few more (and maybe some bugs too), which are available through the 2730usenet. 2731.Sh AUTHORS 2732.An -nosplit 2733.An Bill Joy , 27341978. 2735Job control and directory stack features first implemented by 2736.An J.E. Kulp 2737of IIASA, Laxenburg, Austria, 2738with different syntax than that used now. 2739File name completion code written by 2740.An Ken Greer , 2741HP Labs. 2742Eight-bit implementation by 2743.An Christos S. Zoulas , 2744Cornell University. 2745.Sh BUGS 2746When a command is restarted from a stop, 2747the shell prints the directory it started in if this is different 2748from the current directory; this can be misleading (i.e., wrong) 2749as the job may have changed directories internally. 2750.Pp 2751Shell built-in functions are not stoppable/restartable. 2752Command sequences of the form 2753.Dq a \&; b \&; c 2754are also not handled gracefully 2755when stopping is attempted. 2756If you suspend 2757.Ql b , 2758the shell will immediately execute 2759.Ql c . 2760This is especially noticeable if this 2761expansion results from an alias. 2762It suffices to place the sequence of commands in ()'s to force it to 2763a sub-shell; i.e., 2764.Dq Po a \&; b \&; c Pc . 2765.Pp 2766Control over tty output after processes are started is primitive; 2767perhaps this will inspire someone to work on a good virtual 2768terminal interface. 2769In a virtual terminal interface much more 2770interesting things could be done with output control. 2771.Pp 2772Alias substitution is most often used to clumsily simulate shell procedures; 2773shell procedures should be provided instead of aliases. 2774.Pp 2775Commands within loops, prompted for by 2776.Ql \&? , 2777are not placed on the 2778.Ic history 2779list. 2780Control structure should be parsed instead of being recognized as built-in 2781commands. 2782This would allow control commands to be placed anywhere, 2783to be combined with 2784.Ql | , 2785and to be used with 2786.Ql & 2787and 2788.Ql \&; 2789metasyntax. 2790.Pp 2791It should be possible to use the 2792.Ql \&: 2793modifiers on the output of command 2794substitutions. 2795.Pp 2796The way the 2797.Va filec 2798facility is implemented is ugly and expensive. 2799