Use of mktemp on OSX and BSD

Shaun McCance <shaunm at gnome.org>
Mon Jul 29 10:13:41 EDT 2013

On Mon, 2013-07-29 at 11:07 +0200, Aurélien Naldi wrote:
> Hi,
> 
> 
> we are running yelp-build on linux and OSX and we had one small
> problem on OSX: the mktemp command there behaves differently as the
> GNU version: it requires the "template" argument instead of having a
> default one. Except for this, the yelp tools work fine in our use case
> on OSX.
> We also use a trick based on "dirname $0" to detect the install folder
> instead of hardcoding it upon "build".
> 
> 
> I suppose that this is a problem on BSD as well, and we would love to
> this see it fixed upstream instead of making this (small) change
> ourselves.
> 
> 
> A quick fix is really easy: replace "mktemp" with
> "mktemp /tmp/yelp-XXXXXX"
> Unfortunately you may want something more subtle to handle systems
> with $TMPDIR in a different place, thus I'm not sure what a perfect
> solution is. Maybe detect OSX/BSD and only add the template on these
> systems or check $TMPDIR when creating the template.

Thanks Aurélien. I've added a template to all calls to mktemp, using
TMPDIR if available and /tmp otherwise:

https://git.gnome.org/browse/yelp-tools/commit/?id=5769c06360989f54b44761eb50cb708ea36663e1

There will be an unstable 3.9 release of yelp-tools later today if
you don't like building from git.

--
Shaun