Skip to content
marci543 edited this page Mar 29, 2021 · 1 revision

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)

Clone this wiki locally