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


Making names for temporary files

Commands specified to syscmd or esyscmd might need a temporary file, for output or for some other purpose. There is a builtin macro, maketemp, for making temporary file names:

maketemp(template)

which expands to a name of a non-existent file, made from the string template, which should end with the string `XXXXXX'. The six X's are then replaced, usually with something that includes the process id of the m4 process, in order to make the filename unique.

maketemp(`/tmp/fooXXXXXX')
=>/tmp/fooa07346
maketemp(`/tmp/fooXXXXXX')
=>/tmp/fooa07346

As seen in the example, several calls of maketemp might expand to the same string, since the selection criteria is whether the file exists or not. If a file has not been created before the next call, the two macro calls might expand to the same name.

The builtin macro maketemp is recognized only when given arguments.


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