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

Re: Assigning to $0 (formerly: PATCH: funcstack[-1])



On Mon, Feb 15, 2016 at 6:08 PM, Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Feb 15,  7:51am, Mikael Magnusson wrote:
> }
> } > So typeset will accept 0 as a valid name and -g as a valid option, but
> } > can't actually set the global $0.
> }
> } http://www.zsh.org/mla/workers/2015/msg01400.html Some time before
> } that patch, assigning to $0 was always possible, but at some point it
> } stopped working.
>
> No, I think it was never possible to assign to the global $0 from inside
> a function.
>
> torch% print $ZSH_VERSION
> 4.2.0
> torch% zero() { typeset -g 0=argzero; print $0 }
> torch% print $0; zero; print $0
> /bin/zsh
> argzero
> /bin/zsh
> torch%
>
> This is because the "argzero" C global is handled independently of the
> usual parameter scope code.

Ah, right. I must have assumed on some level that we were talking
about a function-scoped $0 because I have never in my life wanted to
change the top-level $0.

-- 
Mikael Magnusson



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