> From: "Andrew Reilly" <[EMAIL PROTECTED]>
> Date: Mon 4 Jun, 2001
> Subject: Re: Fixing documented bug in env(1)

> > By the way, who uses env(1) anyway?  In the past twenty years, I've only
> > ever used it as shorthand for printenv(1).  What's this csh(1) thing?  :-)
> 
> How else do you throw away your environment, to make sure that
> daemons that you start with sudo don't do anything silly?
> 
> env - PATH=$PATH dhclient ed0

Using env(1) without any assumtion about command line assignment parsing
purely as an illustration:

    $ env - sh -c "PATH=$PATH dhclient ed0"

I'd probably wrap thus up in a script (or external program for ease of
use by various shells) - the semantics are subtly different from env(1):

    $ clearenv() { env - sh -c "$*"; }  # cheap and nasty to illustrate
    $ clearenv PATH=$PATH dhclient ed0

Making clearenv(1) an external program (which doesn't itself parse command
line variable assignments) may simplify quoting, and if ``dhclient'' were
instead a shell builtin such as echo(1), you'd need to avoid the shortcut
above, as in:

    $ clearenv "PATH=$PATH; export PATH; dhclient ed0"

                Cheers,

                Mark.

-- 
Mark Valentine, Thuvia Labs <[EMAIL PROTECTED]>       <http://www.thuvia.co.uk>
"Tigers will do ANYTHING for a tuna fish sandwich."       Mark Valentine uses
"We're kind of stupid that way."   *munch* *munch*        and endorses FreeBSD
  -- <http://www.calvinandhobbes.com>                  <http://www.freebsd.org>

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to