environ -- the user environment


The user environment is a collection of information about a user, such as login directory, mailbox, and terminal type. The environment is stored in special ``environment variables,'' which can be assigned character values, such as names of files, directories, and terminals. These variables are automatically made available to programs and commands invoked by the user. The commands can then use the values to access the user's files and terminal.

The environment can be changed by assigning a new value to a variable. An assignment has the form:

name = value

For example, the assignment:


sets the TERM variable to the value ``h29''. The new value can be ``exported'' to each subsequent invocation of a shell by exporting the variable with the export command (see sh(C)) or by using the env(C) command.

You may also add variables to the environment, but you must be sure that the new names do not conflict with exported shell variables such as MAIL, PS1, PS2, and IFS. Placing assignments in the .profile file is a useful way to change the environment automatically before a session begins.

Note that the environment is made available to all programs as an array of strings. Each string has the form:


where the name is the name of an exported variable and the value is the variable's current value. For programs started with a exec(S) call, the environment is available through the external pointer environ. For other programs, individual variables in environment are available through getenv(S) calls.

The following is a short list of commonly used environment variables.

Used to set the editor. The default editor is ed(C). Using vi as an example, for Bourne Shell users, the syntax is:

EDITOR = /bin/vi

For C-Shell users, the syntax is:

setenv EDITOR /bin/vi

Used to set vi options and define vi abbreviations and mappings. For Bourne Shell users, the syntax is:

EXINIT = 'set options'

For C-Shell users, the syntax is:

setenv EXINIT 'set options'

For example, a C-Shell user might place the following command in $HOME/.cshrc:

setenv EXINIT 'set wm=24 | map g 1G'

This would automatically set vi's wrapmargin option to 24 and would define the ``g'' key to move to the top of the file (just as ``G'' moves to the bottom of the file).

You can set more than one option with the same set command. If you define abbreviations or mappings with this environment variable, you must separate the abbr and map commands from the set command and from each other with a bar (|). The function of the bar is similar to that of the semicolon that separates commands on a shell command line.

If you are defining many customizations, you might prefer to use the .exrc file, where each command can be listed one per line (see vi(C)).

Names the user's login directory. Initially, HOME is set to the login directory given in the user's passwd file entry.

Defines, with a numerical value, the number of clock interrupts per second. The value of this variable is dependent on the hardware, and configured in the file /etc/initscript. If HZ is not defined, programs which depend on this hertz value, such as prof(CP) and times(S), will not run.

Represents the international locale in the format language_territory.codeset. This is used by setlocale(S) to establish the default locale on program startup.

Individual locale-specific functions can be affected independently using the following optional LC_* environment variables:

Locale affecting collation/sorting sequence.

Locale affecting character classification routines (ctype(S)).

Locale affecting message language.

Locale affecting currency formatting.

Locale affecting numeric formatting.

Locale affecting time and date format.

Defines the search path for the directories containing commands. The system searches these directories whenever a user types a command without giving a full pathname. The search path is one or more directory names separated by colons (:). Initially, PATH is set to :/bin:/usr/bin.

Defines the type of terminal being used. This information is used by commands such as more(C) which rely on information about the capabilities of the user's terminal. The variable may be set to any valid terminal name (see terminals(M)) directly or by using the tset(C) command.

Defines time zone information. This information is used by date(C) to display the appropriate time. The variable may have any value of the form:

std offset [ dst [ offset ],[ start [ /time ], end [ /time ]]]

(You may also have:

std offset [ dst [ offset ];[ start [ /time ], end [ /time ]]]

which is the XENIX format. Note that this format is not POSIX compatible.)

std, the standard local time zone abbreviation (1-9 characters), and offset, the difference between the local time and GMT, are the only mandatory fields.

offset should be specified as:

[ + | - ] hh [ :mm [ :ss ]]

where hh is hours (0-24), mm is minutes (0-59), and ss is seconds (0-59). Only the hours field is mandatory. If offset is preceded by a minus (-), it is east of the Prime Meridian, otherwise it is assumed to be west (this can be specified with an optional plus (+)).

dst is a 1-9 character abbreviation for the local summertime timezone. If dst is not specified, the system will not be aware of summertime; it will always be on standard time.

The offset after dst is the difference between local standard time and local summertime. If you do not specify an offset, it is assumed to be one hour. (This is usually what you want.)

Everything following the second offset is the rule for when to change from standard to summertime. start/time is when the change to summertime occurs; end/time is when the time changes back. (Note that, for systems in the Southern Hemisphere, start/time does not have to come earlier in the year than end/time.)

start and end describe the day, while time specifies the time. time is specified in the same way as offset (see above), but the leading ``+'' or ``-'' is not valid. If time is not specified, it is assumed to be 02:00:00 (2 A.M.).

start and end can be specified in any of the following ways:

The Julian day (1-365). Leap years are not counted; February 28 is day 59 and March 1 is day 60, always.

The zero-based Julian day (0-365); you can refer to February 29 in a leap year.

The dth day (0-6, where 0 is Sunday) of week n (1-4).

The dth day (0-6, where 0 is Sunday) of week n (1-5) of month m (1-12). If you specify the week (n) as 5, this means the last d day in m month, as in M8.5.1 which would be the last Monday in August.

If you specify the comma starting off the summertime rule, it is advisable to specify the rest of the rule.

A sample TZ for Eastern Standard Time, EST, might look like this:

We start off with ``EST5:00'': this names our time zone and defines it as five hours west of Greenwich Mean Time. Summertime in this locale is called EDT (Eastern Daylight Time), and is four hours ahead of GMT. Summertime starts on a Sunday in the first week in April at 2 A.M., and standard time resumes on the last Sunday in October at 2 A.M.

Refer to the tz(M) and timezone(F) manual pages for more information on TZ.

See also

env(C), exec(S), getenv(S), locale(M), login(M), profile(M), setlocale(S), sh(C), timezone(F), tz(M)

Standards conformance

environ is conformant with:

ISO/IEC 9945-1:1990, Information technology - Portable Operating System Interface (POSIX) - Part 1: System Application Program Interface (API) [C Language] (IEEE Std 1003.1-1990);
NIST FIPS 151-2;
AT&T SVID Issue 2.

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