ENVAR

Derivation: ENvironmental VARiables

ENVAR sets the initial values for the environment variables that can later be accessed or changed using the C functions getenv(), putenv, setenv, and clearenv.

The set of environment variables established by the end of runtime option processing reflects all the various sources where environment variables are specified, rather than just the one source with the highest precedence. However, if a setting for the same environment variable is specified in more than one source, the setting with the highest precedence is used.

The system() function can be used to create a new environment. Environment variables in effect at the time of the POSIX system() call are copied to the new environment. The copied environment variables are treated the same as those found in the ENVAR runtime option on the command level.

When you specify the RPTOPTS runtime option, the output for the ENVAR runtime option contains a separate entry for each source where ENVAR was specified with the environment variables from that source.

The default value for non-CICS applications is ENVAR('').

The default value for CICS® applications is ENVAR('').

The default value for AMODE 64 applications is ENVAR('').

Read syntax diagramSkip visual syntax diagram
Syntax

             .-,----------.      
             V            |      
>>-ENVAR--(----+--------+-+--)---------------------------------><
               '-string-'        

string
Is specified as name=value, where name and value are sequences of characters that do not contain null bytes or equal signs. The string name is an environment variable, and value is its value.

Blanks are significant in both the name= and the value characters. You can enclose string in either single or double quotation marks to distinguish it from other strings. You can specify multiple environment variables, separating the name=value pairs with commas. Quotation marks are required when specifying multiple variables.

z/OS® UNIX considerations

In a multithreaded environment, the environment variables are shared by all threads in the process.

Usage notes

  • The entire value of the ENVAR operand, whether a single string or multiple strings, cannot exceed 250 characters.
  • string cannot contain DBCS characters.
  • If ENVAR is specified as part of the _CEE_RUNOPTS environment variable, it is ignored.
  • The ENVAR option functions independently of the POSIX runtime option setting.
  • C/C++ consideration—An application can access the environment variables using C function getenv() or the POSIX variable environ, which is defined as:
        extern char **environ;

    Guideline: You should access environment variables through the getenv() function, especially in a multithread environment. getenv() serializes access to the environment variables.

    Environment variables that are passed to the exec or spawn family of functions replace those established by the ENVAR option in the new environment.

For more information