Subject: Re: Environment variables? (Unix)
From: Erik Naggum <>
Date: 1995/04/28
Newsgroups: comp.lang.lisp
Message-ID: <>

[Peter Seibel]

|   Is it possible to access Unix environment variables in Common Lisp.

only on Unix implementations.

|   I looked through CLtL2 and couldn't quite find anything that made it
|   clear to me.

system-dependent issues wouldn't be described in CLtL2.

|   If so how does one access them.

well, first you need find the function.  (apropos "getenv") would be a
start.  (list-all-packages) will list all packages, and you may be able to
focus apropos printout if you limit it to a particular package, as in
(apropos "environment" :extensions).

unfortunately, the three Lisps that I just tested on have not agreed on how
to do it.  here's a unified version

(defun get-environment-variable (var)
  "Return the value of environment variable VAR, or NIL if none."
  (declare (string var))
    #+(and :unix :cmu17) (cdr (assoc (intern var :keyword) *environment-list*))
    #+(and :unix :kcl)   (system:getenv var)	;also AKCL, GCL
    #+(and :unix :clisp) (system::getenv var)

can others add to this for their implementation?  it would be nice to have
a fully portable function among Unix systems.

sufficiently advanced political correctness is indistinguishable from sarcasm