diff options
author | rillig <rillig@pkgsrc.org> | 2020-09-12 20:48:13 +0000 |
---|---|---|
committer | rillig <rillig@pkgsrc.org> | 2020-09-12 20:48:13 +0000 |
commit | 5ecf5a796dc6cd457f6be92dcdb300e2802624e1 (patch) | |
tree | 9c46520ca5f7ebcc2bc709129e27038a62709de6 /mk | |
parent | 6d8f99a1d55cb35714712c8c588de3fa8b7ecae7 (diff) | |
download | pkgsrc-5ecf5a796dc6cd457f6be92dcdb300e2802624e1.tar.gz |
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 (limited to 'mk')
-rw-r--r-- | mk/misc/show.mk | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/mk/misc/show.mk b/mk/misc/show.mk index 66d263a9e49..c2563f2aef5 100644 --- a/mk/misc/show.mk +++ b/mk/misc/show.mk @@ -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 @@ show-all: show-all-${g} # 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 @@ show-all-${g}: .PHONY 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 @@ show-all-${g}: .PHONY 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 @@ show-all-${g}: .PHONY ${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; \ |