On Tue, Aug 15, 2023 at 11:24:31PM -0500, Dennis Williamson wrote: > Your use of colon as a comment character is confusing.
They're running with set -x, so presumably they used those : commands to mark the set -x output with various labels. Which seems nominally clever, except they didn't *show* us the output. Also, the example is way more complicated than it needs to be, to the point where I gave up trying to suss out what part of it they thought was behaving incorrectly. Compare with this example: unicorn:~$ cat foo #!/bin/bash f() { local x=in_function_f echo "still in f" } readonly x=global f unicorn:~$ ./foo ./foo: line 4: local: x: readonly variable still in f As you stated, a variable that has been declared readonly at the global scope is also considered readonly at every other scope. This is the intended behavior. After the failed local variable assignment, the function continues execution. This is also the intended behavior, as this example does not use any of the set -e variants.