[ ECLiPSe Operating System built-in.|Group Index| Full Index]

getenv(+EnvVar, ?Value)

Succeeds if the string EnvVar corresponds to a variable set in the UNIX environment, and it unifies Value with the string which is the value of that variable.

+EnvVar
String or atom.
?Value
String or variable.

Description

The first argument must be a string or an atom. It succeeds if this string corresponds to a variable which has been set in the UNIX environment, and in this case it unifies the second argument with the string which is the value of that variable.

Fail Conditions

Fails if Value is not the value corresponding to the variable EnvVar set in the UNIX environment, or if no such environment variable exists.

Resatisfiable

No.

Exceptions

(4) Instantiation fault
EnvVar is not instantiated.
(5) Type error
EnvVar is instantiated, but not to a string or an atom.
(5) Type error
Value is instantiated, but not to a string.

Examples


Success:
      getenv('HOME',V).    (gives V="/home/username").
      getenv("SHELL",V).   (gives V="/bin/csh").
      getenv('TERM',V).    (gives V="sun-cmd").
      getenv('USER',V).    (gives V="username").

Fail:
      getenv('TERM',"vt100").

Error:
      getenv(TERM,V).               (Error 4).
      getenv('TERM',atom).          (Error 5).
      getenv(1,V).                  (Error 5).


See Also

sh / 1, argv / 2, argc / 1