m4-discuss
[Top][All Lists]
Advanced

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

Re: How to replace with `$1` literally?


From: Peng Yu
Subject: Re: How to replace with `$1` literally?
Date: Mon, 8 Aug 2016 05:19:35 -0500



On Monday, August 8, 2016, Marc Chantreux <address@hidden> wrote:
On Sun, Aug 07, 2016 at 11:30:04PM -0500, Peng Yu wrote:
> Hi, The following code is not able to replace ENV with `$1`.
>
> /tmp$ m4 -D ENV='$1' <<< ENV

you can add a empty string between $ and 1 to avoid interpolation. to do
so, your m4 content must be $`'1, not $1.

if your using a shell with rc quoting (rc, es or zsh with rcquotes
option enabled), you can write:

        m4 -D ENV='$`''1' <<< ENV

the more readable posix way that comes to my mind is

        m4 -D ENV=$\`\'1 <<< ENV

The thing to replace ENV might be read from a file.

m4 -D ENV=$(< file) << ENV

How to escape the content of file so that the content of file will be used to replace ENV literally?


regards

marc


--
Regards,
Peng

reply via email to

[Prev in Thread] Current Thread [Next in Thread]