Subject: Re: How make(1) reacts on failing commands
To: NetBSD Packages Technical Discussion List <tech-pkg@NetBSD.org>
From: Roland Illig <rillig@NetBSD.org>
List: tech-pkg
Date: 11/17/2005 21:21:54
Roland Illig wrote:
> make programs terminating after "echo foo":
> - Solaris 9, /usr/xpg4/bin/make
> - bmake-3.1.12 20050603
> - netbsd-20040210
> - IRIX 6.5:1289570120
>
> make programs continuing:
> - GNU make
> - netbsd-20050327
> - netbsd-20041129
I fear I haven't chosen the right words, once again. What I really
wanted to say is:
When executing a command like "false; echo foo", there are some versions
of NetBSD's make(1) that would execute the "echo foo", and some others
(older ones) that wouldn't do that.
Until today, I had always assumed that the behavior of the "old" make(1)
was the Right One, but after reading POSIX, it was clear that the new
behavior is preferred. The following change has made the difference:
2004-05-07 08:12 sjg
Remove use of sh -e when running in compat mode.
Its not posix compliant and serves very little purpose.
With this change compat and jobs modes are consistent wrt how
they treat each line of a script.
The consequence of this change is that the _complete_ pkgsrc code must
be audited for behavior that has changed with this change. The most
prominent example is code like this:
@cd ${WRKDIR}; ${MAKE_PROGRAM} build
This code has worked fine with the old make(1), even if the WRKDIR did
not exist. Now it could fail, executing ${MAKE_PROGRAM} in the current
directory instead of ${WRKDIR}.
There are (at least) two ways to fix this:
1. Replace the semicolons with &&.
@cd ${WRKDIR} && ${MAKE_PROGRAM} build
2. Start each non-trivial shell command with "set -e".
@set -e; cd ${WRKDIR}; ${MAKE_PROGRAM} build
To maintain consistency, we should decide about one of these two ways
and implement it. Of course I will teach pkglint how to help us humans
during the fixing phase, but we should first discuss a little.
Roland