Subject: Re: make -j and failure modes
To: None <>
From: Alan Barrett <>
List: tech-userlevel
Date: 12/11/2003 11:41:07
On Wed, 10 Dec 2003, Robert Elz wrote:
> It is absurd to require the shell to look inside the commands run by
> the sub-shell and see if they're the kind that should cause "set -e"
> mode to cause the shell to exit

I agree, so far.  But I don't think it's absurd for the parent shell
to check the exit code of the sub shell, and treat any non-zero exit
code as an error for the purposes of "set -e".

In so far as POSIX appears to disagree, I think POSIX is violating the
principle of least astonishment.

In another message, kre said:
> Then how would you handle a Makefile that happened to contain
>         (cd dir && test -f file && cat file)
> If file doesn't exist, that will exit 1, as the last command
> executed is te test, which failed (same if dir doesn't exist).

Yes, that's what I would expect.

> But that isn't what is wanted - the intent there is simply to cat
> the file, if it exists, and do nothing if it doesn't.

If my intent was to cat the file if it exists, and do nothing if it
doesn't exist, and to consider neither case to be an error, then I would
put the following code in the Makefile:

	(cd dir && test -f file && cat file) || true

--apb (Alan Barrett)