-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 According to Eric Blake on 10/7/2006 4:33 PM: > In line with the two aardvarks I just filed against mkstemp(3), I propose > this wording for the mkstemp paragraph in interpretation 117 (the rest of > the proposed solution is fine as is): > > Insert new macro immediately after maketemp > > mkstemp The first argument shall be taken as a template for creating an > empty file, with trailing 'X' characters replaced with characters from the > portable file name set. The behavior is unspecified if the first argument > does not end in at least six 'X' characters. If a temporary file is > successfully created, then the defining text of the macro is the name of > the new file; the file is owned by the effective user and group of the > process, and the file access permission bits are set such that only the > owner can both read and write the file, regardless of the current umask of > the process. If a file could not be created, the defining text of the > macro shall be the empty string. >
Reviving an old thread, but in implementing mkstemp in GNU m4, I realized that there is a very slight chance that the file name generated by mkstemp can happen to match a defined macro name. As written, the interp makes it sound like mkstemp should produce an unquoted file name, but in the event of the random overlap, that means that the rescan of the filename will expand the macro, and the user is left with a different string than the name of the file that was just created, but only on rare occasions, which makes for a very difficult situation to debug. I'm thinking that it would be much nicer to require the mkstemp macro to result in quoted output, so that the rescan of the output strips the quote and leaves the name of the file just created, regardless of any potential macro names already defined. This would mean changing: If a temporary file is successfully created, then the defining text of the macro is the name of the new file; to If a temporary file is successfully created, then the defining text of the macro is the quoted name of the new file; My inspection of several existing m4 implementations shows that maketemp has always produced unquoted output, but since no file was created and this macro has been obsoleted, this is less likely to cause actual problems in user scripts. Therefore, I see no reason to change maketemp. - -- Don't work too hard, make some time for fun as well! Eric Blake [EMAIL PROTECTED] -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (Cygwin) Comment: Public key at home.comcast.net/~ericblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHTjn084KuGfSFAYARAkDXAJ4sCyhm1Ld9kN575UhFYuP1Yl9jrQCgmMKD GfvpYh2uPDKD2rClLHRGXwE= =4QzD -----END PGP SIGNATURE----- _______________________________________________ M4-discuss mailing list M4-discuss@gnu.org http://lists.gnu.org/mailman/listinfo/m4-discuss