Diverting Output and Including Files
You’re already familiar with the divert([N]) macro, but its concept may still be unclear.
Recall that most m4 scripts act as filters that stream data from the standard input to the standard output (first mentioned). Like a natural water stream, a data stream can be temporarily diverted and later restored. The divert([N]) macro handles this data stream diversion.
By calling divert(N), you request m4 to stream the data from the standard input to a temporary storage unit, known as a diversion, numbered N. A diversion can be implemented as a RAM buffer or a file, depending on how much data it needs to hold. The divert(-1) macro discards the output, which is why it was used in previous code examples. The
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access