Re: (cross post from bug-make) A complete example of quoting an arbitrary value as a word in a shell script
Poor Yorick <[email protected]>
| Newsgroups | gmane.comp.gnu.make.general |
|---|---|
| Message-ID | <[email protected]> |
On 2022-11-06 03:59, Kaz Kylheku wrote:
> Just Base64-encode the value as, say, the make variable B64VAL and do
>
> eval "$$(base64dec $(B64VAL))"
>
> in the recipe or in a $(shell ...).
>
> If that isn't palatable, invent some other encoding that is more
> readable.
>
> URL encoding: percent hex notation for control and special characters.
>
>
> Quoted printable from MIME is another possibility.
>
> You just have a dependency on the decoding tool.
>
> Or make up something decodable by an awk or sed one liner. Awk has
> environment access, and gmake can export.
That all sounds more complex than defining the three functions I
provided which can
quote a script that is readable as a literal value in a Makefile:
shquotequote = $(subst ','\'',$(1))
shnlquote = '$(subst $(newline),' ',$(call shquotequote,$(1)))'
shquote = "$$(printf '%s\n' $(call shnlquote,$(1)))"
--
Yorick