On Tue, Jun 16, 2009 at 03:59:42PM -0400, James Carlson wrote: > Glenn Fowler writes: > > the -u description I quoted was from the solaris mktemp(1) > > > > its not semantics assuming the gnu and solaris documentation describe the > > implementation > > > > gnu --dry-run prints the name it would use to creat the file > > but stops short of doing the creat > > > > solaris -u does a creat, unlink, and then prints the name > > In terms of defining what the output means, is there really a > difference between these two? > > The Solaris one does a modest check to see if the name is unused. But > since it doesn't hold onto that newly-created object, anyone else > could slip in a millisecond after mktemp(1) exit and create that same > object with nary a complaint observed.
Worse, one might observe the name via readdir on the tmpdir, and then create a file with the same name after it's unlinked. It'd be better if mktemp -u did no more than a stat of name(s) it generates. Nico --