Subject: Re: [BUG] functions can't create global readonly variables
From: Bart Schaefer <[email-masked]>
To: [email-masked]
Date: Sun, 3 Jan 2016 11:21:25 -0800
List-Id: Zsh Workers List <zsh-workers.zsh.org>

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.