[lug] How does bash "set -e" work?
nagler at bivio.biz
Fri Jan 4 10:10:05 MST 2013
Well, I looked at the code, and it's pretty complicated (and scary) stuff,
but it's pretty clear that there is passing in state to the child
/* Make sure the subshell inherits any CMD_IGNORE_RETURN flag. */
if ((command->flags & CMD_IGNORE_RETURN) && tcom != command)
tcom->flags |= CMD_IGNORE_RETURN;
That's one place the out of band communication happening. "flags" is not
what gets set by "set -e", that's exit_immediately_on_error.
CMD_IGNORE_RETURN is set when you do an 'AND_AND' or 'OR_OR', etc.
It's pretty clear that the code is supposed to do what it is doing. You
can't control that. Indeed, there's not a single "clear" (&=
~CMD_IGNORE_RETURN) in the source. There's also no way to detect it in the
This lack of transparency is why we eschew shell programming in favor of
Perl. It's fairly ironic that this particular code is being used to build
our Perl modules bundle. :)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the LUG