[0m


CSH(1)		    UNIX Programmer's Manual		   CSH(1)



[1mNAME
     [0mcsh - a shell (command interpreter) with C-like syntax

[1mSYNOPSIS
     csh [0m[ [1m-cefinstvVxX [0m] [ arg ...  ]

[1mDESCRIPTION
     [0m_C_s_h is a first implementation of a command language inter-
     preter incorporating a history mechanism (see [1mHistory Sub-
     stitutions[0m), job control facilities (see [1mJobs[0m), interactive
     file name and user name completion (see [1mFile Name Comple-
     tion[0m), and a C-like syntax.  So as to be able to use its job
     control facilities, users of _c_s_h must (and automatically)
     use the new tty driver fully described in _t_t_y(4).	This new
     tty driver allows generation of interrupt characters from
     the keyboard to tell jobs to stop.  See _s_t_t_y(1) for details
     on setting options in the new tty driver.

     An instance of _c_s_h begins by executing commands from the
     file `.cshrc' in the _h_o_m_e directory of the invoker.  If this
     is a login shell then it also executes commands from the
     file `.login' there.  It is typical for users on crt's to
     put the command ``stty crt'' in their ._l_o_g_i_n file, and to
     also invoke _t_s_e_t(1) there.

     In the normal case, the shell will then begin reading com-
     mands from the terminal, prompting with `% '.  Processing of
     arguments and the use of the shell to process files contain-
     ing command scripts will be described later.

     The shell then repeatedly performs the following actions: a
     line of command input is read and broken into _w_o_r_d_s.  This
     sequence of words is placed on the command history list and
     then parsed.  Finally each command in the current line is
     executed.

     When a login shell terminates it executes commands from the
     file `.logout' in the users home directory.

     [1mLexical structure

     [0mThe shell splits input lines into words at blanks and tabs
     with the following exceptions.  The characters `&' `|' `;'
     `<' `>' `(' `)' form separate words.  If doubled in `&&',
     `||', `<<' or `>>' these pairs form single words.	These
     parser metacharacters may be made part of other words, or
     prevented their special meaning, by preceding them with `\'.
     A newline preceded by a `\' is equivalent to a blank.

     In addition strings enclosed in matched pairs of quotations,
     `'', ``' or `"', form parts of a word; metacharacters in
     these strings, including blanks and tabs, do not form



Printed 2/12/91     Revision 1.4 of 11/11/89			1






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



     separate words.  These quotations have semantics to be
     described subsequently.  Within pairs of `'' or `"' charac-
     ters a newline preceded by a `\' gives a true newline char-
     acter.

     When the shell's input is not a terminal, the character `#'
     introduces a comment which continues to the end of the input
     line.  It is prevented this special meaning when preceded by
     `\' and in quotations using ``', `'', and `"'.

     [1mCommands

     [0mA simple command is a sequence of words, the first of which
     specifies the command to be executed.  A simple command or a
     sequence of simple commands separated by `|' characters
     forms a pipeline.	The output of each command in a pipeline
     is connected to the input of the next.  Sequences of pipe-
     lines may be separated by `;', and are then executed sequen-
     tially.  A sequence of pipelines may be executed without
     immediately waiting for it to terminate by following it with
     an `&'.

     Any of the above may be placed in `(' `)' to form a simple
     command (which may be a component of a pipeline, etc.) It is
     also possible to separate pipelines with `||' or `&&' indi-
     cating, as in the C language, that the second is to be exe-
     cuted only if the first fails or succeeds respectively. (See
     _E_x_p_r_e_s_s_i_o_n_s.)

     [1mJobs

     [0mThe shell associates a _j_o_b with each pipeline.  It keeps a
     table of current jobs, printed by the _j_o_b_s command, and
     assigns them small integer numbers.  When a job is started
     asynchronously with `&', the shell prints a line which looks
     like:

	  [1] 1234

     indicating that the job which was started asynchronously was
     job number 1 and had one (top-level) process, whose process
     id was 1234.

     If you are running a job and wish to do something else you
     may hit the key [1m^Z [0m(control-Z) which sends a STOP signal to
     the current job.  The shell will then normally indicate that
     the job has been `Stopped', and print another prompt.  You
     can then manipulate the state of this job, putting it in the
     background with the _b_g command, or run some other commands
     and then eventually bring the job back into the foreground
     with the foreground command _f_g.  A [1m^Z [0mtakes effect immedi-
     ately and is like an interrupt in that pending output and



Printed 2/12/91     Revision 1.4 of 11/11/89			2






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



     unread input are discarded when it is typed.  There is
     another special key [1m^Y [0mwhich does not generate a STOP signal
     until a program attempts to _r_e_a_d(2) it.  This can usefully
     be typed ahead when you have prepared some commands for a
     job which you wish to stop after it has read them.

     A job being run in the background will stop if it tries to
     read from the terminal.  Background jobs are normally
     allowed to produce output, but this can be disabled by giv-
     ing the command ``stty tostop''.  If you set this tty
     option, then background jobs will stop when they try to pro-
     duce output like they do when they try to read input.

     There are several ways to refer to jobs in the shell.  The
     character `%' introduces a job name.  If you wish to refer
     to job number 1, you can name it as `%1'.	Just naming a job
     brings it to the foreground; thus `%1' is a synonym for `fg
     %1', bringing job 1 back into the foreground.  Similarly
     saying `%1 &' resumes job 1 in the background.  Jobs can
     also be named by prefixes of the string typed in to start
     them, if these prefixes are unambiguous, thus `%ex' would
     normally restart a suspended _e_x(1) job, if there were only
     one suspended job whose name began with the string `ex'.  It
     is also possible to say `%?string' which specifies a job
     whose text contains _s_t_r_i_n_g, if there is only one such job.

     The shell maintains a notion of the current and previous
     jobs.  In output pertaining to jobs, the current job is
     marked with a `+' and the previous job with a `-'.  The
     abbreviation `%+' refers to the current job and `%-' refers
     to the previous job.  For close analogy with the syntax of
     the _h_i_s_t_o_r_y mechanism (described below), `%%' is also a
     synonym for the current job.

     [1mStatus reporting

     [0mThis shell learns immediately whenever a process changes
     state.  It normally informs you whenever a job becomes
     blocked so that no further progress is possible, but only
     just before it prints a prompt.  This is done so that it
     does not otherwise disturb your work.  If, however, you set
     the shell variable _n_o_t_i_f_y, the shell will notify you immedi-
     ately of changes of status in background jobs.  There is
     also a shell command _n_o_t_i_f_y which marks a single process so
     that its status changes will be immediately reported.  By
     default _n_o_t_i_f_y marks the current process; simply say
     `notify' after starting a background job to mark it.

     When you try to leave the shell while jobs are stopped, you
     will be warned that `You have stopped jobs.'  You may use
     the _j_o_b_s command to see what they are.  If you do this or
     immediately try to exit again, the shell will not warn you a



Printed 2/12/91     Revision 1.4 of 11/11/89			3






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



     second time, and the suspended jobs will be terminated.

     [1mFile Name Completion

     [0mWhen the file name completion feature is enabled by setting
     the shell variable _f_i_l_e_c (see [1mset[0m), _c_s_h will interactively
     complete file names and user names from unique prefixes,
     when they are input from the terminal followed by the escape
     character (the escape key, or control-[).	For example, if
     the current directory looks like
	       DSC.OLD	 bin	   cmd	     lib       xmpl.c
	       DSC.NEW	 chaosnet  cmtest    mail      xmpl.o
	       bench	 class	   dev	     mbox      xmpl.out
     and the input is
	       % vi ch<escape>
     _c_s_h will complete the prefix ``ch'' to the only matching
     file name ``chaosnet'', changing the input line to
	       % vi chaosnet
     However, given
	       % vi D<escape>
     _c_s_h will only expand the input to
	       % vi DSC.
     and will sound the terminal bell to indicate that the expan-
     sion is incomplete, since there are two file names matching
     the prefix ``D''.

     If a partial file name is followed by the end-of-file char-
     acter (usually control-D), then, instead of completing the
     name, _c_s_h will list all file names matching the prefix.  For
     example, the input
	       % vi D<control-D>
     causes all files beginning with ``D'' to be listed:
	       DSC.NEW	 DSC.OLD
     while the input line remains unchanged.

     The same system of escape and end-of-file can also be used
     to expand partial user names, if the word to be completed
     (or listed) begins with the character ``~''.  For example,
     typing
	       cd ~ro<control-D>
     may produce the expansion
	       cd ~root

     The use of the terminal bell to signal errors or multiple
     matches can be inhibited by setting the variable _n_o_b_e_e_p.

     Normally, all files in the particular directory are candi-
     dates for name completion.  Files with certain suffixes can
     be excluded from consideration by setting the variable _f_i_g_-
     _n_o_r_e to the list of suffixes to be ignored.  Thus, if _f_i_g_-
     _n_o_r_e is set by the command
	       % set fignore = (.o .out)



Printed 2/12/91     Revision 1.4 of 11/11/89			4






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



     then typing
	       % vi x<escape>
     would result in the completion to
	       % vi xmpl.c
     ignoring the files "xmpl.o" and "xmpl.out".  However, if the
     only completion possible requires not ignoring these suf-
     fixes, then they are not ignored.	In addition, _f_i_g_n_o_r_e does
     not affect the listing of file names by control-D.  All
     files are listed regardless of their suffixes.

     [1mSubstitutions

     [0mWe now describe the various transformations the shell per-
     forms on the input in the order in which they occur.

     [1mHistory substitutions

     [0mHistory substitutions place words from previous command
     input as portions of new commands, making it easy to repeat
     commands, repeat arguments of a previous command in the
     current command, or fix spelling mistakes in the previous
     command with little typing and a high degree of confidence.
     History substitutions begin with the character `!' and may
     begin [1manywhere [0min the input stream (with the proviso that
     they [1mdo not [0mnest.) This `!' may be preceded by an `\' to
     prevent its special meaning; for convenience, a `!' is
     passed unchanged when it is followed by a blank, tab, new-
     line, `=', '~' or `('.  (History substitutions also occur
     when an input line begins with `^', `!"', `!~' or `!(". The
     latter 3 forms are for convenience when they could not be
     valid expressions, the `^' is a special abbreviation which
     will be described later.) Any input line which contains his-
     tory substitution is echoed on the terminal before it is
     executed as it could have been typed without history substi-
     tution.

     Commands input from the terminal which consist of one or
     more words are saved on the history list.	The history sub-
     stitutions reintroduce sequences of words from these saved
     commands into the input stream.  The size of which is con-
     trolled by the _h_i_s_t_o_r_y variable; the previous command is
     always retained, regardless of its value.	Commands are num-
     bered sequentially from 1.

     For definiteness, consider the following output from the
     _h_i_s_t_o_r_y command:

	   9  write michael
	  10  ex write.c
	  11  cat oldwrite.c
	  12  diff *write.c




Printed 2/12/91     Revision 1.4 of 11/11/89			5






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



     The commands are shown with their event numbers.  It is not
     usually necessary to use event numbers, but the current
     event number can be made part of the _p_r_o_m_p_t by placing an
     `!' in the prompt string.

     With the current event 13 we can refer to previous events by
     event number `!11', relatively as in `!-2' (referring to the
     same event), by a prefix of a command word as in `!d' for
     event 12 or `!wri' for event 9, or by a string contained in
     a word in the command as in `!?mic?' also referring to event
     9.  These forms, without further modification, simply rein-
     troduce the words of the specified events, each separated by
     a single blank.  As a special case `!!' refers to the previ-
     ous command; thus `!!' alone is essentially a _r_e_d_o.

     To select words from an event we can follow the event
     specification by a `:' and a designator for the desired
     words.  The words of an input line are numbered from 0, the
     first (usually command) word being 0, the second word (first
     argument) being 1, etc.  The basic word designators are:

	  0    first (command) word
	  _n    _n'th argument
	  ^    first argument,	i.e. `1'
	  $    last argument
	  %    word matched by (immediately preceding) ?_s? search
	  _x-_y  range of words
	  -_y   abbreviates `0-_y'
	  *    abbreviates `^-$', or nothing if only 1 word in event
	  _x*   abbreviates `_x-$'
	  _x-   like `_x*' but omitting word `$'

     The `:' separating the event specification from the word
     designator can be omitted if the argument selector begins
     with a `^', `$', `*' `-' or `%'.  After the optional word
     designator can be placed a sequence of modifiers, each pre-
     ceded by a `:'.  The following modifiers are defined:

	  h	 Remove a trailing pathname component, leaving the head.
	  r	 Remove a trailing `.xxx' component, leaving the root name.
	  e	 Remove all but the extension `.xxx' part.
	  s/_l/_r/ Substitute _l for _r
	  t	 Remove all leading pathname components, leaving the tail.
	  &	 Repeat the previous substitution.
	  g	 Apply the change globally, prefixing the above, e.g. `g&'.
	  p	 Print the new command but do not execute it.
	  q	 Quote the substituted words, preventing further substitutions.
	  x	 Like q, but break into words at blanks, tabs and newlines.

     Unless preceded by a `g' the modification is applied only to
     the first modifiable word.  With substitutions, it is an
     error for no word to be applicable.



Printed 2/12/91     Revision 1.4 of 11/11/89			6






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



     The left hand side of substitutions are not regular expres-
     sions in the sense of the editors, but rather strings.  Any
     character may be used as the delimiter in place of `/'; a
     `\' quotes the delimiter into the _l and _r strings.  The
     character `&' in the right hand side is replaced by the text
     from the left.  A `\' quotes `&' also.  A null _l uses the
     previous string either from a _l or from a contextual scan
     string _s in `!?_s?'.  The trailing delimiter in the substitu-
     tion may be omitted if a newline follows immediately as may
     the trailing `?' in a contextual scan.

     A history reference may be given without an event specifica-
     tion, e.g. `!$'.  In this case the reference is to the pre-
     vious command unless a previous history reference occurred
     on the same line in which case this form repeats the previ-
     ous reference.  Thus `!?foo?^ !$' gives the first and last
     arguments from the command matching `?foo?'.

     A special abbreviation of a history reference occurs when
     the first non-blank character of an input line is a `^'.
     This is equivalent to `!:s^' providing a convenient short-
     hand for substitutions on the text of the previous line.
     Thus `^lb^lib' fixes the spelling of `lib' in the previous
     command.  Finally, a history substitution may be surrounded
     with `{' and `}' if necessary to insulate it from the char-
     acters which follow.  Thus, after `ls -ld ~paul' we might do
     `!{l}a' to do `ls -ld ~paula', while `!la' would look for a
     command starting `la'.

     [1mQuotations with ' and "

     [0mThe quotation of strings by `'' and `"' can be used to
     prevent all or some of the remaining substitutions.  Strings
     enclosed in `'' are prevented any further interpretation.
     Strings enclosed in `"' may be expanded as described below.

     In both cases the resulting text becomes (all or part of) a
     single word; only in one special case (see _C_o_m_m_a_n_d _S_u_b_s_t_i_t_i_-
     _t_i_o_n below) does a `"' quoted string yield parts of more
     than one word; `'' quoted strings never do.

     [1mAlias substitution

     [0mThe shell maintains a list of aliases which can be esta-
     blished, displayed and modified by the _a_l_i_a_s and _u_n_a_l_i_a_s
     commands.	After a command line is scanned, it is parsed
     into distinct commands and the first word of each command,
     left-to-right, is checked to see if it has an alias.  If it
     does, then the text which is the alias for that command is
     reread with the history mechanism available as though that
     command were the previous input line.  The resulting words
     replace the command and argument list.  If no reference is



Printed 2/12/91     Revision 1.4 of 11/11/89			7






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



     made to the history list, then the argument list is left
     unchanged.

     Thus if the alias for `ls' is `ls -l' the command `ls /usr'
     would map to `ls -l /usr', the argument list here being
     undisturbed.  Similarly if the alias for `lookup' was `grep
     !^ /etc/passwd' then `lookup bill' would map to `grep bill
     /etc/passwd'.

     If an alias is found, the word transformation of the input
     text is performed and the aliasing process begins again on
     the reformed input line.  Looping is prevented if the first
     word of the new text is the same as the old by flagging it
     to prevent further aliasing.  Other loops are detected and
     cause an error.

     Note that the mechanism allows aliases to introduce parser
     metasyntax.  Thus we can `alias print 'pr \!* | lpr'' to
     make a command which _p_r'_s its arguments to the line printer.

     [1mVariable substitution

     [0mThe shell maintains a set of variables, each of which has as
     value a list of zero or more words.  Some of these variables
     are set by the shell or referred to by it.  For instance,
     the _a_r_g_v variable is an image of the shell's argument list,
     and words of this variable's value are referred to in spe-
     cial ways.

     The values of variables may be displayed and changed by
     using the _s_e_t and _u_n_s_e_t commands.	Of the variables referred
     to by the shell a number are toggles; the shell does not
     care what their value is, only whether they are set or not.
     For instance, the _v_e_r_b_o_s_e variable is a toggle which causes
     command input to be echoed.  The setting of this variable
     results from the [1m-v [0mcommand line option.

     Other operations treat variables numerically.  The `@' com-
     mand permits numeric calculations to be performed and the
     result assigned to a variable.  Variable values are, how-
     ever, always represented as (zero or more) strings.  For the
     purposes of numeric operations, the null string is con-
     sidered to be zero, and the second and subsequent words of
     multiword values are ignored.

     After the input line is aliased and parsed, and before each
     command is executed, variable substitution is performed
     keyed by `$' characters.  This expansion can be prevented by
     preceding the `$' with a `\' except within `"'s where it
     [1malways [0moccurs, and within `''s where it [1mnever [0moccurs.
     Strings quoted by ``' are interpreted later (see _C_o_m_m_a_n_d
     _s_u_b_s_t_i_t_u_t_i_o_n below) so `$' substitution does not occur there



Printed 2/12/91     Revision 1.4 of 11/11/89			8






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



     until later, if at all.  A `$' is passed unchanged if fol-
     lowed by a blank, tab, or end-of-line.

     Input/output redirections are recognized before variable
     expansion, and are variable expanded separately.  Otherwise,
     the command name and entire argument list are expanded
     together.	It is thus possible for the first (command) word
     to this point to generate more than one word, the first of
     which becomes the command name, and the rest of which become
     arguments.

     Unless enclosed in `"' or given the `:q' modifier the
     results of variable substitution may eventually be command
     and filename substituted.	Within `"', a variable whose
     value consists of multiple words expands to a (portion of) a
     single word, with the words of the variables value separated
     by blanks.  When the `:q' modifier is applied to a substitu-
     tion the variable will expand to multiple words with each
     word separated by a blank and quoted to prevent later com-
     mand or filename substitution.

     The following metasequences are provided for introducing
     variable values into the shell input.  Except as noted, it
     is an error to reference a variable which is not set.

     $name
     ${name}
	  Are replaced by the words of the value of variable
	  _n_a_m_e, each separated by a blank.  Braces insulate _n_a_m_e
	  from following characters which would otherwise be part
	  of it.  Shell variables have names consisting of up to
	  20 letters and digits starting with a letter.  The
	  underscore character is considered a letter.
	  If _n_a_m_e is not a shell variable, but is set in the
	  environment, then that value is returned (but [1m: [0mmodif-
	  iers and the other forms given below are not available
	  in this case).

     $name[selector]
     ${name[selector]}
	  May be used to select only some of the words from the
	  value of _n_a_m_e. The selector is subjected to `$' substi-
	  tution and may consist of a single number or two
	  numbers separated by a `-'.  The first word of a vari-
	  ables value is numbered `1'.	If the first number of a
	  range is omitted it defaults to `1'.	If the last
	  member of a range is omitted it defaults to `$#name'.
	  The selector `*' selects all words.  It is not an error
	  for a range to be empty if the second argument is omit-
	  ted or in range.





Printed 2/12/91     Revision 1.4 of 11/11/89			9






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



     $#name
     ${#name}
	  Gives the number of words in the variable.  This is
	  useful for later use in a `[selector]'.

     $0
	  Substitutes the name of the file from which command
	  input is being read.	An error occurs if the name is
	  not known.

     $number
     ${number}
	  Equivalent to `$argv[number]'.

     $*
	  Equivalent to `$argv[*]'.

     The modifiers `:h', `:t', `:r', `:q' and `:x' may be applied
     to the substitutions above as may `:gh', `:gt' and `:gr'.
     If braces `{' '}' appear in the command form then the modif-
     iers must appear within the braces.  [1mThe current implementa-
     tion allows only one `:' modifier on each `$' expansion.

     [0mThe following substitutions may not be modified with `:'
     modifiers.

     $?name
     ${?name}
	  Substitutes the string `1' if name is set, `0' if it is
	  not.

     $?0
	  Substitutes `1' if the current input filename is known,
	  `0' if it is not.

     $$
	  Substitute the (decimal) process number of the (parent)
	  shell.

     $<
	  Substitutes a line from the standard input, with no
	  further interpretation thereafter.  It can be used to
	  read from the keyboard in a shell script.

     [1mCommand and filename substitution

     [0mThe remaining substitutions, command and filename substitu-
     tion, are applied selectively to the arguments of builtin
     commands.	This means that portions of expressions which are
     not evaluated are not subjected to these expansions.  For
     commands which are not internal to the shell, the command
     name is substituted separately from the argument list.  This



Printed 2/12/91     Revision 1.4 of 11/11/89		       10






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



     occurs very late, after input-output redirection is per-
     formed, and in a child of the main shell.

     [1mCommand substitution

     [0mCommand substitution is indicated by a command enclosed in
     ``'.  The output from such a command is normally broken into
     separate words at blanks, tabs and newlines, with null words
     being discarded, this text then replacing the original
     string.  Within `"'s, only newlines force new words; blanks
     and tabs are preserved.

     In any case, the single final newline does not force a new
     word.  Note that it is thus possible for a command substitu-
     tion to yield only part of a word, even if the command out-
     puts a complete line.

     [1mFilename substitution

     [0mIf a word contains any of the characters `*', `?', `[' or
     `{' or begins with the character `~', then that word is a
     candidate for filename substitution, also known as `glob-
     bing'.  This word is then regarded as a pattern, and
     replaced with an alphabetically sorted list of file names
     which match the pattern.  In a list of words specifying
     filename substitution it is an error for no pattern to match
     an existing file name, but it is not required for each pat-
     tern to match.  Only the metacharacters `*', `?' and `['
     imply pattern matching, the characters `~' and `{' being
     more akin to abbreviations.

     In matching filenames, the character `.' at the beginning of
     a filename or immediately following a `/', as well as the
     character `/' must be matched explicitly.	The character `*'
     matches any string of characters, including the null string.
     The character `?' matches any single character.  The
     sequence `[...]' matches any one of the characters enclosed.
     Within `[...]', a pair of characters separated by `-'
     matches any character lexically between the two.

     The character `~' at the beginning of a filename is used to
     refer to home directories.  Standing alone, i.e. `~' it
     expands to the invokers home directory as reflected in the
     value of the variable _h_o_m_e. When followed by a name consist-
     ing of letters, digits and `-' characters the shell searches
     for a user with that name and substitutes their home direc-
     tory;  thus `~ken' might expand to `/usr/ken' and
     `~ken/chmach' to `/usr/ken/chmach'.  If the character `~' is
     followed by a character other than a letter or `/' or
     appears not at the beginning of a word, it is left undis-
     turbed.




Printed 2/12/91     Revision 1.4 of 11/11/89		       11






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



     The metanotation `a{b,c,d}e' is a shorthand for `abe ace
     ade'.  Left to right order is preserved, with results of
     matches being sorted separately at a low level to preserve
     this order.  This construct may be nested.  Thus
     `~source/s1/{oldls,ls}.c' expands to `/usr/source/s1/oldls.c
     /usr/source/s1/ls.c' whether or not these files exist
     without any chance of error if the home directory for
     `source' is `/usr/source'.  Similarly `../{memo,*box}' might
     expand to `../memo ../box ../mbox'.  (Note that `memo' was
     not sorted with the results of matching `*box'.) As a spe-
     cial case `{', `}' and `{}' are passed undisturbed.

     [1mInput/output

     [0mThe standard input and standard output of a command may be
     redirected with the following syntax:

     < name
	  Open file _n_a_m_e (which is first variable, command and
	  filename expanded) as the standard input.

     << word
	  Read the shell input up to a line which is identical to
	  _w_o_r_d. _W_o_r_d is not subjected to variable, filename or
	  command substitution, and each input line is compared
	  to _w_o_r_d before any substitutions are done on this input
	  line.  Unless a quoting `\', `"', `'' or ``' appears in
	  _w_o_r_d variable and command substitution is performed on
	  the intervening lines, allowing `\' to quote `$', `\'
	  and ``'.  Commands which are substituted have all
	  blanks, tabs, and newlines preserved, except for the
	  final newline which is dropped.  The resultant text is
	  placed in an anonymous temporary file which is given to
	  the command as standard input.

     > name
     >! name
     >& name
     >&! name
	  The file _n_a_m_e is used as standard output.  If the file
	  does not exist then it is created; if the file exists,
	  its is truncated, its previous contents being lost.

	  If the variable _n_o_c_l_o_b_b_e_r is set, then the file must
	  not exist or be a character special file (e.g. a termi-
	  nal or `/dev/null') or an error results.  This helps
	  prevent accidental destruction of files.  In this case
	  the `!' forms can be used and suppress this check.

	  The forms involving `&' route the diagnostic output
	  into the specified file as well as the standard output.
	  _N_a_m_e is expanded in the same way as `<' input filenames



Printed 2/12/91     Revision 1.4 of 11/11/89		       12






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



	  are.

     >> name
     >>& name
     >>! name
     >>&! name
	  Uses file _n_a_m_e as standard output like `>' but places
	  output at the end of the file.  If the variable
	  _n_o_c_l_o_b_b_e_r is set, then it is an error for the file not
	  to exist unless one of the `!' forms is given.  Other-
	  wise similar to `>'.

     A command receives the environment in which the shell was
     invoked as modified by the input-output parameters and the
     presence of the command in a pipeline.  Thus, unlike some
     previous shells, commands run from a file of shell commands
     have no access to the text of the commands by default;
     rather they receive the original standard input of the
     shell.  The `<<' mechanism should be used to present inline
     data.  This permits shell command scripts to function as
     components of pipelines and allows the shell to block read
     its input.  Note that the default standard input for a com-
     mand run detached is [1mnot [0mmodified to be the empty file
     `/dev/null'; rather the standard input remains as the origi-
     nal standard input of the shell.  If this is a terminal and
     if the process attempts to read from the terminal, then the
     process will block and the user will be notified (see [1mJobs
     [0mabove).

     Diagnostic output may be directed through a pipe with the
     standard output.  Simply use the form `|&' rather than just
     `|'.

     [1mExpressions

     [0mA number of the builtin commands (to be described subse-
     quently) take expressions, in which the operators are simi-
     lar to those of C, with the same precedence.  These expres-
     sions appear in the @, _e_x_i_t, _i_f, and _w_h_i_l_e commands.  The
     following operators are available:

	  ||  &&  |  ^	&  ==  !=  =~  !~  <=  >=  <  >  <<  >>
     +	-  *  /  %  !  ~  (  )

     Here the precedence increases to the right, `==' `!=' `=~'
     and `!~', `<=' `>=' `<' and `>', `<<' and `>>', `+' and `-',
     `*' `/' and `%' being, in groups, at the same level.  The
     `==' `!=' `=~' and `!~' operators compare their arguments as
     strings; all others operate on numbers.  The operators `=~'
     and `!~' are like `!=' and `==' except that the right hand
     side is a _p_a_t_t_e_r_n (containing, e.g. `*'s, `?'s and instances
     of `[...]') against which the left hand operand is matched.



Printed 2/12/91     Revision 1.4 of 11/11/89		       13






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



     This reduces the need for use of the _s_w_i_t_c_h statement in
     shell scripts when all that is really needed is pattern
     matching.

     Strings which begin with `0' are considered octal numbers.
     Null or missing arguments are considered `0'.  The result of
     all expressions are strings, which represent decimal
     numbers.  It is important to note that no two components of
     an expression can appear in the same word; except when adja-
     cent to components of expressions which are syntactically
     significant to the parser (`&' `|' `<' `>' `(' `)') they
     should be surrounded by spaces.

     Also available in expressions as primitive operands are com-
     mand executions enclosed in `{' and `}' and file enquiries
     of the form `-_l  name' where _l is one of:

	  r    read access
	  w    write access
	  x    execute access
	  e    existence
	  o    ownership
	  z    zero size
	  f    plain file
	  d    directory

     The specified name is command and filename expanded and then
     tested to see if it has the specified relationship to the
     real user.  If the file does not exist or is inaccessible
     then all enquiries return false, i.e. `0'.  Command execu-
     tions succeed, returning true, i.e. `1', if the command
     exits with status 0, otherwise they fail, returning false,
     i.e. `0'.	If more detailed status information is required
     then the command should be executed outside of an expression
     and the variable _s_t_a_t_u_s examined.

     [1mControl flow

     [0mThe shell contains a number of commands which can be used to
     regulate the flow of control in command files (shell
     scripts) and (in limited but useful ways) from terminal
     input.  These commands all operate by forcing the shell to
     reread or skip in its input and, due to the implementation,
     restrict the placement of some of the commands.

     The _f_o_r_e_a_c_h, _s_w_i_t_c_h, and _w_h_i_l_e statements, as well as the
     _i_f-_t_h_e_n-_e_l_s_e form of the _i_f statement require that the major
     keywords appear in a single simple command on an input line
     as shown below.

     If the shell's input is not seekable, the shell buffers up
     input whenever a loop is being read and performs seeks in



Printed 2/12/91     Revision 1.4 of 11/11/89		       14






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



     this internal buffer to accomplish the rereading implied by
     the loop.	(To the extent that this allows, backward goto's
     will succeed on non-seekable inputs.)

     [1mBuiltin commands

     [0mBuiltin commands are executed within the shell.  If a buil-
     tin command occurs as any component of a pipeline except the
     last then it is executed in a subshell.

     [1malias
     alias [0mname
     [1malias [0mname wordlist
	  The first form prints all aliases.  The second form
	  prints the alias for name.  The final form assigns the
	  specified _w_o_r_d_l_i_s_t as the alias of _n_a_m_e; _w_o_r_d_l_i_s_t is
	  command and filename substituted.  _N_a_m_e is not allowed
	  to be _a_l_i_a_s or _u_n_a_l_i_a_s.

     [1malloc
	  [0mShows the amount of dynamic memory acquired, broken
	  down into used and free memory.  With an argument shows
	  the number of free and used blocks in each size
	  category.  The categories start at size 8 and double at
	  each step.  This commands output varies across system
	  types.

     [1mbg
     bg %[0mjob ...
	  Puts the current or specified jobs into the background,
	  continuing them if they were stopped.

     [1mbreak
	  [0mCauses execution to resume after the _e_n_d of the nearest
	  enclosing _f_o_r_e_a_c_h or _w_h_i_l_e. The remaining commands on
	  the current line are executed.  Multi-level breaks are
	  thus possible by writing them all on one line.

     [1mbreaksw
	  [0mCauses a break from a _s_w_i_t_c_h, resuming after the _e_n_d_s_w.

     [1mcase [0mlabel:
	  A label in a _s_w_i_t_c_h statement as discussed below.

     [1mcd
     cd [0mname
     [1mchdir
     chdir [0mname
	  Change the shell's working directory to directory _n_a_m_e.
	  If no argument is given then change to the home direc-
	  tory of the user.
	  If _n_a_m_e is not found as a subdirectory of the current



Printed 2/12/91     Revision 1.4 of 11/11/89		       15






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



	  directory (and does not begin with `/', `./' or `../'),
	  then each component of the variable _c_d_p_a_t_h is checked
	  to see if it has a subdirectory _n_a_m_e. Finally, if all
	  else fails but _n_a_m_e is a shell variable whose value
	  begins with `/', then this is tried to see if it is a
	  directory.

     [1mcontinue
	  [0mContinue execution of the nearest enclosing _w_h_i_l_e or
	  _f_o_r_e_a_c_h. The rest of the commands on the current line
	  are executed.

     [1mdefault:
	  [0mLabels the default case in a _s_w_i_t_c_h statement.  The
	  default should come after all _c_a_s_e labels.

     [1mdirs
	  [0mPrints the directory stack; the top of the stack is at
	  the left, the first directory in the stack being the
	  current directory.

     [1mecho [0mwordlist
     [1mecho -n [0mwordlist
	  The specified words are written to the shells standard
	  output, separated by spaces, and terminated with a new-
	  line unless the [1m-n [0moption is specified.

     [1melse
     end
     endif
     endsw
	  [0mSee the description of the _f_o_r_e_a_c_h, _i_f, _s_w_i_t_c_h, and
	  _w_h_i_l_e statements below.

     [1meval [0marg ...
	  (As in _s_h(1).) The arguments are read as input to the
	  shell and the resulting command(s) executed in the con-
	  text of the current shell.  This is usually used to
	  execute commands generated as the result of command or
	  variable substitution, since parsing occurs before
	  these substitutions.	See _t_s_e_t(1) for an example of
	  using _e_v_a_l.

     [1mexec [0mcommand
	  The specified command is executed in place of the
	  current shell.

     [1mexit
     exit[0m(expr)
	  The shell exits either with the value of the _s_t_a_t_u_s
	  variable (first form) or with the value of the speci-
	  fied _e_x_p_r (second form).



Printed 2/12/91     Revision 1.4 of 11/11/89		       16






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



     [1mfg
     fg %[0mjob ...
	  Brings the current or specified jobs into the fore-
	  ground, continuing them if they were stopped.

     [1mforeach [0mname (wordlist)
	 ...
     [1mend
	  [0mThe variable _n_a_m_e is successively set to each member of
	  _w_o_r_d_l_i_s_t and the sequence of commands between this com-
	  mand and the matching _e_n_d are executed.  (Both _f_o_r_e_a_c_h
	  and _e_n_d must appear alone on separate lines.)

	  The builtin command _c_o_n_t_i_n_u_e may be used to continue
	  the loop prematurely and the builtin command _b_r_e_a_k to
	  terminate it prematurely.  When this command is read
	  from the terminal, the loop is read up once prompting
	  with `?' before any statements in the loop are exe-
	  cuted.  If you make a mistake typing in a loop at the
	  terminal you can rub it out.

     [1mglob [0mwordlist
	  Like _e_c_h_o but no `\' escapes are recognized and words
	  are delimited by null characters in the output.  Useful
	  for programs which wish to use the shell to filename
	  expand a list of words.

     [1mgoto [0mword
	  The specified _w_o_r_d is filename and command expanded to
	  yield a string of the form `label'.  The shell rewinds
	  its input as much as possible and searches for a line
	  of the form `label:' possibly preceded by blanks or
	  tabs.  Execution continues after the specified line.

     [1mhashstat
	  [0mPrint a statistics line indicating how effective the
	  internal hash table has been at locating commands (and
	  avoiding _e_x_e_c's).  An _e_x_e_c is attempted for each com-
	  ponent of the _p_a_t_h where the hash function indicates a
	  possible hit, and in each component which does not
	  begin with a `/'.

     [1mhistory
     history [0m_n
     [1mhistory -r [0m_n
     [1mhistory -h [0m_n
	  Displays the history event list; if _n is given only the
	  _n most recent events are printed.  The [1m-r [0moption rev-
	  erses the order of printout to be most recent first
	  rather than oldest first.  The [1m-h [0moption causes the
	  history list to be printed without leading numbers.
	  This is used to produce files suitable for sourceing



Printed 2/12/91     Revision 1.4 of 11/11/89		       17






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



	  using the -h option to _s_o_u_r_c_e.

     [1mif [0m(expr) command
	  If the specified expression evaluates true, then the
	  single _c_o_m_m_a_n_d with arguments is executed.  Variable
	  substitution on _c_o_m_m_a_n_d happens early, at the same time
	  it does for the rest of the _i_f command.  _C_o_m_m_a_n_d must
	  be a simple command, not a pipeline, a command list, or
	  a parenthesized command list.  Input/output redirection
	  occurs even if _e_x_p_r is false, when command is [1mnot [0mexe-
	  cuted (this is a bug).

     [1mif [0m(expr) [1mthen
	 [0m...
     [1melse if [0m(expr2) [1mthen
	 [0m...
     [1melse
	 [0m...
     [1mendif
	  [0mIf the specified _e_x_p_r is true then the commands to the
	  first _e_l_s_e are executed; otherwise if _e_x_p_r_2 is true
	  then the commands to the second _e_l_s_e are executed, etc.
	  Any number of _e_l_s_e-_i_f pairs are possible; only one
	  _e_n_d_i_f is needed.  The _e_l_s_e part is likewise optional.
	  (The words _e_l_s_e and _e_n_d_i_f must appear at the beginning
	  of input lines; the _i_f must appear alone on its input
	  line or after an _e_l_s_e.)

     [1mjobs
     jobs -l
	  [0mLists the active jobs; given the [1m-l [0moptions lists pro-
	  cess id's in addition to the normal information.

     [1mkill %[0mjob
     [1mkill -[0msig [1m%[0mjob ...
     [1mkill [0mpid
     [1mkill -[0msig pid ...
     [1mkill -l
	  [0mSends either the TERM (terminate) signal or the speci-
	  fied signal to the specified jobs or processes.  Sig-
	  nals are either given by number or by names (as given
	  in /_u_s_r/_i_n_c_l_u_d_e/_s_i_g_n_a_l._h, stripped of the prefix
	  ``SIG'').  The signal names are listed by ``kill -l''.
	  There is no default, saying just `kill' does not send a
	  signal to the current job.  If the signal being sent is
	  TERM (terminate) or HUP (hangup), then the job or pro-
	  cess will be sent a CONT (continue) signal as well.

     [1mlimit
     limit [0m_r_e_s_o_u_r_c_e
     [1mlimit [0m_r_e_s_o_u_r_c_e _m_a_x_i_m_u_m-_u_s_e




Printed 2/12/91     Revision 1.4 of 11/11/89		       18






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



     [1mlimit -h
     limit -h [0m_r_e_s_o_u_r_c_e
     [1mlimit -h [0m_r_e_s_o_u_r_c_e _m_a_x_i_m_u_m-_u_s_e
	  Limits the consumption by the current process and each
	  process it creates to not individually exceed _m_a_x_i_m_u_m-
	  _u_s_e on the specified _r_e_s_o_u_r_c_e.  If no _m_a_x_i_m_u_m-_u_s_e is
	  given, then the current limit is printed; if no
	  _r_e_s_o_u_r_c_e is given, then all limitations are given.  If
	  the [1m-h [0mflag is given, the hard limits are used instead
	  of the current limits.  The hard limits impose a ceil-
	  ing on the values of the current limits.  Only the
	  super-user may raise the hard limits, but a user may
	  lower or raise the current limits within the legal
	  range.

	  Resources controllable currently include _c_p_u_t_i_m_e (the
	  maximum number of cpu-seconds to be used by each pro-
	  cess), _f_i_l_e_s_i_z_e (the largest single file which can be
	  created), _d_a_t_a_s_i_z_e (the maximum growth of the
	  data+stack region via _s_b_r_k(2) beyond the end of the
	  program text), _s_t_a_c_k_s_i_z_e (the maximum size of the
	  automatically-extended stack region), and _c_o_r_e_d_u_m_p_s_i_z_e
	  (the size of the largest core dump that will be
	  created).

	  The _m_a_x_i_m_u_m-_u_s_e may be given as a (floating point or
	  integer) number followed by a scale factor.  For all
	  limits other than _c_p_u_t_i_m_e the default scale is `k' or
	  `kilobytes' (1024 bytes); a scale factor of `m' or
	  `megabytes' may also be used.  For _c_p_u_t_i_m_e the default
	  scaling is `seconds', while `m' for minutes or `h' for
	  hours, or a time of the form `mm:ss' giving minutes and
	  seconds may be used.

	  For both _r_e_s_o_u_r_c_e names and scale factors, unambiguous
	  prefixes of the names suffice.

     [1mlogin
	  [0mTerminate a login shell, replacing it with an instance
	  of [1m/bin/login. [0mThis is one way to log off, included for
	  compatibility with _s_h(1).

     [1mlogout
	  [0mTerminate a login shell.  Especially useful if
	  _i_g_n_o_r_e_e_o_f is set.

     [1mnice
     nice [0m+number
     [1mnice [0mcommand
     [1mnice [0m+number command
	  The first form sets the scheduling priority for this
	  shell to 4.  The second form sets the priority to the



Printed 2/12/91     Revision 1.4 of 11/11/89		       19






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



	  given number.  The final two forms run command at
	  priority 4 and _n_u_m_b_e_r respectively.  The greater the
	  number, the less cpu the process will get.  The super-
	  user may specify negative priority by using `nice
	  -number ...'.  Command is always executed in a sub-
	  shell, and the restrictions placed on commands in sim-
	  ple _i_f statements apply.

     [1mnohup
     nohup [0mcommand
	  The first form can be used in shell scripts to cause
	  hangups to be ignored for the remainder of the script.
	  The second form causes the specified command to be run
	  with hangups ignored.  All processes detached with `&'
	  are effectively _n_o_h_u_p'_e_d.

     [1mnotify
     notify %[0mjob ...
	  Causes the shell to notify the user asynchronously when
	  the status of the current or specified jobs changes;
	  normally notification is presented before a prompt.
	  This is automatic if the shell variable _n_o_t_i_f_y is set.

     [1monintr
     onintr  [0m-
     [1monintr  [0mlabel
	  Control the action of the shell on interrupts.  The
	  first form restores the default action of the shell on
	  interrupts which is to terminate shell scripts or to
	  return to the terminal command input level.  The second
	  form `onintr -' causes all interrupts to be ignored.
	  The final form causes the shell to execute a `goto
	  label' when an interrupt is received or a child process
	  terminates because it was interrupted.

	  In any case, if the shell is running detached and
	  interrupts are being ignored, all forms of _o_n_i_n_t_r have
	  no meaning and interrupts continue to be ignored by the
	  shell and all invoked commands.

     [1mpopd
     popd [0m+n
	  Pops the directory stack, returning to the new top
	  directory.  With an argument `+_n' discards the _nth
	  entry in the stack.  The elements of the directory
	  stack are numbered from 0 starting at the top.

     [1mpushd
     pushd [0mname
     [1mpushd [0m+n
	  With no arguments, _p_u_s_h_d exchanges the top two elements
	  of the directory stack.  Given a _n_a_m_e argument, _p_u_s_h_d



Printed 2/12/91     Revision 1.4 of 11/11/89		       20






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



	  changes to the new directory (ala _c_d) and pushes the
	  old current working directory (as in _c_s_w) onto the
	  directory stack.  With a numeric argument, rotates the
	  _nth argument of the directory stack around to be the
	  top element and changes to it.  The members of the
	  directory stack are numbered from the top starting at
	  0.

     [1mrehash
	  [0mCauses the internal hash table of the contents of the
	  directories in the _p_a_t_h variable to be recomputed.
	  This is needed if new commands are added to directories
	  in the _p_a_t_h while you are logged in.	This should only
	  be necessary if you add commands to one of your own
	  directories, or if a systems programmer changes the
	  contents of one of the system directories.

     [1mrepeat [0mcount command
	  The specified _c_o_m_m_a_n_d which is subject to the same res-
	  trictions as the _c_o_m_m_a_n_d in the one line _i_f statement
	  above, is executed _c_o_u_n_t times.  I/O redirections occur
	  exactly once, even if _c_o_u_n_t is 0.

     [1mset
     set [0mname
     [1mset [0mname=word
     [1mset [0mname[index]=word
     [1mset [0mname=(wordlist)
	  The first form of the command shows the value of all
	  shell variables.  Variables which have other than a
	  single word as value print as a parenthesized word
	  list.  The second form sets _n_a_m_e to the null string.
	  The third form sets _n_a_m_e to the single _w_o_r_d. The fourth
	  form sets the _i_n_d_e_x'_t_h component of name to word; this
	  component must already exist.  The final form sets _n_a_m_e
	  to the list of words in _w_o_r_d_l_i_s_t. In all cases the
	  value is command and filename expanded.

	  These arguments may be repeated to set multiple values
	  in a single set command.  Note however, that variable
	  expansion happens for all arguments before any setting
	  occurs.

     [1msetenv
     setenv [0mname value
     [1msetenv [0mname
	  The first form lists all current environment variables.
	  The last form sets the value of environment variable
	  _n_a_m_e to be _v_a_l_u_e, a single string.  The second form
	  sets _n_a_m_e to an empty string.  The most commonly used
	  environment variable USER, TERM, and PATH are automati-
	  cally imported to and exported from the _c_s_h variables



Printed 2/12/91     Revision 1.4 of 11/11/89		       21






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



	  _u_s_e_r, _t_e_r_m, and _p_a_t_h; there is no need to use _s_e_t_e_n_v
	  for these.

     [1mshift
     shift [0mvariable
	  The members of _a_r_g_v are shifted to the left, discarding
	  _a_r_g_v[_1]. It is an error for _a_r_g_v not to be set or to
	  have less than one word as value.  The second form per-
	  forms the same function on the specified variable.

     [1msource [0mname
     [1msource -h [0mname
	  The shell reads commands from _n_a_m_e. _S_o_u_r_c_e commands may
	  be nested; if they are nested too deeply the shell may
	  run out of file descriptors.	An error in a _s_o_u_r_c_e at
	  any level terminates all nested _s_o_u_r_c_e commands.  Nor-
	  mally input during _s_o_u_r_c_e commands is not placed on the
	  history list; the -h option causes the commands to be
	  placed in the history list without being executed.

     [1mstop
     stop %[0mjob ...
	  Stops the current or specified job which is executing
	  in the background.

     [1msuspend
	  [0mCauses the shell to stop in its tracks, much as if it
	  had been sent a stop signal with [1m^Z[0m.	This is most
	  often used to stop shells started by _s_u(1).

     [1mswitch [0m(string)
     [1mcase [0mstr1:
	 ...
       [1mbreaksw
     [0m...
     [1mdefault:
	 [0m...
       [1mbreaksw
     endsw
	  [0mEach case label is successively matched, against the
	  specified _s_t_r_i_n_g which is first command and filename
	  expanded.  The file metacharacters `*', `?' and `[...]'
	  may be used in the case labels, which are variable
	  expanded.  If none of the labels match before a
	  `default' label is found, then the execution begins
	  after the default label.  Each case label and the
	  default label must appear at the beginning of a line.
	  The command _b_r_e_a_k_s_w causes execution to continue after
	  the _e_n_d_s_w. Otherwise control may fall through case
	  labels and default labels as in C.  If no label matches
	  and there is no default, execution continues after the
	  _e_n_d_s_w.



Printed 2/12/91     Revision 1.4 of 11/11/89		       22






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



     [1mtime
     time [0mcommand
	  With no argument, a summary of time used by this shell
	  and its children is printed.	If arguments are given
	  the specified simple command is timed and a time sum-
	  mary as described under the _t_i_m_e variable is printed.
	  If necessary, an extra shell is created to print the
	  time statistic when the command completes.

     [1mumask
     umask [0mvalue
	  The file creation mask is displayed (first form) or set
	  to the specified value (second form).  The mask is
	  given in octal.  Common values for the mask are 002
	  giving all access to the group and read and execute
	  access to others or 022 giving all access except no
	  write access for users in the group or others.

     [1munalias [0mpattern
	  All aliases whose names match the specified pattern are
	  discarded.  Thus all aliases are removed by `unalias
	  *'.  It is not an error for nothing to be _u_n_a_l_i_a_s_e_d.

     [1munhash
	  [0mUse of the internal hash table to speed location of
	  executed programs is disabled.

     [1munlimit
     unlimit [0m_r_e_s_o_u_r_c_e
     [1munlimit -h
     unlimit -h [0m_r_e_s_o_u_r_c_e
	  Removes the limitation on _r_e_s_o_u_r_c_e.  If no _r_e_s_o_u_r_c_e is
	  specified, then all _r_e_s_o_u_r_c_e limitations are removed.
	  If [1m-h [0mis given, the corresponding hard limits are
	  removed.  Only the super-user may do this.

     [1munset [0mpattern
	  All variables whose names match the specified pattern
	  are removed.	Thus all variables are removed by `unset
	  *'; this has noticeably distasteful side-effects.  It
	  is not an error for nothing to be _u_n_s_e_t.

     [1munsetenv [0mpattern
	  Removes all variables whose name match the specified
	  pattern from the environment.  See also the _s_e_t_e_n_v com-
	  mand above and _p_r_i_n_t_e_n_v(1).

     [1mwait
	  [0mAll background jobs are waited for.  It the shell is
	  interactive, then an interrupt can disrupt the wait, at
	  which time the shell prints names and job numbers of
	  all jobs known to be outstanding.



Printed 2/12/91     Revision 1.4 of 11/11/89		       23






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



     [1mwhile [0m(expr)
	 ...
     [1mend
	  [0mWhile the specified expression evaluates non-zero, the
	  commands between the _w_h_i_l_e and the matching end are
	  evaluated.  _B_r_e_a_k and _c_o_n_t_i_n_u_e may be used to terminate
	  or continue the loop prematurely.  (The _w_h_i_l_e and _e_n_d
	  must appear alone on their input lines.) Prompting
	  occurs here the first time through the loop as for the
	  _f_o_r_e_a_c_h statement if the input is a terminal.

     [1m%[0mjob
	  Brings the specified job into the foreground.

     [1m%[0mjob [1m&
	  [0mContinues the specified job in the background.

     [1m@
     @ [0mname = expr
     [1m@ [0mname[index] = expr
	  The first form prints the values of all the shell vari-
	  ables.  The second form sets the specified _n_a_m_e to the
	  value of _e_x_p_r. If the expression contains `<', `>', `&'
	  or `|' then at least this part of the expression must
	  be placed within `(' `)'.  The third form assigns the
	  value of _e_x_p_r to the _i_n_d_e_x'_t_h argument of _n_a_m_e. Both
	  _n_a_m_e and its _i_n_d_e_x'_t_h component must already exist.

	  The operators `*=', `+=', etc are available as in C.
	  The space separating the name from the assignment
	  operator is optional.  Spaces are, however, mandatory
	  in separating components of _e_x_p_r which would otherwise
	  be single words.

	  Special postfix `++' and `--' operators increment and
	  decrement _n_a_m_e respectively, i.e. `@	i++'.

     [1mPre-defined and environment variables

     [0mThe following variables have special meaning to the shell.
     Of these, _a_r_g_v, _c_w_d, _h_o_m_e, _p_a_t_h, _p_r_o_m_p_t, _s_h_e_l_l and _s_t_a_t_u_s
     are always set by the shell.  Except for _c_w_d and _s_t_a_t_u_s this
     setting occurs only at initialization; these variables will
     not then be modified unless this is done explicitly by the
     user.

     This shell copies the environment variable USER into the
     variable _u_s_e_r, TERM into _t_e_r_m, and HOME into _h_o_m_e, and
     copies these back into the environment whenever the normal
     shell variables are reset.  The environment variable PATH is
     likewise handled; it is not necessary to worry about its
     setting other than in the file ._c_s_h_r_c as inferior _c_s_h



Printed 2/12/91     Revision 1.4 of 11/11/89		       24






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



     processes will import the definition of _p_a_t_h from the
     environment, and re-export it if you then change it.

     [1margv	    [0mSet to the arguments to the shell, it is from
		    this variable that positional parameters are
		    substituted, i.e. `$1' is replaced by
		    `$argv[1]', etc.

     [1mcdpath	    [0mGives a list of alternate directories
		    searched to find subdirectories in _c_h_d_i_r com-
		    mands.

     [1mcwd	    [0mThe full pathname of the current directory.

     [1mecho	    [0mSet when the [1m-x [0mcommand line option is given.
		    Causes each command and its arguments to be
		    echoed just before it is executed.	For non-
		    builtin commands all expansions occur before
		    echoing.  Builtin commands are echoed before
		    command and filename substitution, since
		    these substitutions are then done selec-
		    tively.

     [1mfilec	    [0mEnable file name completion.

     [1mhistchars	    [0mCan be given a string value to change the
		    characters used in history substitution.  The
		    first character of its value is used as the
		    history substitution character, replacing the
		    default character !.  The second character of
		    its value replaces the character |^ in quick
		    substitutions.

     [1mhistory	    [0mCan be given a numeric value to control the
		    size of the history list.  Any command which
		    has been referenced in this many events will
		    not be discarded.  Too large values of _h_i_s_-
		    _t_o_r_y may run the shell out of memory.  The
		    last executed command is always saved on the
		    history list.

     [1mhome	    [0mThe home directory of the invoker, initial-
		    ized from the environment.	The filename
		    expansion of `[1m~[0m' refers to this variable.

     [1mignoreeof	    [0mIf set the shell ignores end-of-file from
		    input devices which are terminals.	This
		    prevents shells from accidentally being
		    killed by control-D's.

     [1mmail	    [0mThe files where the shell checks for mail.
		    This is done after each command completion



Printed 2/12/91     Revision 1.4 of 11/11/89		       25






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



		    which will result in a prompt, if a specified
		    interval has elapsed.  The shell says `You
		    have new mail.' if the file exists with an
		    access time not greater than its modify time.

		    If the first word of the value of _m_a_i_l is
		    numeric it specifies a different mail check-
		    ing interval, in seconds, than the default,
		    which is 10 minutes.

		    If multiple mail files are specified, then
		    the shell says `New mail in _n_a_m_e' when there
		    is mail in the file _n_a_m_e.

     [1mnoclobber	    [0mAs described in the section on _I_n_p_u_t/_o_u_t_p_u_t,
		    restrictions are placed on output redirection
		    to insure that files are not accidentally
		    destroyed, and that `>>' redirections refer
		    to existing files.

     [1mnoglob	    [0mIf set, filename expansion is inhibited.
		    This is most useful in shell scripts which
		    are not dealing with filenames, or after a
		    list of filenames has been obtained and
		    further expansions are not desirable.

     [1mnonomatch	    [0mIf set, it is not an error for a filename
		    expansion to not match any existing files;
		    rather the primitive pattern is returned.  It
		    is still an error for the primitive pattern
		    to be malformed, i.e.  `echo [' still gives
		    an error.

     [1mnotify	    [0mIf set, the shell notifies asynchronously of
		    job completions.  The default is to rather
		    present job completions just before printing
		    a prompt.

     [1mpath	    [0mEach word of the path variable specifies a
		    directory in which commands are to be sought
		    for execution.  A null word specifies the
		    current directory.	If there is no _p_a_t_h vari-
		    able then only full path names will execute.
		    The usual search path is `.', `/bin' and
		    `/usr/bin', but this may vary from system to
		    system.  For the super-user the default
		    search path is `/etc', `/bin' and `/usr/bin'.
		    A shell which is given neither the [1m-c [0mnor the
		    [1m-t [0moption will normally hash the contents of
		    the directories in the _p_a_t_h variable after
		    reading ._c_s_h_r_c, and each time the _p_a_t_h vari-
		    able is reset.  If new commands are added to



Printed 2/12/91     Revision 1.4 of 11/11/89		       26






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



		    these directories while the shell is active,
		    it may be necessary to give the _r_e_h_a_s_h or the
		    commands may not be found.

     [1mprompt	    [0mThe string which is printed before each com-
		    mand is read from an interactive terminal
		    input.  If a `!' appears in the string it
		    will be replaced by the current event number
		    unless a preceding `\' is given.  Default is
		    `% ', or `# ' for the super-user.

     [1msavehist	    [0mis given a numeric value to control the
		    number of entries of the history list that
		    are saved in ~/.history when the user logs
		    out.  Any command which has been referenced
		    in this many events will be saved.	During
		    start up the shell sources ~/.history into
		    the history list enabling history to be saved
		    across logins.  Too large values of _s_a_v_e_h_i_s_t
		    will slow down the shell during start up.

     [1mshell	    [0mThe file in which the shell resides.  This is
		    used in forking shells to interpret files
		    which have execute bits set, but which are
		    not executable by the system.  (See the
		    description of _N_o_n-_b_u_i_l_t_i_n _C_o_m_m_a_n_d _E_x_e_c_u_t_i_o_n
		    below.) Initialized to the (system-dependent)
		    home of the shell.

     [1mstatus	    [0mThe status returned by the last command.  If
		    it terminated abnormally, then 0200 is added
		    to the status.  Builtin commands which fail
		    return exit status `1', all other builtin
		    commands set status `0'.

     [1mtime	    [0mControls automatic timing of commands.  If
		    set, then any command which takes more than
		    this many cpu seconds will cause a line giv-
		    ing user, system, and real times and a utili-
		    zation percentage which is the ratio of user
		    plus system times to real time to be printed
		    when it terminates.

     [1mverbose	    [0mSet by the [1m-v [0mcommand line option, causes the
		    words of each command to be printed after
		    history substitution.

     [1mNon-builtin command execution

     [0mWhen a command to be executed is found to not be a builtin
     command the shell attempts to execute the command via
     _e_x_e_c_v_e(2).  Each word in the variable _p_a_t_h names a directory



Printed 2/12/91     Revision 1.4 of 11/11/89		       27






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



     from which the shell will attempt to execute the command.
     If it is given neither a [1m-c [0mnor a [1m-t [0moption, the shell will
     hash the names in these directories into an internal table
     so that it will only try an _e_x_e_c in a directory if there is
     a possibility that the command resides there.  This greatly
     speeds command location when a large number of directories
     are present in the search path.  If this mechanism has been
     turned off (via _u_n_h_a_s_h), or if the shell was given a [1m-c [0mor
     [1m-t [0margument, and in any case for each directory component of
     _p_a_t_h which does not begin with a `/', the shell concatenates
     with the given command name to form a path name of a file
     which it then attempts to execute.

     Parenthesized commands are always executed in a subshell.
     Thus `(cd ; pwd) ; pwd' prints the _h_o_m_e directory; leaving
     you where you were (printing this after the home directory),
     while `cd ; pwd' leaves you in the _h_o_m_e directory.
     Parenthesized commands are most often used to prevent _c_h_d_i_r
     from affecting the current shell.

     If the file has execute permissions but is not an executable
     binary to the system, then it is assumed to be a file con-
     taining shell commands and a new shell is spawned to read
     it.

     If there is an _a_l_i_a_s for _s_h_e_l_l then the words of the alias
     will be prepended to the argument list to form the shell
     command.  The first word of the _a_l_i_a_s should be the full
     path name of the shell (e.g. `$shell').  Note that this is a
     special, late occurring, case of _a_l_i_a_s substitution, and
     only allows words to be prepended to the argument list
     without modification.

     [1mArgument list processing

     [0mIf argument 0 to the shell is `-' then this is a login
     shell.  The flag arguments are interpreted as follows:

     [1m-b   [0mThis flag forces a ``break'' from option processing,
	  causing any further shell arguments to be treated as
	  non-option arguments.  The remaining arguments will not
	  be interpreted as shell options.  This may be used to
	  pass options to a shell script without confusion or
	  possible subterfuge.	The shell will not run a set-user
	  ID script without this option.

     [1m-c   [0mCommands are read from the (single) following argument
	  which must be present.  Any remaining arguments are
	  placed in _a_r_g_v.

     [1m-e   [0mThe shell exits if any invoked command terminates
	  abnormally or yields a non-zero exit status.



Printed 2/12/91     Revision 1.4 of 11/11/89		       28






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



     [1m-f   [0mThe shell will start faster, because it will neither
	  search for nor execute commands from the file `.cshrc'
	  in the invoker's home directory.

     [1m-i   [0mThe shell is interactive and prompts for its top-level
	  input, even if it appears to not be a terminal.  Shells
	  are interactive without this option if their inputs and
	  outputs are terminals.

     [1m-n   [0mCommands are parsed, but not executed.  This aids in
	  syntactic checking of shell scripts.

     [1m-s   [0mCommand input is taken from the standard input.

     [1m-t   [0mA single line of input is read and executed.	A `\' may
	  be used to escape the newline at the end of this line
	  and continue onto another line.

     [1m-v   [0mCauses the _v_e_r_b_o_s_e variable to be set, with the effect
	  that command input is echoed after history substitu-
	  tion.

     [1m-x   [0mCauses the _e_c_h_o variable to be set, so that commands
	  are echoed immediately before execution.

     [1m-V   [0mCauses the _v_e_r_b_o_s_e variable to be set even before
	  `.cshrc' is executed.

     [1m-X   [0mIs to [1m-x [0mas [1m-V [0mis to [1m-v.

     [0mAfter processing of flag arguments, if arguments remain but
     none of the [1m-c, -i, -s, [0mor [1m-t [0moptions was given, the first
     argument is taken as the name of a file of commands to be
     executed.	The shell opens this file, and saves its name for
     possible resubstitution by `$0'.  Since many systems use
     either the standard version 6 or version 7 shells whose
     shell scripts are not compatible with this shell, the shell
     will execute such a `standard' shell if the first character
     of a script is not a `#', i.e. if the script does not start
     with a comment.  Remaining arguments initialize the variable
     _a_r_g_v.

     [1mSignal handling

     [0mThe shell normally ignores _q_u_i_t signals.  Jobs running
     detached (either by `&' or the _b_g or [1m%... & [0mcommands) are
     immune to signals generated from the keyboard, including
     hangups.  Other signals have the values which the shell
     inherited from its parent.  The shells handling of inter-
     rupts and terminate signals in shell scripts can be con-
     trolled by _o_n_i_n_t_r. Login shells catch the _t_e_r_m_i_n_a_t_e signal;
     otherwise this signal is passed on to children from the



Printed 2/12/91     Revision 1.4 of 11/11/89		       29






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



     state in the shell's parent.  In no case are interrupts
     allowed when a login shell is reading the file `.logout'.

[1mAUTHOR
     [0mWilliam Joy.  Job control and directory stack features first
     implemented by J.E. Kulp of I.I.A.S.A, Laxenburg, Austria,
     with different syntax than that used now.	File name comple-
     tion code written by Ken Greer, HP Labs.

[1mFILES
     [0m~/.cshrc	      Read at beginning of execution by each shell.
     ~/.login	      Read by login shell, after `.cshrc' at login.
     ~/.logout	      Read by login shell, at logout.
     /bin/sh	      Standard shell, for shell scripts not starting with a `#'.
     /tmp/sh*	      Temporary file for `<<'.
     /etc/passwd      Source of home directories for `~name'.

[1mLIMITATIONS
     [0mWords can be no longer than 1024 characters.  The system
     limits argument lists to 10240 characters.  The number of
     arguments to a command which involves filename expansion is
     limited to 1/6'th the number of characters allowed in an
     argument list.  Command substitutions may substitute no more
     characters than are allowed in an argument list.  To detect
     looping, the shell restricts the number of _a_l_i_a_s substitu-
     tions on a single line to 20.

[1mSEE ALSO
     [0msh(1), access(2), execve(2), fork(2), killpg(2), pipe(2),
     sigvec(2), umask(2), setrlimit(2), wait(2), tty(4),
     a.out(5), environ(7), `An introduction to the C shell'

[1mBUGS
     [0mWhen a command is restarted from a stop, the shell prints
     the directory it started in if this is different from the
     current directory; this can be misleading (i.e. wrong) as
     the job may have changed directories internally.

     Shell builtin functions are not stoppable/restartable.  Com-
     mand sequences of the form `a ; b ; c' are also not handled
     gracefully when stopping is attempted.  If you suspend `b',
     the shell will then immediately execute `c'.  This is espe-
     cially noticeable if this expansion results from an _a_l_i_a_s.
     It suffices to place the sequence of commands in ()'s to
     force it to a subshell, i.e. `( a ; b ; c )'.

     Control over tty output after processes are started is prim-
     itive; perhaps this will inspire someone to work on a good
     virtual terminal interface.  In a virtual terminal interface
     much more interesting things could be done with output con-
     trol.




Printed 2/12/91     Revision 1.4 of 11/11/89		       30






CSH(1)		    UNIX Programmer's Manual		   CSH(1)



     Alias substitution is most often used to clumsily simulate
     shell procedures; shell procedures should be provided rather
     than aliases.

     Commands within loops, prompted for by `?', are not placed
     in the _h_i_s_t_o_r_y list.  Control structure should be parsed
     rather than being recognized as built-in commands.  This
     would allow control commands to be placed anywhere, to be
     combined with `|', and to be used with `&' and `;' metasyn-
     tax.

     It should be possible to use the `:' modifiers on the output
     of command substitutions.	All and more than one `:' modif-
     ier should be allowed on `$' substitutions.

     The way the [1mfilec [0mfacility is implemented is ugly and expen-
     sive.






































Printed 2/12/91     Revision 1.4 of 11/11/89		       31



[0m