Manual page for CSH_BUILTINS(1)
csh, %, @, alias, bg, break, breaksw, case, continue, default, dirs, else, end, endif, endsw, eval, exec, exit, fg, foreach, glob, goto, hashstat, history, if, jobs, label, limit, logout, notify, onintr, popd, pushd, rehash, repeat, set, setenv, shift, source, stop, suspend, switch, then, umask, unalias, unhash, unlimit, unset, unsetenv, while - C shell built-in commands, see .Hr -url ../html1/csh.1.html csh(1)
C-SHELL BUILTIN COMMANDS
Built-in commands are executed within the C shell.
If a built-in command occurs as any component of a pipeline
except the last, it is executed in a subshell.
- :
-
Null command. This command is interpreted, but performs no action.
- alias
[
name
[
def
] ]
-
Assign
def
to the alias
name.
def
is a list of words that may contain escaped history-substitution
metasyntax.
name
is not allowed to be
alias
or
unalias.
If
def
is omitted, the alias
name
is displayed along with its current definition. If both
name
and
def
are omitted, all aliases are displayed.
- bg
[%job] ...
-
Run the current or specified jobs in the background.
- break
-
Resume execution after the
end
of the nearest enclosing
foreach
or
while
loop.
The remaining commands on the current line
are executed. This allows multilevel breaks to be written as a
list of
break
commands, all on one line.
- breaksw
-
Break from a
switch,
resuming after the
endsw.
- case label:
-
A label in a
switch
statement.
- cd
[
dir
]
-
- chdir
[
dir
]
-
Change the shell's working directory to directory
dir.
If no argument is given, change to the home directory of the user.
If
dir
is a relative pathname not found in the current directory, check for
it in those directories listed in the
cdpath
variable. If
dir
is the name of a shell variable whose value starts with a
/,
change to the directory named by that value.
- continue
-
Continue execution of the nearest enclosing
while
or
foreach.
- default:
-
Labels the default case in a
switch
statement.
The default should come after all
case
labels.
Any remaining commands on the command line are first executed.
- dirs
[
-l
]
-
Print the directory stack, most recent to the left;
the first directory shown is the current directory.
With the
-l
argument, produce an unabbreviated printout; use of the
~
notation is suppressed.
- echo
[
-n
]
list
-
The words in
list
are written to the shell's standard output, separated by
SPACE
characters.
The output is terminated with a
NEWLINE
unless the
-n
option is used.
- eval argument ...
-
Reads the arguments as input to the shell, and executes the resulting
command(s). This is usually used to execute commands
generated as the result of command or variable substitution, since
parsing occurs before these substitutions. See
tset.1
for an example of how to use
eval.
- exec command
-
Execute
command
in place of the current shell, which terminates.
- exit
[
(expr)
]
-
The shell exits, either with the value of the status
variable, or with the value of the specified by the expression
expr.
- fg %
[
job
]
-
Bring the current or specified
job
into the foreground.
- foreach var (wordlist)
-
- ...
-
- end
-
The variable
var
is successively set to each member of
wordlist.
The sequence of commands between this command and the matching
end
is executed for each new value of
var.
(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
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.
- glob wordlist
-
Perform filename expansion on
wordlist.
Like
echo,
but no
\
escapes are recognized. Words are delimited by
null
characters in the output.
- goto label
-
The specified
label
is filename and command expanded to yield a label.
The shell rewinds its input as much as possible
and searches for a line of the form
label:
possibly preceded by
SPACE
or
TAB
characters.
Execution continues after the indicated line.
It is an error to jump to a label that occurs between a
while
or
for
built-in, and its corresponding
end.
- hashstat
-
Print a statistics line indicating how effective the internal hash
table has been at locating commands (and avoiding
execs).
An
exec
is attempted for each component of the
path
where the hash function indicates a possible hit, and in each component
that does not begin with a
`/'.
- history
[
-hr
] [
n
]
-
Display the history list; if
n
is given, display only the
n
most recent events.
-
- -r
-
Reverse the order of printout to be most recent first rather than oldest first.
- -h
-
Display the history list without leading numbers.
This is used to produce files suitable for sourcing using the
-h
option to
source.
- if (expr) command
-
If the specified expression evaluates to 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. Note: I/O redirection occurs even
if
expr
is false, when
command
is
not
executed (this is a bug).
- if (expr) then
-
- ...
-
- else if (expr2) then
-
- ...
-
- else
-
- ...
-
- endif
-
If
expr
is true, commands up to the first
else
are executed. Otherwise, if
expr2
is true, the commands between the
else if
and the second
else
are executed. Otherwise, commands between the
else
and the
endif
are executed.
Any number of
else if
pairs are allowed, but only one
else.
Only one
endif
is needed, but it is required.
The words
else
and
endif
must be the first nonwhite characters on a line.
The
if
must appear alone on its input line or after an
else.)
- jobs[ -l ]
-
List the active jobs under job control.
-
- -l
-
List process
IDs,
in addition to the normal information.
- kill
[
-sig
] [
pid
] [
%job
] ...
-
- kill -l
-
Send the
TERM
(terminate) signal, by default, or the signal specified, to the
specified process
ID,
the
job
indicated, or the current
job.
Signals are either given by number or by name.
There is no default. Typing
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 process is sent a
CONT
(continue) signal as well.
-
- -l
-
List the signal names that can be sent.
- limit
[
-h
] [
resource
[
max-use
] ]
-
Limit the consumption by the current process or any process it spawns,
each not to exceed
max-use
on the specified
resource.
If
max-use
is omitted, print the current limit; if
resource
is omitted, display all limits.
-
- -h
-
Use hard limits instead of the current limits. Hard limits impose a
ceiling on the values of the current limits. Only the super-user may
raise the hard limits.
resource
is one of:
-
- cputime
-
Maximum
CPU
seconds per process.
- filesize
-
Largest single file allowed.
- datasize
-
Maximum data size (including stack) for the process.
- stacksize
-
Maximum stack size for the process.
- coredumpsize
-
Maximum size of a core dump (file).
- descriptors
-
Maximum value for a file descriptor.
max-use
is a number, with an optional scaling factor, as follows:
-
- nh
-
Hours (for
cputime).
- nk
-
n
kilobytes.
This is the default for all but
cputime.
- nm
-
n
megabytes or minutes (for
cputime).
- mm:ss
-
Minutes and seconds (for
cputime).
- login
[
username|-p
]
-
Terminate a login shell and invoke
login.1
The
.logout
file is not processed. If
username
is omitted,
login
prompts for the name of a user.
-
- -p
-
Preserve the current environment (variables).
- logout
-
Terminate a login shell.
- nice
[
+n|-n
] [
command
]
-
Increment the process priority value for the shell or for
command
by
n.
The higher the priority value, the lower the priority of a process, and
the slower it runs.
When given,
command
is always run in a subshell, and the restrictions placed on
commands in simple
if
commands apply.
If
command
is omitted,
nice
increments the value for the current shell.
If no increment is specified,
nice
sets the nice value to 4. The range of nice values is
from -20 through 19. Values of
n
outside this range set the value to the lower, or to the higher
boundary, respectively.
-
- +n
-
Increment the process priority value by
n.
- -n
-
Decrement by
n.
This argument can be used only by the super-user.
- nohup
[
command
]
-
Run
command
with
HUPs
ignored. With no arguments, ignore
HUPs
throughout the remainder of a script.
When given,
command
is always run in a subshell, and the restrictions placed on
commands in simple
if
commands apply.
All processes detached with
&
are effectively
nohup'd.
- notify
[
%job
] ...
-
Notify the user asynchronously when the status of the current, or of specified
jobs, changes.
- onintr
[ - |
label]
-
Control the action of the shell on interrupts.
With no arguments,
onintr
restores the default action of the shell on interrupts.
(The shell terminates shell scripts and returns to the
terminal command input level).
With the
-
argument, the shell ignores all interrupts.
With a
label
argument, the shell executes a
goto label
when an interrupt is received or a child process terminates because
it was interrupted.
- popd
[+n]
-
Pop the directory stack, and
cds
to the new top directory.
The elements of the directory stack are numbered from 0 starting at the top.
-
- +n
-
Discard the
n'th
entry in the stack.
- pushd
[+n |
dir]
-
Push a directory onto the directory stack.
With no arguments, exchange the top two elements.
-
- +n
-
Rotate the
n'th
entry to the top of the stack and
cd
to it.
- dir
-
Push the current working directory onto the stack and change to
dir.
- rehash
-
Recompute the internal hash table of the contents of directories listed
in the
path
variable to account for new commands added.
- repeat count command
-
Repeat
command
count
times
command
is subject to the same restrictions as with the one-line
if
statement.
- set
[var
[
= value
] ]
-
- set var[n] = word
-
With no arguments,
set
displays the values of all shell variables. Multiword values
are displayed as a parenthesized list. With the
var
argument alone,
set
assigns an empty (null) value to the variable
var.
With arguments of the form
var = value
set
assigns
value
to
var,
where
value
is one of:
-
-
- word
-
A single word (or quoted string).
- (wordlist)
-
A space-separated list of words enclosed in parentheses.
Values are command and filename expanded before being assigned.
The form
set var[n] = word
replaces the
n'th
word in a multiword value with
word.
- setenv
[
VAR
[
word
] ]
-
With no arguments,
setenv
displays all environment variables.
With the
VAR
argument sets the environment variable
VAR
to have an empty (null) value. (By convention, environment
variables are normally given upper-case names.)
With both
VAR
and
word
arguments
setenv
sets the environment variable
NAME
to the value
word,
which must be either a single word or a quoted string.
The most commonly used environment variables,
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.
In addition,
the shell sets the
PWD
environment variable from the
csh
variable
cwd
whenever the latter changes.
- shift
[
variable
]
-
The components of
argv,
or
variable,
if supplied, are shifted to the left, discarding
the first component.
It is an error for the variable not to be set, or to have a null value.
- source
[
-h
]
name
-
Reads commands from
name.
source
commands may be nested, but if they are nested too deeply the shell may
run out of file descriptors.
An error in a sourced file at any level terminates all nested
source
commands.
-
- -h
-
Place commands from the file
name
on the history list without executing them.
- stop
[%job] ...
-
Stop the current or specified background job.
- suspend
-
Stop the shell 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.
- switch (string)
-
- case label:
-
- ...
-
- breaksw
-
- ...
-
- default:
-
- ...
-
- breaksw
-
- endsw
-
Each
label
is successively matched, against the specified
string,
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,
execution begins after the default label.
Each
case
statement and the
default
statement must appear at the beginning of a line.
The command
breaksw
continues execution after the
endsw.
Otherwise control falls through subsequent
case
and
default
statements as with C.
If no label matches and there is no default, execution continues after
the
endsw.
- time
[
command
]
-
With no argument, print a summary of time used by
this C shell and its children.
With an optional
command,
execute
command
and print a summary of the time it uses.
- umask
[
value
]
-
Display the file creation mask.
With
value
set the file creation mask.
value
is given in octal, and is
XORed
with the permissions of 666 for files and 777 for directories to arrive
at the permissions for new files.
Common values include 002, giving complete access to the group, and
read (and directory search) access to others, or 022, giving read
(and directory search) but not write permission to the group and others.
- unalias pattern
-
Discard aliases that match (filename substitution)
pattern.
All aliases are removed by
unalias *.
- unhash
-
Disable the internal hash table.
- unlimit
[
-h
] [
resource
]
-
Remove a limitation on
resource.
If no
resource
is specified, then all
resource
limitations are removed.
See the description of the
limit
command for the list of
resource
names.
-
- -h
-
Remove corresponding hard limits. Only the super-user may do this.
- unset pattern
-
Remove variables whose names match (filename substitution)
pattern.
All variables are removed by
`unset *';
this has noticeably distasteful side-effects.
- unsetenv variable
-
Remove
variable
from the environment.
Pattern matching, as with
unset
is not performed.
- wait
-
Wait for background jobs to finish (or for an interrupt) before
prompting.
- while (expr)
-
- ...
-
- end
-
While
expr
is true (evaluates to non-zero), repeat commands between the
while
and the matching
end
statement.
break
and
continue
may be used to terminate or continue the loop prematurely.
The
while
and
end
must appear alone on their input lines.
If the shell's input is a terminal, it prompts for commands
with a question-mark until the
end
command is entered and then performs the commands in the loop.
- %[
job
] [
&
]
-
Bring the current or indicated
job
to the foreground.
With the ampersand, continue running
job
in the background.
- @
[
var
=expr
]
-
- @
[
var[n]
=expr
]
-
With no arguments, display the values for all shell variables.
With arguments,
the variable
var,
or the
n'th
word in the value of
var,
to the value that
expr
evaluates to.
(If
[n]
is supplied, both
var
and its
n'th
component must already exist.)
If the expression contains the characters
>,
<,
&
or
|,
then at least this part of
expr
must be placed within parentheses.
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
that would otherwise be single words.
Special postfix operators,
++
and
--
increment or decrement
name,
respectively.
SEE ALSO
csh(1), sh(1)
Created by unroff & hp-tools.
© somebody (See intro for details). All Rights Reserved.
Last modified 11/5/97