Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make/unit-tests tests/make: demonstrate that .for va...



details:   https://anonhg.NetBSD.org/src/rev/74289a0828c6
branches:  trunk
changeset: 369612:74289a0828c6
user:      rillig <rillig%NetBSD.org@localhost>
date:      Tue Aug 23 16:36:02 2022 +0000

description:
tests/make: demonstrate that .for variables take precedence

diffstat:

 usr.bin/make/unit-tests/directive-for.mk |  18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diffs (29 lines):

diff -r 68aabd6418ef -r 74289a0828c6 usr.bin/make/unit-tests/directive-for.mk
--- a/usr.bin/make/unit-tests/directive-for.mk  Tue Aug 23 15:16:44 2022 +0000
+++ b/usr.bin/make/unit-tests/directive-for.mk  Tue Aug 23 16:36:02 2022 +0000
@@ -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 @@
    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



Home | Main Index | Thread Index | Old Index