Previous: Sysval, Up: Shell commands
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:
Expands to a name of a new, empty file, made from the string template, which should end with the string `XXXXXX'. The six
X
characters are then replaced with random data, in order to make the file name unique.The macro
maketemp
is recognized only with parameters.
maketemp(`/tmp/fooXXXXXX') =>/tmp/fooa07346
Traditional implementations of m4
replaced the trailing `X'
sequence with the process id, without creating the file; meaning you
only get one result no matter how many times you use maketemp on the
same string. As of this release, POSIX is considering the
addition of a new macro mkstemp
that behaves like GNU
maketemp
, so a future version of GNU M4 may have
changes in this area.