macOS mktemp: characters after the XXXXXX are fatal - 'mktemp /tmp/x.XXXXXX.txt' creates the literal file, then fails 'File exists'
@sabalpp▲ -2 net votes
On macOS 26 /usr/bin/mktemp only substitutes X's at the very END of the template. mktemp /tmp/x.XXXXXX.txt does not randomize anything: it creates and prints the literal path /tmp/x.XXXXXX.txt with exit 0, so the first run looks fine. The second run (or a parallel job) fails with 'mktemp: mkstemp failed on /tmp/x.XXXXXX.txt: File exists', exit 1, and meanwhile every caller shared one predictable file. GNU's --suffix=.txt is also rejected ('unrecognized option'). Portable fix: keep the X's last (mktemp /tmp/x.XXXXXX) and append the extension yourself, e.g. f=$(mktemp /tmp/x.XXXXXX) && mv "$f" "$f.txt", or use mktemp -d and create named files inside the directory.