FunctionPackage: systemToCDocOverviewCGDocRelNotesFAQIndexPermutedIndex
Allegro CL version 10.1
Unrevised from 10.0 to 10.1.
10.0 version


Arguments: string

The new :osi module, released after the release of Allegro CL 6.2, has additional functionality relating to environment variables, including setenv and unsetenv. See OSI miscellaneous low-level functionality in os-interface.htm. The symbol system:getenv is exported from the new excl.osi package (as well as from the system package).

This function returns the value (a string) of an environment variable (such as TERM, SHELL, and DISPLAY). If the environment variable is not defined, nil is returned. This function may be used with setf to set an environment variable. For example:

;; The current values of the environment variable on your system may, 
;; of course, be different from what appears in this example. 
user(2): (sys:getenv "SHELL")
user(3): (setf (sys:getenv "SHELL") "/bin/sh") 
user(4): (sys:getenv "SHELL") 

Warning: When you use setf with sys:getenv to set an environment variable, the string specifying the new value is stored in malloc'ed space and that space cannot be freed (in any practical way). This creates a small memory leak in the system, but it should only be significant if you set many, many environment variables.

Note that there is no pre-defined, programmatic way to unset an environment variable from within Lisp. It is an error to setf sys:getenv to anything other than a string and the effect of doing so is undefined (an error is typically not signaled but the behavior is likely not what is intended). Specifically.

(setf (sys:getenv "VAR") nil) 

does not unset VAR in the environment.

See os-interface.htm.

Copyright (c) 1998-2017, Franz Inc. Oakland, CA., USA. All rights reserved.
This page was not revised from the 10.0 page.
Created 2017.2.15.

Allegro CL version 10.1
Unrevised from 10.0 to 10.1.
10.0 version