On 1/24/24 7:06 PM, Emanuele Torre wrote:
I recently discovered that it is possible to set attributes on readonly variables
You've been able to set attributes on readonly variables forever. Even the historical Bourne shell allowed you to export readonly variables.
$ declare -p PPID declare -ir PPID="759437" $ declare -l PPID $ declare -p PPID declare -irl PPID="759437" I noticed SHELLOPTS and BASHOPTS among the default readonly variables set by bash. They are modified by bash whenever you set a set option or shopt. I tried setting the -i attribute on them, and got this result:
Well, is this a "my arm hurts when I do this" problem, or should bash restrict the types of attributes that can be set on readonly variables?
The arithmetic syntax error caused by trying to assign the new list of options to SHELLOPTS prevents bash from changing its value, and re-adding the readonly attribute to SHELLOPTS.
That's clearly a problem that needs to be fixed.
Then SHELLOPTS can be modified, and unset freely. :-) The same is possible with BASHOPTS.
Sure, it's a problem that you can do it, but it's not really harmful. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/