"env" or "export env"?
Nick Guenther
kousue at gmail.com
Mon Aug 11 15:56:43 PDT 2008
On Mon, Aug 11, 2008 at 4:40 PM, Woodchuck <marmot at pennswoods.net> wrote:
> On Mon, 11 Aug 2008, Nick Guenther wrote:
>
>> 'export' is a command that takes a list of strings, treats them as
>> environment variables, and pushes those variables out to the world
>> outside of your current shell (that's why you have to use export in
>> .profile, because .profile gets run in its own subshell, just like
>> every script).
>
>
> A subprocess (which is what a subshell is) cannot affect its
> parent's environment (or other parts of its address space without
> special measures, not discussed here). This is an "iron law" of
> the Unix process model.
>
> If you put lines in .profile:
>
> ZIP="zap"
> export ZIP
>
> and execute .profile as:
>
> $ ./.profile
>
> then
> $ echo $ZIP
>
> you get nothing.
>
> On the other hand
>
> $ . ./.profile
> $ echo $ZIP
> zap
Oh, I didn't realize that. Thanks. That's very subtle.
-Nick
More information about the Openbsd-newbies
mailing list