我有一个带有 for 循环的 Makefile。问题是当循环内发生错误时,执行会继续进行。
SUBDIRS += $(shell ls -d */ | grep amore)
# breaks because can't write in /, stop execution, return 2
test:
mkdir /
touch /tmp/zxcv
# error because can't write in / but carry on, finally return 0
tests:
@for dir in $(SUBDIRS); do \
mkdir / ; \
touch /tmp/zxcv ; \
done;
遇到错误时如何让循环停止?