Next: , Previous: , Up: Component Statement   [Contents][Index]


3.3.4 Environment

Normally all components inherit the environment of the master pies process. You can modify this environment using the env statement. It has two variants: compound and legacy. The legacy one-line statement was used in pies versions up to 1.3 and is still retained for backward compatibility. It is described in env legacy syntax. This subsection describes the modern compound syntax.

The env statement can also be used in global context, in which case it modifies environment for the master pies program, i.e. the environment that will be inherited by all components (see Global Configuration). The global env is available only in compound syntax described here.

Config: component: env { ... }

The compound env statement has the following syntax:

env {
   clear;
   keep pattern;
   set "name=value";
   eval "value";
   unset pattern;
}

Statements inside the env block define operations that modify the environment. The clear and keep statements are executed first. Then, the set and unset statements are applied in the order of their appearance in the configuration.

env: clear

Clears the environment by removing (unsetting) all variables, except those listed in keep statements, if such are given (see below). The clear statement is always executed first.

env: keep pattern

Declares variables matching pattern (a globbing pattern) as exempt from clearing. This statement implies clear.

For example, the following configuration fragment removes from the environment all variables except ‘HOME’, ‘USER’, ‘PATH’, and variables beginning with ‘LC_’:

env {
  clear;
  keep HOME;
  keep USER;
  keep PATH;
  keep "LC_*";
}
env: keep "name=value"

Retains the variable name, if it has the given value. Note, that the argument must be quoted.

env: set "name=value"

Assigns value to environment variable name. The value is subject to variable expansion using the same syntax as in shell. The set and unset (see below) statements are executed in order of their appearance. For example

env {
  set "MYLIB=$HOME/lib";
  set "LD_LIBRARY_PATH=$LD_LIBRARY_PATH${LD_LIBRARY_PATH:+:}$MYLIB";
}
env: eval "value"

Perform variable expansion on value and discard the result. This is useful for side-effects. For example, to provide default value for the LD_LIBRARY_PATH variable, one may write:

env {
  eval "${LD_LIBRARY_PATH:=/usr/local/lib}";
}
env: unset pattern

Unset environment variables matching pattern. The following will unset the LOGIN variable:

unset LOGIN;

The following will unset all variables starting with ‘LD_’:

unset "LD_*";

Notice, that patterns containing wildcard characters must be quoted.


Next: , Previous: , Up: Component Statement   [Contents][Index]