Contents | < Browse | Browse >
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 built-in 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.