Module Name: src
Committed By: rillig
Date: Sun Oct 4 08:14:35 UTC 2020
Modified Files:
src/usr.bin/make/unit-tests: var-op-sunsh.mk
Log Message:
make(1): add another test for parsing :sh assignments
To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/usr.bin/make/unit-tests/var-op-sunsh.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/var-op-sunsh.mk
diff -u src/usr.bin/make/unit-tests/var-op-sunsh.mk:1.3 src/usr.bin/make/unit-tests/var-op-sunsh.mk:1.4
--- src/usr.bin/make/unit-tests/var-op-sunsh.mk:1.3 Sun Oct 4 08:02:17 2020
+++ src/usr.bin/make/unit-tests/var-op-sunsh.mk Sun Oct 4 08:14:35 2020
@@ -1,4 +1,4 @@
-# $NetBSD: var-op-sunsh.mk,v 1.3 2020/10/04 08:02:17 rillig Exp $
+# $NetBSD: var-op-sunsh.mk,v 1.4 2020/10/04 08:14:35 rillig Exp $
#
# Tests for the :sh= variable assignment operator, which runs its right-hand
# side through the shell. It is a seldom-used alternative to the !=
@@ -89,5 +89,23 @@ VAR :sh :sh :sh :sh= echo multiple
. error
.endif
+# The word ':sh' is not the only thing that can occur after a variable name.
+# Since the parser just counts braces and parentheses instead of properly
+# expanding nested expressions, the token ' :sh' can be used to add arbitrary
+# text between the variable name and the assignment operator, it just has to
+# be enclosed in braces or parentheses.
+VAR :sh(Put a comment here)= comment in parentheses
+.if ${VAR} != "comment in parentheses"
+. error
+.endif
+
+# The unintended comment can include multiple levels of nested braces and
+# parentheses, they don't even need to be balanced since they are only
+# counted by Parse_IsVar and ignored by Parse_DoVar.
+VAR :sh{Put}((((a}{comment}}}}{here}= comment in braces
+.if ${VAR} != "comment in braces"
+. error
+.endif
+
all:
@:;