Next: , Previous: , Up: posix   [Index]


4.4 Interfacing with the execution environment

The Scheme level representation of environment variables names and values is a string, but internally it is a bytevector; strings are internally converted to bytevectors using string->utf8.

Function: getenv varname

Interface to the C function getenv(), (libc)getenv. Retrieve the value of environment variables. variable must reference a string object representing the name of the environment variable. If the environment variable is set: return a string representing its value; else return false.

(getenv "PATH")
⇒ "/usr/local/bin:/usr/bin:/bin"
Function: setenv variable value overwrite

Interface to the C function setenv(), (libc)setenv. Set a new value for an environment variable.

variable must reference a string object representing the name of the environment variable; value must reference a string object representing the new value. If overwrite is false and the environment variable already exists: the environment variable is left untouched; else the new value is set, either creating a new environment variable or replacing the old value.

If successful return true, if an error occurs in setenv() return false.

Function: unsetenv variable

Interface to the C function unsetenv(), (libc)unsetenv. Unset an environment variable. variable must reference a string object representing the name of the environment variable. Return true if variable has the correct format, else return false; there is no way to know if a variable was actually unset.

Function: environ

Interface to the global C variable environ, (libc)unsetenv. Retrieve the full environment. Return a list of strings representing the contents of the environ array; if the environment is empty (no environment variables set) return nil.

Function: environ-table

Internally invoke environ and convert the alist of strings into a hashtable; return the hashtable. Both keys and values are strings.

Function: environ->table environ
Function: table->environ table

Convert between an alist in “environ” format and a hashtable.


Next: , Previous: , Up: posix   [Index]