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.
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.