How to force m4 to continue processing line if value has hash?
$ echo a a a | m4 -D a=B+
B+ B+ B+
$ echo a a a | m4 -D a=B#
B# a a
I want identical behavior for second case - is it possible? (all three occurrences to be replaced).
In my understanding observed behavior is inconsistent and I couldn't find explanation in user manual.
The
#
character is the first character of a comment and a newline is the last character. Them4
parses the firsta
and replace it toB#
. It doesn't scan more because it runs into a comment.The solution is to change the comment characters with
changecom
:Of course you can choose better comment begin- and end-sequences.
Ps. you can turn off the comment with simple
changecom
without arguments:echo changecom a a a
. You can read it from manual :)