pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/mk/misc show-all: fix escaping of '$' in variable modi...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/ffc32894f155
branches:  trunk
changeset: 438935:ffc32894f155
user:      rillig <rillig%pkgsrc.org@localhost>
date:      Sat Sep 12 20:48:13 2020 +0000

description:
show-all: fix escaping of '$' in variable modifiers

The previous code relied on the exact implementation of Var_Parse in
bmake, and that it does not issue any error messages in case of $$ in
variable modifiers.

In variable modifiers, a $ is escaped using \$, not $$, as documented in
the manual page.

At the time when I wrote the previous version with the _SHOW_ALL.d4 and
_SHOW_ALL.d8 hacks, I did not know about the backslash escaping rule,
and I just added dollar signs until everything seemed to work.  I
couldn't explain why it worked though, which is not surprising since the
code was using an undocumented implementation flaw of bmake.

diffstat:

 mk/misc/show.mk |  11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

diffs (46 lines):

diff -r c395100fd911 -r ffc32894f155 mk/misc/show.mk
--- a/mk/misc/show.mk   Sat Sep 12 20:43:58 2020 +0000
+++ b/mk/misc/show.mk   Sat Sep 12 20:48:13 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: show.mk,v 1.23 2020/07/04 18:08:35 rillig Exp $
+# $NetBSD: show.mk,v 1.24 2020/09/12 20:48:13 rillig Exp $
 #
 # This file contains some targets that print information gathered from
 # variables. They do not modify any variables.
@@ -166,9 +166,6 @@
 # using the :sh modifier may show warnings, for example because ${WRKDIR}
 # doesn't exist.
 
-_SHOW_ALL.d4=  $$$$            # see regress/infra-unittests/show-all.sh
-_SHOW_ALL.d8=  $$$$$$$$        # see regress/infra-unittests/show-all.sh
-
 show-all-${g}: .PHONY
        @${RUN} printf '%s:\n' ${g:Q}
 
@@ -185,7 +182,7 @@
          printf '  %-6s%-${w}s # empty\n' ${_LABEL.${c}} ${v:Q}=;      \
        else                                                            \
          printf '  %-6s%-${w}s \\\n' ${_LABEL.${c}} ${v:Q}=;           \
-         printf '        %-${w}s %s \\\n' ${${v}:O:C,\\$$,${_SHOW_ALL.d8},g:@x@'' ${x:Q}@}; \
+         printf '        %-${w}s %s \\\n' ${${v}:O:C,\\\$,\$\$\$\$,g:@x@'' ${x:Q}@}; \
          printf '        %-${w}s # end of %s (sorted)\n' '' ${v:Q};    \
        fi
 
@@ -199,7 +196,7 @@
          printf '  %-6s%-${w}s # empty\n' ${_LABEL.${c}} ${v:Q}=;      \
        else                                                            \
          printf '  %-6s%-${w}s \\\n' ${_LABEL.${c}} ${v:Q}=;           \
-         printf '        %-${w}s %s \\\n' ${${v}:C,\\$$,${_SHOW_ALL.d8},g:@x@'' ${x:Q}@}; \
+         printf '        %-${w}s %s \\\n' ${${v}:C,\\\$,\$\$\$\$,g:@x@'' ${x:Q}@}; \
          printf '        %-${w}s # end of %s\n' '' ${v:Q};             \
        fi
 
@@ -209,7 +206,7 @@
        ${RUN}                                                          \
        if ${!defined(${v}) :? true : false}; then                      \
          printf '  %-6s%-${w}s # undefined\n' ${_LABEL.${c}} ${v:Q};   \
-       elif value=${${v}:U:C,\\$$,${_SHOW_ALL.d4},gW:Q} && test "x$$value" = "x"; then \
+       elif value=${${v}:U:C,\\\$,\$\$,gW:Q} && test "x$$value" = "x"; then \
          printf '  %-6s%-${w}s # empty\n' ${_LABEL.${c}} ${v:Q}=;      \
        else                                                            \
          case "$$value" in (*[\        \ ]) eol="# ends with space";; (*) eol=""; esac; \



Home | Main Index | Thread Index | Old Index