Go to the first, previous, next, last section, table of contents.


Reading the output of commands

If you want m4 to read the output of a UNIX command, use esyscmd:

esyscmd(shell-command)

which expands to the standard output of the shell command shell-command.

Prior to executing the command, m4 flushes its output buffers. The default standard input and error output of shell-command are the same as those of m4. The error output of shell-command is not a part of the expansion: it will appear along with the error output of m4.

Assume you are positioned into the `checks' directory of GNU m4 distribution, then:

define(`vice', `esyscmd(grep Vice ../COPYING)')
=>
vice
=>  Ty Coon, President of Vice
=>

Note how the expansion of esyscmd has a trailing newline.

The builtin macro esyscmd is recognized only when given arguments.


Go to the first, previous, next, last section, table of contents.