what is an environment variable?

Smoot Carl-Mitchell smoot at tic.com
Sat Mar 17 12:51:51 UTC 2012

On Fri, 2012-03-16 at 20:21 -0400, Robert P. J. Day wrote:

>   just my $0.02, but i like to avoid PATH being part of the
> *environment*.  it's obviously a useful *shell* variable but, if you
> think about it, its value is to locate commands based on how
> complicated you want to make your search path.

Once you export it, PATH is part of the environment.  Do a

ps euxww

and you will see every process forked by your shell gets PATH put in the
environment of the process.  Take a look at the man page for execve
which is the basic system call to execute a program.  One of the
arguments it takes is envp which is a pointer to a list of environment
variables and their values.

There are too many programs which rely on PATH or rather use the execlp
or the execvp library calls (really wrappers around execve) to not put a
reasonable PATH in the environment.

Smoot Carl-Mitchell
System/Network Architect
voice: +1 480 922-7313
cell: +1 602 421-9005
smoot at tic.com

More information about the ubuntu-users mailing list