When building bash
scripts, I use a lot of readonly
and local -r
when making variables. That rapidly fills a script and makes the code less readable (and repetitive). Is there a way (like a set
flag at the top of the script) to make all variables readonly
and/or local -r
by default?
With the added caveat, it has to work on 3.2.57(1)-release
, as I’m on macOS.
I’m pretty sure this isn’t possible, but want to make sure.
Please don’t answer “drop bash
and use a proper scripting language”. I use other scripting languages as well. bash
scripts have their place and I like coding them.