Re: readonly inconsistency with arrays

2024-06-04 Thread Chet Ramey
On 6/3/24 6:57 PM, Zachary Santer wrote: On Mon, Jun 3, 2024 at 6:16 PM Will Allan via Bug reports for the GNU Bourne Again SHell wrote: My understanding is that the readonly builtin isn't supposed to handle compound assignment syntax like the declare and local builtins do.[1][2] That it migh

Re: readonly inconsistency with arrays

2024-06-04 Thread Chet Ramey
On 6/3/24 5:54 PM, Will Allan via Bug reports for the GNU Bourne Again SHell wrote: I'm seeing what appears to be an inconsistency with using `readonly` on variables declared in a previous scope. I think this is a functionality mismatch, and probably a bug in readonly and export. While readonl

Re: readonly inconsistency with arrays

2024-06-03 Thread Will Allan
Thanks for the workaround. It's odd that it appears to work for scalar types in both cases, but not indexed arrays (in the second case) or associative arrays (in both cases). Would be nice to save an extra line when initializing and freezing each variable like you can do with declare/local. Als

Re: readonly inconsistency with arrays

2024-06-03 Thread Zachary Santer
On Mon, Jun 3, 2024 at 6:16 PM Will Allan via Bug reports for the GNU Bourne Again SHell wrote: > > init_vars () { readonly string="foo" readonly int=100 readonly array=(1 2) My understanding is that the readonly builtin isn't supposed to handle compound assignment syntax like the declare and