csh.1 (2010 09)

c
csh(1) csh(1)
of the expression must be placed within parentheses. The third form assigns the value of
expression to the indexth argument of name. Both name and its index th component must
already exist.
The operators
*=, +=, etc., are available as in C. White space can optionally separate the
name from the assignment operator. However, spaces are mandatory in separating com-
ponents of expression which would otherwise be single words.
Special postfix
++ and --
operators increment and decrement name, respectively (e.g.,
@ i++).
Non-Built-In Command Execution
When a command to be executed is not a built-in command,
csh attempts to execute the command via
exec(2). Each word in the variable path names a directory in which the shell attempts to find the com-
mand (if the command does not begin with
/). If neither -c nor -t is given, the shell hashes the names
in these directories into an internal table so that an exec is attempted only in those directories where the
command might possibly reside. This greatly speeds command location when a large number of direc-
tories are present in the search path. If this mechanism has been turned off (via
unhash), or if -c or
-t was given, or if any directory component of path does not begin with a
/, the shell concatenates the
directory name and the given command name to form a path name of a file which it then attempts to exe-
cute.
Commands placed inside parentheses are always executed in a subshell. Thus
(cd ; pwd)
prints the home directory then returns to the current directory upon completion, whereas:
cd ; pwd
remains in the home directory upon completion.
When commands are placed inside parentheses, it is usually to prevent chdir from affecting the current
shell.
If the file has execute permissions but is not an executable binary file, it is assumed to be a script file,
which is a file of data for an interpreter that is executed as a separate process.
csh first attempts to load and execute the script file (see exec (2)). If the first two characters of the script
file are #!, exec(2) expects an interpreter path name to follow and attempts to execute the specified inter-
preter as a separate process to read the entire script file.
If no
#! interpreter is named, and there is an alias for the shell, the words of the alias are inserted at
the beginning of the argument list to form the shell command. The first word of the alias should be the
full path name of the command to be used. Note that this is a special, late-occurring case of alias substi-
tution, which inserts words into the argument list without modification.
If no
#! interpreter is named and there is no shell alias , but the first character of the file is
#, the inter-
preter named by the
$shell variable is executed (note that this normally would be /usr/bin/csh,
unless the user has reset $shell). If $shell is not set, /usr/bin/csh is executed.
If no
!# interpreter is named, and there is no shell alias, and the first character of the file is not #,
/usr/bin/sh is executed to interpret the script file.
History Substitutions
History substitutions enable you to repeat commands, use words from previous commands as portions of
new commands, repeat arguments of a previous command in the current command, and fix spelling or
typing mistakes in an earlier command.
History substitutions begin with an exclamation point (!). Substitutions can begin anywhere in the input
stream, but cannot be nested. The exclamation point can be preceded by a backslash to cancel its special
meaning. For convenience, an exclamation point is passed to the parser unchanged when it is followed by
a blank, tab, newline, equal sign, or left parenthesis. Any input line that contains history substitution is
echoed on the terminal before it is executed for verification.
Commands input from the terminal that consist of one or more words are saved on the history list. The
history substitutions reintroduce sequences of words from these saved commands into the input stream.
The number of previous commands saved is controlled by the
history variable. The previous com-
mand is always saved, regardless of its value. Commands are numbered sequentially from 1.
8 Hewlett-Packard Company 8 HP-UX 11i Version 3: September 2010