mktemp improvements

- add -p dir, -t and -u.
- fix dirname(tmp) check (did not check null terminator).

the semantics of mktemp is now the same as OpenBSD mktemp.
This commit is contained in:
Hiltjo Posthuma
2015-05-09 20:38:20 +02:00
committed by sin
parent 590f34c4a9
commit 347f0828f3
2 changed files with 54 additions and 15 deletions

View File

@@ -1,4 +1,4 @@
.Dd January 31, 2015
.Dd May 8, 2015
.Dt MKTEMP 1
.Os sbase
.Sh NAME
@@ -6,7 +6,8 @@
.Nd create temporary file or directory
.Sh SYNOPSIS
.Nm
.Op Fl dq
.Op Fl dqtu
.Op Fl p Ar directory
.Op Ar template
.Sh DESCRIPTION
.Nm
@@ -20,8 +21,25 @@ tmpdir set to '/tmp' or, if set, the TMPDIR environment variable.
.Bl -tag -width Ds
.It Fl d
Create a temporary directory instead of a file.
.It Fl p Ar directory
Use the specified
.Ar directory
as a prefix when generating the temporary filename. The directory will be
overridden by the user's
.Ev TMPDIR
environment variable if it is set. This option implies the
.Fl t
flag (see below).
.It Fl q
Fail silently if an error occurs.
.It Fl t
Generate a path rooted in a temporary directory.
.It Fl u
Unlink file before
.Nm
exits. This is slightly better than
.Xr mktemp 3
but still introduces a race condition. Use of this option is not encouraged.
.El
.Sh SEE ALSO
.Xr mkdtemp 3 ,