(Possibly this is the same question as Function local read-only vs. global read-only variable with the same name)
In a script I wrote I'm using readonly key="$1"
(for the program parameter) at the global level, and a function uses local key="$1"
(for the function parameter this time), too.
To my surprise BASH 4.4 outputs:
...: local: key: readonly variable
In my understanding there is a global readonly variable, but the local
variable should be independent of it, even when having the same name, right?
Or did I misunderstand something?
Reading the manual page on local
did not bring me any further.
Or is it that local
does not declare a local variable, but a local value for a (global) variable (thus the global read-only status preventing even a local change)?
Would be a rather confusing concept then IMHO.