On 05/13/2015 09:24 AM, Peng Yu wrote: > Hi > > The following code works. > > echo AUTHOR YEAR | m4 -D AUTHOR=Shakespeare -D YEAR=1587 > > But if I not space between AUTHORYEAR, how I should call m4 to do it? Thanks.
$ echo "AUTHOR\`'YEAR" | m4 -D AUTHOR=Shakespeare -D YEAR=1587 Shakespeare1587 That is, any time you want to guarantee that the parser sees the end of one macro name, insert a quoted empty string to call out the start of the next string. Or, you can define the macro itself to end with an empty quoted string, at which point it may be easier to call the macro with 1 (empty) argument instead of with 0 arguments: $ echo "AUTHOR()YEAR" | m4 -D AUTHOR='Shakespeare`'\' -D YEAR=1587 Shakespeare1587 By the way, using m4 from the shell like this is rather difficult, due to the pains of quoting ` and ' correctly; you may want to use m4 with changequote done fairly early so that the rest of your scripting can use quoting more convenient for the shell. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
