[sf-lug] shell "vs." environment variables

Michael Paoli Michael.Paoli at cal.berkeley.edu
Mon Aug 22 23:22:40 PDT 2016


> From: "Alex Kleider" <akleider at sonic.net>
> Subject: Re: printenv "vs." set [was: Re: shell, man(1) [was: ...
> Date: Sun, 21 Aug 2016 09:52:49 -0700

> ...but TFMs suggest to me that without params, they should in fact  
> be doing the same thing.  (... unless "shell variable" is not the  
> same as "environment VARIABLE" in which case I've more to learn.)

Yes, "shell variable", a.k.a. "named parameter", is definitely* not
the same as "environment variable".

Yup, more to learn - have a look at export on sh(1) or similar,
for starters.  If you read sh(1) carefully enough, and well learn
from it, then you'll even be able to explain stuff like this:
$ echo $FOO $BAR

$ FOO=FOO BAR=BAR
$ set | egrep '^(FOO|BAR)='
BAR=BAR
FOO=FOO
$ env | egrep '^(FOO|BAR)='
$ FOO=FOO BAR=BAR env | egrep '^(FOO|BAR)='
FOO=FOO
BAR=BAR
$ FOO=foo BAR=bar env | egrep '^(FOO|BAR)='
FOO=foo
BAR=bar
$ env | egrep '^(FOO|BAR)='
$ export FOO BAR
$ env | egrep '^(FOO|BAR)='
FOO=FOO
BAR=BAR
$

*though there's certainly some overlap/commonality and sometime
they're "the same" - or more precisely environment variable
(typically/effectively) is also shell variable, but not necessarily
vice versa.





More information about the sf-lug mailing list