When Value is an atom or number, it is first converted to a string, and the environment variable is set to the resulting string value.
The mechanism can be used to pass information from an eclipse-process to its sub-processes. Note however, that due to operating system limitations, environment strings cannot contain null characters (unlike ECLiPSe strings). Also, the strings used as arguments to setenv/2 cannot be garbage collected and will accumulate.
Operating system dependencies: Because of portability issues, on UNIX there is currently no facility to unset an environment variable completely, but it can set to an empty string. On Windows on the other hand, an environment variable's value cannot be the empty string: setting an environment variable to the empty string makes it indistinguishable from an unset or nonexisting one.
?- setenv(abc, hello), getenv(abc, X). X = "hello" Yes (0.00s cpu) ?- setenv("abc", "world"), getenv(abc, X). X = "world" Yes (0.00s cpu) ?- setenv(abc, 999), getenv(abc, X). X = "999" Yes (0.00s cpu) ?- setenv(abc, data), sh("echo $abc"). data Yes (0.00s cpu) ?- setenv(abc, data), exec([sh,"-c","echo $abc"], []). data Yes (0.00s cpu) ?- setenv(abc, data), exec([eclipse,"-e","getenv(abc,X),writeln(X)"], []). data Yes (0.00s cpu) ?- setenv(abc, ""), getenv(abc, X). % on UNIX X = "" Yes (0.00s cpu) ?- setenv(abc, ""), getenv(abc, X). % on Windows No (0.00s cpu)