1 .\" $NetBSD: csh.1,v 1.46 2009/03/29 01:02:48 mrg Exp $
3 .\" Copyright (c) 1980, 1990, 1993
4 .\" The Regents of the University of California. All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
14 .\" 3. Neither the name of the University nor the names of its contributors
15 .\" may be used to endorse or promote products derived from this software
16 .\" without specific prior written permission.
18 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
19 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
22 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 .\" @(#)csh.1 8.2 (Berkeley) 1/21/94
37 .Nd a shell (command interpreter) with C-like syntax
47 is a command language interpreter
48 incorporating a history mechanism (see
49 .Sx History Substitutions ) ,
50 job control facilities (see
53 and user name completion (see
54 .Sx File Name Completion ) ,
56 It is used both as an interactive
57 login shell and a shell script command processor.
58 .Ss Argument list processing
59 If the first argument (argument 0) to the shell is
61 then this is a login shell.
62 A login shell also can be specified by invoking the shell with the
64 flag as the only argument.
66 The rest of the flag arguments are interpreted as follows:
69 This flag forces a ``break'' from option processing, causing any further
70 shell arguments to be treated as non-option arguments.
71 The remaining arguments will not be interpreted as shell options.
72 This may be used to pass options to a shell script without confusion
73 or possible subterfuge.
74 The shell will not run a set-user ID script without this option.
76 Commands are read from the (single) following argument which must
78 Any remaining arguments are placed in
81 The shell exits if any invoked command terminates abnormally
82 or yields a non-zero exit status.
84 The shell will start faster, because it will neither search for nor
85 execute commands from the file
87 in the invoker's home directory.
89 The shell is interactive and prompts for its top-level input,
90 even if it appears not to be a terminal.
91 Shells are interactive without this option if their inputs
92 and outputs are terminals.
94 The shell is a login shell (only applicable if
96 is the only flag specified).
100 even if not owned by the user.
101 This flag is normally given only by
104 Commands are parsed, but not executed.
105 This aids in syntactic checking of shell scripts.
107 Command input is taken from the standard input.
109 A single line of input is read and executed.
112 may be used to escape the newline at the end of this
113 line and continue onto another line.
117 variable to be set, with the effect
118 that command input is echoed after history substitution.
122 variable to be set, so that commands are echoed immediately before execution.
126 variable to be set even before
138 After processing of flag arguments, if arguments remain but none of the
144 options were given, the first argument is taken as the name of a file of
145 commands to be executed.
146 The shell opens this file, and saves its name for possible resubstitution
148 Since many systems use either the standard version 6 or version 7 shells
149 whose shell scripts are not compatible with this shell, the shell will
150 execute such a `standard' shell if the first character of a script
151 is not a `#', i.e., if the script does not start with a comment.
152 Remaining arguments initialize the variable
157 begins by executing commands from the file
160 if this is a login shell,
161 .Pa \&/etc/csh.login .
167 directory of the invoker, and, if this is a login shell, the file
169 in the same location.
170 It is typical for users on crt's to put the command ``stty crt''
173 file, and to also invoke
177 In the normal case, the shell will begin reading commands from the
178 terminal, prompting with `% '.
179 Processing of arguments and the use of the shell to process files
180 containing command scripts will be described later.
182 The shell repeatedly performs the following actions:
183 a line of command input is read and broken into
185 This sequence of words is placed on the command history list and parsed.
186 Finally each command in the current line is executed.
188 When a login shell terminates it executes commands from the files
193 .Pa /etc/csh.logout .
194 .Ss Lexical structure
195 The shell splits input lines into words at blanks and tabs with the
196 following exceptions.
198 `\*[Am]' `\&|' `;' `\*[Lt]' `\*[Gt]' `(' `)'
200 If doubled in `\*[Am]\*[Am]',
201 `\&|\&|', `\*[Lt]\*[Lt]' or `\*[Gt]\*[Gt]' these pairs form single words.
202 These parser metacharacters may be made part of other words, or prevented their
203 special meaning, by preceding them with `\e'.
204 A newline preceded by a `\e' is equivalent to a blank.
206 Strings enclosed in matched pairs of quotations,
207 `'\|', `\*(ga' or `"',
208 form parts of a word; metacharacters in these strings, including blanks
209 and tabs, do not form separate words.
210 These quotations have semantics to be described later.
211 Within pairs of `\'' or `"' characters, a newline preceded by a `\e' gives
212 a true newline character.
214 When the shell's input is not a terminal,
215 the character `#' introduces a comment that continues to the end of the
217 It is prevented this special meaning when preceded by `\e'
218 and in quotations using `\`', `\'', and `"'.
220 A simple command is a sequence of words, the first of which
221 specifies the command to be executed.
223 a sequence of simple commands separated by `\&|' characters
225 The output of each command in a pipeline is connected to the input of the next.
226 Sequences of pipelines may be separated by `;', and are then executed
228 A sequence of pipelines may be executed without immediately
229 waiting for it to terminate by following it with an `\*[Am]'.
231 Any of the above may be placed in `(' `)' to form a simple command (that
232 may be a component of a pipeline, etc.).
233 It is also possible to separate pipelines with `\&|\&|'
234 or `\*[Am]\*[Am]' showing, as in the C language,
235 that the second is to be executed only if the first fails or succeeds
240 The shell associates a
244 a table of current jobs, printed by the
246 command, and assigns them small integer numbers.
247 When a job is started asynchronously with `\*[Am]',
248 the shell prints a line that looks like:
249 .Bd -filled -offset indent
254 showing that the job which was started asynchronously was job number
255 1 and had one (top-level) process, whose process id was 1234.
257 If you are running a job and wish to do something else you may hit the key
259 (control-Z) which sends a STOP signal to the current job.
260 The shell will then normally show that the job has been `Stopped',
261 and print another prompt.
262 You can then manipulate the state of this job, putting it in the
266 command, or run some other
267 commands and eventually bring the job back into the foreground with
274 takes effect immediately and
275 is like an interrupt in that pending output and unread input are discarded
277 There is another special key
279 that does not generate a STOP signal until a program attempts to
282 This request can usefully be typed ahead when you have prepared some commands
283 for a job that you wish to stop after it has read them.
285 A job being run in the background will stop if it tries to read
287 Background jobs are normally allowed to produce output,
288 but this can be disabled by giving the command ``stty tostop''.
290 tty option, then background jobs will stop when they try to produce
291 output like they do when they try to read input.
293 There are several ways to refer to jobs in the shell.
294 The character `%' introduces a job name.
295 If you wish to refer to job number 1, you can name it as `%1'.
296 Just naming a job brings it to the foreground; thus
297 `%1' is a synonym for `fg %1', bringing job number 1 back into the foreground.
298 Similarly saying `%1 \*[Am]' resumes job number 1 in the background.
299 Jobs can also be named by prefixes of the string typed in to start them,
300 if these prefixes are unambiguous, thus `%ex' would normally restart
303 job, if there were only one suspended job whose name began with
305 It is also possible to say `%?string'
306 which specifies a job whose text contains
308 if there is only one such job.
310 The shell maintains a notion of the current and previous jobs.
311 In output about jobs, the current job is marked with a `+'
312 and the previous job with a `\-'.
313 The abbreviation `%+' refers
314 to the current job and `%\-' refers to the previous job.
315 For close analogy with the syntax of the
317 mechanism (described below),
318 `%%' is also a synonym for the current job.
320 The job control mechanism requires that the
325 It is an artifact from a
329 tty driver that allows generation of interrupt characters from
330 the keyboard to tell jobs to stop.
333 for details on setting options in the new tty driver.
335 The shell learns immediately whenever a process changes state.
336 It normally informs you whenever a job becomes blocked so that
337 no further progress is possible, but only just before it prints
339 This is done so that it does not otherwise disturb your work.
340 If, however, you set the shell variable
342 the shell will notify you immediately of changes of status in background
344 There is also a shell command
346 that marks a single process so that its status changes will be immediately
350 marks the current process;
351 simply say `notify' after starting a background job to mark it.
353 When you try to leave the shell while jobs are stopped, you will
354 be warned that `You have stopped jobs.'
357 command to see what they are.
358 If you try to exit again immediately,
359 the shell will not warn you a second time, and the suspended
360 jobs will be terminated.
361 .Ss File Name Completion
362 When the file name completion feature is enabled by setting
369 interactively complete file names and user names from unique
370 prefixes, when they are input from the terminal followed by
371 the escape character (the escape key, or control-[)
373 if the current directory looks like
374 .Bd -literal -offset indent
375 DSC.OLD bin cmd lib xmpl.c
376 DSC.NEW chaosnet cmtest mail xmpl.o
377 bench class dev mbox xmpl.out
382 .Dl % vi ch\*[Lt]escape\*[Gt]
385 will complete the prefix ``ch''
386 to the only matching file name ``chaosnet'', changing the input
393 .Dl % vi D\*[Lt]escape\*[Gt]
396 will only expand the input to
400 and will sound the terminal bell to indicate that the expansion is
401 incomplete, since there are two file names matching the prefix ``D''.
403 If a partial file name is followed by the end-of-file character
404 (usually control-D), then, instead of completing the name,
406 will list all file names matching the prefix.
410 .Dl % vi D\*[Lt]control-D\*[Gt]
412 causes all files beginning with ``D'' to be listed:
416 while the input line remains unchanged.
418 The same system of escape and end-of-file can also be used to
419 expand partial user names, if the word to be completed
420 (or listed) begins with the character ``~''.
423 .Dl cd ~ro\*[Lt]escape\*[Gt]
425 may produce the expansion
429 The use of the terminal bell to signal errors or multiple matches
430 can be inhibited by setting the variable
433 Normally, all files in the particular directory are candidates
435 Files with certain suffixes can be excluded
436 from consideration by setting the variable
439 list of suffixes to be ignored.
445 .Dl % set fignore = (.o .out)
449 .Dl % vi x\*[Lt]escape\*[Gt]
451 would result in the completion to
455 ignoring the files "xmpl.o" and "xmpl.out".
456 However, if the only completion possible requires not ignoring these
457 suffixes, then they are not ignored.
460 does not affect the listing of file names by control-D.
462 are listed regardless of their suffixes.
464 We now describe the various transformations the shell performs on the
465 input in the order in which they occur.
466 .Ss History substitutions
467 History substitutions place words from previous command input as portions
468 of new commands, making it easy to repeat commands, repeat arguments
469 of a previous command in the current command, or fix spelling mistakes
470 in the previous command with little typing and a high degree of confidence.
471 History substitutions begin with the character `!' and may begin
473 in the input stream (with the proviso that they
476 This `!' may be preceded by a `\e' to prevent its special meaning; for
477 convenience, an `!' is passed unchanged when it is followed by a blank,
478 tab, newline, `=' or `('.
479 (History substitutions also occur when an input line begins with `\*(ua'.
480 This special abbreviation will be described later.)
481 Any input line that contains history substitution is echoed on the terminal
482 before it is executed as it would have been typed without history substitution.
484 Commands input from the terminal that consist of one or more words
485 are saved on the history list.
486 The history substitutions reintroduce sequences of words from these
487 saved commands into the input stream.
488 The size of the history list is controlled by the
490 variable; the previous command is always retained,
491 regardless of the value of the history variable.
492 Commands are numbered sequentially from 1.
494 For example, consider the following output from the
497 .Bd -literal -offset indent
504 The commands are shown with their event numbers.
505 It is not usually necessary to use event numbers, but the current event
506 number can be made part of the
508 by placing an `!' in the prompt string.
510 With the current event 13 we can refer to previous events by event
511 number `!11', relatively as in `!\-2' (referring to the same event),
512 by a prefix of a command word
513 as in `!d' for event 12 or `!wri' for event 9, or by a string contained in
514 a word in the command as in `!?mic?' also referring to event 9.
515 These forms, without further change, simply reintroduce the words
516 of the specified events, each separated by a single blank.
517 As a special case, `!!' refers to the previous command; thus `!!' alone is a
520 To select words from an event we can follow the event specification by
521 a `:' and a designator for the desired words.
522 The words of an input line are numbered from 0,
523 the first (usually command) word being 0, the second word (first argument)
525 The basic word designators are:
527 .Bl -tag -width Ds -compact -offset indent
534 first argument, i.e., `1'
538 word matched by (immediately preceding)
539 .No \&? Ns Ar s Ns \&?
547 abbreviates `\*(ua\-$', or nothing if only 1 word in event
554 but omitting word `$'
557 The `:' separating the event specification from the word designator
558 can be omitted if the argument selector begins with a `\*(ua', `$', `*',
560 After the optional word designator can be
561 placed a sequence of modifiers, each preceded by a `:'.
562 The following modifiers are defined:
564 .Bl -tag -width Ds -compact -offset indent
566 Remove a trailing pathname component, leaving the head.
568 Remove a trailing `.xxx' component, leaving the root name.
570 Remove all but the extension `.xxx' part.
577 Remove all leading pathname components, leaving the tail.
579 Repeat the previous substitution.
581 Apply the change once on each word, prefixing the above, e.g., `g\*[Am]'.
583 Apply the change as many times as possible on a single word, prefixing
585 It can be used together with `g' to apply a substitution
588 Print the new command line but do not execute it.
590 Quote the substituted words, preventing further substitutions.
592 Like q, but break into words at blanks, tabs and newlines.
595 Unless preceded by a `g' the change is applied only to the first
597 With substitutions, it is an error for no word to be applicable.
599 The left hand side of substitutions are not regular expressions in the sense
600 of the editors, but instead strings.
601 Any character may be used as the delimiter in place of `/';
602 a `\e' quotes the delimiter into the
607 The character `\*[Am]' in the right hand side is replaced by the text from
609 A `\e' also quotes `\*[Am]'.
613 uses the previous string either from an
616 contextual scan string
619 .No \&`!? Ns Ar s Ns \e?' .
620 The trailing delimiter in the substitution may be omitted if a newline
621 follows immediately as may the trailing `?' in a contextual scan.
623 A history reference may be given without an event specification, e.g., `!$'.
624 Here, the reference is to the previous command unless a previous
625 history reference occurred on the same line in which case this form repeats
626 the previous reference.
627 Thus `!?foo?\*(ua !$' gives the first and last arguments
628 from the command matching `?foo?'.
630 A special abbreviation of a history reference occurs when the first
631 non-blank character of an input line is a `\*(ua'.
632 This is equivalent to `!:s\*(ua' providing a convenient
633 shorthand for substitutions on the text of the previous line.
634 Thus `\*(ualb\*(ualib' fixes the spelling of
636 in the previous command.
637 Finally, a history substitution may be surrounded with `{' and `}'
638 if necessary to insulate it from the characters that follow.
639 Thus, after `ls \-ld ~paul' we might do `!{l}a' to do `ls \-ld ~paula',
640 while `!la' would look for a command starting with `la'.
641 .Ss Quotations with \' and \&"
642 The quotation of strings by `\'' and `"' can be used
643 to prevent all or some of the remaining substitutions.
644 Strings enclosed in `\'' are prevented any further interpretation.
645 Strings enclosed in `"' may be expanded as described below.
647 In both cases the resulting text becomes (all or part of) a single word;
648 only in one special case (see
649 .Em Command Substitution
650 below) does a `"' quoted string yield parts of more than one word;
651 `\'' quoted strings never do.
652 .Ss Alias substitution
653 The shell maintains a list of aliases that can be established, displayed
659 After a command line is scanned, it is parsed into distinct commands and
660 the first word of each command, left-to-right, is checked to see if it
662 If it does, then the text that is the alias for that command is reread
663 with the history mechanism available
664 as though that command were the previous input line.
665 The resulting words replace the
666 command and argument list.
667 If no reference is made to the history list, then the argument list is
670 Thus if the alias for `ls' is `ls \-l' the command `ls /usr' would map to
671 `ls \-l /usr', the argument list here being undisturbed.
672 Similarly if the alias for `lookup' was `grep !\*(ua /etc/passwd' then
673 `lookup bill' would map to `grep bill /etc/passwd'.
675 If an alias is found, the word transformation of the input text
676 is performed and the aliasing process begins again on the reformed input line.
677 Looping is prevented if the first word of the new text is the same as the old
678 by flagging it to prevent further aliasing.
679 Other loops are detected and cause an error.
681 Note that the mechanism allows aliases to introduce parser metasyntax.
682 Thus, we can `alias print \'pr \e!* \&| lpr\'' to make a command that
684 its arguments to the line printer.
685 .Ss Variable substitution
686 The shell maintains a set of variables, each of which has as value a list
687 of zero or more words.
688 Some of these variables are set by the shell or referred to by it.
691 variable is an image of the shell's argument list, and words of this
692 variable's value are referred to in special ways.
694 The values of variables may be displayed and changed by using the
699 Of the variables referred to by the shell a number are toggles;
700 the shell does not care what their value is,
701 only whether they are set or not.
704 variable is a toggle that causes command input to be echoed.
705 The setting of this variable results from the
709 Other operations treat variables numerically.
710 The `@' command permits numeric calculations to be performed and the result
711 assigned to a variable.
712 Variable values are, however, always represented as (zero or more) strings.
713 For the purposes of numeric operations, the null string is considered to be
714 zero, and the second and additional words of multiword values are ignored.
716 After the input line is aliased and parsed, and before each command
717 is executed, variable substitution
718 is performed keyed by `$' characters.
719 This expansion can be prevented by preceding the `$' with a `\e' except
722 occurs, and within `\''s where it
725 Strings quoted by `\*(ga' are interpreted later (see
726 .Sx Command substitution
727 below), so `$' substitution does not occur there until later, if at all.
728 A `$' is passed unchanged if followed by a blank, tab, or end-of-line.
730 Input/output redirections are recognized before variable expansion,
731 and are variable expanded separately.
732 Otherwise, the command name and entire argument list are expanded together.
733 It is thus possible for the first (command) word (to this point) to generate
734 more than one word, the first of which becomes the command name,
735 and the rest of which become arguments.
737 Unless enclosed in `"' or given the `:q' modifier the results of variable
738 substitution may eventually be command and filename substituted.
739 Within `"', a variable whose value consists of multiple words expands to a
740 (portion of) a single word, with the words of the variable's value
742 When the `:q' modifier is applied to a substitution
743 the variable will expand to multiple words with each word separated
744 by a blank and quoted to prevent later command or filename substitution.
746 The following metasequences are provided for introducing variable values into
748 Except as noted, it is an error to reference a variable that is not set.
750 .Bl -tag -width Ds -compact -offset indent
753 Are replaced by the words of the value of variable
755 each separated by a blank.
758 from following characters that would otherwise be part of it.
759 Shell variables have names consisting of up to 20 letters and digits
760 starting with a letter.
761 The underscore character is considered a letter.
764 is not a shell variable, but is set in the environment, then
765 that value is returned (but `:' modifiers and the other forms
766 given below are not available here).
767 .It $name Ns Op selector
768 .It ${name Ns [ selector ] Ns }
769 May be used to select only some of the words from the value of
771 The selector is subjected to `$' substitution and may consist of a single
772 number or two numbers separated by a `\-'.
773 The first word of a variable's value is numbered `1'.
774 If the first number of a range is omitted it defaults to `1'.
775 If the last number of a range is omitted it defaults to `$#name'.
776 The selector `*' selects all words.
777 It is not an error for a range to be empty if the second argument is omitted
781 Gives the number of words in the variable.
782 This is useful for later use in a
785 Substitutes the name of the file from which command input is being read.
786 An error occurs if the name is not known.
796 The modifiers `:e', `:h', `:t', `:r', `:q' and `:x' may be applied to
797 the substitutions above as may `:gh', `:gt' and `:gr'.
798 If braces `{' '}' appear in the command form then the modifiers
799 must appear within the braces.
800 The current implementation allows only one `:' modifier on each `$' expansion.
802 The following substitutions may not be modified with `:' modifiers.
803 .Bl -tag -width Ds -compact -offset indent
806 Substitutes the string `1' if name is set, `0' if it is not.
808 Substitutes `1' if the current input filename is known, `0' if it is not.
810 Substitute the (decimal) process number of the (parent) shell.
812 Substitute the (decimal) process number of the last background process
813 started by this shell.
815 Substitutes a line from the standard
816 input, with no further interpretation.
817 It can be used to read from the keyboard in a shell script.
819 .Ss Command and filename substitution
820 The remaining substitutions, command and filename substitution,
821 are applied selectively to the arguments of builtin commands.
822 By selectively, we mean that portions of expressions which are
823 not evaluated are not subjected to these expansions.
824 For commands that are not internal to the shell, the command
825 name is substituted separately from the argument list.
826 This occurs very late,
827 after input-output redirection is performed, and in a child
829 .Ss Command substitution
830 Command substitution is shown by a command enclosed in `\*(ga'.
831 The output from such a command is normally broken into separate words
832 at blanks, tabs and newlines, with null words being discarded;
833 this text then replaces the original string.
834 Within `"'s, only newlines force new words; blanks and tabs are preserved.
836 In any case, the single final newline does not force a new word.
837 Note that it is thus possible for a command substitution to yield
838 only part of a word, even if the command outputs a complete line.
839 .Ss Filename substitution
840 If a word contains any of the characters `*', `?', `[' or `{'
841 or begins with the character `~', then that word is a candidate for
842 filename substitution, also known as `globbing'.
843 This word is then regarded as a pattern, and replaced with an alphabetically
844 sorted list of file names that match the pattern.
845 In a list of words specifying filename substitution it is an error for
846 no pattern to match an existing file name, but it is not required
847 for each pattern to match.
848 Only the metacharacters `*', `?' and `[' imply pattern matching,
849 the characters `~' and `{' being more akin to abbreviations.
851 In matching filenames, the character `.' at the beginning of a filename
852 or immediately following a `/', as well as the character `/' must
853 be matched explicitly.
854 The character `*' matches any string of characters, including the null
856 The character `?' matches any single character.
859 matches any one of the characters enclosed.
862 a pair of characters separated by `\-' matches any character lexically between
865 The character `~' at the beginning of a filename refers to home
867 Standing alone, i.e., `~' it expands to the invoker's home directory as reflected
868 in the value of the variable
870 When followed by a name consisting of letters, digits and `\-' characters,
871 the shell searches for a user with that name and substitutes their
872 home directory; thus `~ken' might expand to `/usr/ken' and `~ken/chmach'
873 to `/usr/ken/chmach'.
874 If the character `~' is followed by a character other than a letter or `/'
875 or does not appear at the beginning of a word,
876 it is left undisturbed.
878 The metanotation `a{b,c,d}e' is a shorthand for `abe ace ade'.
879 Left to right order is preserved, with results of matches being sorted
880 separately at a low level to preserve this order.
881 This construct may be nested.
882 Thus, `~source/s1/{oldls,ls}.c' expands to
883 `/usr/source/s1/oldls.c /usr/source/s1/ls.c'
884 without chance of error
885 if the home directory for `source' is `/usr/source'.
886 Similarly `../{memo,*box}' might expand to `../memo ../box ../mbox'.
887 (Note that `memo' was not sorted with the results of the match to `*box'.)
888 As a special case `{', `}' and `{}' are passed undisturbed.
890 The standard input and the standard output of a command may be redirected
891 with the following syntax:
893 .Bl -tag -width Ds -compact -offset indent
897 (which is first variable, command and filename expanded) as the standard
899 .It \*[Lt]\*[Lt] word
900 Read the shell input up to a line that is identical to
903 is not subjected to variable, filename or command substitution,
904 and each input line is compared to
906 before any substitutions are done on the input line.
907 Unless a quoting `\e', `"', `\*(aa' or `\*(ga' appears in
909 variable and command substitution is performed on the intervening lines,
910 allowing `\e' to quote `$', `\e' and `\*(ga'.
911 Commands that are substituted have all blanks, tabs, and newlines
912 preserved, except for the final newline which is dropped.
913 The resultant text is placed in an anonymous temporary file that
914 is given to the command as its standard input.
917 .It \*[Gt]\*[Am] name
918 .It \*[Gt]\*[Am]! name
921 is used as the standard output.
922 If the file does not exist then it is created;
923 if the file exists, it is truncated; its previous contents are lost.
927 is set, then the file must not exist or be a character special file (e.g., a
928 terminal or `/dev/null') or an error results.
929 This helps prevent accidental destruction of files.
930 Here, the `!' forms can be used to suppress this check.
932 The forms involving `\*[Am]' route the standard error output into the specified
933 file as well as the standard output.
935 is expanded in the same way as `\*[Lt]' input filenames are.
936 .It \*[Gt]\*[Gt] name
937 .It \*[Gt]\*[Gt]\*[Am] name
938 .It \*[Gt]\*[Gt]! name
939 .It \*[Gt]\*[Gt]\*[Am]! name
942 as the standard output;
943 like `\*[Gt]' but places output at the end of the file.
946 is set, then it is an error for the file not to exist unless
947 one of the `!' forms is given.
948 Otherwise similar to `\*[Gt]'.
951 A command receives the environment in which the shell was
952 invoked as modified by the input-output parameters and
953 the presence of the command in a pipeline.
954 Thus, unlike some previous shells, commands run from a file of shell commands
955 have no access to the text of the commands by default;
956 instead they receive the original standard input of the shell.
957 The `\*[Lt]\*[Lt]' mechanism should be used to present inline data.
958 This permits shell command scripts to function as components of pipelines
959 and allows the shell to block read its input.
960 Note that the default standard input for a command run detached is
962 modified to be the empty file
964 instead the standard input
965 remains as the original standard input of the shell.
966 If this is a terminal
967 and if the process attempts to read from the terminal, then the process
968 will block and the user will be notified (see
972 The standard error output may be directed through
973 a pipe with the standard output.
974 Simply use the form `\&|\*[Am]' instead of just `\&|'.
976 Several of the builtin commands (to be described later)
977 take expressions, in which the operators are similar to those of C, with
978 the same precedence, but with the
979 .Em opposite grouping :
981 These expressions appear in the
988 The following operators are available:
989 .Bd -ragged -offset indent
990 \&|\&| \*[Am]\*[Am] \&| \*(ua \*[Am] == != =~ !~ \*[Le] \*[Ge]
991 \*[Lt] \*[Gt] \*[Lt]\*[Lt] \*[Gt]\*[Gt] + \- * / % ! ~ ( )
994 Here the precedence increases to the right,
995 `==' `!=' `=~' and `!~', `\*[Le]' `\*[Ge]' `\*[Lt]'
996 and `\*[Gt]', `\*[Lt]\*[Lt]' and `\*[Gt]\*[Gt]', `+' and `\-',
997 `*' `/' and `%' being, in groups, at the same level.
998 The `==' `!=' `=~' and `!~' operators compare their arguments as strings;
999 all others operate on numbers.
1000 The operators `=~' and `!~' are like `!=' and `==' except that the right
1003 (containing, e.g., `*'s, `?'s and instances of `[...]')
1004 against which the left hand operand is matched.
1005 This reduces the need for use of the
1007 statement in shell scripts when all that is really needed is pattern matching.
1009 Strings that begin with `0' are considered octal numbers.
1010 Null or missing arguments are considered `0'.
1011 The result of all expressions are strings,
1012 which represent decimal numbers.
1013 It is important to note that no two components of an expression can appear
1014 in the same word; except when adjacent to components of expressions that
1015 are syntactically significant to the parser
1016 (`\*[Am]' `\&|' `\*[Lt]' `\*[Gt]' `(' `)'),
1017 they should be surrounded by spaces.
1019 Also available in expressions as primitive operands are command executions
1020 enclosed in `{' and `}'
1021 and file enquiries of the form
1027 .Bd -literal -offset indent
1038 The specified name is command and filename expanded and then tested
1039 to see if it has the specified relationship to the real user.
1040 If the file does not exist or is inaccessible then all enquiries return
1042 Command executions succeed, returning true, i.e., `1',
1043 if the command exits with status 0, otherwise they fail, returning
1045 If more detailed status information is required then the command
1046 should be executed outside an expression and the variable
1050 The shell contains several commands that can be used to regulate the
1051 flow of control in command files (shell scripts) and
1052 (in limited but useful ways) from terminal input.
1053 These commands all operate by forcing the shell to reread or skip in its
1054 input and, because of the implementation, restrict the placement of some
1062 statements, as well as the
1066 statement require that the major keywords appear in a single simple command
1067 on an input line as shown below.
1069 If the shell's input is not seekable,
1070 the shell buffers up input whenever a loop is being read
1071 and performs seeks in this internal buffer to accomplish the rereading
1072 implied by the loop.
1073 (To the extent that this allows, backward goto's will succeed on
1074 non-seekable inputs.)
1075 .Ss Builtin commands
1076 Builtin commands are executed within the shell.
1077 If a builtin command occurs as any component of a pipeline
1078 except the last then it is executed in a subshell.
1080 .Bl -tag -width Ds -compact -offset indent
1082 .It Ic alias Ar name
1083 .It Ic alias Ar name wordlist
1084 The first form prints all aliases.
1085 The second form prints the alias for name.
1086 The final form assigns the specified
1091 is command and filename substituted.
1093 is not allowed to be
1099 Shows the amount of dynamic memory acquired, broken down into used and
1101 With an argument shows the number of free and used blocks in each size
1103 The categories start at size 8 and double at each step.
1104 This command's output may vary across system types, since
1105 systems other than the VAX may use a different memory allocator.
1108 .It Ic bg \&% Ns Ar job ...
1109 Puts the current or specified jobs into the background, continuing them
1110 if they were stopped.
1113 Causes execution to resume after the
1115 of the nearest enclosing
1119 The remaining commands on the current line are executed.
1120 Multi-level breaks are thus possible by writing them all on one line.
1123 Causes a break from a
1128 .It Ic case Ar label :
1131 statement as discussed below.
1136 .It Ic chdir Ar name
1137 Change the shell's working directory to directory
1139 If no argument is given then change to the home directory of the user.
1142 is not found as a subdirectory of the current directory (and does not begin
1143 with `/', `./' or `../'), then each
1144 component of the variable
1146 is checked to see if it has a subdirectory
1148 Finally, if all else fails but
1150 is a shell variable whose value begins with `/', then this
1151 is tried to see if it is a directory.
1154 Continue execution of the nearest enclosing
1158 The rest of the commands on the current line are executed.
1161 Labels the default case in a
1164 The default should come after all
1169 Prints the directory stack; the top of the stack is at the left,
1170 the first directory in the stack being the current directory.
1172 .It Ic echo Ar wordlist
1173 .It Ic echo Fl n Ar wordlist
1174 The specified words are written to the shell's standard output, separated
1175 by spaces, and terminated with a newline unless the
1177 option is specified.
1183 See the description of the
1191 .It Ic eval Ar arg ...
1194 The arguments are read as input to the shell and the resulting
1195 command(s) executed in the context of the current shell.
1196 This is usually used to execute commands
1197 generated as the result of command or variable substitution, since
1198 parsing occurs before these substitutions.
1201 for an example of using
1204 .It Ic exec Ar command
1205 The specified command is executed in place of the current shell.
1208 .It Ic exit Ar ( expr )
1209 The shell exits either with the value of the
1211 variable (first form) or with the value of the specified
1216 .It Ic fg % Ns Ar job ...
1217 Brings the current or specified jobs into the foreground, continuing them if
1220 .It Ic foreach Ar name ( wordlist )
1225 is successively set to each member of
1227 and the sequence of commands between this command and the matching
1234 must appear alone on separate lines.)
1237 may be used to continue the loop prematurely and the builtin
1240 to terminate it prematurely.
1241 When this command is read from the terminal, the loop is read once
1242 prompting with `?' before any statements in the loop are executed.
1243 If you make a mistake typing in a loop at the terminal you can rub it out.
1245 .It Ic glob Ar wordlist
1248 but no `\e' escapes are recognized and words are delimited
1249 by null characters in the output.
1250 Useful for programs that wish to use the shell to filename expand a list
1256 is filename and command expanded to yield a string of the form `label'.
1257 The shell rewinds its input as much as possible
1258 and searches for a line of the form `label:'
1259 possibly preceded by blanks or tabs.
1260 Execution continues after the specified line.
1263 Print a statistics line showing how effective the internal hash
1264 table has been at locating commands (and avoiding
1268 is attempted for each component of the
1270 where the hash function indicates a possible hit, and in each component
1271 that does not begin with a `/'.
1275 .It Ic history Fl r Ar n
1276 .It Ic history Fl h Ar n
1277 Displays the history event list; if
1281 most recent events are printed.
1284 option reverses the order of printout to be most recent first
1285 instead of oldest first.
1288 option causes the history list to be printed without leading numbers.
1289 This format produces files suitable for sourcing using the \-h
1293 .It Ic if Ar ( expr ) No command
1294 If the specified expression evaluates true, then the single
1296 with arguments is executed.
1297 Variable substitution on
1299 happens early, at the same
1300 time it does for the rest of the
1304 must be a simple command, not
1305 a pipeline, a command list, or a parenthesized command list.
1306 Input/output redirection occurs even if
1308 is false, i.e., when command is
1310 executed (this is a bug).
1312 .It Ic if Ar ( expr ) Ic then
1314 .It Ic else if Ar ( expr2 ) Ic then
1321 is true then the commands up to the first
1323 are executed; otherwise if
1325 is true then the commands up to the
1331 pairs are possible; only one
1336 part is likewise optional.
1341 must appear at the beginning of input lines;
1344 must appear alone on its input line or after an
1349 Lists the active jobs; the
1351 option lists process id's in addition to the normal information.
1353 .It Ic kill % Ns Ar job
1354 .It Ic kill Ar pid ...
1355 .It Ic kill Fl l Op Ar exit_status
1356 .It Ic kill Fl s Ar signal_name pid ...
1357 .It Ic kill Fl Ar signal_name Ar pid ...
1358 .It Ic kill Fl Ar signal_number Ar pid ...
1359 Sends either the TERM (terminate) signal or the
1360 specified signal to the specified jobs or processes.
1361 Signals are either given by number or by names (as given in
1363 stripped of the prefix ``SIG'').
1364 The signal names are listed by ``kill \-l'';
1367 is specified, only the corresponding signal name will be written.
1368 There is no default, just saying `kill' does not
1369 send a signal to the current job.
1370 If the signal being sent is TERM (terminate) or HUP (hangup),
1371 then the job or process will be sent a CONT (continue) signal as well.
1374 .It Ic limit Ar resource
1375 .It Ic limit Ar resource maximum-use
1377 .It Ic limit Fl h Ar resource
1378 .It Ic limit Fl h Ar resource maximum-use
1379 Manipulates per-process system resource limits via the
1384 limits the consumption by the current process and each process
1385 it creates to not individually exceed
1393 the current limit is printed; if no
1396 all limitations are given.
1400 flag is given, the hard limits are used instead of the current
1402 The hard limits impose a ceiling on the values of the current limits.
1403 Only the super-user may raise the hard limits,
1404 but a user may lower or raise the current limits within the legal range.
1406 Resources controllable currently include:
1407 .Bl -tag -width coredumpsize
1409 The maximum number of CPU-seconds to be used by each process.
1411 The largest single file (in bytes) that can be created.
1413 The maximum growth of the data+stack region via
1415 beyond the end of the program text.
1418 size of the automatically-extended stack region.
1420 The size of the largest core dump (in bytes) that will be created.
1422 The maximum size (in bytes) to which a process's resident set
1423 size (RSS) may grow.
1425 The maximum size (in bytes) which a process may lock into memory using the
1429 The maximum number of simultaneous processes for this user id.
1431 The maximum number of simultaneous open files for this user id.
1433 The maximum socket buffer size of a process (in bytes).
1435 The maximum size (in bytes) which a process can obtain.
1440 may be given as a (floating point or integer)
1441 number followed by a scale factor.
1442 For all limits other than
1444 the default scale is `k' or `kilobytes' (1024 bytes);
1445 a scale factor of `m' or `megabytes' may also be used.
1448 the default scale is `seconds';
1449 a scale factor of `m' for minutes
1450 or `h' for hours, or a time of the form `mm:ss' giving minutes
1451 and seconds also may be used.
1455 names and scale factors, unambiguous prefixes
1456 of the names suffice.
1458 Limits of an arbitrary process can be displayed or set using the
1465 man pages for an additional description of system resource limits.
1468 Terminate a login shell, replacing it with an instance of
1469 .Pa /usr/bin/login .
1470 This is one way to log off, included for compatibility with
1474 Terminate a login shell.
1475 Especially useful if
1480 .It Ic nice Ar +number
1481 .It Ic nice Ar command
1482 .It Ic nice Ar +number command
1483 The first form sets the
1485 for this shell to 4.
1486 The second form sets the
1490 The final two forms run command at priority 4 and
1493 The greater the number, the less CPU the process will get.
1494 The super-user may specify negative priority by using `nice \-number ...'.
1496 is always executed in a sub-shell, and the restrictions
1497 placed on commands in simple
1502 .It Ic nohup Ar command
1503 The first form can be used in shell scripts to cause hangups to be
1504 ignored for the remainder of the script.
1505 The second form causes the specified command to be run with hangups
1507 All processes detached with `\*[Am]' are effectively
1511 .It Ic notify % Ns Ar job ...
1512 Causes the shell to notify the user asynchronously when the status of the
1513 current or specified jobs change; normally notification is presented
1515 This is automatic if the shell variable
1521 .It Ic onintr Ar label
1522 Control the action of the shell on interrupts.
1523 The first form restores the default action of the shell on interrupts
1524 which is to terminate shell scripts or to return to the terminal command
1526 The second form `onintr \-' causes all interrupts to be ignored.
1527 The final form causes the shell to execute a `goto label' when
1528 an interrupt is received or a child process terminates because
1531 In any case, if the shell is running detached and interrupts are
1532 being ignored, all forms of
1534 have no meaning and interrupts
1535 continue to be ignored by the shell and all invoked commands.
1538 statements are ignored in the system startup files where interrupts
1539 are disabled (/etc/csh.cshrc, /etc/csh.login).
1543 Pops the directory stack, returning to the new top directory.
1549 The members of the directory stack are numbered from the top starting at 0.
1552 .It Ic pushd Ar name
1556 exchanges the top two elements of the directory stack.
1561 changes to the new directory (ala
1563 and pushes the old current working directory
1566 onto the directory stack.
1567 With a numeric argument,
1571 argument of the directory
1572 stack around to be the top element and changes to it.
1574 of the directory stack are numbered from the top starting at 0.
1577 Causes the internal hash table of the contents of the directories in
1580 variable to be recomputed.
1581 This is needed if new commands are added to directories in the
1583 while you are logged in.
1584 This should only be necessary if you add
1585 commands to one of your own directories, or if a systems programmer
1586 changes the contents of a system directory.
1588 .It Ic repeat Ar count command
1591 which is subject to the same restrictions
1600 I/O redirections occur exactly once, even if
1606 .It Ic set Ar name Ns =word
1607 .It Ic set Ar name[index] Ns =word
1608 .It Ic set Ar name Ns =(wordlist)
1609 The first form of the command shows the value of all shell variables.
1610 Variables that have other than a single word as their
1611 value print as a parenthesized word list.
1612 The second form sets
1619 The fourth form sets
1626 this component must already exist.
1629 to the list of words in
1631 The value is always command and filename expanded.
1633 These arguments may be repeated to set multiple values in a single set command.
1634 Note however, that variable expansion happens for all arguments before any
1638 .It Ic setenv Ar name
1639 .It Ic setenv Ar name value
1640 The first form lists all current environment variables.
1643 The last form sets the value of environment variable
1648 The second form sets
1651 The most commonly used environment variables
1656 are automatically imported to and exported from the
1663 there is no need to use
1668 .It Ic shift Ar variable
1671 are shifted to the left, discarding
1675 not to be set or to have less than one word as value.
1676 The second form performs the same function on the specified variable.
1678 .It Ic source Ar name
1679 .It Ic source Fl h Ar name
1680 The shell reads commands from
1683 commands may be nested; if they are nested too deeply the shell may
1684 run out of file descriptors.
1687 at any level terminates all nested
1690 Normally input during
1692 commands is not placed on the history list;
1693 the \-h option causes the commands to be placed on the
1694 history list without being executed.
1697 .It Ic stop % Ns Ar job ...
1698 Stops the current or specified jobs that are executing in the background.
1701 Causes the shell to stop in its tracks, much as if it had been sent a stop
1704 This is most often used to stop shells started by
1707 .It Ic switch Ar ( string )
1708 .It Ic case Ar str1 :
1710 .It Ic \ \ \ \ breaksw
1714 .It Ic \ \ \ \ breaksw
1716 Each case label is successively matched against the specified
1718 which is first command and filename expanded.
1719 The file metacharacters `*', `?' and `[...]'
1720 may be used in the case labels,
1721 which are variable expanded.
1722 If none of the labels match before the `default' label is found, then
1723 the execution begins after the default label.
1724 Each case label and the default label must appear at the beginning of a line.
1727 causes execution to continue after the
1729 Otherwise control may fall through case labels and the default label as in C.
1730 If no label matches and there is no default, execution continues after
1735 .It Ic time Ar command
1736 With no argument, a summary of time used by this shell and its children
1738 If arguments are given
1739 the specified simple command is timed and a time summary
1740 as described under the
1742 variable is printed.
1743 If necessary, an extra shell is created to print the time
1744 statistic when the command completes.
1747 .It Ic umask Ar value
1748 The file creation mask is displayed (first form) or set to the specified
1749 value (second form).
1750 The mask is given in octal.
1752 the mask are 002 giving all access to the group and read and execute
1753 access to others or 022 giving all access except write access for
1754 users in the group or others.
1756 .It Ic unalias Ar pattern
1757 All aliases whose names match the specified pattern are discarded.
1758 Thus all aliases are removed by `unalias *'.
1759 It is not an error for nothing to be
1763 Use of the internal hash table to speed location of executed programs
1767 .It Ic unlimit Ar resource
1769 .It Ic unlimit Fl h Ar resource
1770 Removes the limitation on
1774 is specified, then all
1776 limitations are removed.
1779 is given, the corresponding hard limits are removed.
1781 super-user may do this.
1783 .It Ic unset Ar pattern
1784 All variables whose names match the specified pattern are removed.
1785 Thus all variables are removed by `unset *'; this has noticeably
1786 distasteful side-effects.
1787 It is not an error for nothing to be
1790 .It Ic unsetenv Ar pattern
1791 Removes all variables whose name match the specified pattern from the
1799 Wait for all background jobs.
1800 If the shell is interactive, then an interrupt can disrupt the wait.
1801 After the interrupt, the shell prints names and job numbers of all jobs
1802 known to be outstanding.
1804 .It Ic which Ar command
1805 Displays the resolved command that will be executed by the shell.
1807 .It Ic while Ar ( expr )
1810 While the specified expression evaluates non-zero, the commands between
1819 may be used to terminate or continue the loop prematurely.
1824 must appear alone on their input lines.)
1825 Prompting occurs here the first time through the loop as for the
1827 statement if the input is a terminal.
1830 Brings the specified job into the foreground.
1832 .It Ic % Ns Ar job Ic \*[Am]
1833 Continues the specified job in the background.
1836 .It Ic @ Ar name Ns = expr
1837 .It Ic @ Ar name[index] Ns = expr
1838 The first form prints the values of all the shell variables.
1839 The second form sets the specified
1843 If the expression contains `\*[Lt]', `\*[Gt]', `\*[Am]' or `|' then at least
1844 this part of the expression must be placed within `(' `)'.
1845 The third form assigns the value of
1855 component must already exist.
1858 The operators `*=', `+=', etc are available as in C.
1859 The space separating the name from the assignment operator is optional.
1860 Spaces are, however, mandatory in separating components of
1862 which would otherwise be single words.
1864 Special postfix `+\|+' and `\-\|\-' operators increment and decrement
1866 respectively, i.e., `@ i++'.
1867 .Ss Pre-defined and environment variables
1868 The following variables have special meaning to the shell.
1878 are always set by the shell.
1883 this setting occurs only at initialization;
1884 these variables will not then be modified unless done
1885 explicitly by the user.
1887 The shell copies the environment variable
1898 and copies these back into the environment whenever the normal
1899 shell variables are reset.
1900 The environment variable
1902 is likewise handled; it is not
1903 necessary to worry about its setting other than in the file
1907 processes will import the definition of
1909 from the environment, and re-export it if you then change it.
1910 .Bl -tag -width histchars
1912 Set to the arguments to the shell, it is from this variable that
1913 positional parameters are substituted, i.e., `$1' is replaced by
1917 Gives a list of alternative directories searched to find subdirectories
1922 The full pathname of the current directory.
1926 command line option is given.
1927 Causes each command and its arguments
1928 to be echoed just before it is executed.
1929 For non-builtin commands all expansions occur before echoing.
1930 Builtin commands are echoed before command and filename substitution,
1931 since these substitutions are then done selectively.
1933 Enable file name completion.
1935 Can be given a string value to change the characters used in history
1937 The first character of its value is used as the
1938 history substitution character, replacing the default character `!'.
1939 The second character of its value replaces the character `^' in
1940 quick substitutions.
1942 Can be set to the pathname where history is going to be saved/restored.
1944 Can be given a numeric value to control the size of the history list.
1945 Any command that has been referenced in this many events will not be
1949 may run the shell out of memory.
1950 The last executed command is always saved on the history list.
1952 The home directory of the invoker, initialized from the environment.
1953 The filename expansion of
1955 refers to this variable.
1957 If set the shell ignores
1958 end-of-file from input devices which are terminals.
1959 This prevents shells from accidentally being killed by control-D's.
1961 The files where the shell checks for mail.
1962 This checking is done after each command completion that will
1964 if a specified interval has elapsed.
1965 The shell says `You have new mail.'
1966 if the file exists with an access time not greater than its modify time.
1968 If the first word of the value of
1970 is numeric it specifies a different mail checking interval, in seconds,
1971 than the default, which is 10 minutes.
1973 If multiple mail files are specified, then the shell says
1976 when there is mail in the file
1979 As described in the section on
1981 restrictions are placed on output redirection to ensure that
1982 files are not accidentally destroyed, and that `\*[Gt]\*[Gt]' redirections
1983 refer to existing files.
1985 If set, filename expansion is inhibited.
1986 This inhibition is most useful in shell scripts that
1987 are not dealing with filenames,
1988 or after a list of filenames has been obtained and further expansions
1991 If set, it is not an error for a filename expansion to not match any
1992 existing files; instead the primitive pattern is returned.
1993 It is still an error for the primitive pattern to be malformed, i.e.,
1995 still gives an error.
1997 If set, the shell notifies asynchronously of job completions;
1998 the default is to present job completions just before printing
2001 Each word of the path variable specifies a directory in which
2002 commands are to be sought for execution.
2003 A null word specifies the current directory.
2006 variable then only full path names will execute.
2007 The usual search path is `.', `/bin' and `/usr/bin', but this
2008 may vary from system to system.
2009 For the super-user the default search path is `/etc', `/bin' and `/usr/bin'.
2010 A shell that is given neither the
2014 option will normally hash the contents of the directories in the
2016 variable after reading
2021 If new commands are added to these directories
2022 while the shell is active, it may be necessary to do a
2024 or the commands may not be found.
2026 The string that is printed before each command is read from
2027 an interactive terminal input.
2028 If a `!' appears in the string it will be replaced by the current event number
2029 unless a preceding `\e' is given.
2030 Default is `% ', or `# ' for the super-user.
2032 Is given a numeric value to control the number of entries of the
2033 history list that are saved in ~/.history when the user logs out.
2034 Any command that has been referenced in this many events will be saved.
2035 During start up the shell sources ~/.history into the history list
2036 enabling history to be saved across logins.
2039 will slow down the shell during start up.
2042 is just set, the shell will use the value of
2045 The file in which the shell resides.
2046 This variable is used in forking shells to interpret files that have execute
2047 bits set, but which are not executable by the system.
2048 (See the description of
2049 .Sx Non-builtin Command Execution
2051 Initialized to the (system-dependent) home of the shell.
2053 The status returned by the last command.
2054 If it terminated abnormally, then 0200 is added to the status.
2055 Builtin commands that fail return exit status `1',
2056 all other builtin commands set status to `0'.
2058 Controls automatic timing of commands.
2059 This setting allows two parameters.
2060 The first specifies the CPU time threshold at which reporting should be done
2061 for a process, and the optional second specifies the output format.
2062 The following format strings are available:
2064 .Bl -tag -width Ds -compact -offset indent
2066 Number of involuntary context switches.
2068 Average unshared data size.
2070 Elapsed (wall\-clock) time.
2074 Filesystem blocks in.
2076 Average total data memory used.
2078 Number of signals received.
2080 Maximum Resident Set Size.
2082 Filesystem blocks out.
2084 Total percent time spent running.
2088 Socket messages received.
2090 Total system CPU time used.
2092 Socket messages sent.
2094 Total user CPU time used.
2098 Number of voluntary context switches (waits).
2100 Average shared text size.
2103 The default summary is "%Uu %Ss %E %P %X+%Dk %I+%Oio %Fpf+%Ww"
2107 command line option, causes the words of each command to be printed
2108 after history substitution.
2110 .Ss Non-builtin command execution
2111 When a command to be executed is found to not be a builtin command
2112 the shell attempts to execute the command via
2114 Each word in the variable
2116 names a directory from which the shell will attempt to execute the command.
2117 If it is given neither a
2121 option, the shell will hash the names in these directories into an internal
2122 table so that it will only try an
2124 in a directory if there is a possibility that the command resides there.
2125 This shortcut greatly speeds command location when many directories
2126 are present in the search path.
2127 If this mechanism has been turned off (via
2129 or if the shell was given a
2133 argument, and in any case for each directory component of
2135 that does not begin with a `/',
2136 the shell concatenates with the given command name to form a path name
2137 of a file which it then attempts to execute.
2139 Parenthesized commands are always executed in a subshell.
2142 .Dl (cd ; pwd) ; pwd
2146 directory; leaving you where you were (printing this after the home directory),
2154 Parenthesized commands are most often used to prevent
2156 from affecting the current shell.
2158 If the file has execute permissions but is not an
2159 executable binary to the system, then it is assumed to be a
2160 file containing shell commands and a new shell is spawned to read it.
2166 then the words of the alias will be prepended to the argument list to form
2168 The first word of the
2170 should be the full path name of the shell
2172 Note that this is a special, late occurring, case of
2175 and only allows words to be prepended to the argument list without change.
2177 The shell normally ignores
2180 Jobs running detached (either by
2186 commands) are immune to signals generated from the keyboard, including
2188 Other signals have the values which the shell inherited from its parent.
2189 The shell's handling of interrupts and terminate signals
2190 in shell scripts can be controlled by
2192 Login shells catch the
2194 signal; otherwise this signal is passed on to children from the state in the
2196 Interrupts are not allowed when a login shell is reading the file
2199 .Bl -tag -width /etc/passwd -compact
2201 Read at beginning of execution by each shell.
2203 Read by login shell, after `.cshrc' at login.
2205 Read by login shell, at logout.
2207 Standard shell, for shell scripts not starting with a `#'.
2209 Temporary file for `\*[Lt]\*[Lt]'.
2211 Source of home directories for `~name'.
2215 Words can be no longer than 1024 characters.
2216 The system limits argument lists to 10240 characters.
2217 The number of arguments to a command that involves filename expansion
2218 is limited to 1/6'th the number of characters allowed in an argument list.
2219 Command substitutions may substitute no more characters than are
2220 allowed in an argument list.
2221 To detect looping, the shell restricts the number of
2223 substitutions on a single line to 20.
2240 .%T "An introduction to the C shell"
2246 It was a first implementation of a command language interpreter
2247 incorporating a history mechanism (see
2248 .Sx History Substitutions ) ,
2249 job control facilities (see
2251 interactive file name
2252 and user name completion (see
2253 .Sx File Name Completion ) ,
2254 and a C-like syntax.
2255 There are now many shells that also have these mechanisms, plus
2256 a few more (and maybe some bugs too), which are available through the
2260 Job control and directory stack features first implemented by J.E. Kulp of
2261 IIASA, Laxenburg, Austria,
2262 with different syntax than that used now.
2263 File name completion code written by Ken Greer, HP Labs.
2264 Eight-bit implementation Christos S. Zoulas, Cornell University.
2266 When a command is restarted from a stop,
2267 the shell prints the directory it started in if this is different
2268 from the current directory; this can be misleading (i.e., wrong)
2269 as the job may have changed directories internally.
2271 Shell builtin functions are not stoppable/restartable.
2272 Command sequences of the form `a ; b ; c' are also not handled gracefully
2273 when stopping is attempted.
2274 If you suspend `b', the shell will immediately execute `c'.
2275 This is especially noticeable if this expansion results from an
2277 It suffices to place the sequence of commands in ()'s to force it to
2278 a subshell, i.e., `( a ; b ; c )'.
2280 Control over tty output after processes are started is primitive;
2281 perhaps this will inspire someone to work on a good virtual
2283 In a virtual terminal interface much more
2284 interesting things could be done with output control.
2286 Alias substitution is most often used to clumsily simulate shell procedures;
2287 shell procedures should be provided instead of aliases.
2289 Commands within loops, prompted for by `?', are not placed on the
2292 Control structure should be parsed instead of being recognized as built-in
2294 This would allow control commands to be placed anywhere,
2295 to be combined with `\&|', and to be used with `\*[Am]' and `;' metasyntax.
2297 It should be possible to use the `:' modifiers on the output of command
2302 facility is implemented is ugly and expensive.