2 Customizing the Lisp Environment

2.9 Accessing environment variables

Certain operating systems allow you to assign values to a set of variables called environment variables to customize the operating system environment. Additions or modifications to environment variables are visible only to Lisp and to programs invoked from Lisp by the functionsshell orrun-program; the programs that are invoked inherit the modifications. Environment variables that have been changed or added revert to their original values when Lisp exits.

The following function allows you to create, access, modify, and delete environment variables from within the Lisp environment:

environment-variable
This function returns the value of a specified environment variable. You can also use this function with the Common Lisp macrosetf to set the value of or delete an environment variable. If you set the value of an environment variable that does not already exist, the variable is automatically created. Similarly, if you set the value of an environment variable tonil, the variable is automatically deleted.

Liquid Common Lisp provides additional environment variables for setting up the Lisp environment. These variables set the string values returned by the Common Lisp functionsmachine-type, machine-version, software-version, short-site-name, and long-site-name respectively:

LISP_LONG_SITE_NAME
LISP_MACHINE_TYPE (not available for LCL/HP and LCL/SGI)
LISP_MACHINE_VERSION
LISP_SHORT_SITE_NAME
LISP_SOFTWARE_VERSION (not available for LCL/HP and LCL/SGI)

To set the values of these variables from the UNIX operating system or from a C shell, you must use the commandsetenv before invoking Lisp, as the following example demonstrates:

% setenv LISP_MACHINE_VERSION "ROSIE" 
% lisp

If you are working in a Bourne shell, use this technique to set the value of the environment variable before invoking Lisp:

$ LISP_MACHINE_VERSION=ROSIE 
$ export LISP_MACHINE_VERSION 
$ lisp

It is not necessary to enclose the value of the environment variable in double quotation marks unless it contains more than one word.

You could add these commands to your initialization file if you wanted to set the values of these variables each time you started up Lisp, or you could save them as part of a Lisp image.

Regardless of the method used to set these variables, you can check their values by using the appropriate Common Lisp function from within Lisp:

> (machine-version) 
"ROSIE"


The Advanced User's Guide - 9 SEP 1996

Generated with Harlequin WebMaker