Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ csh(1) — AIX PS/2 1.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

cd

make

pr

sh, Rsh

access

exec

fork

pipe

umask

wait

environ

environment



CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



-------------------------------------------------------------------------------
csh



PURPOSE

Interprets commands read from a file or entered from the keyboard.

SYNTAX


                                                 +-------------------------+
       +--------+   +--------+   +-----------+   |         one of          |
csh ---| one of |---| one of |---|           |---|   +----------------+    |--|
       | +----+ |   | +----+ |   | +-------+ |   |   | -c"cmd string" |    |
       +-| -v |-+   +-| -x |-+   +-| -b    |-+   | +-| -s             |--+ |
         | -V |       | -X |      ^| -e -f ||    +-| | -t             |  |-+
         +----+       +----+      || -i -n ||      | +----------------+  |
                                  |+-------+|      |           +-------+ |
                                  +---------+      +--- file --|       |-+
                                                               +- arg -+
                                                                ^     |
                                                                +-----+


DESCRIPTION

The csh command is a command language interpreter incorporating a history
mechanism (see "History Substitutions"), job control facilities (see "Jobs"),
interactive file name and user name completion (see "File Name Completion"),
and a C-like syntax.  To use the csh job control facilities, you must also use
the tty driver described in the termino file (see the termino special file in
AIX Operating System Technical Reference).  The tty driver enables generation
of interrupt characters from the keyboard to stop jobs.  See "stty, STTY" for
details on setting options in the tty driver.

The csh command begins by executing commands from the .cshrc file in the home
directory of the invoker.  If this is a login shell, csh also executes commands
from the .login file in the invoker's home directory.  Typically, users put the
command stty crt in their .login file and also set their terminal type for
full-screen commands such as vi.

The user may want certain commands to be run only from interactive shells.  To
accomplish this, add instructions to the .cshrc file, using the following
model:

  if ($?prompt) then
     # Do interactive-only things
  endif





Processed November 8, 1990         CSH(1,C)                                   1





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



Normally, the shell then begins reading commands from the terminal, prompting
with "%".  If the user redefines the prompt, it should be done after the test
above.

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

When a login shell terminates, it executes commands from the .logout file in
the user's home directory.

LEXICAL STRUCTURE

The csh command interprets commands according to the following lexical
structure:

The csh shell splits input lines into words at blanks and tabs.  (Japanese
characters must be separated by spaces if they are to be treated as separate
words.)  The characters &  |  ;  <  >  (  ) form separate words.  The &&, ||,
<<, or >> terms also form single words.  You can make these parser
metacharacters part of other words or prevent the metacharacters from having
their special meaning by preceding them with \.  A new line preceded by a \ is
equivalent to a blank.

Strings enclosed in matched pairs of quotations (' ` or ") form parts of a
word.  In these strings, metacharacters (including blanks and tabs) do not form
separate words.  (The semantics of quotations are described in "Quotations with
Single and Double Quotes.") Within pairs of ' or " characters, a new line
preceded by a \ gives a true new-line character.

When the shell's input is not a terminal, the character # introduces a comment,
which continues until the end of the input line.  The # character is prevented
from having this special meaning when it is preceded by \ or is in quotations
(`, ', or ").

COMMANDS

In the csh interpreter, a 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
pipelines can be separated by semicolons (;) and then are executed
sequentially.  When a sequence of pipelines is followed by an &, it is executed
without waiting for the preceding pipeline to terminate.

Commands and pipelines can be placed in parentheses ( ) to a form simple
commands, which, in turn, can be used as components of a pipeline.  You also
can separate pipelines with || or &&, indicating, as in C language, that the
second is to be executed only if the first fails or succeeds, respectively (see
"Expressions").




Processed November 8, 1990         CSH(1,C)                                   2





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



JOBS

The csh shell associates a job with each pipeline.  The shell keeps a table of
current jobs, printed by the jobs command (see page         17 for information
on the jobs built-in command), and assigns them small integer numbers.  When a
job is started asynchronously with &, the shell prints a line which looks like
this:

  [1] 1234

This line indicates that the job which was started asynchronously was job
number 1 and had one top-level process with an ID of 1234.

If you are running a job and wish to do something else, you can press Ctrl-Z to
send a stop signal to the current job.  The shell then normally indicates the
job has been stopped and prints another prompt.  You then can manipulate the
state of this job, putting it in the background with the bg command (see page
        14 for information on the bg built-in command), running some other
commands, and eventually bringing the job back into the foreground with the fg
command (see page         16 for information on the fg command).  Ctrl-Z takes
effect immediately.  Like an interrupt, Ctrl-Z causes pending output and unread
input to be discarded.

A job running in the background stops if it tries to read from the terminal.
Background jobs are normally allowed to produce output, but this can be
disabled by the command stty tostop.  If you set this tty option, background
jobs stop when they try to produce output as well as when they try to read
input.

There are several ways to refer to jobs in the csh shell.  The character %
introduces a job name.  For example, if you wish to refer to job number 1, you
can name it %1.  Naming a job brings it to the foreground; that is, %1 is a
synonym for fg %1.  Similarly, %1 & puts job 1 in the background.  Jobs also
can be named by prefixes of the string that would start them, if these prefixes
are unambiguous.  For example, %ex restarts a suspended ex job if there is only
one suspended job whose name begins with the string ex.  You can also use
%?string to specify a job whose text contains string if there is only one such
job.

The shell maintains a record 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 history mechanism (see
"History Substitutions"), %% is also a synonym for the current job.

STATUS REPORTING

The csh shell learns immediately whenever a process changes state.  If a job
becomes blocked so that no further progress is possible, the shell informs you,
but not until just before it prints a prompt.  However, if you set the shell
variable notify (see page         26 for information on the notify variable),
the shell notifies you immediately of changes of status in background jobs.



Processed November 8, 1990         CSH(1,C)                                   3





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



There is also a notify shell command (see page         19) that marks a single
process so that its status changes are immediately reported.  By default,
notify marks the current process; simply enter notify after starting a
background job to mark it.

When you try to leave the shell while jobs are stopped, you are warned that you
have stopped jobs.  You can use the jobs command to see what they are.  If you
use the jobs command or immediately try to exit again, the shell does not warn
you a second time, and the suspended jobs are terminated.

FILE NAME COMPLETION

When the file name completion feature of the csh command is enabled by setting
the shell variable filec, the csh command interactively completes file names
and user names from unique prefixes input from the terminal and followed by the
escape character (the Esc key or Ctrl-[).  For example, if the current
directory looks like this:

  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<Esc>

the csh command completes the prefix "ch" to the only matching file name,
chaosnet, changing the input line to:

% vi chaosnet

However, given a prefix that matches more than one file name:

% vi D<Esc>

the csh expands the input to:

% vi DSC.

and sounds the terminal bell to indicate the expansion is incomplete since
there are two file names beginning with "D".

If, instead of completing a name, you enter a partial file name followed by the
end-of-file character (usually Ctrl-D), the csh command lists all file names
matching the prefix.  For example, the input:

% vi D<Ctrl-D>

causes all files beginning with D to be listed:

DSC.NEW    DSC.OLD




Processed November 8, 1990         CSH(1,C)                                   4





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



while the input line remains unchanged.

The same sequence of escape and end-of-file characters can also be used to
expand partial user names if the word to be completed begins with the character
~.  For example, entering:

cd ~ro<Ctrl-D>

produces the expansion:

cd ~root

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

Normally, all files in the particular directory are candidates for name
completion.  Files with certain suffixes can be excluded from consideration by
setting the variable fignore to the list of suffixes to be ignored.  Thus, if
fignore is set by the command:

% set fignore = (.o .out)

then entering:

% vi x<Esc>

results in the completion to

% vi xmpl.c

ignoring the files xmpl.o and xmpl.out.  However, if the only possible
completions involve files named with one of these suffixes, ".o" and ".out" are
not ignored.  (Note:  The fignore variable does not affect usage of Ctrl-D.  If
you begin a partial file name and then press Ctrl-D, all files, regardless of
suffix, are listed.)

The use of file completion requires the terminal setting of ctlecho (see page
stty-9 for information on ctlecho).  Also, the use of Esc for file name
completion conflicts with the use of Esc for other purposes.  Therefore, these
two functions cannot be used at the same time.

SUBSTITUTIONS

The following sections describe the various transformations the csh shell
performs on the input in the order in which they occur:  history, alias,
variable, command, and file-name substitutions.

History Substitutions

History 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



Processed November 8, 1990         CSH(1,C)                                   5





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



command.  History substitutions begin with the character ! and can begin
anywhere in the input stream as long as they are not nested.  The ! can be
preceded by a \ to negate its special meaning; for convenience, a ! is passed
unchanged when it is followed by a blank, tab, new-line character, =, or (.
(History substitutions also occur when an input line begins with ^.)  Any input
line which contains history substitution is echoed on the terminal before it is
executed as it would have been typed without history substitution.

Commands input from the terminal are saved on the history list.  The history
substitutions reintroduce sequences of words from these saved commands into the
input stream.  The size of the history list is controlled by the history
variable (see         25 for information on the history variable).  The
previous command is always retained, regardless of its value.  Commands are
numbered sequentially from 1.

For example, consider the following output from the history command:

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

The commands are shown with their event numbers.  The current event number can
be made part of the prompt by placing the set prompt=\! command in the .schrc
file, or by entering the set prompt command at the command line.

If the current event is 13, we can refer to previous events in several ways:
by event number (for example, !11); relatively (for example, !-2, referring to
event 11); by a prefix of a command word (for example, !d for event 12 or !wri
for event 9); or by a string contained in a word in the command (for example,
!?mic?, referring to event 9).  Without further modification, these forms
simply reintroduce the words of the specified events, each separated by a
single blank.  As a special case, !! refers to the previous command.

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

0       First (command) word.
n       nth argument.
^       First argument (for example, 1).
$       Last argument.
%       Word matched by (immediately preceding) ?s? search.
x-y     Range of words.
-y      Abbreviation for 0-y.
*       Abbreviation for ^ - $, or nothing if only one word in event.
x*      Abbreviation for x  - $.
x-      Like x*, but omitting word $.

The : (colon) separating the event specification from the word designator can
be omitted if the argument selector begins with a ^, $, *, -, or %.  After the



Processed November 8, 1990         CSH(1,C)                                   6





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



optional word designator, a sequence of modifiers can be placed, each preceded
by a colon.  The following modifiers are defined:

h       Removes a trailing path name component, leaving the head.
r       Removes a trailing .xxx component, leaving the root name.
e       Removes all but the extension part.  (yyy.xxx becomes xxx.)
s/l/r/  Substitutes l for r.
t       Removes all leading path name components, leaving the tail.
&       Repeats the previous substitution.
g       Applies the change globally, prefixing the above, for example, g&.
p       Prints the new command but does not execute it.
q       Quotes the substituted words, preventing further substitutions.
x       Like q, but breaks into words at blanks, tabs, and new-line characters.

Unless preceded by a g, the modification is applied only to the first
modifiable word.  Using a substitution that does not apply to any word is
considered an error.

The left-hand side of substitutions are not regular expressions as editors
would treat them, but instead are strings.  Any character can 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 substitution
can be omitted if a new line follows immediately, as can the trailing ? in a
contextual scan.

A history reference can be given without an event specification.  For example,
in the case of !$, the reference is to the previous command unless a previous
history reference occurred on the same line, in which case this form repeats
the previous 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 shorthand 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 can be surrounded with { and } if necessary to
insulate it from the characters which follow.  Thus, after ls -ld ~paul we
could enter !{l}a to do ls -ld ~paula, while !la would look for a command
starting la.

Quotations with Single and Double Quotes

The quotation of strings by ' and " can be used to prevent all or some of the
remaining substitutions.  Strings enclosed in ' are prevented from any further
interpretation.  Strings enclosed in " can 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 "Command Substitution") does a string quoted in " yield
parts of more than one word; strings quoted in ' never do.




Processed November 8, 1990         CSH(1,C)                                   7





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



Alias Substitutions

The csh shell maintains a list of aliases which can be established, displayed,
and modified by the alias and unalias commands (see pages         14 and
        23 for information about these built-in 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,
the text which is the alias for that command is reread with the history
mechanism as though that command were the previous input line.  The resulting
words replace the command and argument list.  If no reference is made to the
history list, the argument list is left unchanged.

For example, if the alias for ls is ls -l, the command ls /usr would map to ls
-l /usr.  Similarly, if the alias for lookup was grep !^ /etc/passwd, 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.

The alias substitution mechanism allows aliases to introduce parser metasyntax.
For example, the command alias p 'pr \!* | print' creates an alias which
applies the pr command to its arguments.

Variable Substitution

The csh shell maintains a set of variables, each of which has as its 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 argv variable is an image of the shell's
argument list, and words of this variable's value are referred to in special
ways.  No multibyte characters are allowed in variable names.  However, the
contents of the variables can contain multibyte characters.

The values of variables can be displayed and changed by using the set and unset
commands (see page         20 for more information on these built-in commands).
Of the variables referred to by the shell, many are toggles.  For instance, the
verbose variable is a toggle which causes command input to be echoed.  The
setting of this variable results from the -v command line option.

Other operations treat variables numerically.  The @ command  (see page
        24 for more information on the @ built-in command) permits numeric
calculations to be performed and the result assigned to a variable.  Variable
values are, however, always represented as strings.  For numeric operations,
the null string is considered to be zero, and the second and subsequent words
of multi-word values are ignored.

After the input line is aliased and parsed, and before each command is
executed, variable substitution is performed with "$" characters.  This
expansion can be prevented by preceding the "$" with a backslash ("\") except
within double quotes ("""), where it always occurs, and within single quotes
('), where it never occurs.  Strings quoted by single back quotes ("`") are



Processed November 8, 1990         CSH(1,C)                                   8





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



interpreted later (see "Command Substitution"), so "$" substitution does not
occur there until later, if at all.  A "$" is passed unchanged if followed by a
blank, tab, or end-of-line character.

Input and output redirections are recognized before variable expansion and are
variable-expanded separately.  Otherwise, the command name and entire argument
list are expanded together.  Thus, it is possible for the first command word 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 can eventually be command and file-name 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 substitution, the variable expands to multiple
words, with each word separated by a blank and quoted to prevent later command
or file name substitution.

The following meta-sequences are provided for introducing variable values into
the shell input.  Unless otherwise noted, referencing an unset variable is an
error.

$name
${name}
    Replaced by the words of the value of the variable specified by name, each
    word separated by a blank.  Braces separate name from characters which
    otherwise would be part of it.  Shell variables can have names consisting
    of up to 20 letters and numbers, starting with a letter.  The underscore
    character is considered a letter.

    If name is not a shell variable but is set in the environment, that value
    is returned; however, the : modifiers (see page         7 for more
    information on the :  modifiers) are not available in this case.

$name[selector]
${name[selector]}
    Selects words from the value of name.  The selector is subjected to $
    substitution and can consist of a single number or two numbers separated by
    a -.  The first word of a variable's 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.
    A range can be empty if the second argument is omitted or is in the range.

$#name
${#name}
    Specifies the number of words in the variable; useful for later use in a
    selector.

$0  Substitutes the name of the file from which command input is being read.






Processed November 8, 1990         CSH(1,C)                                   9





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



$number
${number}
    Equivalent to $argv[number] (see page         24 for information on the
    argv variable).

$*  Equivalent to $argv[*] (see page         24).

The modifiers :h, :t, :r, :q, and :x can be applied to the substitutions above
as can the combinations :gh, :gt, and :gr.  If braces { } appear in the command
form, the modifiers must appear within the braces.  Only one : modifier on each
$ expansion is allowed.  The following substitutions cannot be modified with :
modifiers.

$?name
${?name}
    Substitutes the string "1" if name is set and "0" if it is not.

$?0 Substitutes "1" if the current input file name is known and "0" if it is
    not known.

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

$<  Substitutes a line from the standard input with no further interpretation;
    used to read from the keyboard in a shell script.

Command and File-Name Substitution

Command and file-name substitution are applied selectively to the arguments of
built-in commands.  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
occurs in a child of the main shell after input and output redirection is
performed.

COMMAND SUBSTITUTION:  Command substitution is indicated by a command enclosed
in '.  The output from such a command is normally broken into separate words at
blanks, tabs, and new lines, with null words being discarded.  The resulting
text then replaces the original string.  Within ", only new lines force new
words; blanks and tabs are preserved.  In any case, the single final new line
does not force a new word.  Consequently, a command substitution can yield only
part of a word even if the command outputs a complete line.

FILE-NAME SUBSTITUTION:  If a word contains any of the characters *, ?, [, or
{, or begins with the character ~, that word is a candidate for file-name
substitution.  This word is then regarded as a pattern and replaced with an
alphabetically sorted list of file names that match the pattern.  The current
collating sequence is used, which can be specified by the environment variables
LC_COLLATE or LANG.  In a list of words specifying file-name substitution, not
every pattern has to match an existing file name; however, at least one pattern
must match.  Only the metacharacters *, ?, and [ imply pattern matching.





Processed November 8, 1990         CSH(1,C)                                  10





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



In matching file names, the character . (period) at the beginning of a file
name 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 characters
that match this pattern are defined by the current collating sequence (see
"ctab").

The character ~ at the beginning of a filename refers to home directories.
Standing alone, the ~ character expands to the invoker's home directory as
reflected in the value of the variable $HOME.  When ~ is followed by a name
consisting of letters, digits, and - characters, the shell searches for a user
with that name and substitutes the user's home directory.  Thus, ~ken expands
to /usr/ken and ~ken/chmach to /usr/ken/chmach.  If the character ~ is followed
by a character other than a letter or /, or if it does not appear at the
beginning of a word, it is left undisturbed.

For example, the meta-notation 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.  File name substitution can
be nested.  For example, ~source/s1/{oldls,ls}.c expands to
/usr/source/s1/oldls.c /usr/source/s1/ls.c if the home directory for source is
/usr/source.  Similarly, ../{memo,*box} expands to ../memo ../box ../mbox.
(Note that memo is not sorted with the results of matching *box.)  As a special
case, the characters {, }, and {} are passed unexpanded.

INPUT/OUTPUT

The standard input and standard output of a command can be redirected with the
following syntax:

< name
    Opens file name (which is first variable, command, and file-name expanded),
    as the standard input.

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









Processed November 8, 1990         CSH(1,C)                                  11





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



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

    If the variable noclobber is set, the file must not exist or be a character
    special file (for example, a terminal or /dev/null), which helps to prevent
    accidental destruction of files.  The ! forms can be used to suppress this
    check.

    The forms involving & route the diagnostic output into the specified file
    as well as the standard output.  The name specifier is expanded in the same
    way as < input file names are.

>> name
>>& name
>>! name
>>&! name
    Uses file name as standard output like > but places output at the end of
    the file.  If the variable noclobber is set, it is an error for the file
    not to exist, unless one of the ! forms is given.  Otherwise similar to >.

A command executes in 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 command run detached is not modified to
be the empty file /dev/null; rather, the standard input remains as the original
standard input of the shell.  If this is a terminal and if the process attempts
to read from the terminal, the process is blocked and the user is notified.

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

EXPRESSIONS

A number of the built-in commands (to be described later) take expressions, in
which the operators are similar to those of C, with the same precedence.  These
expressions appear in the @, exit, if, and while commands.  The following
operators are available:

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

Here the precedence increases to the right, "==  !=  =~" and "!~,  <=  >=  <"
and ">,  <<" and ">>,  +" and "-", "*  /" and "%" being, in groups, at the same



Processed November 8, 1990         CSH(1,C)                                  12





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



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 pattern (containing, for
example, "*", "?", and instances of "[...]") against which the left-hand
operand is matched.  This reduces the need for use of the switch statement in
shell scripts when all that is really needed is pattern matching.

Strings that 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.  No two components of an expression can appear in
the same word; they should be surrounded by spaces except when adjacent to
components of expressions which are syntactically significant to the parser (
"&  |  <  >  (  )" ).

Also available in expressions as primitive operands are command executions
enclosed in "{" and "}" and file inquiries of the form -l file where l is one
of:

r    The file exists and permits read access.
w    The file exists and permits write access.
x    The file exists and permits execute access.
e    The file exists.
o    The file exists and is owned by this user.
z    The file exists and has zero size.
f    The file exists and is a regular file.
d    The file exists and is a directory.

The specified file is command and file-name 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, all inquiries return false (that is, 0).  Command
executions succeed, returning true (that is, 1) if the command exits with
status 0; otherwise, they fail, returning false (0).  If more detailed status
information is required, the command should be executed outside of an
expression and the variable status examined.

The following example checks for the existence of the file /u/janie/core.  If
the file is found, the echo command runs.

  if ( -e /u/janie/core ) then
         echo "core file found."
  fi

CONTROL FLOW

The csh 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, because of the implementation, restrict the
placement of some of the commands.






Processed November 8, 1990         CSH(1,C)                                  13





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



The foreach, switch, and while statements, as well as the if-then-else form of
the if 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 this internal buffer to accomplish the
rereading implied by the loop.  (To the extent that this allows, backward gotos
will succeed on nonseekable inputs.)

BUILT-IN COMMANDS

Built-in commands are executed within the csh shell.  If a built-in command
occurs as any component of a pipeline except the last, it is executed in a
subshell.

alloc
    Shows the amount of dynamic memory acquired, broken down into used and free
    memory.  With an argument, shows the number of free blocks in each size
    category.  The categories start at size 8 and double at each step.  For
    example:

      alloc
      alloc "64"

alias
alias name
alias name wordlist
    The first form prints all aliases.  The second form prints the alias for
    name.  The final form assigns the specified wordlist as the alias of name;
    wordlist is command and file-name substituted.  name is not allowed to be
    alias or unalias.

bg
bg %job...
    Puts the current or specified jobs into the background, continuing them if
    they were stopped.

break
    Causes execution to resume after the end of the nearest enclosing foreach
    or while.  The remaining commands on the current line are executed.
    Multi-level breaks are thus possible by writing them all on one line.

breaksw
    Causes a break from a switch, resuming after the endsw.

case label:
    A label in a switch statement as discussed below.








Processed November 8, 1990         CSH(1,C)                                  14





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



cd
cd name
chdir
chdir name
    Changes the shell's working directory to directory name.  If no argument is
    given, changes to the home directory of the user.

    If name is not found as a subdirectory of the current directory (and does
    not begin with /, ./, or ../), each component of the variable cdpath is
    checked to see if it has a subdirectory name.  Finally, if all else fails
    but name is a shell variable whose value begins with /, this is tried to
    see if it is a directory.

continue
    Continues execution of the nearest enclosing while or foreach.  The rest of
    the commands on the current line are executed.

default:
    Labels the default case in a switch statement.  The default should come
    after all case labels.

dirs
    Prints the directory stack; the top of the stack is at the left, the first
    directory in the stack being the current directory.

echo wordlist
echo -n wordlist
    The specified words are written to the shell's standard output, separated
    by spaces, and terminated with a new-line character unless the -n option is
    specified.

else
end
endif
endsw
    See the description of the foreach, if, switch, and while statements below.

eval arg...
    The arguments are read as input to the shell and the resulting command(s)
    executed in the context 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.

exec command
    The specified command is executed in place of the current shell.

exit
exit (expr)
    The shell exits either with the value of the status variable (first form)
    or with the value of the specified expr (second form).





Processed November 8, 1990         CSH(1,C)                                  15





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



fg
fg %job...
    Brings the current or specified jobs into the foreground, continuing them
    if they were stopped.

foreach name (wordlist)
...
end The variable name is successively set to each member of wordlist, and the
    sequence of commands between this command and the matching end are
    executed.  (Both foreach and end must appear alone on separate lines.)

    The built-in command continue may be used to continue the loop prematurely,
    and the built-in command break used 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 executed.  If you make a mistake
    typing in a loop at the terminal, you can backspace to retype it (depending
    on the user setup).

glob wordlist
    Like echo, 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 file-name expand a list of words.

goto word
    The specified word is file-name 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.

history
history n
history -r n
history -h n
    Displays the history event list; if n is given, only the n most recent
    events are printed.  The -r option reverses the order of printout to be
    most recent first rather than oldest first.  The -h option causes the
    history list to be printed without leading numbers.  This is used to
    produce files suitable to source using the -h option.

if (expr) command
    If the specified expression evaluates true, the single command with
    arguments is executed.  Variable substitution on command happens early, at
    the same time it does for the rest of the if command.  command must be a
    simple command, not a pipeline, a command list, or a parenthesized command
    list.  Input/output redirection occurs even if expr is false, the second
    command is not executed.









Processed November 8, 1990         CSH(1,C)                                  16





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



if (expr) then
...
else if (expr2) then
...
else
...
endif
    If the specified expr is true, the commands up to the first else are
    executed; otherwise, if expr2 is true, the commands up to the second else
    are executed, etc.  Any number of else-if pairs are possible; only one
    endif is needed.  The else part is likewise optional.  (The words else and
    endif must appear at the beginning of input lines; the if must appear alone
    on its input line or after an else.)

jobs
jobs -l
    Lists the active jobs; given the -l options lists process IDs and execution
    cluster site name, in addition to the normal information.

kill %job
kill -sig % job...
kill pid
kill -sig pid...
kill -l
    Sends either the TERM (terminate) signal or the specified signal to the
    specified jobs or processes.  Signals are either given by number or by
    names (as given in /usr/include/signal.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), the job or process will be sent a CONT
    (continue) signal as well.

limit
limit resource
limit resource maximum-use
limit -h
limit -h resource
limit -h resource maximum-use
    Limits the consumption by the current process and each process it creates
    to not individually exceed maximum-use on the specified resource.  If no
    maximum-use is given, the current limit is printed; if no resource is
    given, all limitations are given.  If the -h flag is given, the hard limits
    are used instead of the current limits.  The hard limits impose a ceiling
    on the values of the current limits.  Only the superuser may raise the hard
    limits, but a user may lower or raise the current limits within the legal
    range.

    Resources controllable currently include cputime (the maximum number of
    CPU-seconds to be used by each process), filesize (the largest single file
    which can be created), datasize (the maximum growth of the data region via
    sbrk (see sbrk in AIX Operating System Technical Reference) beyond the end
    of the program text), stacksize (the maximum size of the



Processed November 8, 1990         CSH(1,C)                                  17





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



    automatically-extended stack region), and coredumpsize (the size of the
    largest core dump that will be created).

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

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

logout
    Terminates a login shell.  Especially useful if ignoreeof is set.

migrate pid
migrate -site pid
migrate % job
migrate -site % job
migrate -site
    Moves a process or job between sites.  In the first and third forms
    (without a -site flag) the process or job is migrated to the site on which
    the csh is running.  In the second and fourth forms (that include a -site
    flag), the process or job is migrated to the specified site.  In the fifth
    form, the csh itself will migrate to the specified site.  In all cases, the
    site to which the process or job is to migrate must be of the same CPU type
    as the site on which the process or job is running, or no migration will
    occur.

    When the shell is migrated by migrate -site (or migrate -site $$), the
    shell will perform a setlocal system call to set the <LOCAL> to the default
    local for the new site.  (See the setlocal system call in AIX Operating
    System Technical Reference and "printlocal").

nice
nice +number
nice command
nice +number command
    The first form sets the scheduling priority for this shell to 4.  The
    second form sets the priority to the given number.  The final two forms run
    the specified command at priority 4 and number respectively.  The greater
    the number, the less CPU the process will get.  The superuser may specify
    negative priority by using nice -number. command is always executed in a
    subshell, and the restrictions placed on commands in simple if statements
    apply.

nohup
nohup command
    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 nohup'ed.



Processed November 8, 1990         CSH(1,C)                                  18





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)




notify
notify %job...
    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 notify is set.

onsite [-v] sitename command [arg...]
onsite [-v] sitenumber command [arg...]
onsite [-v] sitetype command [arg...]
    The command is run on the specified site or on a site of the specified
    sitetype.  If a sitename or sitenumber is given, the command is run on the
    specified site if it is accessible in the current partition.  If a sitetype
    is given, the command is run on a site of the specified type if any are
    available.

    The possible sitetype values are:

    i386    An AIX PS/2 system.

    i370    An AIX/370 system.

    xa370   An XA AIX/370 system.

    s370    A non-XA AIX/370 system.

    The command is run on the chosen site with the <LOCAL> alias set to refer
    to that site.  The onsite prefix can precede built-in commands, which still
    execute locally but has the <LOCAL> alias set to the specified site.  The
    arg... is passed as arguments to command.

    Input-output redirection is done before the execution site is set, so that
    the <LOCAL> alias used for input-output redirection may be different than
    the one that the executed command will use.  This is done for compatibility
    with shells that don't have the onsite command built in and so execute the
    separate onsite command (see "onsite, on"), but may cause some confusion.
    For example, if the csh is running on site atlas, then onsite polaris cat <
    /tmp/foo will display the contents of /atlas/tmp/foo, while onsite polaris
    cat /tmp/foo will display the contents of /polaris/tmp/foo, since in the
    first case the shell opened /tmp/foo using its <LOCAL> alias, while in the
    second the cat command opened /tmp/foo with its <LOCAL> alias set to
    polaris' local.  If the -v option is given, the shell will tell the user
    which site is being used in the command.

onintr
onintr -
onintr label
    controls 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




Processed November 8, 1990         CSH(1,C)                                  19





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



    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 onintr have no meaning, and interrupts continue to be
    ignored by the shell and all invoked commands.

popd
popd +n
    Pops the directory stack, returning to the new top directory.  With an
    argument +n discards the nth entry in the stack.  The directory stack
    elements are numbered from 0 starting at the top.

pushd
pushd name
pushd +n
    With no arguments, pushd exchanges the top two elements of the directory
    stack.  Given a name argument, pushd changes to the new directory (as with
    cd) and pushes the old current working directory (as in cwd) 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.

rehash
    Causes the internal hash table of the contents of the directories in the
    path variable to be recomputed.  This is needed if new commands are added
    to directories in the path 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.

repeat count command
    The specified command, which is subject to the same restrictions as the
    command in the one line if statement above, is executed count times.  I/O
    redirections occur exactly once, even if count is 0.

set
set name
set name=word
set name[index]=word
set name=(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 name to the null string.
    The third form sets name to the single word.  The fourth form sets the
    index'ed component of name to word; this component must already exist.  The
    final form sets name to the list of words in wordlist.  In all cases, the
    value is command and file-name 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.




Processed November 8, 1990         CSH(1,C)                                  20





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



setenv
setenv name value
setenv name
    The first form lists all current environment variables.  The second form
    sets the value of environment variable name to be value, a single string.
    The last form sets name to an empty string.  The most commonly used
    environment variable USER, TERM, and PATH are automatically imported to and
    exported from the csh variables user, term, and path; there is no need to
    use setenv for these.

    If you modify the environment variables LANG, LC_COLLATE, LC_CTYPE,
    LC_MESSAGE, LC_TIME, or LC_MONETARY, the current international character
    support environment and collating sequences are changed as specified for
    subsequent commands executed from the shell.

setspath [ LOCAL | site | cpu ] ...
    Sets the site path.  Sites may be specified by name or by number.  CPU
    types may be specified by the same names which are used in hidden
    directories.  If an argument is specified as LOCAL, a "nullsite" site path
    entry is created (see setspath in the AIX Operating System Technical
    Reference).  The arguments to this command are file name and command
    substituted.

    Use this command with caution.  A poorly formed site path can make it
    difficult to execute any commands.

setxvers
setxvers string
    The first form removes any experimental-version prefix.  The second form
    sets the experimental-version prefix to string.  The prefix is used when
    searching hidden directories for executable files.  A hidden directory
    component whose name begins with the prefix is selected for execution in
    preference to a component whose name does not begin with string.  The
    experimental-version prefix is inherited by child processes.  See AIX
    Operating System Technical Reference for more information on hidden
    directories and executable hidden directory components.

shift
shift variable
    The members of argv are shifted to the left, discarding argv[1].  It is an
    error for argv not to be set or to have less than one word as value.  The
    second form performs the same function on the specified variable.

source name
source -h name
    The shell reads commands from name.  source commands may be nested; if they
    are nested too deeply, the shell may run out of file descriptors.  An error
    in a source at any level terminates all nested source commands.  Normally
    input during source commands is not placed on the history list; the -h
    option causes the commands to be placed in the history list without being
    executed.




Processed November 8, 1990         CSH(1,C)                                  21





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



stop
stop %job...
    Stops the current or specified job which is executing in the background.

suspend
    Causes the shell to stop in its tracks, much as if it had been sent a stop
    signal with ^Z.  This is most often used to stop shells started by su.
    (See "su.")

switch (string)
case str1:
...
breaksw
...
default:
...
breaksw
endsw
    Each case label is successively matched, against the specified string,
    which is first command and file-name 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, execution
    begins after the default label.  Each case label and the default label must
    appear at the beginning of a line.  The command breaksw causes execution to
    continue after the endsw.  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 endsw.

time
time command
    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 summary as described under the time variable is printed.  If
    necessary, an extra shell is created to print the time statistic when the
    command completes.  A sample output of time command is as follows:

      0.5u 0.4s O:04.3 24% 18+125k 20+0io 14pf+0w

    0.5u        User-mode CPU time consumed by the command.

    0.4s        CPT time consumed by the system running on behalf of the
                command.

    18+125k     Time-averaged integral of the (shared) text space used by the
                command, in units of kilobytes-times-seconds.

    0:04.3      Prints the elapsed time to tenths of a second.

    24%         Percentage of CPU utilization of this command, computed as the
                sum of user and system CPU time divided by the elapsed time.





Processed November 8, 1990         CSH(1,C)                                  22





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



    20+0io      Prints the number of block-I/O reads performed on behalf of the
                process.

    14pf+0w     Prints number of swaps occurring during execution of the
                command.

umask
umask value
    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.

unalias pattern
    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
    unaliased.

unhash
    Use of the internal hash table to speed location of executed programs is
    disabled.

unlimit
unlimit resource
unlimit -h
unlimit -h resource
    Removes the limitation on resource.  If no resource is specified, all
    resource limitations are removed.  If -h is given, the corresponding hard
    limits are removed.  Only the superuser may do this.

unset pattern
    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 unset.

unsetenv pattern
    Removes all variables whose name match the specified pattern from the
    environment.  See also the setenv command.

wait
    All background jobs are waited for.  If the shell is interactive, an
    INTERRUPT can disrupt the wait, at which time the shell prints names and
    job numbers of all jobs known to be outstanding.

while (expr)
...
end While the specified expression evaluates nonzero, the commands between the
    while and the matching end are evaluated.  break and continue may be used
    to terminate or continue the loop prematurely.  (The while and end must
    appear alone on their input lines.)  Prompting occurs here the first time
    through the loop as for the foreach statement if the input is a terminal.



Processed November 8, 1990         CSH(1,C)                                  23





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)




%job
    Brings the specified job into the foreground.

%job &
    Continues the specified job in the background.

@
@ name = expr
@ name[index] = expr
    The first form prints the values of all the shell variables.  The second
    form sets the specified name to the value of expr.  If the expression
    contains <, >, &, or |, then at least this part of the expression must be
    placed within ( ).  The third form assigns the value of expr to the indexed
    argument of name.  Both name and its indexed 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 expr, which would otherwise be single
    words.

    Special postfix ++ and - - operators increment and decrement name
    respectively, for example, @  i++.

PREDEFINED AND ENVIRONMENT VARIABLES

The following variables have special meaning to the csh shell.  Of these, argv,
cwd, home, path, prompt, shell, and status are always set by the shell.  Except
for cwd and status, this setting occurs only at initialization; these variables
will not then be modified unless this is done explicitly by the user.

The csh shell copies the environment variable USER into the variable user, TERM
into term, and HOME into home, 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 .cshrc, as inferior csh processes will import the definition of
path from the environment, and re-export it if you change it.

argv           Set to the arguments to the shell, it is from this variable that
               positional parameters are substituted, that is, $1 is replaced
               by $argv[1], etc.

cdpath         Gives a list of alternate directories searched to find
               subdirectories in chdir commands.

cwd            The full path name of the current directory.

echo           Set when the -x command line option is given.  Causes each
               command and its arguments to be echoed just before it is
               executed.  For non-built-in commands, all expansions occur
               before echoing.  Built-in commands are echoed before command and




Processed November 8, 1990         CSH(1,C)                                  24





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



               file-name substitution, since these substitutions are then done
               selectively.

filec          Enable file-name completion.

histchars      Can 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.

history        Can be given a numeric value to control the size of the history
               list.  Any command which has been referenced within this many
               events will not be discarded.  Too large values of history may
               run the shell out of memory.  The last executed command is
               always saved on the history list.

home           The home directory of the invoker, initialized from the
               environment.  The file name expansion of ~ refers to this
               variable.

ignoreeof      If set, the shell ignores end-of-file from input devices which
               are terminals.  This prevents shells from accidentally being
               killed by Ctrl-Ds.

mail           The files where the shell checks for mail.  This is done after
               each command completion, 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 mail is numeric, it specifies
               a different mail checking interval, in seconds, than the
               default, which is 10 minutes.

               If multiple mail files are specified, the shell says New mail in
               name when there is mail in the file name.

noclobber      As described in the section on "Input/output", restrictions are
               placed on output redirection to insure that files are not
               accidentally destroyed and that >> redirections refer to
               existing files.

noglob         If set, file name expansion is inhibited.  This is most useful
               in shell scripts which are not dealing with file names, or after
               a list of file names has been obtained and further expansions
               are not desirable.

nonomatch      If set, it is not an error for a file-name 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, for example, echo [ still gives an error.



Processed November 8, 1990         CSH(1,C)                                  25





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)




notify         If set, the shell notifies asynchronously of job completions.
               The default is rather to present job completions just before
               printing a prompt.

path           Each 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 path variable, 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
               superuser, the default search path is /etc, /bin, and /usr/bin.
               A shell which is given neither the -c nor the -t option will
               normally hash the contents of the directories in the path
               variable after reading .cshrc and each time the path variable is
               reset.  If new commands are added to these directories while the
               shell is active, it may be necessary to give the rehash, or the
               commands may not be found.

prompt         The string which is printed before each command is read from an
               interactive terminal input.  If a ! appears in the string and
               ONLY if the ! is preceded by a \ will it be replaced by the
               current event number.  Default is %, or # for the superuser.

savehist       Is 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 within this many
               events will be saved.  During startup the shell sources
               ~/.history into the history list, enabling history to be saved
               across logins.  Too large values of savehist will slow down the
               shell during startup.

shell          The 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
               "Nonbuilt-in Command Execution" below.)  Initialized to the
               (system-dependent) home of the shell.

status         The status returned by the last command.  If it terminated
               abnormally, 0200 is added to the status.  Built-in commands
               which fail return exit status 1, all other built-in commands set
               status 0.

time           Controls automatic timing of commands.  If the first or only
               word of its value is numeric, then any command that takes more
               than this many CPU seconds will cause a line showing the
               resources utilized by the command and all its children to be
               printed.  If the value of the time variable has two words, the
               second is used as a format string controlling the printing of
               the resource information.  The string is interpreted similarly
               to the format string used by printf (see printf in AIX Technical
               Reference).  The % character identifies characters that will be
               replaced by certain resource information.  If the value of the



Processed November 8, 1990         CSH(1,C)                                  26





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



               time variable has only one word, the string used is "%Uu %Ss %E
               %P %X+%Dk %I+%Oio %Fpf+%Ww".  The following characters can be
               used in the format string:

U      Prints the user-mode CPU time consumed by the command.

S      Prints the CPU time consumed by the system running on behalf of the
       command.

E      Prints the elapsed time to tenths of a second.

P      Prints the percentage CPU utilization of this command.  This is computed
       as the sum of user and system CPU time divided by the elapsed time.

W      Prints number of swaps suffered by the command.

X      Prints the time-averaged integral of the (shared) text space used by the
       command, in units of kbytes times seconds.

D      Prints the time-averaged integral of the (unshared) data and stack space
       used by the command, in units of kbytes times seconds.

K      Prints the time-averaged integral of the total space used by the
       command, in units of kbytes times seconds.

M      Prints the maximum amount of memory in use by the command at any time,
       in units of kbytes.

F      Prints the number of "major" page faults suffered by the command.  These
       are page faults where the page had to be brought in from disk.

R      Prints the number of "minor" page faults suffered by the command.

I      Prints the number of block-I/O reads performed on behalf of the process.

verbose
       Set by the -v command line option, causes the words of each command to
       be printed after history substitution.

NONBUILT-IN COMMAND EXECUTION

When a command to be executed is found to not be a built-in command, the shell
attempts to execute the command via execve.  Each word in the variable path
names a directory from which the shell will attempt to execute the command.  If
it is given neither a -c nor a -t option, the shell will hash the names in
these directories into an internal table so that it will only try an exec 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 unhash) or if
the shell was given a -c or -t argument (and in any case for each directory
component of path which does not begin with a /), the shell concatenates with




Processed November 8, 1990         CSH(1,C)                                  27





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



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 home directory; leaving you where you were (printing this after
the home directory); while cd ; pwd leaves you in the home directory.
Parenthesized commands are most often used to prevent chdir from affecting the
current shell.

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

If there is an alias for shell, the words of the alias will be prepended to the
argument list to form the shell command.  The first word of the alias should be
the full path name of the shell (for example, $shell).  This is a special,
late-occurring case of alias substitution and only allows words to be prepended
to the argument list without modification.

ARGUMENT LIST PROCESSING

If argument 0 to the shell is -, this is a login shell.  The flag arguments are
interpreted as follows:

-b   This flag forces a break from option processing, causing any further shell
     arguments to be treated as nonoption 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.

-c   Commands are read from the (single) following argument, which must be
     present.  Any remaining arguments are placed in argv.

-e   The shell exits if any invoked command (other than built-in commands)
     terminates abnormally or yields a nonzero exit status.  Without this flag,
     the shell does not exit if any invoked command returns a nonzero exit
     status.

     Note:  The shell always exits if any built-in command returns a nonzero
            exit status, even if the -e flag is set.

-f   The shell will start faster, because it will neither search for nor
     execute commands from the file .cshrc in the invoker's home directory.

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

-n   Commands are parsed but not executed.  This aids in syntactic checking of
     shell scripts.





Processed November 8, 1990         CSH(1,C)                                  28





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



-s   Command input is taken from the standard input.

-t   A single line of input is read and executed.  A \ can be used to escape
     the new-line character at the end of this line and continue onto another
     line.

-v   Causes the verbose variable to be set, with the effect that command input
     is echoed after history substitution.

-V   Causes the verbose variable to be set even before .cshrc is executed.

-x   Causes the echo variable to be set, so that commands are echoed
     immediately before execution.

-X   Causes the echo variable to be set even before .cshrc is executed.

After processing of flag arguments, if arguments remain but none of the -c, -i,
-s, or -t options 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 re-substitution by $0.

If the first characters of the shell procedure are #!shell_path name, csh runs
the specified shell to process the procedure.  Otherwise, csh runs the standard
shell (sh).  Remaining parameters initialize the arg variable.  For more
information on the #!shell_path name comment, see the exec system call in AIX
Operating System Technical Reference.

SIGNAL HANDLING

The shell normally ignores QUIT signals.  Jobs running detached (either by & or
the bg or %...& commands) are immune to signals generated from the keyboard,
including HANGUPS.  Other signals have the values which the shell inherited
from its parent.  The shell's handling of INTERRUPTS and TERMINATE signals in
shell scripts can be controlled by onintr.  Login shells catch the TERMINATE
signal; otherwise, this signal is passed on to children from the state in the
shell's parent.  In no case are INTERRUPTS allowed when a login shell is
reading the file .logout.

FILES

~/.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.
/tmp/sh*       Temporary file for <<.
/etc/passwd    Source of home directories for ~name.

LIMITATIONS

Words can be no longer than 1024 characters.  The system limits argument lists
to a maximum of 10240 characters.  If you have selected a language (through the
LANG environment variable) that supports multibyte characters, these character



Processed November 8, 1990         CSH(1,C)                                  29





CSH(1,C)                    AIX Commands Reference                     CSH(1,C)



limits may be reduced by as much as 50%, depending on the character code set
being used.

The number of arguments to a command which involves file name expansion is
limited to 1/6th 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 alias substitutions
on a single line to 20.

NOTES

When 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 (that is, wrong), as the job may have changed directories
internally.

Shell built-in functions are not stoppable and restartable, nor are command
sequences of the form command1; command2; command3.  If you suspend command2,
the shell immediately executes command3.  This is especially noticeable if this
expansion results from an alias.  It suffices to place the sequence of commands
in parentheses, "( command1; command2; command3 )", to force it to a subshell.

RELATED INFORMATION

See the following commands:  "cd,"  "make,"  "pr," and "sh, Rsh."

See the access, exec, fork, pipe, umask, and wait system calls, the a.out and
environ files, and the environment miscellaneous facility in AIX Operating
System Technical Reference.

See "Overview of International Character Support" in Managing the AIX Operating
System.























Processed November 8, 1990         CSH(1,C)                                  30



Typewritten Software • bear@typewritten.org • Edmonds, WA 98026