Make - ftsrg/cheat-sheets GitHub Wiki

foreach in Makefile swallows errors

foreach in this example separates commands by ; in the sequence. Use && separator and true as the last command or try set -e to stop on the first error.

Incorrect error handling:

all:
	@$(foreach DOCUMENT, $(DOCUMENTS),\
		false; \
	)

Fail on first error:

all:
	@$(foreach DOCUMENT, $(DOCUMENTS),\
		false && \
	) true

(source)