The following script fails when run with bash 4.4.20(1)
#!/bin/bash
bar() {
local args=("y")
}
foo() {
local -r args=("x")
bar
}
foo
with error line 3: args: readonly variable
but succeeds when run with bash 4.2.46(2), which makes sense after reading 24.2. Local Variables.
The following script with non-array variables runs without any issues:
#!/bin/bash
bar() {
local args="y"
}
foo() {
local -r args="x"
bar
}
foo
I could not find any changes that explain the difference between bash 4.2.46(2) and bash 4.4.20(1).
Q: is this a bug in bash 4.4.20(1)? if this is expected behavior then why does the second script not fail?