On Tue, Sep 22, 2026 at 02:59:49PM -0400, Zack Weinberg wrote:
> On Tue, Sep 22, 2026, at 2:51 PM, R. Diez wrote:
> > But are those flags safe to set in Makefile.am? For example:
> >
> > SHELL := bash  -o nounset  -o pipefail  -o errexit
> >
> > or with modern GNU Make versions:
> >
> > .SHELLFLAGS := -o nounset  -o pipefail  -o errexit  -c
> >
> > Or will Automake generate some code which may break with those flags?
> 
> I doubt that this is safe now, just because it's so easy for code that
> won't work with those flags turned on to get written by accident in the
> absence of these flags.  However, "make this safe and turn it on by
> default when the shell supports it" seems like a desirable goal, and one
> I'd support for both Automake and Autoconf.  Is it something you are
> interested in working on yourself?

The biggest problem with these options is that they are portability
nightmares: the behaviour of "set -e / set -o errexit" is quite incon-
sistent between different shells (not to mention full of surprising
gotchas if shell functions are used), and portable scripts can't assume
pipefail is even available (this feature was added to POSIX in Issue 8).

That being said, portable makefiles basically have to be be written
carefully so that all commands work regardless of the initial state of
the "errexit" option, because many make implementations do run commands
with it on most of the time (as specified by POSIX), but there are some
implementations (GNU, NetBSD) which do not do this by default.  So as
far as Automake-generated rules are concerned, I'd expect "errexit"
to be generally safe to enable.

Cheers,
  Nick

Reply via email to