Next: , Previous: , Up: Configuration   [Contents][Index]


5.5 Environment modification

By default, each handler inherits the environment of the master direvent process augmented with the following variables:

environment variable: DIREVENT_SYSEV_CODE

The system-dependent event code (see the sysev_code macro variable).

environment variable: DIREVENT_SYSEV_NAME

The system-dependent event name (see the sysev_name variable). If several system-dependent events are delivered, this variable contains their names separated with single horizontal space character.

environment variable: DIREVENT_GENEV_CODE

The generic event code (see the genev_code variable).

environment variable: DIREVENT_GENEV_NAME

The generic event name (see the genev_name variable). If several generic events are delivered, this variable contains their names separated with single horizontal space character.

environment variable: DIREVENT_FILE

The name of the affected file relative to the current working directory (see the file variable).

This environment can be further modified, using the environ configuration statement:

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

Statements inside the environ block define operations that modify the environment. Their arguments undergo variable expansion (see variable expansion). 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.

environ: 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.

environ: keep pattern
environ: keep "name=value"

Declares variables matching pattern as exempt from clearing. This statement implies clear.

The pattern is either a variable name or a globbing pattern matching one or more names.

In the second form, the variable will be retained only if it has the given value. Note, that the argument must be quoted.

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

environ {
  clear;
  keep HOME;
  keep USER;
  keep PATH;
  keep "DIREVENT_*";
}
environ: set "name=value"

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

environ {
  set "MYLIB=$HOME/lib";
  set "LD_LIBRARY_PATH=$LD_LIBRARY_PATH${LD_LIBRARY_PATH:+:}$MYLIB";
}
environ: eval "expr"

Perform variable expansion on expr 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:

environ {
  eval "${LD_LIBRARY_PATH:=/usr/local/lib}";
}
environ: unset pattern
environ: unset "name=value"

Unset environment variables matching pattern.

The pattern is either a variable name or a globbing pattern matching one or more names.

In the second form, the variable will be unset only if it has the given value. Note, that the argument must be quoted.

E.g., the following will unset the LOGIN variable:

unset LOGIN;

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

unset "LD_*";

Notice, that patterns containing wildcard characters must be quoted.


Next: , Previous: , Up: Configuration   [Contents][Index]