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

Re: Can't overwrite $0 in functions anymore



On Sun, Jun 14, 2015 at 1:58 AM, Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Jun 14,  1:05am, Mikael Magnusson wrote:
> }
> } Is this an intended change?
>
> Hm.  Sort of.  It's a side-effect of implementing POSIX_ARGZERO.
>
> With POSIX_ARGZERO set, $0 must always contain the name used to invoke
> the shell.  If POSIX_ARGZERO changes from set to not set, $0 has to be
> restored as specified by the (on or off) setting of FUNCTION_ARGZERO.
>
> Consequently the value of $0 became fixed for both cases; assignments
> to it are no-ops.
>
> However, you can still change the value of $0 by hiding the special:
>
> torch% () { local -h 0=hello; echo $0 }
> hello

Ah, I see. I was only using it in a single helper function out of
laziness, precisely because it let me leave out a local statement. :)

-- 
Mikael Magnusson



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