On 2025-04-17 19:44, Sean Whitton wrote:
m4 is the only way POSIX.1-2017 defines to safely create a temporary file (outside of writing and compiling a C program).
I was not aware of using m4 for this, so that piqued my interest.
I think the newer POSIX standard has not improved on this particular point.
It seems it has not. Adding mktemp(1) to POSIX has been proposed: https://www.austingroupbugs.net/view.php?id=1616 See also: https://unix.stackexchange.com/questions/614808/why-is-there-no-mktemp-command-in-posixEspecially the quote from Geoff Clare: "However, I don't know how widespread support for the new mkstemp() macro is."
https://mywiki.wooledge.org/BashFAQ/062#Using_m4 says, "For example, the m4 in MacOS (July 2021) was too old to have the mkstemp macro included."
I tested on macOS Sonoma 14.4.1 just now, and m4 is broken for me. That said, I might have a broken installation of Xcode developer tools on this system. It's unclear to me if m4 requires Xcode developer tools normally or what. Installing them was estimating 21 hours, so I didn't do that.
So, personally, I think getting mktemp(1) added to POSIX would be better for portability in the long run anyway.
-- Richard
OpenPGP_signature.asc
Description: OpenPGP digital signature