Environment variables defined in this chapter affect the operation of multiple utilities, functions, and applications. There are other environment variables that are of interest only to specific utilities. Environment variables that apply to a single utility only are defined as part of the utility description. See the ENVIRONMENT VARIABLES section of the utility descriptions in the Shell and Utilities volume of IEEE Std 1003.1-2001 for information on environment variable usage.
The value of an environment variable is a string of characters. For a C-language program, an array of strings called the environment shall be made available when a process begins. The array is pointed to by the external variable environ, which is defined as:
extern char **environ;
These strings have the form name=value; names shall not contain the character '=' . For values to be portable across systems conforming to IEEE Std 1003.1-2001, the value shall be composed of characters from the portable character set (except NUL and as indicated below). There is no meaning associated with the order of strings in the environment. If more than one string in a process' environment has the same name, the consequences are undefined.
Environment variable names used by the utilities in the Shell and Utilities volume of IEEE Std 1003.1-2001 consist
solely of uppercase letters, digits, and the '_' (underscore) from the characters defined in Portable Character Set and do not begin with a digit. Other characters may be permitted by
an implementation; applications shall tolerate the presence of such names. Uppercase and lowercase letters shall retain their
unique identities and shall not be folded together. The name space of environment variable names containing lowercase letters is
reserved for applications. Applications can define any environment variables with names from this name space without modifying the
behavior of the standard utilities.
The values that the environment variables may be assigned are not restricted except that they are considered to end with a null byte and the total space used to store the environment and the arguments to the process is limited to {ARG_MAX} bytes.
Other name= value pairs may be placed in the environment by, for example, calling any of the setenv(), unsetenv(), [XSI] or putenv() functions, manipulating the environ variable, or by using envp arguments when creating a process; see exec in the System Interfaces volume of IEEE Std 1003.1-2001.
It is unwise to conflict with certain variables that are frequently exported by widely used command interpreters and applications:
ARFLAGS |
IFS |
MAILPATH |
PS1 |
CC |
LANG |
MAILRC |
PS2 |
CDPATH |
LC_ALL |
MAKEFLAGS |
PS3 |
CFLAGS |
LC_COLLATE |
MAKESHELL |
PS4 |
CHARSET |
LC_CTYPE |
MANPATH |
PWD |
COLUMNS |
LC_MESSAGES |
MBOX |
RANDOM |
DATEMSK |
LC_MONETARY |
MORE |
SECONDS |
DEAD |
LC_NUMERIC |
MSGVERB |
SHELL |
EDITOR |
LC_TIME |
NLSPATH |
TERM |
ENV |
LDFLAGS |
NPROC |
TERMCAP |
EXINIT |
LEX |
OLDPWD |
TERMINFO |
FC |
LFLAGS |
OPTARG |
TMPDIR |
FCEDIT |
LINENO |
OPTERR |
TZ |
FFLAGS |
LINES |
OPTIND |
USER |
GET |
LISTER |
PAGER |
VISUAL |
GFLAGS |
LOGNAME |
PATH |
YACC |
HISTFILE |
LPDEST |
PPID |
YFLAGS |
HISTORY |
|
PRINTER |
|
HISTSIZE |
MAILCHECK |
PROCLANG |
|
HOME |
MAILER |
PROJECTDIR |
|
If the variables in the following two sections are present in the environment during the execution of an application or utility, they shall be given the meaning described below. Some are placed into the environment by the implementation at the time the user logs in; all can be added or changed by the user or any ancestor of the current process. The implementation adds or changes environment variables named in IEEE Std 1003.1-2001 only as specified in IEEE Std 1003.1-2001. If they are defined in the application's environment, the utilities in the Shell and Utilities volume of IEEE Std 1003.1-2001 and the functions in the System Interfaces volume of IEEE Std 1003.1-2001 assume they have the specified meaning. Conforming applications shall not set these environment variables to have meanings other than as described. See getenv() and the Shell and Utilities volume of IEEE Std 1003.1-2001, Section 2.12, Shell Execution Environment for methods of accessing these variables.
This section describes environment variables that are relevant to the operation of internationalized interfaces described in IEEE Std 1003.1-2001.
Users may use the following environment variables to announce specific localization requirements to applications. Applications can retrieve this information using the setlocale() function to initialize the correct behavior of the internationalized interfaces. The descriptions of the internationalization environment variables describe the resulting behavior only when the application locale is initialized in this way. The use of the internationalization variables by utilities described in the Shell and Utilities volume of IEEE Std 1003.1-2001 is described in the ENVIRONMENT VARIABLES section for those utilities in addition to the global effects described in this section.
For example:
NLSPATH="/system/nlslib/%N.cat"
defines that catopen() should look for all message catalogs in the directory /system/nlslib, where the catalog name should be constructed from the name parameter passed to catopen() ( %N ), with the suffix .cat.
Conversion specifications consist of a '%' symbol, followed by a single-letter keyword. The following keywords are currently defined:
An empty string is substituted if the specified value is not currently defined. The separators underscore ( '_' ) and period ( '.' ) are not included in the %t and %c conversion specifications.
Templates defined in NLSPATH are separated by colons ( ':' ). A leading or two adjacent colons "::" is equivalent to specifying %N . For example:
NLSPATH=":%N.cat:/nlslib/%L/%N.cat"
indicates to catopen() that it should look for the requested message catalog in name, name.cat, and /nlslib/category/name.cat, where category is the value of the LC_MESSAGES category of the current locale.
Users should not set the NLSPATH variable unless they have a specific reason to override the default system path. Setting NLSPATH to override the default system path produces undefined results in the standard utilities and in applications with appropriate privileges.
The environment variables LANG , LC_ALL , LC_COLLATE , LC_CTYPE , LC_MESSAGES , LC_MONETARY , LC_NUMERIC , LC_TIME , [XSI] and NLSPATH provide for the support of internationalized applications. The standard utilities shall make use of these environment variables as described in this section and the individual ENVIRONMENT VARIABLES sections for the utilities. If these variables specify locale categories that are not based upon the same underlying codeset, the results are unspecified.
The values of locale categories shall be determined by a precedence order; the first condition met below determines the value:
If the LC_ALL environment variable is defined and is not null, the value of LC_ALL shall be used.
If the LC_* environment variable ( LC_COLLATE , LC_CTYPE , LC_MESSAGES , LC_MONETARY , LC_NUMERIC , LC_TIME ) is defined and is not null, the value of the environment variable shall be used to initialize the category that corresponds to the environment variable.
If the LANG environment variable is defined and is not null, the value of the LANG environment variable shall be used.
If the LANG environment variable is not set or is set to the empty string, the implementation-defined default locale shall be used.
If the locale value is "C" or "POSIX" , the POSIX locale shall be used and the standard utilities behave in accordance with the rules in POSIX Locale for the associated category.
If the locale value begins with a slash, it shall be interpreted as the pathname of a file that was created in the output format used by the localedef utility; see OUTPUT FILES under localedef. Referencing such a pathname shall result in that locale being used for the indicated category.
[XSI] If the locale value has the form:
language[_territory][.codeset]
it refers to an implementation-provided locale, where settings of language, territory, and codeset are implementation-defined.
LC_COLLATE , LC_CTYPE , LC_MESSAGES , LC_MONETARY , LC_NUMERIC , and LC_TIME are defined to accept an additional field @ modifier, which allows the user to select a specific instance of localization data within a single category (for example, for selecting the dictionary as opposed to the character ordering of data). The syntax for these environment variables is thus defined as:
[language[_territory][.codeset][@modifier]]
For example, if a user wanted to interact with the system in French, but required to sort German text files, LANG and LC_COLLATE could be defined as:
LANG=Fr_FR LC_COLLATE=De_DE
This could be extended to select dictionary collation (say) by use of the @ modifier field; for example:
LC_COLLATE=De_DE@dict
An implementation may support other formats.
If the locale value is not recognized by the implementation, the behavior is unspecified.
At runtime, these values are bound to a program's locale by calling the setlocale() function.
Additional criteria for determining a valid locale name are implementation-defined.
Users should not need to set this variable in the environment unless there is a specific reason to override the implementation's default behavior, such as to display data in an area arbitrarily smaller than the terminal or window.
Users should not need to set this variable in the environment unless there is a specific reason to override the implementation's default behavior, such as to display data in an area arbitrarily smaller than the terminal or window.
:characters
or:
std offset dst offset, rule
If TZ is of the first format (that is, if the first character is a colon), the characters following the colon are handled in an implementation-defined manner.
The expanded format (for all TZ s whose value does not have a colon as the first character) is as follows:
stdoffset[dst[offset][,start[/time],end[/time]]]
Where:
Each of these fields may occur in either of two formats quoted or unquoted:
In the quoted form, the first character shall be the less-than ( '<' ) character and the last character shall be the greater-than ( '>' ) character. All characters between these quoting characters shall be alphanumeric characters from the portable character set in the current locale, the plus-sign ( '+' ) character, or the minus-sign ( '-' ) character. The std and dst fields in this case shall not include the quoting characters.
In the unquoted form, all characters in these fields shall be alphabetic characters from the portable character set in the current locale.
The interpretation of these fields is unspecified if either field is less than three bytes (except for the case when dst is missing), more than {TZNAME_MAX} bytes, or if they contain characters other than those specified.
hh[:mm[:ss]]
The minutes ( mm) and seconds ( ss) are optional. The hour ( hh) shall be required and may be a single digit. The offset following std shall be required. If no offset follows dst, the alternative time is assumed to be one hour ahead of standard time. One or more digits may be used; the value is always interpreted as a decimal number. The hour shall be between zero and 24, and the minutes (and seconds)-if present-between zero and 59. The result of using values outside of this range is unspecified. If preceded by a '-' , the timezone shall be east of the Prime Meridian; otherwise, it shall be west (which may be indicated by an optional preceding '+' ).
date[/time],date[/time]
where the first date describes when the change from standard to alternative time occurs and the second date describes when the change back happens. Each time field describes when, in current local time, the change to the other time is made.
The format of date is one of the following:
The time has the same format as offset except that no leading sign ( '-' or '+' ) is allowed. The default, if time is not given, shall be 02:00:00.