Subject: Re: Assigning to $0 (formerly: PATCH: funcstack[-1])
From: Mikael Magnusson <[email-masked]>
To: Bart Schaefer <[email-masked]>
Cc: Zsh hackers list <[email-masked]>
Date: Mon, 15 Feb 2016 07:51:32 +0100
List-Id: Zsh Workers List <zsh-workers.zsh.org>

On Sun, Feb 14, 2016 at 10:52 PM, Bart Schaefer
<[email-masked]> wrote:
> On Feb 5, 10:27pm, Peter Stephenson wrote:
> }
> } By the way, looking at the code I just notice that the following isn't
> } an error even though it doesn't do what you presumably expect:
> }
> } % setopt posixargzero
> } % print $0
> } zsh
> } % 0=foo
> } % print $0
> } zsh
> }
> } Maybe that's OK so far, but you don't even get the value back when you
> } unset the option; it's silently lost.
>
> So what behavior would be preferable?
>
> 1. POSIXARGZERO makes $0 report an error on assignment (read only?)
>
> 2. the value is stored and reappears when POSIXZERO is unset?
>
> 3. as (2) but a warning is printed?
>
> As another by-the-way:
>
> torch% print $0; () { typeset -g 0=argzero; print $0 }; print $0
> Src/zsh
> argzero
> Src/zsh
>
> 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.

-- 
Mikael Magnusson