forloop.mk (bmake-20201101) | : | forloop.mk (bmake-20201117) | ||
---|---|---|---|---|
# $NetBSD: forloop.mk,v 1.6 2020/10/24 08:50:17 rillig Exp $ | # $NetBSD: forloop.mk,v 1.7 2020/11/03 17:37:57 rillig Exp $ | |||
all: for-loop | all: for-loop | |||
LIST= one "two and three" four "five" | LIST= one "two and three" four "five" | |||
.if make(for-fail) | .if make(for-fail) | |||
for-fail: | for-fail: | |||
XTRA_LIST= xtra | XTRA_LIST= xtra | |||
.else | .else | |||
. for x in ${LIST} | . for x in ${LIST} | |||
X!= echo 'x=$x' >&2; echo | . info x=$x | |||
. endfor | . endfor | |||
CFL= -I/this -I"This or that" -Ithat "-DTHIS=\"this and that\"" | CFL= -I/this -I"This or that" -Ithat "-DTHIS=\"this and that\"" | |||
cfl= | cfl= | |||
. for x in ${CFL} | . for x in ${CFL} | |||
X!= echo 'x=$x' >&2; echo | . info x=$x | |||
. if empty(cfl) | . if empty(cfl) | |||
cfl= $x | cfl= $x | |||
. else | . else | |||
cfl+= $x | cfl+= $x | |||
. endif | . endif | |||
. endfor | . endfor | |||
X!= echo 'cfl=${cfl}' >&2; echo | . info cfl=${cfl} | |||
. if ${cfl} != ${CFL} | . if ${cfl} != ${CFL} | |||
. error ${.newline}'${cfl}' != ${.newline}'${CFL}' | . error ${.newline}${cfl} != ${.newline}${CFL} | |||
. endif | . endif | |||
. for a b in ${EMPTY} | . for a b in ${EMPTY} | |||
X!= echo 'a=$a b=$b' >&2; echo | . info a=$a b=$b | |||
. endfor | . endfor | |||
# Since at least 1993, iteration stops at the first newline. | # Since at least 1993, iteration stops at the first newline. | |||
# Back then, the .newline variable didn't exist, therefore it was unlikely | # Back then, the .newline variable didn't exist, therefore it was unlikely | |||
# that a newline ever occurred. | # that a newline ever occurred. | |||
. for var in a${.newline}b${.newline}c | . for var in a${.newline}b${.newline}c | |||
X!= echo 'newline-item=('${var:Q}')' 1>&2; echo | . info newline-item=(${var}) | |||
. endfor | . endfor | |||
.endif # for-fail | .endif # for-fail | |||
.for a b in ${LIST} ${LIST:tu} ${XTRA_LIST} | .for a b in ${LIST} ${LIST:tu} ${XTRA_LIST} | |||
X!= echo 'a=$a b=$b' >&2; echo | . info a=$a b=$b | |||
.endfor | .endfor | |||
for-loop: | for-loop: | |||
@echo We expect an error next: | @echo We expect an error next: | |||
@(cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} for-fail) && \ | @(cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} for-fail) && \ | |||
{ echo "Oops that should have failed!"; exit 1; } || echo OK | { echo "Oops that should have failed!"; exit 1; } || echo OK | |||
End of changes. 8 change blocks. | ||||
8 lines changed or deleted | 8 lines changed or added |