In addition to what everyone else has said about env(1), there is the
fact that Korn derived shells also supports some of the same features.

env VAR1=foo VAR2=bar random-command
VAR1=foo VAR2=bar random-command

If running a Korn-like shell (ksh, bash, zsh), both would set the
envvars VAR1 and VAR2 to those values.  (Note: I don't *think* earlier
Bourne shells support that, but I may be misremembering when the
feature was introduced.  It was likely before even my time.)

However, C-shell derived do not, you must use the env(1) command.

But, env(1) does also offers the -i and -u flags to initialize and
unset envvars.  I use -u a lot during dev/testing to make sure scripts
I write work correctly in various combinations.

mrc

Reply via email to