DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Configuring and working with the shells

Setting environment variables

The shells use some variables to configure their operations. For example, the Bourne shell and Korn shell provide a facility to make the shell notify you when mail arrives. To use it, set the shell variable MAIL to the name of the file in which you keep your mail (usually .mailbox). If the file grows, ksh will notify you. The existence of the MAIL variable is used by the shell as a flag to indicate that it should notify you whenever new mail arrives. You can set the variable within the shell, or set it in one of the profile files executed at login; the presence or absence of the variable affects the way the shell behaves.

The following is a list of the environment variables automatically set by the Korn shell (see ksh(C)). The other supported shells have a similar list of variables; for details see sh(C) and csh(C).


ERRNO
Set the value of the last error condition returned by a failed system call.

LINENO
Set to the current line number of the script or function being executed.

OLDPWD
The previous directory set by cd(C).

OPTARG
The value of the last option argument processed by the getopts(C) special command.

OPTIND
The index of the last option argument processed by the getopts special command.

PPID
The process number of the parent of the shell.

PWD
Present working directory.

RANDOM
A random integer number (in the range 0 to 32767).

REPLY
Set by the select statement (see ``Generating a simple menu: the select statement'') and by the read special command (see ksh(C)) when no arguments are supplied.

SECONDS
The number of seconds since ksh was invoked.
The following environment variables are also used by the Korn shell:

CDPATH
The search path for the cd command.

COLUMNS
The width of the edit window for the shell edit modes and for printing select lists.

FCEDIT
The default editor name for the fc(C) command.

FPATH
The search path for function definitions.

IFS
Defines the character used as the internal field separator.

HISTFILE
The pathname of the file that will be used to store the command history.

HISTSIZE
The number of previously entered commands that are accessible by the shell; the default is 128.

HOME
The default home directory for the cd command.

LINES
The number of lines on the terminal. Used by ksh and some other programs when presenting menus; the default is 24.

MAIL
A mailfolder. If it grows, the shell notifies you that mail has arrived.

MAILCHECK
The time interval in seconds between checks for new mail.

MAILPATH
Tells the shell to inform the user of any modifications to the specified files that have occurred within the last MAILCHECK seconds.

PATH
The search path for commands.

PS1 ... PS4
Prompt strings (see ksh(C) for more details).

SHELL
The pathname of the shell.

TERM
The terminal type; used by many programs that write to the screen.

TMOUT
The number of seconds of inactivity after which the shell will automatically terminate; a value of 0 means that the shell will not automatically terminate.

Many programs other than the shells look for specific variables every time they run; such variables are used to control the execution of these programs. For example, vi checks for a variable called EXINIT whenever it starts up. If any vi options are specified in EXINIT, vi sets them accordingly. Likewise, mail checks for a variable called MAILRC which specifies the startup file from which mail reads its options. By setting some environment variables, usually at login time, you can customize these programs to your requirements.
Next topic: Exporting variables to the environment
Previous topic: Setting shell variables

© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003