Module Name: src Committed By: rillig Date: Tue Aug 23 16:36:02 UTC 2022
Modified Files: src/usr.bin/make/unit-tests: directive-for.mk Log Message: tests/make: demonstrate that .for variables take precedence To generate a diff of this commit: cvs rdiff -u -r1.13 -r1.14 src/usr.bin/make/unit-tests/directive-for.mk Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/make/unit-tests/directive-for.mk diff -u src/usr.bin/make/unit-tests/directive-for.mk:1.13 src/usr.bin/make/unit-tests/directive-for.mk:1.14 --- src/usr.bin/make/unit-tests/directive-for.mk:1.13 Sat Jan 15 12:35:18 2022 +++ src/usr.bin/make/unit-tests/directive-for.mk Tue Aug 23 16:36:02 2022 @@ -1,4 +1,4 @@ -# $NetBSD: directive-for.mk,v 1.13 2022/01/15 12:35:18 rillig Exp $ +# $NetBSD: directive-for.mk,v 1.14 2022/08/23 16:36:02 rillig Exp $ # # Tests for the .for directive. # @@ -228,3 +228,19 @@ var= outer endfor .endfor .MAKEFLAGS: -d0 + + +# When there is a variable definition 'scope=cmdline' from the command line +# (which has higher precedence than global variables) and a .for loop iterates +# over a variable of the same name, the expression '${scope}' expands to the +# value from the .for loop. This is because when the body of the .for loop is +# expanded, the expression '${scope}' is textually replaced with ${:Uloop}', +# without resolving any variable names. Later, when the body of the .for loop +# is actually interpreted, the body text doesn't contain the word 'scope' +# anymore. +.MAKEFLAGS: scope=cmdline +.for scope in loop +. if ${scope} != "loop" +. error +. endif +.endfor