Subject: Re: make -j and failure modes
To: James Chacon <jmc@NetBSD.org>
From: Ben Harris <bjh21@NetBSD.org>
List: tech-userlevel
Date: 12/10/2003 14:48:28
On Wed, 10 Dec 2003, James Chacon wrote:

> The subshell should exit by normal rules and based on the fact that -e
> transfers to it. (and return according to the rules for subshells
> which is the exit code from the last command).
>
> Past that I think it's obvious then that the parent would exit as it's got
> the e flag set and it just had a command exit non-zero and it's not part
> of the exclusion list of ones to ignore for checking on error.

So you think that that the parent should treat the entire group of
commands in the subshell as a single command, and exit if it fails, yes?

This seems entirely sane to me, and seems to match the behaviour of shells
other than Bash, but I'm having difficulty reconciling it with the POSIX
definition of "-e", and in particular its statement that "-e" only applies
to simple commands, which the group is not.  I think this is probably a
bug in POSIX, but I'm not sure I have the energy to pursue it right now.

> I was saying fix our /bin/sh (to what I beleive is perfectly correctly
> POSIX/SUSE behavior), possibly fix the Makefiles (though long term I beleive
> adding || exit $? everywhere will get missed and this problem creep back in),
> and then provide /bin/sh as nbsh during builds so a known sh implementation
> is available during builds.

I think that adding a host tool to work around our inability to write
portable shell scripts is silly.  If we really can't trust ourselves,
nbmake could always add "|| exit $?" to every command it passes to the
shell, hence avoiding the need to trust "sh -e" at all.

-- 
Ben Harris                                                   <bjh21@NetBSD.org>
Portmaster, NetBSD/acorn26           <URL:http://www.NetBSD.org/Ports/acorn26/>