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 make(1): add another test for parsin...



details:   https://anonhg.NetBSD.org/src/rev/032bef0f4026
branches:  trunk
changeset: 940124:032bef0f4026
user:      rillig <rillig%NetBSD.org@localhost>
date:      Sun Oct 04 08:14:35 2020 +0000

description:
make(1): add another test for parsing :sh assignments

diffstat:

 usr.bin/make/unit-tests/var-op-sunsh.mk |  20 +++++++++++++++++++-
 1 files changed, 19 insertions(+), 1 deletions(-)

diffs (33 lines):

diff -r a11b664a55ad -r 032bef0f4026 usr.bin/make/unit-tests/var-op-sunsh.mk
--- a/usr.bin/make/unit-tests/var-op-sunsh.mk   Sun Oct 04 08:09:12 2020 +0000
+++ b/usr.bin/make/unit-tests/var-op-sunsh.mk   Sun Oct 04 08:14:35 2020 +0000
@@ -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 @@
 .  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:
        @:;



Home | Main Index | Thread Index | Old Index