On Thu, Apr 30, 2020 at 10:43:53PM -0400, Dale R. Worley wrote: > This is a common issue in language design. The Perl language originally > only had "local" declarations that behaved the same way as bash local > declarations. But the above behavior got to be so much of a problem for > large programs that Perl added a separate lexically-scoped local > declaration.
Perl is a programming language. It makes sense that perl would evolve in a way that makes it more useful for writing programs. Bash, on the other hand, is first and foremost a *shell*. It's designed to act as an interface for executing commands, either interactively, or in a script. Its use as a programming language is a distant second goal. In the context of a shell, variables have *power* and *meaning*. If a variable is declared readonly, it's because someone wants it to remain unchanged. Consider what happens when someone changes PATH or HOME. Readonly variables become immutable, because changing them would break something. Someone decided that, and *made* the variable readonly, and they had some reason to do that. You're not allowed to circumvent that restriction. It has nothing to do with language design.