Subject: Re: pkglint -Wall
To: Roland Illig <rillig@NetBSD.org>
From: Iain Hibbert <plunky@rya-online.net>
List: tech-pkg
Date: 02/11/2006 20:04:57
On Sun, 5 Feb 2006, Roland Illig wrote:

> In general, use the :Q operator. But pay attention if the variable appears in
> 'single quotes', "double quotes" or `backticks`. There are subtle differences
> in the way the shell interprets those strings, and I'm not sure yet how to do
> it right. One popular example where pkglint could issue a warning but
> suppresses it are sed(1) replacements:
>
> SUBST_SED.foo+=       -e 's,@PREFIX@,${PREFIX},g'

btw in the package I was twiddling, I used something akin to

SUBST_SED.foo+=		s,@PREFIX@,${PREFIX},g

as I determined that in this case (a single editing command) the -e is not
needed, which makes the quotes not needed either.

> Here, PREFIX is first interpreted by the shell. For that, it would suffice to
> write ${PREFIX:Q}. But after that, the string gets further interpreted by
> sed(1), which handles backslashes and & specially. As long as we don't have
> backslashes and & in the ${PREFIX}, this doesn't matter. But if you replace
> PREFIX with CPPFLAGS in this example, things look different. It is not
> uncommon to say CPPFLAGS += -DLLONG=long\ long, and there you have a
> backslash. Of course, one could write
> s,@CPPFLAGS@,${CPPFLAGS:C/\\/\\\\/g:C/&/\\\&/:Q},g, but this looks terribly
> complicated, and casual packagers should not be required to write, read and
> understand this.

since the place where the command line is built is in fact in subst.mk,
can this construct not be included there rather than in the package
Makefile?

iain