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

Re: f() { local -ar path=(/bin); };f gives an error



On 11/27/2017 03:17 PM, Stephane Chazelas wrote:
> 
> Thanks.
> 
> But that creates a non-special local "path" variable.
> 
> The issue here is that when you're trying to make $path (the
> special array variable tied to $PATH) readonly (with a value)
> locally in a function, that doesn't work.
> 

That wasn't really asked by your original link. While not common, people do
ask in #zsh why after attempting to use an local (non-readonly)
variable named path to reference an filename or something, they can no longer
execute commands. Using typeset's -h option to hide the special attribute allows
them to do so, so setting it `42' like in the stackexchange link would work
without breaking other stuff.

But to actually allow what you are now asking, I'll defer to someone else.



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