It is possible to `save' some text until the end of the normal input has
been seen. Text can be saved, to be read again by m4
when the
normal input has been exhausted. This feature is normally used to
initiate cleanup actions before normal exit, e.g., deleting temporary
files.
To save input text, use the builtin m4wrap
:
m4wrap(string, ...)
which stores string and the rest of the arguments in a safe place, to be reread when end of input is reached.
define(`cleanup', `This is the `cleanup' actions. ') => m4wrap(`cleanup') => This is the first and last normal input line. =>This is the first and last normal input line. ^D =>This is the cleanup actions.
The saved input is only reread when the end of normal input is seen, and
not if m4exit
is used to exit m4
.
It is safe to call m4wrap
from saved text, but then the order in
which the saved text is reread is undefined. If m4wrap
is not used
recursively, the saved pieces of text are reread in the opposite order
in which they were saved (LIFO--last in, first out).
Go to the first, previous, next, last section, table of contents.