summaryrefslogtreecommitdiff
path: root/tempfile.1
diff options
context:
space:
mode:
Diffstat (limited to 'tempfile.1')
-rw-r--r--tempfile.188
1 files changed, 88 insertions, 0 deletions
diff --git a/tempfile.1 b/tempfile.1
new file mode 100644
index 0000000..0f0ef57
--- /dev/null
+++ b/tempfile.1
@@ -0,0 +1,88 @@
+.\" -*- nroff -*-
+.TH TEMPFILE 1 "27 Jun 2012" "Debian"
+.SH NAME
+tempfile \- create a temporary file in a safe manner
+.SH SYNOPSIS
+.B tempfile
+[\-d DIR] [\-p STRING] [\-s STRING] [\-m MODE] [\-n FILE] [\-\-directory=DIR]
+[\-\-prefix=STRING] [\-\-suffix=STRING] [\-\-mode=MODE]
+[\-\-name=FILE] [\-\-help] [\-\-version]
+.SH DESCRIPTION
+.B tempfile
+creates a temporary file in a safe manner. It uses
+.BR mkstemps (3)
+to choose the name and opens it with O_RDWR | O_CREAT | O_EXCL. The filename
+is printed on standard output.
+.PP
+The directory in which to create the file might be searched for in this
+order:
+.TP 3
+a)
+In case the environment variable
+.B TMPDIR
+exists and
+contains the name of an appropriate directory, that is used.
+.TP
+b)
+Otherwise, if the
+.I \-\-directory
+argument is specified and appropriate, it is used.
+.TP
+c)
+Otherwise,
+.I P_tmpdir
+(as defined in
+.IR <stdio.h> )
+is used when appropriate.
+.TP
+d)
+Finally an implementation-defined directory
+.RI ( /tmp )
+may be used.
+.SH OPTIONS
+.TP
+.BI "\-d, \-\-directory " DIR
+Place the file in DIR.
+.TP
+.BI "\-m, \-\-mode " MODE
+Open the file with MODE instead of 0600.
+.TP
+.BI "\-n, \-\-name " FILE
+Use FILE for the name instead of
+.BR tempnam (3) .
+The options \-d, \-p, and \-s are ignored if this option is given.
+.TP
+.BI "\-p, \-\-prefix " STRING
+Use up to five letters of STRING to generate the name.
+.TP
+.BI "\-s, \-\-suffix " STRING
+Generate the file with STRING as the suffix.
+.TP
+.B \-\-help
+Print a usage message on standard output and exit successfully.
+.TP
+.B \-\-version
+Print version information on standard output and exit successfully.
+.SH RETURN VALUES
+An exit status of 0 means the temporary file was created successfully.
+Any other exit status indicates an error.
+.SH BUGS
+Exclusive creation is not guaranteed when creating files on NFS
+partitions. tempfile cannot make temporary directories.
+tempfile is deprecated; you should use
+.BR mktemp (1)
+instead.
+.SH EXAMPLE
+.nf
+#!/bin/sh
+#[...]
+t=$(tempfile) || exit
+trap "rm \-f \-\- '$t'" EXIT
+#[...]
+rm \-f \-\- "$t"
+trap - EXIT
+exit
+.fi
+.SH SEE ALSO
+.BR tempnam (3),
+.BR mktemp (1)