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

Re: Read-only variables in emulation mode



On Tue, Jun 16, 2015 at 5:54 PM, Bart Schaefer
<schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Jun 16,  8:24am, Mikael Magnusson wrote:
> }
> } > On Jun 16,  2:10am, Mikael Magnusson wrote:
> } > }
> } > } % echo hi; _=foo; echo $_
> } > } hi
> } > } hi
> } >
> } > That's actually a bug -- the assignment _=foo should erase $_ , I think.
> } >
> } > } % for _ in a b c; do echo $_ hi; done
> } > } hi
> } > } hi hi
> } > } hi hi
> } >
> } > If you go back to the original message in the thread, the whole point
> } > was to use $_ as a dummy variable that didn't need to be declared and
> } > whose value was instantly discarded.  For that purpose, the warning is
> } > extraneous.
> }
> } It's currently hooked up to nullstrsetfn, and was when it was readonly
> } too, so I guess this never worked as intended.
>
> I'm not sure what "never worked as intended" is aimed at.
>
> "That's actually a bug" -- $_ should be erased because there is no command
> for a last argument to be taken from, not because it's been assigned foo.
>
> "use $_ as a dummy variable" -- that didn't work as intended before, but
> it does now.
>
> So what never worked and what was intended?
>
> As with $0 in the other thread, "local -h _" works.

Oh, the intention was never to actually use the assigned value of $_?
In that case I completely misunderstood things... Oops, I just went
back to the original message and noticed "throwaway" now. I came here
from IRC where we were talking about using variables without having to
declare them local, so my context was a bit wrong.

-- 
Mikael Magnusson



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