ICI Modules: env

Modules by name : by type


The env module provides access to the process environment via what appears to be a normal struct object called env. To access the environment through the env struct you simply index it with the name of an environment variable (a string). Fetching from env struct reads from the environment while assigning to the envstruct either modifies an exisiting environment variable or adds a new one to the environment.

The env struct restricts keys and values to being string objects as required by the process environment.


The module exports no functions. The env object (or the result of evaluating load("env")) is for all intensive purposes a normal struct object. It simply has the side-effect of modifying the program's environment when it is assigned to and restricts keys and values to strings.


To fetch values from the environment you simply index the env variable,

    home_dir := env.HOME;

    forall (dir in gettokens(env.PATH, ":"))

To assign into the environment just assign a new value to a member of env or add a new member,

    env.ICIPATH = my_lib_dir + ":" + env.ICIPATH;

    env.CVSROOT = "/home/ncvs";


The env module is experimental. It is implemented by dynamically modifiying the type method table for a struct object. This has caused problems on some platforms. Please advise me if you encounter any bad behaviour.