[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

System User's Guide: Operating System and Devices


Environment Variables in the C Shell

Certain variables have special meaning to the C shell. Of these, argv, cwd, home, path, prompt, shell, and status are always set by the shell. Except for the cwd and status variables, this action occurs only at initialization. These variables maintain their settings unless you explicitly reset them.

The csh command copies the USER, TERM, HOME, and PATH environment variables into the csh variables, user, term, home, and path, respectively. The values are copied back into the environment whenever the normal shell variables are reset. the path variable cannot set in other than in the .cshrc file, because csh subprocesses import the path definition from the environment and reexport it if changed.

The following variables have special meanings:

argv Contains the arguments passed to shell scripts. Positional parameters are substituted from this variable.
cdpath Specifies a list of alternate directories to be searched by the chdir or cd command to find subdirectories.
cwd Specifies the full path name of the current directory.
echo Set when the -x command line flag is used; when set, causes each command and its arguments to echo just before being run. For commands that are not built-in, all expansions occur before echoing. Built-in commands are echoed before command and file name substitution because these substitutions are then done selectively.
histchars Specifies a string value to change the characters used in history substitution. Use the first character of its value as the history substitution character, this replaces the default character, !. The second character of its value replaces the ^ character in quick substitutions.

Note: Setting the histchars value to a character used in command or file names might cause unintentional history substitution.
history Contains a numeric value to control the size of the history list. Any command that is referenced in this many events is not discarded. Very large values of the history variable might cause the shell to run out of memory. Regardless of whether this variable is set, the C shell always saves the last command that ran on the history list.
home Indicates your home directory, initialized from the environment. The file name expansion of the tilde (~) character refers to this variable.
ignoreeof Specifies that the shell ignore an end-of-file character from input devices that are workstations. This prevents shells from accidentally being killed when it reads an end-of-file character (Ctrl-D).
mail Specifies the files where the shell checks for mail. This is done after each command completion which results in a prompt if a specified time interval has elapsed. The shell displays the message Mail in file. if the file exists with an access time less than its change time.
  If the first word of the value of the mail variable is numeric, it specifies a different mail checking time interval (in seconds); the default is 600 (10 minutes). If you specify multiple mail files, the shell displays the message New mail in file, when there is mail in the specified file.
noclobber Places restrictions on output redirection to ensure that files are not accidentally destroyed and that redirections append to existing files.
noglob Inhibits file name expansion. This is most useful in shell scripts that are not dealing with file names, or when a list of file names has been obtained and further expansions are not desirable.
nonomatch Specifies that no error results if a file name expansion does not match any existing files; rather, the primitive pattern returns. It is still an error for the primitive pattern to be malformed.
notify Specifies that the shell send asynchronous notification of changes in job status. The default presents status changes just before displaying the shell prompt.
path Specifies directories in which commands are sought for execution. A null word specifies the current directory. If there is no path variable set, then only full path names can run. The default search path (from the /etc/environment file used during login) is:

/usr/bin /etc /usr/sbin /usr/ucb /usr/bin/X11 /sbin
  A shell given neither the -c nor the -t flag normally hashes the contents of the directories in the path variable after reading the .cshrc and also each time the path variable is reset. If new commands are added to these directories while the shell is active, you must give the rehash command, or the commands might not be found.
prompt Specifies the string displayed before each command is read from an interactive workstation input. If an ! appears in the string, it is replaced by the current event number. If the ! character is in a quoted string enclosed by single or double quotation marks, the ! character must be preceded by a \. The default prompt for users without root authority is % . The default prompt for the root user is #.
savehist Specifies a numeric value to control the number of entries of the history list that are saved in the ~/.history file when you log out. Any command referenced in this number of events is saved. During startup, the shell reads ~/.history into the history list, enabling history to be saved across logins. Very large values of the savehist variable slow down the shell startup.
shell Specifies the file in which the C shell resides. This is used in forking shells to interpret files that have execute bits set, but which are not executable by the system. This is initialized to the home of the C shell.
status Specifies the status returned by the last command. If the command ends abnormally, 0200 is added to the status. Built-in commands that are unsuccessful return an exit status of 1. Successful built-in commands set status to a value of 0.
time Controls automatic timing of commands. If this variable is set, any command that takes more than the specified number of CPU seconds will display a line of resources used, at the end of execution. For more information about the default outputs, see the built-in time command.
verbose Set by the -v command line flag, this variable causes the words of each command to display after history substitution.


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]