git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [TopGit PATCH/RFC] Do not use mktemp

From
Jonathan Nieder <jrnieder@uchicago.edu>
Date
Aug 12, 2008, 21:07 UTC
Message-ID
<Pine.GSO.4.62.0808121557290.24244@harper.uchicago.edu>
In-Reply-To
<20080812204433.GM10151@machine.or.cz>
Hi,
Petr Baudis wrote:
Show 6 quoted lines
> On Tue, Aug 12, 2008 at 01:14:27PM -0500, Jonathan Nieder wrote:
> > Old operating systems may not even have mktemp; less old
> > operating systems may have a mktemp which is not compatible with
> > the usual post-1.5 version.  Let's try to do without.
> 
>   can you give some concrete examples?

SunOS 5.8 has no mktemp (which is not so bad, because as you say, we could provide our own stub).

Mac OS X mktemp does not allow omitting the template argument but otherwise shouldn't be much of a problem. On Mac OS X (and old BSDs, too, presumably), "mktemp -t arg" treats arg as a prefix for a filename rather than a template for a filename, but that is just a cosmetic problem.

So thinking it through, perhaps we should do the following:
 - provide a simple mini-mktemp for users install to install themselves
   on old systems
 - always provide the template argument to mktemp

The arcane umask use would then go in that mini-mktemp which most people would not be using. I still would appreciate suggestions from any shell hackers on how to implement it properly (in particular, how to get random numbers that change more than once/second).

I'll work on a patch in a few hours when I get home. Thanks for the comments.

Jonathan
Previous: Petr BaudisNext: Jonathan Nieder
Message 4 of 6 in “Do not use mktemp”
  1. Do not use mktempJonathan Nieder, Aug 12, 2008
  2. suppress "cannot overwrite existing file" errorJonathan Nieder, Aug 12, 2008
  3. Petr BaudisAug 12, 2008
  4. Jonathan NiederAug 12, 2008
  5. supply template argument to mktempJonathan Nieder, Aug 13, 2008
  6. tg-info: fix sed typoJonathan Nieder, Aug 13, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.