| United States-English |
|
|
|
![]() |
Shells: User's Guide: HP 9000 Computers > Chapter 13 Shell VariablesBuilt-In Shell Variables |
|
C Shell maintains a set of variables that can be assigned values by the set command. Shell variables are useful for storing values for later use in commands. The most commonly referenced shell variables are, however, those which the shell itself refers to. By changing the values of these variables, you can directly affect the shell behavior. The following variables are supported by C Shell on HP-UX. This variable is used to automatically log you off the system if you do not use the system for a specified amount of time. For example,
will automatically log you off the system if you do not use the system for an hour (60 minutes). To disable autologout, set it to zero (0) time. For example:
or
The cwd variable contains the path name to your current working directory. This variable is automatically changed with each cd (Change Directory) command. At logon, the default for this variable is the directory in the system variable HOME. The home variable contains the path name to your home directory. The default value for this variable is specified in the system file /etc/passwd. (See passwd(5).) The boolean variable ignoreeof determines whether CTRL-D is allowed to log you off the system. If set,
logout must be used to terminate a session. If ignoreeof is unset,
you can also use CTRL-D to log off. The default is set. Use this variable to specify alternate directories to be searched by the system when locating subdirectory arguments used with pushd, cd, and chdir commands. Suppose you use the following command sequence to send keyboard input to a file called newfile.
If newfile exists before this command sequence is executed, the old copy of newfile will be overwritten and thus destroyed. To prevent accidental overwriting of a file containing valuable information, set the boolean noclobber variable so that C Shell cannot overwrite files by including the command line:
in your .login file. To demonstrate its effectiveness, type the following C Shell commands:
When you try to cat to an existing file with noclobber set, the system tells you the File Exists and aborts the command. To override the noclobber, use the exclamation point metacharacter. For example:
If the notify variable is set, you are immediately notified when a background process finishes. If unset, notification messages related to background process completion occur with the next presentation of the C Shell prompt. Use the set command to set notify. The path variable is one of the most important variables in C Shell operation. This variable contains a sequence of directory names C Shell searches for commands. For example:
or
PATH is a system variable, and path is a C Shell variable that serves the same purpose. The first is global, while the second is local to the running shell. When C Shell is first executed, a hash table of command locations is created. This table is created by looking through the directories specified in PATH (except for the current working directory) in the order specified by PATH. Suppose you were to write one or more new commands and store them in one of the directories in your path other than your current working directory. The system has no way of knowing they are there until you notify it of their presence by using the rehash command. The hash table never gets built from commands in ., your current working directory, so new commands put into . don't affect the hash table. But, if your path contained $HOME/tools/bin and you put a new command in there, then rehash would add it to hash table. The hash table also gets rebuilt whenever your PATH is changed. This variable is used to customize your C Shell prompt. For example,
sets the prompt to indicate the command (event) number of the current command. This is very useful when using the History mechanism. Some HP-UX commands, such as mailx and vi, spawn a new shell when they begin execution, while others may spawn one or more new shells during normal operation. If the program or command is written so that it recognizes the shell variable, you can set the variable to define the type of shell to be spawned by the program. For example:
selects C Shell, while
selects POSIX Shell. This technique is valid only if the command or program recognizes that uses the variable when spawning new shells. Be careful when using the shell variable. The result may or may not be what you intended. |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||