csh(1) DG/UX R4.11MU05 csh(1)
NAME
csh - invoke a shell (command interpreter) having a C-like syntax
SYNOPSIS
csh [ -bcefinstvVxX ] [ script ] [ arg ... ]
where:
script The pathname of a file containing a C shell script.
arg An argument to the script.
DESCRIPTION
The csh command invokes a C shell, a command interpreter, which was
developed at the University of California at Berkeley. The C shell
is both a command line interpreter and a programming language, which
allows you to compose executable shell scripts.
The primary attributes of the C shell are job control, history, and
aliasing. The C shell also has predefined variables to prevent
accidental file overwrites and log offs, and to disable filename
expansion.
Through the C shell, you can enable editread, an optional command
line editor. The editread history facility is similar to the C
shell's, but its implementation and use are different. Refer to
editread(5) for more information.
This man page covers the following csh topics:
-- Command Line Options
-- Initialization and Termination
-- Command Line Words
-- Quoting Special Characters
-- Predefined Variables
-- Built-in Commands
-- Filename Completion
-- History Substitution
-- Aliasing
-- Job Control
-- Pipes, Sequential Command Processes, and Command Groups
-- Input/Output Redirection
-- Variables and Variable Substitution
-- Command Substitution
-- File Substitution
-- Expressions and Operators
-- Signal Handling and Status Reporting
-- Parsing Order and Execution
-- International Features
Command Line Options
-b Force a "break" from option processing. Subsequent command-line
arguments are not interpreted as C shell options. This allows
the passing of options to a script without confusion. The shell
does not run a set-user-ID script unless this option is present.
-c Reads commands from the first argument (a filename), which must
be present. Any remaining arguments on the command line are
placed in the predefined shell variable argv, which stores the
argument list.
-e Exits if any invoked command terminates abnormally or yields a
nonzero exit status.
-f Fast start-up; does not search for or execute commands from the
.cshrc file or the .login file (if in a login shell), thus
reducing shell start-up time.
-i Forced interactive; prompts for input from the terminal, even if
standard input does not appear to be a terminal (for example, a
special character device). If a shell's I/O devices are
terminals, interactive operation is assumed without having to
set this option.
-n Parses but does not execute commands. This may aid in syntactic
checking of shell scripts.
-s Takes commands from standard input.
-t Takes one line of input to read and execute. You can use a
backslash (\) to escape each terminating new-line so that input
can continue on the next line.
-v Sets the verbose predefined variable, which echoes a command's
input after history substitution but before command execution.
See the section on Predefined Variables for more about the
verbose predefined variable.
-V Sets the verbose variable before .cshrc is executed.
-x Sets the echo variable so that commands are echoed immediately
before execution.
-X Sets the echo variable before .cshrc is executed.
Initialization and Termination
When you log in to the system, a shell executes the commands in these
files:
/etc/login.csh Executes only during login to the system; is
maintained by the system administrator. Typically
contains environment and local shell variables.
.cshrc If it exists in your home directory, executes at login
and each time a shell executes a script or creates a
subshell. Typically contains aliases and local shell
variables.
.history If it exists in your home directory, executes at
login, reading in a list of saved history events into
the current history list.
.login If it exists in your home directory, executes
following execution of .cshrc and only during initial
login. Typically contains environment variables, the
umask settings (default permissions assigned to
user-created files), stty settings, and other commands
to be executed at login only.
.logout If it exists in your home directory, executes at
logout only.
After you have successfully logged in, an interactive shell will
usually begin reading commands from the terminal, prompting with
hostname% (the default) for the ordinary user; f2hostname# for the
user with appropriate privilege.
Command Line Words
The C shell splits input lines into words at blank(s), tab(s), and
new-line(s). Regardless of surrounding space, the following special
characters are also recognized as words:
space tab new-line Command argument separator.
$ Variable identifier.
* [ ] ? { } ~ Filename expansion characters.
< > & ! Redirection symbols.
! ^ History characters.
| Pipe.
; Command separator.
( ) Command group.
\ ' " Quoting.
` Command substitution.
& Background execution.
These words must be quoted (escaped) with a backslash (\) to inhibit
their interpretation as special characters.
Quoting Special Characters
In addition to the backslash (\), you can also use the following
characters to inhibit the interpretation of the special characters
listed in the previous section:
`command` Command substitution; see the section on
Command Substitution.
'string' String characters taken literally.
"string" Allows command substitution and variable
substitution.
Predefined Variables
The predefined variables in this section have special meaning to the
shell. Of these, the shell automatically sets argv, cwd, home, path,
prompt, shell and status. Except for cwd and status, the shell sets
these variables only at login.
You can set a variable as an environment variable (variable is
exported to subshells) or a local shell variable (variable is known
only to the current shell) using the set and setenv commands (covered
in the section on Built-in Commands). By convention, environment
variables are set in uppercase characters, and local shell variables
are set in lowercase characters. (See the section on Variables and
Variable Substitution for more information on how to set variables.)
Display local variables with the built-in command set. Display
environment variables with the printenv(1) command.
The shell copies the environment variable TERM into term, HOME into
home, and PATH into path and copies these back into the environment
when a variable's value changes.
Except for those predefined variables that the shell sets
automatically, you must set explicitly all other predefined
variables. You set a variable by either declaring it or by assigning
it a value, whichever is appropriate. The predefined variables
follow:
argv Contains the command line arguments supplied to the
current shell. This variable contains the values for
the positional parameters, referenced as $0, $1, $2,
and so on, through $9. With argv, you can reference
the first item on the command line with argv[0], the
second item with argv[1], and so on, through argv[9];
you can reference all arguments with argv[*], and the
number of arguments with #argv.
cdpath Change directory path; contains a list of alternate
directory pathnames used by commands (such as cd,
chdir, and popd) when searching for subdirectories.
cshscript Causes shell scripts that start with a pound sign (#)
to be interpreted by the C shell instead of the Bourne
shell. If this option is not set, only scripts that
start with #! /bin/csh will be interpreted by the C
shell. Setting this option provides compatibility
with other implementations of the C shell, but Bourne
shell scripts that start with a pound sign (except for
#! /bin/sh) will probably break.
cwd Contains the full pathname of the current working
directory.
echo Causes each command and its arguments to be echoed
just before it is executed. This is set when the -x
command line option is given (see the -x option in the
previous section on Command Line Options). This
option can also be set with the set echo command.
fignore A list of filename suffixes to ignore when attempting
filename completion. Typically the single word `.o'.
filec Enable filename completion, in which case the Ctrl-D
character and the ESC character have special
significance when typed in at the end of a terminal
input line.
histchars Identifies a two-character string used as history
substitution metacharacters. The first character
replaces the default history substitution character,
!. The second character replaces the quick
substitution character, ^.
history Specifies the number of history events (commands
issued from the command line) to be saved in the
history list. A large number of events saved in the
history list can exceed available shell memory. If
the history variable is not set to a specific value,
only the last executed command is saved in the history
list.
home Specifies the user's home directory. The filename
expansion of ~ refers to the value of the home
variable.
ignoreeof If set, makes the shell ignore the end-of-file signal
from terminal input devices. Setting ignoreeof
prevents accidental logouts issued with Ctrl-D.
mail Defines file location(s) where the shell checks for
mail and the interval at which you are notified of the
arrival of new mail. The variable is specified in
this form:
set mail = [n] mailfile-path [mailfile-path]
The optional n value specifies the mail-checking
interval in seconds and is used to override the
default, 600 seconds.
If new mail arrives, you are alerted with the message,
"You have new mail." If a command is being executed
during the arrival of mail, the message is postponed
until the prompt returns to the the terminal screen.
If multiple mailfile paths are specified, you are
alerted with the message, "New mail in mailfile-path."
nobeep Suppress the bell during filename completion when
asking the C shell to extend an ambiguous filename.
Note: this does not work if EDITREAD is enabled.
noclobber Restricts output redirection to ensure that files are
not accidentally destroyed or "clobbered" (described
in the section on Input/Output Redirection). It
prevents you from overwriting an existing file when
using the redirection symbol (>). Also, it prevents
the creation of a new file when you attempt to append
output to a nonexistent file when using the append
output symbol (>>). Instead, error messages are
displayed to alert you to the problem.
noglob If set, inhibits global filename expansion. Filename
expansion metacharacters * ? [] ~ {} are not
recognized and are treated as literal characters
instead. Setting noglob in shell scripts is useful
after filenames have been expanded or when filename
expansion is not desired. (Refer to the section on
Filename Substitution for more information on filename
expansion and metacharacters.)
nonomatch If set, inhibits the display of error messages if
commands containing filename expansion fail to locate
a matching pattern. Malformed patterns, however, are
considered errors for which error messages are
displayed. For example, the command, echo [, returns
an error.
notify If set, the shell notifies you asynchronously of a
job's completion. The default is to issue a job's
completion message before the prompt returns to the
terminal screen.
path Specifies a list of directories that is searched for
an executable command. If this variable is not set,
then only full pathnames will execute. The default
search path is (. /bin /usr/bin); however, the default
varies from system to system. A null word specifies
the current directory. For the user with appropriate
privilege the default search path is (/etc /bin
/usr/bin).
A shell command with neither the -c nor the -t options
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, you
may need to use the rehash command to update the
command list.
prompt Defines the string used by an interactive shell as a
prompt for your input. If a ! appears in the prompt
string, it will be replaced by the current history
event number (assigned to each command issued from the
command line) unless a preceding \ is given. (Refer
to the section on History Substitution for more
information on the current event.) The default is %
for the normal user, or # for the user with
appropriate privilege.
savehist Specifies the number of events in the history list
saved in the .history file in your home directory when
you log out. During shell startup, the shell reads
the contents of .history into the history list. A
large value for savehist slows down the shell during
startup.
shell Specifies the file in which the shell resides. The
default is /bin/csh.
status Contains the status returned by the last command. If
a command terminates abnormally, then 0200 is added to
the status. Built-in commands (those that do not
execute as child processes) that fail will return exit
status 1; all other built-in commands set status 0.
(See the status command under Built-in Commands.)
time Control automatic timing of commands. Can be supplied
with one or two values. The first is the reporting
threshold in CPU seconds. The second is a string of
tags and text indicating which resources to report on.
A tag is a percent sign (%) followed by a single
upper-case letter (unrecognized tags print as text):
%D Average amount of unshared data space
used in Kilobytes.
%E Elapsed (wallclock) time for the
command.
%F Page faults.
%I Number of block input operations.
%K Average amount of unshared stack
space used in Kilobytes.
%M Maximum real memory used during
execution of the process.
%O Number of block output operations.
%P Total CPU time -- U (user) plus S
(system) -- as a percentage of E
(elapsed) time.
%S Number of seconds of CPU time
consumed by the kernel on behalf of
the user's process.
%U Number of seconds of CPU time devoted
to the user's process.
%W Number of swaps.
%X Average amount of shared memory used
in Kilobytes.
The default summary display outputs from the %U, %S,
%E, %P, %X, %D, %I, %O, %F and %W tags, in that order.
(Also see the time command under Built-in Commands.)
verbose Prints the words of each command after history
substitution. This is set by the -v command line
option.
Built-in Commands
C shell built-in commands are executed within the shell. If a
built-in command is any component of a pipeline or a command group
(except the last one), then it is executed in a subshell.
alias name definition
An alias is an alternate name you can assign to an existing
DG/UX system command. This form of the alias command assigns
the specified definition to the alias name. (See the section on
Aliasing for more information.)
bg
bg %job ...
The first form (without an argument) moves the last suspended
job to the background for continued execution. The second form
puts the specified job into the background for continued
execution. (Refer to the section on Job Control for
information.)
break
Interrupts a foreach or while loop. break executes the
remaining commands on the current line before it transfers
control to the instruction following the end of the loop.
breaksw
Breaks from a switch, resuming after the endsw.
case label:
Specifies a label in a switch statement (discussed in a later
paragraph about switch).
cd
chdir
cd dir
chdir dir
The first and second forms change from the C shell's working
directory to the user's home directory. The third and fourth
forms change the C shell's working directory to a directory
named dir. If dir is not found as a subdirectory of the current
directory (and does not begin with /, ./, or ../), then each
component of the predefined variable cdpath is checked for a
subdirectory named dir. If dir is a shell variable whose value
begins with /, then the shell changes to this directory. The
second and fourth forms (the chdir expression) are the same as
the first and third forms, respectively.
continue
Interrupts a while or foreach loop. continue executes the
remaining commands on the line before it transfers control to
the end statement, which then sends control back to the top of
the loop.
default:
Labels the default case in a switch statement. The default
should follow all case labels.
dirs
Prints the directory stack. The first directory in the stack is
the current directory. With the -l argument, produce an
unabbreviated printout; use of the ~ notation is suppressed.
(See also pushd and popd later in this section.)
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 unless the
-n option is specified, in which case the new-line is
suppressed.
else
end
endif
endsw
See the upcoming descriptions of foreach, if, switch, and while
.
eval arg ...
The arguments are read as input to the shell and the resulting
command(s) executed. This is used usually to execute commands
generated as the result of variable or command substitution (see
the sections on Variables and Variable Substitution and Command
Substitution), because parsing occurs before these
substitutions.
exec command
Executes command in place of the current shell.
exit
exit (expr)
Terminates the shell with either the value of the status
variable (first form) or with the value of the specified expr
(second form).
fg
fg %job ...
Brings the current job (first form) or a specified job (second
form) into the foreground for execution.
foreach name (wordlist)
...
end
The variable name is set successively to each member of
wordlist, and the sequence of commands between the foreach
command and the matching end command are executed. (Both
foreach and end must appear on separate lines.)
glob wordlist
Performs filename expansion on a wordlist. The glob command
performs similarly to echo but no \ escapes are recognized.
Words are delimited by null characters in the output.
goto label
Unconditionally transfers control to a routine located in
another part of the script which is identified with the
specified label. A colon (:) follows the label to signify the
contents of the routine. Program execution continues after the
specified label.
history n
History enables you to recall and re-execute previously issued
commands that are saved in a list. This form of the command
lists n most recent items from the history list. (See the
section on History Substitution for more information.)
if (expr) command
If the specified expression evaluates to true, then the single
command with arguments is executed. Command must be simple; it
cannot be a pipeline, a command list (separated by semicolons),
or a command group (surrounded by parentheses). Note that I/O
redirection occurs even if expr is false and the command is not
executed (this is a bug). (See the later section on Pipes,
Sequential Command Processes, and Command Groups.)
if (expr) then
...
else if (expr2) then
...
else
...
endif
If the specified expr is true, then the commands following then
(up to the first else if) are executed; if expr2 is true, then
the commands following the second then (up to the second else)
are executed, and so on. Any number of else if pairs can be
used, but only one else (optional) and one endif (required) can
be used. 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
Enables you to list the active jobs that you can control through
the job control facility. (Refer to the section on Job Control
for more information.)
kill %job
Terminates an active job that is identified by a specific number
preceded by a percent sign (%). (See the section on Job Control
for more information.)
limit
limit resource
limit resource maximum-use
limit -h resource maximum-use
Limits resource consumption for each process and each of its
forked processes to no more than maximum-use on the specified
resource. If no maximum-use is given, then the current limit is
printed; if no resource is given, then all limitations are
given.
-h Use hard limits instead of the current limits. Hard
limits impose a ceiling on the values of the current
limits. Only the privileged user may raise the hard
limits.
Resource is one of the following:
cputime Maximum number of CPU-seconds to be
used by each process.
filesize Largest single file that can be
created.
datasize Maximum growth of the data and stack
for the process beyond the end of text.
stacksize Maximum size of the stack for the
process.
coredumpsize Size of the largest core dump file that
will be created.
memoryuse Maximum size that a process' resident
set size may grow to.
descriptors Maximum number of open files that a
process may have at one time.
Maximum-use can be a number (floating point or integer) followed
by a scale factor.
nk (kilobytes); default for all limits
other than cputime and descriptors.
nm (megabytes); an alternative to
kilobytes for all limits other than
cputime and descriptors.
n Default cputime limit in seconds.
nm n minutes for cputime.
nh n hours for cputime.
mm:ss Minutes and seconds for cputime.
login
Terminates the current login shell, replacing it with an
instance of /bin/login. This method of logging off is used for
compatibility with the Bourne shell.
logout
Terminates a login shell, which is especially useful if
ignoreeof is set.
newgrp
Changes the group identification of the caller; for details, see
the newgrp(1) man page. newgrp executes a new shell so that the
previous shell state is lost.
nice
nice + number
nice command
nice + number command
nice - number command
Executes a process at a lower priority (or a higher priority for
users with appropriate privileges only), which reduces the
demand that the process makes on the system. The "nice" number
is the factor (4 by default) that is added to (or subtracted
from) your job's priority. The higher the nice number, the
lower the priority of a process. The nice priority values range
from 0 to 39. The default priority is 20.
The first form sets the nice number for the current shell to 4
(the default), which means that the nice value would be 24. The
second form sets the priority to 20 + n. The third form runs
command at the default nice value. The fourth form runs command
at a priority of 20 + n. The final form (for the user with
appropriate privilege only) runs command at a priority of 20 -
number. The maximum changes to the nice value are: nice + 19
and nice - 20.
This nice command is not the same as the one documented in the
nice(1) manual page. The nice(1) manual page documents the
program /usr/bin/nice.
nohup
nohup command
The first form can be used in shell scripts to ignore hangups
for the remainder of the script. The second form causes the
specified command to run with hangups ignored. Command is always
run in a subshell. All processes run in the background
(commands appended with &) are effectively run without hangups.
notify
notify %job ...
If set, notifies you immediately when the status of the current
job (first form) or a specified job (second form) changes;
normally, notification is presented after a process has
completed just before the prompt reappears on the screen. (See
the notify variable under Predefined Variables.)
onintr
onintr -
onintr label
Controls the action of the shell on interrupts. The first form
restores the default action of the shell, which is to terminate
a shell script 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.
If the shell is running in the background (detached) and
interrupts are being ignored, no form of onintr has meaning.
The shell and all invoked commands continue to ignore
interrupts.
popd
popd + n
Pops the directory stack, returning to the new top directory.
With an argument +n, the nth entry in the stack is discarded.
The elements of the directory stack are numbered from 0,
starting at the top.
pushd
pushd name
pushd + n
With no arguments, pushd (first form) exchanges the top two
elements of the directory stack and changes the current
directory to the top directory. Given a name argument, pushd
(second form) changes to the new directory and pushes the old
current working directory onto the directory stack. With a
numeric argument, pushd +n (final form) rotates the nth argument
of the directory stack to the top and changes to it. The
members of the directory stack are numbered from the top,
starting at 0.
rehash
Recomputes the internal hash table of the contents of the
directories in the path variable to account for new entries
added while logged in. This action is necessary only if you add
commands (or scripts) to the directories in the path.
repeat count command
Repeats command count times. I/O redirections occur exactly
once, even if count is 0.
set variable = value
Assigns a value to shell variable. (Refer to the section on
Variables and Variable Substitution for more information.)
setenv variable value
Assigns a value to environment variable. (Refer to the section
on Variables and Variable Substitution for more information.)
Display your environment variables with the printenv(1) command.
shift
shift variable
In the first form, the components of argv are shifted to the
left, discarding argv[1]. It is an error for argv to be set to
null or to have no words as a value. The second form performs
the same function on the specified variable.
source file
source -h file
The first form reads commands from file. These commands may be
nested; if they are nested too deeply, however, the shell can
run out of file descriptors. An error in a source at any level
terminates all nested source commands. Commands read from a
file will not be added explicitly to the history list. The -h
option, however, (second form) will add the commands to the
history list without being executed.
stop %job ...
Stops the specified job that is executing in the background.
(See the section on Job Control for more information.)
suspend
Interrupts the shell temporarily (until you execute a command to
handle the suspended shell), much as if it had been sent a stop
signal with <Ctrl-Z>. This is most often used to stop shells
started by su(1).
switch (string)
case string1:
commands
breaksw
case string2:
commands
breaksw
default:
commands
breaksw
endsw
Each case label (such as string1 and string2) is successively
matched against the specified string. The file metacharacters
*, ? and [...] may be used in the case labels, which are
resolved to a filename. If none of the labels match before a
default label is found, then execution begins after the default
label. Each case label and the default label must appear at the
beginning of a line. The command breaksw continues execution
after the endsw. If no label matches and there is no default,
execution continues after endsw.
time
time command
With no argument (first form), prints a summary of time and
system resources used by the current shell and subprocesses. If
arguments are given (second form), the specified simple command
is timed and a summary of time and system resources used is
printed. The information is printed in seven fields. An
explanation of a "zero consumption" case with each field
description follows:
0.0u User time, in seconds.
0.0s System time, in seconds.
0:00 Real time, in minutes and seconds.
0% Rough approximation of the percentage of CPU cycles used
during real time, which is calculated by adding system
and user times and dividing the sum by elapsed real time.
0+0k Average amount of shared and unshared memory-time, in
kilobyte-seconds, each separated by +.
0+0io Number of blocks input and output, each separated by +.
0pf+0w Number of page faults (pf) and number of times the
process was swapped out to disk (w).
If necessary, an additional shell is created to print the time
statistic when the command completes. The time variable,
discussed in the section on Predefined Variables, can be set to
a threshold; thereafter, time use information (system, user,
real) is printed whenever any program or command exceeds that
threshold.
umask
umask value
Displays the three-digit octal mask value (first form) that
identifies the access mode created for files and directories.
By default, all files are created with a umask value of 666; for
directories, 777. The first digit identifies the owner's
permissions; the middle digit, the group's permissions; the last
digit, permissions for all other users.
The second form is the octal mask value that the owner sets.
Each specified digit removes a specific permission; a value of 1
removes execute permission, 2 removes write permission, and 4
turns off read permission. As an example, an owner could deny
the permission for group and other with a umask of 022, which
yields a umask of 644 (owner has read and write permission,
group has only read permission, and other has only read
permission). Values are additive; for example 6 turns off read
and write permissions.
Note that umask 000 is effectively umask 111; the shell creates
files with a default permission of 666, which means that no one
(not even the owner) has execute permission for the file. Use
chmod(1) to add execute permission.
unalias pattern
Deletes specified alias with a matching pattern. You can delete
all aliases using the filename metacharacter *. For example,
all aliases are removed with unalias *. (See the section on
Aliasing for more information.)
unhash
Disables the internal hash table.
unlimit
unlimit resource
unlimit -h resource
If no resource is specified (first form), then all resource
limitations are removed. (Refer to the limit command for
information on resource names.) Removes the limitation on
resource (second form).
-h Remove corresponding hard limits. Only the privileged
user may do this.
unset name
Deletes specified variable.
unsetenv name
Deletes specified environment variable. (Refer to the setenv
command in this section and the printenv(1) command for
information on setting and displaying environment variables.)
wait
Delays some action until all background jobs are completed. If
the shell is interactive, an interrupt can disrupt the wait, at
which time the shell lists all jobs and associated numbers that
are in the background, suspended, or stopped.
while (expr)
...
end
While the specified expr is true (evaluates to nonzero), the
commands between the while and the matching end are executed.
The while expr and end must appear alone on a line each. (See
continue and break for information on interrupting a loop.)
%job
%job &
Brings the specified job into the foreground (first form);
continues the specified job in the background (second form).
(See the section on Job Control for more information.)
@ variable = expr
This form sets the specified variable equal to the value of
expr. (See the section on Variables and Variable Substitution
for more information.)
Filename Completion
When enabled by setting the variable filec, an interactive C shell
can complete a partially typed filename or user name. When an
unambiguous partial filename is followed by an ESC character on the
terminal input line, the shell fills in the remaining characters of a
matching filename from the working directory.
If a partial filename is followed by the EOF character (usually typed
as Ctrl-D), the shell lists all filenames that match. It then
prompts once again, supplying the incomplete command line typed in so
far.
When the last (partial) word begins with a tilde (~), the shell
attempts completion with a user name, rather than a file in the
working directory.
The terminal bell signals errors or multiple matches; this can be
inhibited by setting the variable nobeep. You can exclude files with
certain suffixes by listing those suffixes in the variable fignore.
If, however, the only possible completion includes a suffix in the
list, it is not ignored. fignore does not affect the listing of
filenames by the EOF character.
History Substitution
History substitution allows you to recall, re-execute, and edit
previously entered commands. With this facility, you can repeat
commands, repeat arguments of a previous command in the current
command, or edit a previous command (for example, to fix spelling
mistakes). Command lines, known as history events, are saved in a
history list, the length of which is controlled by the predefined
history variable (refer to the section on Predefined Variables).
History substitutions begin with the character ! and may begin
anywhere in the input stream, as long as they do not nest. You can
change the value to another character and store it in predefined
variable histchars. The ! can be escaped with a \ to prevent its
special meaning; the ! is not interpreted as a special character if
it is followed by a blank, tab, new-line, =, or (. History
substitutions can also be performed using the ^ character, discussed
in the subsection on Event Modifiers. Any input line that contains
history substitution is expanded and echoed on the terminal before it
is executed.
set history = n
history
history n
history -r n
history -h n
The first form sets the number of history events to be contained
in the history list. The second form prints a history list.
The third form prints only the n most recent events. The fourth
form reverses the order of the history list so that the more
recent events are at the top of the list; the older events are
at the bottom. The final form prints the history list without
leading numbers, which produces files suitable for using the -h
option to the source command.
An example of setting the history list length follows:
set history = 5
Regardless of the number of command lines entered, the five most
recent commands are saved in the list. Command lines are
numbered sequentially from 1. For example, event 6 would be
maintained as the most recent event, and event 1 would be
deleted, thus maintaining a constant length of 5.
The second form prints a history list. An example follows:
8 ls -l
9 write michael
10 vi write.c
11 cat oldwrite.c
12 diff write.c write.d
The commands are shown with their event numbers, which can be
used in the prompt by preceding the prompt string with a !. An
example follows:
% set prompt = '\! %'
Event Designators
An event designator is used to invoke an event from a history list.
! Designates a history substitution, except
when followed by a space, tab, new-line, =,
or (.
!! Recalls the previous event just executed.
!n Recalls event n from the history list.
!-n Recalls event -n relative to the current
event.
! string Recalls the most recent history event
beginning with string.
!?string? Recalls the most recent history event
containing the embedded string.
!{string1}string2 Recalls the most recent history event
matching string1 and appends string2 to it.
The following examples of event designators are based on the
preceding history list given in this section.
13% !!
diff write.c write.d
14% !9
write michael
15% !v
vi write.c
16% !?old?
cat oldwrite.c
17% !{d} > save.file
diff write.c write.d > save.file
Word Designators
To select words from an event, follow the event designator by a colon
(:) and a designator for the desired words. The words of an input
line are numbered from 0, the first word being 0 (the command), the
second word (first argument) being 1, and so on. The basic word
designators are:
0 First word, which is always the command.
n nth argument
^ Second word, which is the first argument.
$ Last argument.
% Word matched by (immediately preceding) ?string? search.
x-y Range of words.
-y Abbreviates 0-y.
* Abbreviates ^-$, or nothing if only one word in event.
x* Abbreviates x-$.
x- Like x*, but without word $.
The : separating the event designator from the word designator can be
omitted if the word designator begins with a ^, $, *, - or %.
Examples of word designators are based on the following history
event:
12% cd test ; ls | grep '\.h$'
Command Produces
% !12:0 cd
% !12:3 ls
% !?rep?:% Bob names grep Bob names
% !12:0-1 cd test
% !12:3* ls | grep '\.h$'
% echo !12:^ !$ echo test '\.h$'
Word Modifiers
A sequence of modifiers can follow the optional word designator.
Precede each with a :. The following modifiers are defined:
h (head); removes a trailing pathname
component, leaving the head.
r (root); removes a trailing filename
extension, leaving the root name.
e (extension); removes all of the filename
except the extension.
s/str1/str2/ (substitute); substitutes search pattern
str1 with replacement pattern str2.
t (tail); removes all leading pathname
components, leaving the tail.
& (repeat); repeats the previous substitution.
g (global); applies the change to the first match in
each word on the line; precedes other word
modifiers; for example, g&.
p (print); prints the new command but does
not execute it.
q (quote); quotes the substituted words (no
further substitutions).
x Similar to q, but breaks into words at
spaces, tabs and new-lines.
For substitutions, unless preceded by a g, only the first occurrence
of the matched word str1 is modified. An error results if no word is
matched.
The search string, signified by str2, is expressed using a literal
string; regular expressions cannot be used. Any character can
replace / as a delimiter. A \ can be used to quote the substitution
delimiters separating str1 and str2 to escape their meanings. The &
character, which stores the value contained in str1 is a legal value
that can be used in str2. The & construct modifies rather than
replaces str2. The & can be quoted with a \ to preserve its literal
meaning. A null str1 uses the previous string from str2 or from a
contextual scan string str in !?str?. The trailing delimiter / in a
substitution and the trailing ? in a contextual scan may be omitted
if a new-line follows immediately.
The sequence ^str1^str2^ can be used as a shortcut for
!!:s/str1/str2/.
Examples of word modifiers are given based on the following event:
4% ls /usr/della/test.1
Command Prints and Executes
% ^della^eunice ls /usr/eunice/test.1
% !4:s/test.1/quiz ls /usr/della/quiz
% !4:h ls /usr/della
% !4:1:r /usr/della/test
% !4:s/test.1/re&/ ls /usr/della/retest.1
% !4:p ls /usr/della/test.1 (prints but
doesn't execute)
Aliasing
You can assign alternate names to existing DG/UX system commands with
the alias facility. Specifically, you can rename a command, supply
default arguments to a command, or construct new commands from
existing ones.
alias
alias name
alias name definition
unalias pattern
The first form of the command displays the current list of
aliases. The second form lists the corresponding definition for
the specified alias. The third form assigns a simple definition
to the alias. The final form deletes an alias name matching the
specified pattern.
Aliases can also take user-supplied arguments, which require the use
of the history facility. An example follows:
% alias man 'man \!* | more'
The alias man is assigned a definition wherein the man command and a
user-supplied argument, signified by !*, are piped through the more
command. The single quotation marks enclose the definition to
prevent shell expansion. Also, the \ escapes the ! to prevent it
from being interpreted as you define the alias.
When executing the man alias, you can enter an argument, which is
placed automatically in the history list and is then retrieved and
substituted into the alias command. The !* expression refers to the
previous history event (!) and the first through final arguments in
that event (*).
Job Control
The C shell associates a numbered job with each executed command line
to keep track of all commands in the background and all commands
suspended temporarily (with <Ctrl-Z>). In addition to starting a
command in the background, with the shell job control facility, you
can switch a job's processing between three states: foreground,
background, and suspension. The form of a job started asynchronously
with & follows:
% command arg [ arg2 ] ...&
[n] pid-number
For example, if the pid-number is [1]1234, the number, 1, surrounded
by square brackets would be the job number, which has one (top-level)
process, and 1234 would be the process identifier.
Listing Jobs
jobs
jobs -l
The first form lists the active jobs. The -l option (second
form) lists PIDs, the job numbers, corresponding command lines,
and status (running or stopped). An example follows:
% jobs
[1] - Stopped man jobs | more
[2] + Stopped cat large.out
[3] Running /usr/bin/lp -w -s -t report &
The shell maintains a list of the current and previous jobs. The
current job is marked with a + and the previous job with a -.
Manipulating Jobs
There are several ways to manipulate jobs:
%n Refer to job number n.
<Ctrl-Z>
Suspend foreground job.
<Ctrl-Y>
Suspend foreground job when interactive read is
attempted.
bg Put job in background.
fg Put job in foreground.
kill Terminate job.
stop Suspend background job.
% %+ %%
%-
% n
%?string
Three ways of referring to the current job are specified in the
first line. For example, the command fg % puts the currently
stopped job in the foreground.
The second form (second line) refers to the previous job. The
command fg %- puts the first previous job in the foreground.
The third form (third line) refers to an absolute job number.
The command fg %3 puts the third job in the foreground.
The fourth form (fourth line) specifies an unambiguous string
occurring at the beginning of the line. The command fg %?/usr
would put in the foreground the job containing the string "/usr"
at the beginning of the line, which is the third job. To
manipulate a stopped job, you specify the current job with a +
command preceded by a percent sign (%). You specify the
previous job with the - command preceded by a %. After the
current job (indicated by +) completes or moves to the
foreground, the previous job (indicated by -) becomes the
current job and assumes a + status. If there were a third
stopped job, it would become the previous job and assume a -
status.
<Ctrl-Z>
Suspends temporarily a foreground job, which sends a STOP signal
to the executing job. The C shell should indicate that the job
has been stopped by displaying a Stopped message followed by
another prompt. A <Ctrl-Z> takes effect immediately and behaves
like an interrupt; pending output and unread input are discarded
when typed in.
<Ctrl-Y>
The <Ctrl-Y> command does not generate a STOP signal until the
executing job attempts an interactive read from the terminal.
Thus, you can issue the <Ctrl-Y> command during such a job's
execution and the job will continue to execute until an
interactive read from the terminal is attempted. A background
job stops if it tries to read from the terminal. Conversely,
however, a background job normally is allowed to produce output,
but this can be disabled with the command stty tostop.
bg
bg % job... The first form prints a list of jobs running in the
background. The second form puts the currently stopped job or a
specified job into the background for continued execution.
fg
fg % job... Brings the current job (first form) or a specified job
(second form) into the foreground.
kill -sig %job ...
kill pid
kill -sig pid ...
kill -l
Sends either the TERM (terminate) signal or the signal (sig) to
either a specific process (pid) or a specific job number.
Signals are given either by number or name (as given in
/usr/include/sys/signal.h, stripped of the prefix SIG).
The kill -l command lists the signal names. Using kill alone
does not send a signal to the current job. If the kill command
sends either a TERM (terminate) or HUP (hangup) signal to a job
or process, then it also sends a CONT (continue) signal.
stop
stop % job
Stops the current job (first form) or the specified job (second
form) that is executing in the background. Using stop 0 in a
login shell (the one that you log in to) will hang your
terminal. Also, you must be using the Berkeley line discipline
driver (berk_stty) for stop and suspend signals to be handled
properly.
Pipes, Sequential Command Processes, and Command Groups
command | command ...
command ; command ; command ...
( command group )...
The first form uses a pipe symbol (|); the second uses a set of
sequential commands (;); the third signifies a command group
(( )).
The pipe symbol is used for connecting a series of simple
commands to form a pipeline. The output of each command in a
pipeline is connected to the input of the next command. To
execute a sequence of pipelines without immediately waiting for
the sequence to terminate, follow it with the & symbol, which
executes the job in the background.
An example of a pipeline follows (note that the quote marks are
back quotes):
% echo There are `who | wc -l` users on the system today.
The second form shows a sequence of commands separated by
semicolons (;), which cause each command to be performed
unconditionally from left to right in a sequential manner.
Commands can also be separated by || or &&, which represent
conditional execution. The expression on the right of one of
these symbols is performed if the left expression (signified by
||) is false (failure) or if the left expression (signified by
&&) is true (success).
An example of conditional execution follows:
% grep "Using" filea && echo "I found it."
If an instance of "Using" is found in filea, the expression
would be considered true (success) and the expression to the
right of && would be performed.
The third form illustrates a command group, which can be
composed of a pipeline or command sequence, enclosed in
parentheses to form a part of a larger pipeline or command
sequence. A command group processes a set of commands in a
subshell, establishing an environment separate from its parent,
or puts a group of commands (processed sequentially) in the
background.
Examples of command grouping follow:
% ( cat test1 ; cat test2 ) > bigtest.out
% ( grep micro *.me > micro.out ; lp micro.out ) &
Input/Output Redirection
The following special characters are used to redirect standard input,
standard output, or standard error from a command to a file.
< filename
Opens filename as standard input.
<< word
Reads the shell's input up to a line that is identical to word.
If word contains a special character (see section on Command
Line Words), it will be interpreted unless escaped with a
backslash (\). Commands that 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 a temporary
file that is given to the command as standard input.
> filename >& filename >! filename >&! filename
Angle bracket (>) signifies a redirection of standard output to
filename. If filename does not exist, then it is created. If
the file exists, it is overwritten; its previous contents are
lost (first form).
The second form redirects standard output and standard error
(diagnostic output) to filename. The terminal is standard error
by default. If filename exists, it is overwritten; its previous
contents are lost.
If the noclobber variable is set when using either the first or
second forms, it prevents the shell from redirecting output to
an existing file and issues an error message instead. setting
the noclobber variable prevents accidental file overwriting of
files that already exist. Note that noclobber permits
redirection to terminals and /dev/null.
Alternatively, it is possible to override the noclobber setting
with the ! symbol. The third form, >!, allows an existing file
to be overwritten. The final form, >&!, overwrites an existing
file with standard output and standard error.
>> filename >>& filename >>! filename >>&! filename
Appends standard output to a file (first form). It is similar
to the > notation but appends to, rather than creates, a file.
If the file does not already exist, it is created.
The second form appends standard output and standard error
(diagnostic output) to filename.
If the noclobber variable is set when using either the first or
second forms, and if a file does not already exist, an error
message is issued and no output is appended to a file.
Alternatively, it is possible to override the noclobber setting
with the ! symbol. The third form, >>!, creates a file if one
does not already exist. Likewise, the final form, >>&!, creates
a file if one does not already exist.
Variables and Variable Substitution
There are two types of variables that the C shell maintains:
predefined and user-defined. The C shell automatically sets some
predefined variables; others you can set (refer to the previous
section on Predefined Variables for more information). User-defined
variables can be restricted to the current shell (local variables) or
exported to the environment (environment variables). Also, user
variables can be defined as string or numeric. All variables have a
name and a corresponding value of one or more words. A user-defined
variable name can consist of as many as 251 characters (alphabetic
and numeric and the underscore character).
A reference to the value of a variable begins with $, which is a
signal to the shell to interpret the dollar sign and the adjacent
expression as a variable. The shell then expands the variable,
effectively substituting the variable with its corresponding value.
You can suppress variable substitution by preceding the $ with a
backslash (\), except within double quotation marks ("), which allow
variable substitution. Single quotation marks (') suppress variable
substitution. A $ is interpreted literally if followed by a space,
tab, or new-line. Also, braces ({ }) can be used to insulate a
variable name from subsequent adjacent characters (for example,
${VAR}).
Metasequences introduce variable values into the shell input. Except
as noted, referencing an unset variable is an error. Most of the
metasequences covered in this section can be modified using a set of
word modifiers introduced in the Word Modifiers subsection of the
History Substitution section in this manual page. These modifiers
(:h, :gh, :t, :gt, :r, :gr, :q and :x) can be applied to some
variable metasequences. If braces { } appear in the command form,
the modifiers must appear within the braces. Only one :x modifier is
allowed on each $ expansion. The following metasequences can be
modified:
$var
${var}
In the first form, var is replaced by the word(s) of the value
of variable var, each separated by a blank. Braces insulate var
from following characters that would otherwise be part of it
(second form). If var is not a local shell variable, but an
environment variable, then that value is returned (but :x
modifiers and the other forms given as follows are not available
in this case).
$var[index]
${var[index]}
Selects only the specified word, represented by index, from var.
The index value can be represented by a single number or two
numbers separated by a dash (-) to indicate a range. 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 $#var (see the next item).
The argument, *, selects all words. It is not an error for a
range to be empty if the second argument is omitted or within
range.
$#var
$#{var}
Gives the number of words in the variable, which is useful with
wordlists.
$number
${number}
Is equivalent to $argv[number]. Substitutes the value
corresponding to the positional parameter given in the command
line. For example, $0 refers to the command name, $1 refers to
the first argument, $2 refers to the second argument, and so on.
$*
${*}
Is equivalent to $argv[*], which refers to all arguments.
The following metasequences cannot be modified.
$?var
${?var}
Returns the value of 1 if var is set; 0 if var is not set.
$?0
Returns the value of 1 if the current input filename is known, 0
if it is not set.
$$
Substitutes the (decimal) process number of the (parent) shell.
$<
Substitutes a line from the standard input, with no further
interpretation. A shell script can use this form to read from
standard input.
Commands for Setting Variables
set
set name ...
set name = word
set name[index] = word
set name = (wordlist)
The first form of the command lists the values of all variables.
Values that form a list of multiple words are surrounded with
parentheses. The second form sets name equal to the null
string. The third form sets name equal to the single word. The
fourth form sets the nth component of name (specified by index)
equal to word. Before you can assign a single index value to a
variable, the variable must exist. The final form sets name
equal to the list of space-separated words in wordlist. In all
forms, the value is command- and filename-expanded before it is
assigned.
These arguments may be repeated to set multiple values in a
single set command. Note, however, that variables in arguments
are expanded before they are set.
setenv name value
Sets the value of environment variable name equal to value, a
single word. Two commonly used environment variables, TERM and
PATH, are automatically imported to and exported from the C
shell local variables, term and path. Setting these variables
in the environment is unnecessary.
@
@ name = expr
@ name[index] = expr
The first form lists the values of all shell variables. The
second form sets the specified name equal to the value of expr.
If expr contains one of these four characters: <, >, &, or |,
then at least this part of the expression must be placed within
parentheses ( ).
The third form assigns the value of expr equal to the argument
specified by the index of name. Both name and the index
argument must already exist.
Other assignment operators in addition to = can be used. (Refer
to the section on Expressions and Operators for more
information.)
unset name ...
Deletes specified variable.
unsetenv name ...
Deletes specified environment variable. (See also printenv(1)
for more information.)
Command Substitution
The output produced by a command can be substituted as an argument to
some other command on the same command line. The command to be
substituted is surrounded by backquotes (``).
`command`
Executes the backquoted command (`command`) and substitutes the
result in the command line before executing the entire command
line.
Command substitution is performed in a subshell. The output
from such a command is normally broken into separate words at
spaces, tabs, and new-lines. Null words are discarded.
Within double quotation marks (" "), only new-lines force new
words; spaces and tabs are preserved.
The single, final new-line does not force a new word. Note that
it is thus possible for a command substitution to yield only a
partial word, even if the command outputs a complete line.
An example follows:
% echo The date of today is: `date`
The date of today is: Mon Aug 29 16:59:57 EST 1988
Filename Substitution
Words containing any of these characters (*, ?, [, or {) or beginning
with the character (~) are candidates for filename expansion. Such a
word represents a pattern that is matched and consequently replaced
with a list of filenames containing the matched pattern.
* Matches zero or more character(s) in a filename.
? Matches any single character in a filename. For example, the ls
oct.? command may produce this result: oct.1, oct.2, and
oct.9, but not oct.12.
[...]
Matches any single character from the enclosed list, which is
referred to as a character class. A list can also be expressed
as a range, which is designated by two characters separated by a
hyphen (-). The elements forming the beginning and end of a
range must follow the ASCII collation sequence; as examples, a-z
and 1-4. For example, the ls *.[123] may produce this result:
oct.1, oct.2, and oct.3, but not oct.4.
~ Expands to the user's home directory, which is defined by the
home shell variable. When the tilde is followed by a name
consisting of alphabetic and numeric characters or the hyphen
(-), the shell searches for the user's home directory and
substitutes it in place of ~. For example, ~ken might expand to
/usr/ken and ~ken/chmach to /usr/ken/chmach. If the ~ is
followed by a character that is not alphabetic or numeric, or a
hyphen, or if the ~ does not appear at the beginning of a word,
it is left undisturbed.
{...}
Rather than having to type multiple full pathnames that contain
a common component, you can type the commonly shared component
only once and enclose the unique filename fragments in brackets.
A comma follows each filename fragment.
This expression a{b,c,d}e is shorthand for abe ace ade.
Left-to-right order is preserved. This construct may be nested.
Thus,
~source/s1/{oldls,ls}.c
may expand to
/usr/source/s1/oldls.c /usr/source/s1/ls.c
Successful filename expansions do not imply that the expanded
filenames exist.
As a special case {, } and {} are passed undisturbed.
Expressions and Operators
Some of the built-in commands (see the section on Built-in Commands)
take expressions as arguments, in which the operators are similar to
those of the C language, with the same precedence. These expressions
appear in the @, exit, if, and while commands, which are used to
control the flow of executing commands.
Strings beginning with 0 are considered octal numbers. Null or
missing arguments are considered 0. The results 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. In most cases these characters (&, |, <, >, (, and )) should
be surrounded by spaces.
The following operators are grouped in order of precedence.
(...) Change precedence.
~ Perform 1's complement.
! Logically negate.
* / %
Multiply, divide, modulo.
+ - Add, subtract.
<< >> Bitwise shift left, bitwise shift right.
< > <= >=
Less than, greater than, less than or equal to, greater
than or equal to.
== != =~ !~
Equal to, not equal to, filename substitution match,
filename substitution pattern mismatch. The operators,
=~ and !~, check for a match between the string on the
left of the expression and a filename substitution
pattern on the right of the expression. These two
operators reduce the need for use of the switch
statement in shell scripts when pattern-matching
between strings is all that is needed.
& Bitwise AND.
^ Bitwise XOR (exclusive or).
| Bitwise inclusive OR.
&& Logical AND.
|| Logical OR.
The assignment operators are given as follows:
++ Increment.
-- Decrement.
= Assign.
*= Multiply left side by right side and update left side.
/= Divide left side by right side and update left side.
+= Add left side to right side and update left side.
-= Subtract left side from right side and update left side.
^= Exclusive OR left side to right side and update left side.
%= Modulo; divide left side by right side and update left
side with remainder.
File status operators are available in the form -l filename, where l
is one of the following values:
-r filename Read access.
-w filename Write access.
-x filename Execute access.
-e filename Existence.
-o filename Ownership.
-z filename Zero size.
-f filename Plain file.
-d filename Directory.
The specified filename is command- and filename-expanded and then
tested for the file's status with regard to the user (for example, do
you have write access?). If the file does not exist or is
inaccessible, then all inquiries return a false value (0).
You can use a command as a boolean component in an expression. The
status returned by the executing command determines the value of the
expression. Successful command execution returns a true (0) value;
failure returns a false (nonzero) value. The command name should
appear in braces delimited by spaces (like { /bin/m88k }).
An example of using a file status expression in a shell script
follows:
echo "Enter a filename:"
set file = $<
if (-r $file && -w $file && -x $file) then
echo "$file is readable, writable, and executable."
else
echo "$file doesn't have correct permissions."
endif
Signal Handling and Status Reporting
The shell normally ignores quit signals. Background jobs running
either by the & symbol, the bg command, or %job& command are immune
to signals generated from the keyboard, including hangups. Other
signals have values that the shell inherits from its parent. The
shell's handling of interrupt and terminate signals in shell scripts
can be controlled by the onintr commands. Login shells catch the
terminate signal; otherwise, this signal is passed to children from
the state in the shell's parent. Interrupts are not allowed when a
login shell is reading the file .logout.
The shell learns immediately whenever a process changes state. It
normally informs you when a job becomes blocked and prevents further
progress, but only just before it prints a prompt so as to avoid
disturbing your work. However, if the shell variable notify is set,
the shell notifies you immediately of status changes in background
jobs. There is also a shell command notify that marks a single
process so that its status changes will be reported immediately. By
default, notify marks the current process; after starting a
background job, you can issue the notify command to mark it.
If you try to exit the shell while jobs are stopped, the shell
displays a message indicating that there are stopped jobs. You can
issue the built-in jobs command to list the currently stopped jobs.
If you again attempt to terminate the shell while jobs are stopped,
the shell will not issue a second warning, but will terminate the
stopped jobs.
Parsing Order and Execution
The order in which the shell deals with special characters on the
command line affects the result produced. Here are the steps of the
parsing process:
History substitution Expands the ! and ^ history
metacharacters.
Line parsing Divides the command line into words,
numbering the first item 0; the second
item, 1, and so on.
History update Places the command line in the history
list, allowing access to specific events
and words.
Word parsing Performs six separate steps, as follows:
' and " resolution
Both forms quote (prevent interpretation of) special
characters for filename expansion, redirection,
background execution, and pipes. Only single quotation
marks (' ') quote variable expansion and command
substitution special characters. Also, to prevent
interpretation of the history metacharacter, ! must be
quoted within single quotation marks.
Alias substitution
Substitutes an alias with its assigned executable
command.
<, >, <<, >>, &, and | recognition
Recognizes these metacharacters but does not process
them.
Variable substitution
Expands variables to assigned values.
Command substitution
Executes any command within backquotes (``) and
substitutes the result in standard output on the command
line.
Filename substitution
Expands filenames according to the filename
metacharacters used.
Command Execution After parsing occurs, the shell executes
commands (informing the DG/UX system of
the command to locate and the files to
use for input and output).
International Features
csh can process characters from supplementary code sets in addition
to ASCII characters. Characters from supplementary code sets can be
used for command arguments, as values of variables, as alias name,
and in comments and pipes.
Strings used in history substitution can contain characters from
supplementary code sets.
Searches and pattern matching using metacharacters are performed in
character units, not bytes.
? Matches an character from supplementary code sets.
* Matches any string, including the null string.
[ ] Matches any one character in the string enclosed by square
brackets, or any one character with a code value within the
range designated using a minus (-) sign. When the characters
in the range are from different code sets, one of the
characters specified in the range is matched.
C-shell scripts may also contain characters from supplementary code
sets.
FILES
/etc/login.csh Is read at login.
~/.cshrc Is read at beginning of execution by each shell.
~/.login Is read by login shell, after ~/.cshrc at login.
~/.logout Is read by login shell, at logout.
/bin/sh Identifies the standard shell (for shell scripts
not starting with #! /bin/csh)
/tmp/sh* Identifies the temporary file for <<.
/etc/passwd Specifies the source of home directories for
~username.
~/.history Contains the current history list saved at
logout.
LIMITATIONS
A word cannot exceed 1024 characters. The DG/UX system limits an
argument list to 524,288 characters. The number of arguments to a
command that involves filename expansion is limited to 1/6 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 C shell restricts the number of alias
substitutions on a single line to 20.
SEE ALSO
printenv(1), sh(1), stty(1), access(2), exec(2), fork(2), killpg(2),
pipe(2), umask(2), wait(2), jobs(3C), a.out(4), editread(5),
environ(5), and ttcompat(7).
NOTES
When a command is restarted from a stop, the shell prints the
directory it started in if different from the current directory; this
can be misleading, since the job may have changed directories
internally.
If a process reading from a pipe ends before the process writing to
the pipe, a harmless "Broken Pipe" error message is printed.
Example: ls -l | head in a large directory.
Shell built-in functions cannot be stopped and then restarted.
Command sequences of the form "a ; b ; c" also are not handled
gracefully when you attempt to stop them. If you suspend b, the
shell will then immediately execute c. This is especially noticeable
if this expansion results from an alias. You can place the sequence
of commands in parentheses to force it to a subshell. For example,
"( a ; b ; c )" will suffice.
Control over tty output after processes are started is primitive;
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 control.
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
history list. Control structure should be parsed rather than be
recognized as built-in commands. Such a change would allow you to
place the control commands anywhere, to combine control structure
with pipes (|), and to use with commands executed in the background
(&) and sequentially (;).
It should be possible to use the : word modifiers on the output of
command substitutions. Furthermore, multiple modifiers (at least
more than one) should be allowed on variable substitutions.
Licensed material--property of copyright holder(s)