Your Browser is not longer supported

Please use Google Chrome, Mozilla Firefox or Microsoft Edge to view the page correctly
Loading...

{{viewport.spaceProperty.prod}}

Environment variables

&pagelevel(3)&pagelevel

The environment variables (also called shell variables) described in this section affect the operation of commands, functions and applications. There are other environment variables that are of interest only to specific commands (refer to the keyword "shell variables" in the manual "POSIX Commands" [2 (Related publications)]). When a process begins execution, an array of strings called the environment is made available by the exec functions (see exec). The following external variable points to this vector:

extern char **environ;

In accordance with the XPG4 Version 2 standard, these strings have the form "name=value", e.g. "PATH=/sbin:/usr/sbin".

Applications may also define their own environment variables, provided the naming conventions are complied with (see manual "POSIX Commands" [2 (Related publications)]).

Supplying the environment variables with default values from BS2000

If a program is not started from the shell but from SDF-environment via /START-EXECUTABLE-PROGRAM, the environment variables are not defined by default.
In this case you can supply them with default values from within BS2000 by defining an SDF-P variable with the name SYSPOSIX as a structure (see the manual "SDF-P" [9 (Related publications)]). When the value of the variable SYSPOSIX.name is value, the string "name=value" is written to the global data area of the program; however, only variables of the type ’string’ are taken into account.

Only uppercase letters may be used for variable names at the BS2000 command level. Hyphens in the names of SDF-P variables are converted to underscores, e.g. SYSPOSIX.LC-NAME would be converted to the string "LC_NAME=...".

Environment variables for internationalization

An internationalized program makes no fixed assumptions about its runtime environment. It determines its specific runtime environment from environment variables.

For example, the environment for displaying outputs is determined from the environment variables LANG and LC_xxx, while the functions for processing message catalogs interpret the NLSPATH environment variable.

The following environment variables are supported for internationalization:


LANG

Determines the locale category for native language, local customs and coded character set in the absence of LC_ALL and other environment variables. LANG can be used by applications to determine the language and format for error messages, collating sequences, date formats, and so forth.
The value of this environment variable has the form:

LANG=language[_territory[.codeset]]

For example, a user from Austria who speaks German and is using a terminal with the ISO 8859/1 character set would set the LANG variable to the following value:

LANG=De_A.88591

This enables a user to find the appropriate message catalogs, assuming that they exist.

Specific language operations are initialized at runtime by calling the setlocale() function. Normally, the user's language requirements, as specified by the setting of LANG, are bound to a program's locale in a subsequent invocation of setlocale() as follows:

setlocale (LC_ALL, "");

LC_ALL

On X/Open systems, this form of a setlocale() call is defined to initialize the program locale from the associated environment variables. LC_ALL addresses the program's entire locale, and LANG provides the necessary defaults if any of the category-specific variables are not set or are set to the empty string.

LC_COLLATE

This category specifies the collation sequence to be used. The related information is stored in a database that is created by the colltbl() command.
This environment variable affects strcoll() and strxfrm().

LC_CTYPE

This category determines character classification, case conversion, and the size of multi-byte characters. The related information is stored in a database that is created by the chrtbl() command. The default definition for C corresponds to the 7-bit codeset. This environment variable is used by ctype(), mbchar() and several commands, e.g. cat, ed, ls and vi.

LC_MESSAGES

This category determines the language of the message catalog used. For example, an application may have one message catalog with French messages and another containing messages in German.

LC_MONETARY

Specifies the currency symbols and separators for a specific environment.
This environment variable is used by localeconv().

LC_NUMERIC

This category defines the separators for decimal places and thousands.
The environment variable is used by localeconv(), printf() and strtod().

LC_TIME

NLSPATH

This category specifies the date and time formats.

The environment variable NLSPATH returns the location of message catalogs in the form of a search path as well as the naming conventions associated with the message catalogs. For example:

NLSPATH=/nlslib/%L/%N.cat:/nlslib/%N/%L

The metacharacter % indicates a substitution field, where %L is replaced by the current setting of the environment variable LANG (see below) and %N is replaced by the value of the name parameter passed to catopen(). In the example above, catopen() looks first in /nlslib/$LANG/name.cat and then in /nlslib/name/$LANG for the specified message catalog .

NLSPATH is usually set system-wide (e.g. in /etc/profile) and therefore makes the location and naming conventions for message catalogs transparent to programs as well as the user.

The complete set of metacharacters include the following symbols:

Metacharacter

Meaning

%N

Value of the name parameter passed to catopen()

%L

Value of LANG

%l

Value of the language element from LANG

%t

Value of the territory element from LANG

%c

Value of the codeset element from LANG

%%

A single % character

The behavior of the language information function nl_langinfo() is likewise affected by the values set for these environment variables (see also langinfo.h).

LC_COLLATE, LC_CTYPE, 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 wants to interact with the system in French, but needs 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 (for example) by use of the @modifier field:

LC_COLLATE=De_DE@dict

These values are linked to a program ́s locale at runtime by calling setlocale().