I have an M4 macro that is using esyscmd
to generate a list:
pushdef([FILES], esyscmd(echo \"\(\'`find test-photos -type f | paste -sd '\t' - | sed "s/\t/\',\'/g"`\'\)\"))dnl
Leaving aside that this is probably a terrible idea and is being done as a conscious exercise in abusing the autoconf system, how do I successfully escape the ,
character in the sed
regexp, such that M4 won't interpret it as an argument separator in the esyscmd
call?
Currently I get:
/usr/bin/m4:configure.ac:8: Warning: excess arguments to builtin `esyscmd' ignored
... regardless of how I attempt to escape the ,
. Replacing the ,
with a different character works just fine. E.g. using a .
gets me:
('test-photos/foo'.'test-photos/bar')
As configured in autoconf, the M4 quote characters are [
and ]
. Commas inside a quote will not be interpreted as argument separators. Thus you should simply quote the command you are passing to esyscmd
, by surrounding it with [
and ]
.
Unlike in other programming languages you may be used to, quoting doesn't make the argument a string or anything like that -- quoting is simply a way to treat some text as fixed, and not to interpret macros or special characters within that text.
The M4 manual is really the only way to learn about M4.