Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: handling of variables



* Peter Stephenson <pws@xxxxxxx> [20050201 15:51]:
> Michael Prokop wrote:

> > I'm just wondering about:

> > % zsh -f
> > % FOO=BAR /bin/echo "$FOO"

> > %

> > Why doesn't this work? Am I running out of coffee? :)

> The sequence of interepretation is

> line gets parsed to <environment-assignment> <command+args>
> line gets expanded to /bin/echo "" (assuming FOO is currently empty)
> shell forks
> FOO=BAR is put in the environment
> shell execs /bin/echo ""

> Compare this with the result of

> FOO=BAR printenv FOO

> where the command itself examines the environment.

Thanks for explanation, Peter.

> > And I'm wondering what's happening at:

> > % zsh -f
> > % FOO=BAR BAR=FOO echo $FOO $BAR

> > % FOO=BAR BAR=FOO echo $FOO $BAR
> > BAR
> > %

> This looks suspiciously like a bug.  The value of BAR is being restored
> after the echo, but the value of FOO isn't.

Ok. ;-)

Thanks also to Stephane for his explanation!
thx && regards,
-mika-



Messages sorted by: Reverse Date, Date, Thread, Author