Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: sh -e changes broke pkgsrc

On Mon, May 26, 2008 at 03:44:43PM +0100, Matthias Scheler wrote:
 > Please explain why "true && false" should be different from "false && true".

Well, there are two possible theories about this: one is that failed
exit status that has been explicitly checked (as is the case for
"false && true" but not "true && false") should not result in an exit.
This is in accordance with the sh man page and general sanity.

The other is that the standard apparently says that failures on *both*
sides of an && or || should not result in an exit:

 > >
 > > says:
 > > -e When this option is on, if a simple command fails for any of
 > >    the reasons listed in Consequences of Shell Errors or returns
 > >    an exit status value >0, and is not part of the compound list
 > >    following a while, until, or if keyword, and is not a part of
 > >    an AND or OR list, and is not a pipeline preceded by
 > >    the ! reserved word, then the shell shall immediately exit.
 > If an "AND list" in the above definition refers to "foo && var" why
 > would "true && false" terminate "bash".

Because the standard is stupid?

I found this yesterday and I was hoping it was just vagueness that was
specified more explicitly somewhere else, but that doesn't appear to
be the case. However, if we go along with it we'll be diverging from
(AFAICT) everyone else, and that doesn't seem like a good idea,
especially when it's fairly clear that the standard is poorly worded.

In any event I think we need to decide explicitly which of these
models we want to go with. I'll update the atf test accordingly.


Also, while we're digging around in standards, there's another unclear
issue. In bin/32282, if I understand correctly, dsl@ says that -e
failures inside a () subshell should cause the outside shell to exit
also. This doesn't seem like a great idea to me, and it would also
diverge from everyone else, but if possible we should come to a
definite conclusion about it too.

David A. Holland

Home | Main Index | Thread Index | Old Index