[lug] "errexit": suggested bash manpage clarification
Rob Nagler
nagler at bivio.biz
Sun Jan 6 08:13:10 MST 2013
Hi Chet & My Fellow Serfs in Boulder,
Thanks, Jeff, for following up on this.
> Thank you for your perennial efforts to improve the man page.
Ditto and the code.
I do have a question about the standard:
If the exit status of a compound command other than a
subshell command was the result of a failure while -e was
being ignored, then -e shall not apply to this command.
I don't understand the carve out for subshells, since both of these
behave identically:
(set -e; false; echo ok) || true
{ set -e; false; echo ok; } || true
This also relates to the new manual text:
If a compound command or shell function executes in a context
To me, it would be clearer if it said:
If a compound command, shell function, or subshell executes in a context
If I had seen that, I wouldn't have emailed the question.
As near as I can tell, this is the only behavior that is passed from
parent to child that can't be passed explicitly or detected. It seems
to me that it would be very useful to at least have the ability to
detect that the shell has the flag CMD_IGNORE_RETURN set. Most bash
shells do not run in POSIX compliant mode so it would be a useful
feature. At a minimum, by providing this capability (and describing
it in the set -e section), it would let folks like me who RTFM that
there's something funky going on. From my perspective, these two
should be equivalent:
sh -$- -c 'set -e; false; echo one' || echo two
(set -e; false; echo one) || echo two
I guess another place you might want to modify is under COMMAND
EXECUTION ENVIRONMENT where it says:
except that traps caught by the
shell are reset to the values that the shell inherited from its parent
at invocation.
ERR is treated specially if CMD_IGNORE_RETURN is set in subshells. I
think that's the only one which does not obey the above.
>> In this case, you might point folks to the
>> bug-bash mailing list, where the most recent episode of this very
>> discussion took place only recently:
I didn't know what "errexit" was until Jeff mentioned it. (I'm old
school. :) That would have made googling easier. I suggest that you
add a reverse pointer back to errexit option in the description of
"-e". I would have googled for errexit instead of "set -e" (which
yields pretty good results).
>> I was in Denver for Educause this year, but only made it up to Boulder as
>> far as Boulder Beer. Maybe next time. :-)
Too bad Corky and Lenny's doesn't export. :)
Thanks for all the help.
Rob
More information about the LUG
mailing list