When I create a random file on macOS with mktemp I get:
mktemp /tmp/test.XXXXXXX.json
mktemp: mkstemp failed on /tmp/test.XXXXXXX.json: File exists
It does not replace XXXXXXX
with random string. Works fine on Linux but not on macOS.
Turns out, for whatever reason, macOS version of mktemp
supports only trailing XXXXXX
for random string, in other words mktemp /tmp/test.XXXX
will work but not /tmp/test.XXXX.json
This is the documented behaviour, from man mktemp:
The template may be any file name with some number of `Xs' appended to it, for example /tmp/temp.XXXXXX