Re: Scanning Environment Variables

From: Andrew Valencia <vandys_at_nospam.org>
Date: Fri Mar 24 1995 - 08:19:09 PST

[koogler@bedford.progress.com (David Koogler) writes:]

>... However there
>does not seem to be a routine for scanning the whole set of environment
>variables.

This is a side effect of there not being "the" environment. Your process
lives in a global hierarchy of variables; I guess you could get a list of
all the environment variable names with something like:

vars=""
dir="/env/namer/$USER/#"
while test "$dir" != ""
do
    cd $dir
    vars=$vars" "`echo *`
    dir=`echo $dir | sed 's|\(.*\)/.*|\1'`
done
vars=`echo $vars | tr ' ' '\12' | sort -u`

Note that this is an expensive operation; it also loses the ability to see
global environment variables change.

What kind of application is it? I've only run into this with shells, and
shells usually *benefit* from avoiding the manual handling of all those
variables.

                                                Andy
Received on Fri Mar 24 07:33:31 1995

This archive was generated by hypermail 2.1.8 : Thu Sep 22 2005 - 15:12:17 PDT