How do I create both local
and declare -r
(read-only) variable in bash?
If I do:
function x {
declare -r var=val
}
Then I simply get a global var
that is read-only
If I do:
function x {
local var=val
}
If I do:
function x {
local var=val
declare -r var
}
Then I get a global again (I can access var
from other functions).
How to combine both local and read-only in bash?