Lines Matching defs:for
1 # $NetBSD: directive-for.mk,v 1.32 2025/07/01 04:24:20 rillig Exp $
3 # Tests for the .for directive.
5 # TODO: Describe naming conventions for the loop variables.
6 # .for f in values
7 # .for file in values
8 # .for _FILE_ in values
9 # .for .FILE. in values
10 # .for _f_ in values
15 # A typical use case for a .for loop is to populate a variable with a list of
19 .for num in 1 2 3
27 # The .for loop also works for multiple iteration variables.
29 .for name value in VARNAME value NAME2 value2
37 # The .for loop splits the items at whitespace, taking quotes into account,
40 # Until 2012-06-03, the .for loop had split the items exactly at whitespace,
43 .for var in one t\ w\ o "three three" 'four four' `five six`
51 # In the body of the .for loop, the iteration variables can be accessed
54 # Instead, before interpreting the body of the .for loop, the body is
58 # A noticeable effect of this implementation technique is that the .for
60 # namespaces and do not influence each other. The "scope" of the .for loop
65 .for var var2 in 1 2 3 4
68 . warning After the .for loop, var must still have its original value.
71 . warning After the .for loop, var2 must still have its original value.
79 .for var var2 in ${:U}
82 . warning After the .for loop, var must still have its original value.
85 . warning After the .for loop, var2 must still have its original value.
88 # Before for.c 1.39 from 2008-12-21, the values of the iteration variables
94 # Before that date, the .for loop below expanded to:
96 # Since that date, the .for loop below expands to:
101 .for plus in +
111 # When the outer .for loop is expanded, it sees the expression ${i} and
114 .for i in outer
115 . for i in inner
124 # Until 2008-12-21, the .for loop was expanded by replacing the variable
129 # Until 2012-06-03, the .for loop had split the words at whitespace, without
134 .for path in a:\ a:\file.txt d:\\ d:\\file.txt
142 # Ensure that braces and parentheses are properly escaped by the .for loop.
145 .for v in ( [ { ) ] } (()) [[]] {{}} )( ][ }{
162 # except for whitespace, allowing for creative side effects, as usual for
165 # expect+1: Invalid character ":" in .for loop variable name
166 .for var:Q in value "quoted"
172 # expect+1: Invalid character "$" in .for loop variable name
173 .for $ in value
179 # variable name in .for loops, based on some other variable. The .for loops
184 # expect+1: Invalid character "$" in .for loop variable name
185 .for $(INDIRECT) in value
192 # Regular global variables and the "variables" from the .for loop don't
195 # .for loop. The expression '${INDIRECT}' refers to the global variable, not
196 # to the one from the .for loop.
199 .for DIRECT in iteration
207 # expect+1: Missing iteration variables in .for loop
208 .for in value
214 .for var in
220 .for var in ${:U}
226 .for var in 1 2 3
230 # A mismatched .if inside a .for loop is detected each time when the loop body
232 .for var in value
238 # check for mismatched conditionals is not performed.
239 .for var in ${:U}
244 # When a .for without the corresponding .endfor occurs in an inactive branch
245 # of an .if, the .for directive is just skipped, it does not even need a
249 . for var in value # does not need a corresponding .endfor
251 # expect+1: for-less endfor
257 # When a .for without the corresponding .endfor occurs in an active branch of
258 # an .if, the parser just counts the number of .for and .endfor directives,
261 . for var in value
264 . endfor # no 'for-less endfor'
268 # Before for.c 1.172 from 2023-05-08, when make parsed a .for loop, it
269 # assumed that there was no line continuation between the '.' and the 'for'
273 # When make scanned the outer .for loop, it did not recognize the inner .for
275 # the outer .for loop thus ended above the '.endfor'.
277 # When make scanned the inner .for loop, it did not recognize the inner
278 # .endfor as such, which led to a parse error 'Unexpected end of file in .for
279 # loop' from the '.endfor' line, followed by a second parse error 'for-less
282 .for outer in o
284 for inner in i
292 # (which has higher precedence than global variables) and a .for loop iterates
294 # value from the .for loop. This is because when the body of the .for loop is
297 # the body of the .for loop is actually interpreted, the body text doesn't
300 .for scope in loop
310 .for var in a${.newline}b${.newline}c