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
The other supported shells have a similar list of variables; for
The following environment variables are also used by the Korn shell:
Set the value of the last error condition returned by a failed
Set to the current line number of the script or function being
The previous directory set by
The value of the last option argument processed by the
The index of the last option argument processed by the
getopts special command.
The process number of the parent of the shell.
Present working directory.
A random integer number (in the range 0 to 32767).
Set by the select statement (see
``Generating a simple menu: the select statement'')
and by the read special command (see
when no arguments are supplied.
The number of seconds since ksh was invoked.
The search path for the cd command.
The width of the edit window for the shell edit modes and for
printing select lists.
The default editor name for the
The search path for function definitions.
Defines the character used as the internal field separator.
The pathname of the file that will be used to store the command
The number of previously entered commands that are accessible by the
shell; the default is 128.
The default home directory for the cd command.
The number of lines on the terminal. Used by ksh and some
other programs when presenting menus; the default is 24.
A mailfolder. If it grows, the shell notifies you that mail has
The time interval in seconds between checks for new mail.
Tells the shell to inform the user of any modifications to the
specified files that have occurred within the last
The search path for commands.
PS1 ... PS4
Prompt strings (see
for more details).
The pathname of the shell.
The terminal type; used by many programs that write to the screen.
The number of seconds of inactivity after which the shell will
automatically terminate; a value of 0 means that the shell will not
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.
Exporting variables to the environment
Setting shell variables
© 2003 Caldera International, Inc. All rights reserved.
SCO OpenServer Release 5.0.7 -- 11 February 2003