Hi all:

Shells ignore errors by default, and the results are often brittle scripts that 
only work reliably on sunny days. So I have become accustomed to these lines at 
the top of my scripts:

set -o errexit
set -o nounset
set -o pipefail

Unfortunately, you cannot set these flags in configure.ac, as Autoconf 
generates code which relies in undefined variables being considered empty, etc.

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 could set the flags in every recipe, but that is easy to forget, and it would 
be a lot of duplication.

I know the resulting makefile will be less portable, as not all shells support 
those options, but that is a price I am willing to pay. Note also that those 
flags are now part of the POSIX/IEEE Std 1003.1-2024 specification, see: 
https://pubs.opengroup.org/onlinepubs/9799919799/utilities/V3_chap02.html#tag_19_26

How about the ".ONESHELL" pseudotarget? Can I use it in Makefile.am without 
worries?

Please copy me on any answers, as I am not subscribed to this mailing list.

Thanks in advance,
  rdiez

Reply via email to