Subject: Re: bug in handling of != in make?
To: None <tech-userlevel@NetBSD.org>
From: Alan Barrett <apb@cequrux.com>
List: tech-userlevel
Date: 06/09/2006 16:49:13
On Fri, 09 Jun 2006, Roland Illig wrote:
> >The only way around it, AFAIK, is to apply a :Q modifier after the
> >shell expansion but before saving the result into a variable, as in
> >${VERSION_CMD:sh:Q}.
> 
> That doesn't help either, because \$NetBSD\$ is still interpreted as 
> (backslash, value_of("N"), e, t, B, S, D, backslash, value_of("")).

You are correct; I thought I had tested, but obviously I got it wrong.

> VERSION_CMD would need a "| sed 's,\$,$$,g'" appended to it to make this 
> work:
> 
> VERSION_cmd=    echo '$$NetBSD$$' | sed -e 's,\$$,$$$$,g'
> VERSION:=       ${VERSION_cmd:sh}
> all:
>         echo ${VERSION:Q}

That works, and so does this:

VERSION_cmd=    echo '$$NetBSD$$'
VERSION:=       ${VERSION_cmd:sh:C/\\\$/\$\$/g}
all:
	echo ${VERSION:Q}

(The documentation for the :C/// modifier says that it works with
regular expressions, but if you read carefully enough it refers you to
the definition of the :S/// modifier, which says that it does variable
expansion first.  That's why so many backslashes are needed.)

--apb (Alan Barrett)