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 more tests for the vari...
details: https://anonhg.NetBSD.org/src/rev/7a74f49b9480
branches: trunk
changeset: 956573:7a74f49b9480
user: rillig <rillig%NetBSD.org@localhost>
date: Sun Nov 01 19:49:28 2020 +0000
description:
make(1): add more tests for the variable modifier :M
Despite its popularity and usefulness, the variable modifier :M is
implemented so weirdly that it's not surprising people get confused
about make's parsing and escaping rules.
diffstat:
usr.bin/make/unit-tests/varmod-match-escape.exp | 5 +++-
usr.bin/make/unit-tests/varmod-match-escape.mk | 26 ++++++++++++++++++++++++-
2 files changed, 29 insertions(+), 2 deletions(-)
diffs (51 lines):
diff -r 3af74b75a810 -r 7a74f49b9480 usr.bin/make/unit-tests/varmod-match-escape.exp
--- a/usr.bin/make/unit-tests/varmod-match-escape.exp Sun Nov 01 19:47:46 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-match-escape.exp Sun Nov 01 19:49:28 2020 +0000
@@ -55,4 +55,7 @@
make: "varmod-match-escape.mk" line 42: warning: XXX: Oops
Global:.MAKEFLAGS = -r -k -d cv -d
Global:.MAKEFLAGS = -r -k -d cv -d 0
-exit status 0
+make: "varmod-match-escape.mk" line 67: Dollar followed by nothing
+make: Fatal errors encountered -- cannot continue
+make: stopped in unit-tests
+exit status 1
diff -r 3af74b75a810 -r 7a74f49b9480 usr.bin/make/unit-tests/varmod-match-escape.mk
--- a/usr.bin/make/unit-tests/varmod-match-escape.mk Sun Nov 01 19:47:46 2020 +0000
+++ b/usr.bin/make/unit-tests/varmod-match-escape.mk Sun Nov 01 19:49:28 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: varmod-match-escape.mk,v 1.4 2020/11/01 19:25:23 rillig Exp $
+# $NetBSD: varmod-match-escape.mk,v 1.5 2020/11/01 19:49:28 rillig Exp $
#
# As of 2020-08-01, the :M and :N modifiers interpret backslashes differently,
# depending on whether there was a variable expression somewhere before the
@@ -44,5 +44,29 @@
.MAKEFLAGS: -d0
+# XXX: As of 2020-11-01, unlike all other variable modifiers, a '$' in the
+# :M and :N modifiers is written as '$$', not as '\$'. This is confusing,
+# undocumented and hopefully not used in practice.
+.if ${:U\$:M$$} != "\$"
+. error
+.endif
+
+# XXX: As of 2020-11-01, unlike all other variable modifiers, '\$' is not
+# parsed as an escaped '$'. Instead, ApplyModifier_Match first scans for
+# the ':' at the end of the modifier, which results in the pattern '\$'.
+# No unescaping takes place since the pattern neither contained '\:' nor
+# '\{' nor '\}'. But the text is expanded, and a lonely '$' at the end
+# is silently discarded. The resulting expanded pattern is thus '\', that
+# is a single backslash.
+.if ${:U\$:M\$} != ""
+. error
+.endif
+
+# In lint mode, the case of a lonely '$' is covered with an error message.
+.MAKEFLAGS: -dL
+.if ${:U\$:M\$} != ""
+. error
+.endif
+
all:
@:;
Home |
Main Index |
Thread Index |
Old Index