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

Re: [BUG] functions can't create global readonly variables



On Jan 3,  7:00pm, Peter Stephenson wrote:
}
} $ readonly foo=empty
} $ fn() { local foo=bar; echo $foo; }
} $ fn
} bash: local: foo: readonly variable
} empty

I suppose if you consider locality to be a property of the variable,
then making the variable readonly means you can't change that property.

Fortunately readonly in a nested function, where the name is declared
local in the outer function, does work like zsh's "typeset -gr" and
does not force the readonly into truly global scope.



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