summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mk/subst.mk4
-rw-r--r--regress/infra-unittests/subst.sh9
2 files changed, 6 insertions, 7 deletions
diff --git a/mk/subst.mk b/mk/subst.mk
index 099a130a0ba..cd9b769748a 100644
--- a/mk/subst.mk
+++ b/mk/subst.mk
@@ -1,4 +1,4 @@
-# $NetBSD: subst.mk,v 1.76 2020/04/18 11:42:34 rillig Exp $
+# $NetBSD: subst.mk,v 1.77 2020/04/18 12:21:10 rillig Exp $
#
# The subst framework replaces text in one or more files in the WRKSRC
# directory. Packages can define several ``classes'' of replacements.
@@ -128,7 +128,7 @@ SUBST_FILTER_CMD.${class}?= LC_ALL=C ${SED} ${SUBST_SED.${class}}
SUBST_VARS.${class}?= # none
SUBST_MESSAGE.${class}?= Substituting "${class}" in ${SUBST_FILES.${class}}
. for v in ${SUBST_VARS.${class}}
-SUBST_FILTER_CMD.${class}+= -e s,@${v:C|[^A-Za-z0-9_]|\\\\&|gW:Q}@,${${v}:S|\\|\\\\|gW:S|,|\\,|gW:S|&|\\\&|gW:S|${.newline}|\\${.newline}|gW:Q},g
+SUBST_FILTER_CMD.${class}+= -e s,@${v:C|[.[\\*^${$}]|\\\\&|gW:Q}@,${${v}:S|\\|\\\\|gW:S|,|\\,|gW:S|&|\\\&|gW:S|${.newline}|\\${.newline}|gW:Q},g
. endfor
. if ${SUBST_SHOW_DIFF.${class}:U${SUBST_SHOW_DIFF}:tl} == yes
_SUBST_KEEP.${class}?= LC_ALL=C ${DIFF} -u "$$file" "$$tmpfile" || true
diff --git a/regress/infra-unittests/subst.sh b/regress/infra-unittests/subst.sh
index aae897ded88..1c8395fac20 100644
--- a/regress/infra-unittests/subst.sh
+++ b/regress/infra-unittests/subst.sh
@@ -801,7 +801,7 @@ if test_case_begin "SUBST_VARS for variables with regex characters"; then
'SUBST_CLASSES+= vars' \
'SUBST_STAGE.vars= pre-configure' \
'SUBST_FILES.vars= vars.txt' \
- 'SUBST_VARS.vars= VAR...... VAR.abcde VAR.() VAR.<>' \
+ 'SUBST_VARS.vars= VAR...... VAR.abcde VAR.() VAR.<> VAR.[]' \
'' \
'VAR......= dots' \
'VAR.abcde= letters' \
@@ -817,20 +817,19 @@ if test_case_begin "SUBST_VARS for variables with regex characters"; then
"@VAR.()@" \
"@VAR.<>@" \
"@VAR.[]@"
+cp "$tmpdir/testcase.mk" /tmp
run_bmake "testcase.mk" "pre-configure" \
1> "$tmpdir/stdout" \
2> "$tmpdir/stderr" \
&& exitcode=0 || exitcode=$?
- # TODO: Why are the angle brackets replaced, but not the parentheses
- # and square brackets?
assert_that "vars.txt" --file-is-lines \
"dots" \
"letters" \
- "@VAR.()@" \
+ "parentheses" \
"angle brackets" \
- "@VAR.[]@"
+ "square brackets"
assert_that "stdout" --file-is-lines \
"=> Substituting \"vars\" in vars.txt"
assert_that "stderr" --file-is-empty