That comes up regularly on the Austin Group mailing list, and I'm not under the impression the Open Group would be opposed to specifying it. It just needs someone to propose something. See for instance this message from Eric Blake (Red Hat, sits on the weekly POSIX meeting) from 2011 (here copied from gmane):
Date: Tue, 10 May 2011 07:13:32 -0600
From: Eric Blake <eblake-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>
To: Nico Schottelius <nico-posix-xuaVFQXs+5hIG4jRRZ66WA@public.gmane.org>
Subject: Re: No mktemp in posix?
Organization: Red Hat
Xref: news.gmane.org gmane.comp.standards.posix.austin.general:4151
On 05/10/2011 04:50 AM, Nico Schottelius wrote:
> Good morning,
> digging through Issue 7, I haven't found any utility that gives
> the ability to create a secure, temporary file that is usually
> implemented in mktemp.
echo 'mkstemp(fileXXXXXX)' | m4
will output the name of a just-created temporary file. However, I agree
that there does not seem to be any standardized utility that gives
mkdtemp functionality, which is often more useful than mkstemp (after
all, once you have a secure temporary directory, then you can create
secure fifos within that directory, rather than having to wish for a
counterpart 'mkftemp' function).
> Is there no mktemp utility by intent or can we add it in the
> next issue?
I know both BSD and GNU have a mktemp(1) that wraps mktemp(), mkstemp(),
and mkdtemp(). In my inbox, I have record of some off-list email in
February of this year regarding some work between those teams to try and
converge on some common functionality and to word that in a manner
appropriate for the standard, although I can't find any publicly
archived messages to that effect. But yes, I think adding mktemp(1) to
the next revision of the standard would be worthwhile. I'll try to
revive those efforts and actually post some proposed wording.
Eric Blake eblake-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org +1-801-349-2682
Libvirt virtualization library http://libvirt.org
In a more recent thread (worth reading), Geoff Clare (from the Open Group):
Date: Wed, 2 Nov 2016 15:13:46 +0000
From: Geoff Clare <gwc-7882/jkIBncuagvECLh61g@public.gmane.org>
Subject: Re: [1003.1(2013)/Issue7+TC1 0001016]: race condition with set -C
Xref: news.gmane.org gmane.comp.standards.posix.austin.general:13408
Stephane Chazelas <stephane.chazelas-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote, on 02 Nov 2016:
> At the moment, there's no way (that I know) to create a temp file
> reliably with POSIX utilities
Given an m4 utility that conforms to the 2008 standard, there is:
tmpfile=$(echo 'mkstemp(/tmp/fooXXXXXX)' | m4)
However, I don't know how widespread support for the new mkstemp()
Geoff Clare <g.clare-7882/jkIBncuagvECLh61g@public.gmane.org>
The Open Group, Apex Plaza, Forbury Road, Reading, RG1 1AX, England
(which is where I learned that trick which you're referring to in your question).