In
m4
, is it possible to expand a macro and to immediately put it in quotes? That is, instead of
define(HELLO, `Hello!')dnl
define(MACRO, `HELLO')dnl
MACRO
expanding to Hello!
, I would love to have some function qexpand
, for example, such that
define(HELLO, `Hello!')dnl
define(MACRO, `HELLO')dnl
qexpand(`MACRO')
expands to HELLO
. But any other line after the first two that expands MACRO
into a string would do as well, of course.
---
*Background*. I want to operate substitutions on the expansion of a macro using patsubst
, say substituting commas in it. Unfortunately
define(MACRO',
x,y,z')dnl
patsubst(MACRO',
,',`.')
yields x,y,z
, as the substitution is performed on the string MACRO
. But if the expansion of the macro contains commas, the variant
define(MACRO',
x,y,z')dnl
patsubst(MACRO,,',
.')
has the second line first expand to `patsubst(x,y,z,
,',.')
, giving the error
Warning: excess arguments to builtin
patsubst' ignored``. The possibility of expanding a macro into quotes would solve this.
Asked by k.stm
(739 rep)
Feb 17, 2019, 09:53 AM
Last activity: Feb 24, 2019, 10:11 AM
Last activity: Feb 24, 2019, 10:11 AM