what does the env in "env name=value command" buy me?

what does the env in "env name=value command" buy me?

Post by Dan Jacobso » Sat, 18 Jan 2003 08:52:13



dear sirs, is
$ env PAGER=cat LC_CTYPE=en_US.ISO8859-1 perldoc perltw
the same as
$     PAGER=cat LC_CTYPE=en_US.ISO8859-1 perldoc perltw
--
http://jidanni.org/ Taiwan(04)25854780
 
 
 

what does the env in "env name=value command" buy me?

Post by John » Sat, 18 Jan 2003 14:18:40



> dear sirs, is
> $ env PAGER=cat LC_CTYPE=en_US.ISO8859-1 perldoc perltw
> the same as
> $     PAGER=cat LC_CTYPE=en_US.ISO8859-1 perldoc perltw

Yes. What the env command buys you is the ability to remove either the whole
environment or just selected parts of it. This can be very useful in testing, and in
making sure that your lovingly-developed new program does not have a hidden
dependency on something you added to your .profile three years ago.
Look at env -i or -u. Note that env -u VARIABLE command is *different* from
VARIABLE= command -- in the latter case VARIABLE is still in command's
environment even though it has been set to nothing.

John.

 
 
 

what does the env in "env name=value command" buy me?

Post by Barry Margoli » Sun, 19 Jan 2003 02:11:07






>> dear sirs, is
>> $ env PAGER=cat LC_CTYPE=en_US.ISO8859-1 perldoc perltw
>> the same as
>> $     PAGER=cat LC_CTYPE=en_US.ISO8859-1 perldoc perltw

>Yes. What the env command buys you is the ability to remove either the whole
>environment or just selected parts of it. This can be very useful in
>testing, and in
>making sure that your lovingly-developed new program does not have a hidden
>dependency on something you added to your .profile three years ago.
>Look at env -i or -u. Note that env -u VARIABLE command is *different* from
>VARIABLE= command -- in the latter case VARIABLE is still in command's
>environment even though it has been set to nothing.

Another thing that the env command buys is shell-independence.  In
csh/tcsh, to run a command with temporary environment changes, you would
need to do:

(setenv PAGER cat; setenv LC_TYPE=en_US.ISO8859-1; perldoc perltw)

The env command works the same no matter what shell you're using it from.

--

Genuity, Woburn, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.
Please DON'T copy followups to me -- I'll assume it wasn't posted to the group.