Module Name: src
Committed By: rillig
Date: Wed Aug 19 05:51:19 UTC 2020
Modified Files:
src/usr.bin/make/unit-tests: varname-dot-newline.exp
varname-dot-newline.mk
Log Message:
make(1): add test for the .newline variable
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/usr.bin/make/unit-tests/varname-dot-newline.exp
cvs rdiff -u -r1.2 -r1.3 src/usr.bin/make/unit-tests/varname-dot-newline.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/varname-dot-newline.exp
diff -u src/usr.bin/make/unit-tests/varname-dot-newline.exp:1.1 src/usr.bin/make/unit-tests/varname-dot-newline.exp:1.2
--- src/usr.bin/make/unit-tests/varname-dot-newline.exp:1.1 Sun Aug 16 12:07:52 2020
+++ src/usr.bin/make/unit-tests/varname-dot-newline.exp Wed Aug 19 05:51:18 2020
@@ -1 +1,4 @@
+make: "varname-dot-newline.mk" line 16: The .newline variable can be overwritten. Just don't do that.
+first
+second
exit status 0
Index: src/usr.bin/make/unit-tests/varname-dot-newline.mk
diff -u src/usr.bin/make/unit-tests/varname-dot-newline.mk:1.2 src/usr.bin/make/unit-tests/varname-dot-newline.mk:1.3
--- src/usr.bin/make/unit-tests/varname-dot-newline.mk:1.2 Sun Aug 16 14:25:16 2020
+++ src/usr.bin/make/unit-tests/varname-dot-newline.mk Wed Aug 19 05:51:18 2020
@@ -1,8 +1,23 @@
-# $NetBSD: varname-dot-newline.mk,v 1.2 2020/08/16 14:25:16 rillig Exp $
+# $NetBSD: varname-dot-newline.mk,v 1.3 2020/08/19 05:51:18 rillig Exp $
#
# Tests for the special .newline variable.
+#
+# Contrary to the special variable named "" that is used in expressions like
+# ${:Usome-value}, the variable ".newline" is not protected against
+# modification. Nobody exploits that though.
+
+NEWLINE:= ${.newline}
+
+.newline= overwritten
+
+.if ${.newline} == ${NEWLINE}
+.info The .newline variable cannot be overwritten. Good.
+.else
+.info The .newline variable can be overwritten. Just don't do that.
+.endif
-# TODO: Implementation
+# Restore the original value.
+.newline= ${NEWLINE}
all:
- @:;
+ @echo 'first${.newline}second'