c

csh(1)

csh(1)

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 components of expression which would otherwise be single words.

Special post®x ++ 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 ®nd the command (if the command does not begin with /). If neither -cnor -tis 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 directories are present in the search path. If this mechanism has been turned off (via unhash), or if -cor -twas 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 ®le which it then attempts to execute.

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 ®le has execute permissions but is not an executable binary ®le, it is assumed to be a script ®le, which is a ®le of data for an interpreter that is executed as a separate process.

csh ®rst attempts to load and execute the script ®le (see exec(2)). If the ®rst two characters of the script ®le are #!, exec(2) expects an interpreter path name to follow and attempts to execute the speci®ed interpreter as a separate process to read the entire script ®le.

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 ®rst 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 substitu- tion, which inserts words into the argument list without modi®cation.

If no #! interpreter is named and there is no shell alias, but the ®rst character of the ®le is #, the interpreter 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 exe- cuted.

If no !# interpreter is named, and there is no shell alias, and the ®rst character of the ®le is not #, /usr/bin/sh is executed to interpret the script ®le.

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 ®x 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 veri®cation.

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 command is always saved, regardless of its value. Commands are numbered sequentially from 1.

You can refer to previous events by event number (such as !10 for event 10), relative event location (such as !-2for the second previous event), full or partial command name (such as !d for the last event using a command with initial character d), and string expression (such as !?mic? referring to an event containing the characters mic).

Section 1136

− 8 −

HP-UX Release 11i: December 2000