On Mon, Jun 3, 2024 at 6:16 PM Will Allan via Bug reports for the GNU
Bourne Again SHell <bug-bash@gnu.org> 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 local builtins
do.[1][2] That it might try to anyway is likely unintended.

Your best bet is to do:
  array=(1 2)
  readonly array
instead of trying to combine the two. This should give you the
behavior you expect.

[1]: 
https://www.gnu.org/software/bash/manual/html_node/Bourne-Shell-Builtins.html#index-readonly
[2]: https://www.gnu.org/software/bash/manual/html_node/Arrays.html

Reply via email to