"env" or "export env"?
macintoshzoom
macintoshzoom at lavabit.com
Tue Aug 12 03:30:33 PDT 2008
konsole 1.6.6 on KDE 3.5.9:
$ echo $SHELL
/bin/ksh
$
Mac
Woodchuck 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).
>
> .profile is used to modify the *current* environment, and it is
> typically run as
> $ . ./.profile
>
> i.e., without a subshell.
>
> 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
>
> There are three dots in that . ./.profile, each different. For the
> record,
> the first one means "execute without spawning a subshell"
> the 2nd one means "the current working directory"
> the 3rd one is just part of the file name and has almost no
> special significange except to ls(1).
>
> This is for ksh.
>
> env is not needed in ksh.
>
> $ FOO=bar program
>
> program will see FOO with value bar in its (program's) environment.
>
>
>> "export env DESTDIR=/ make distrib-dirs" doesn't mean anything. Well,
>> rather, it does not mean what you think it does. Try this:
>
> It will attempt to export an environment variable named "env", and
> export an environment variable DESTDIR with value "/", and also export
> two more blank variables "make" and "distrib-dirs".
>
>
>> $ export env DESTDIR=/ make distrib-dirs
>> $ set #shows the current environment variables
>>
>> Anyway, why would using KDE have any impact on how commands in a shell work?
>
> Who knows what wonders KDE is capable of inflicting on the young
> and innocent? I have no idea which shell KDE runs in its "konsole".
>
> csh does not do environemnt variables exactly the same as ksh or sh.
>
> this "env" command is probably an attempt to get consistent results
> across different shells.
>
> Dave "garrulous in a good cause"
More information about the Openbsd-newbies
mailing list