Some environment variables are defined by POSIX.1 in the Single UNIX Specification, whereas others are defined only if the XSI option is supported. Figure 7.7 lists the environment variables defined by the Single UNIX Specification and notes which implementations support the variables. Any environment variable defined by POSIX.1 is marked with •; otherwise, it is part of the XSI option. Many additional implementation-dependent environment variables are used in the four implementations described in this book. Note that ISO C doesn’t define any environment variables.

enter image description here

Are the environment variables defined by POSIX for a shell, or for any process which doesn't necessarily run shell?


My post is inspired from What are the environment variables by default?


They are defined for any process, but they don’t have to exist in any process (as a general rule).

POSIX gives meaning to a number of environment variables. It should be thought of as a dictionary; the fact that a variable is defined in POSIX doesn’t mean that it has to exist (unless its definition says so), but if the variable is present in any process’ environment, its value must be understood (and, for conformant utilities where it is relevant, acted upon) according to the POSIX definition.

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.

As always “placed into the environment” must be understood as affecting the relevant process tree (children created with the variable set), there is no global environment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.