summaryrefslogtreecommitdiff
path: root/tempfile.1
blob: 69a9f36a200e327b93bb83f66c1fce6e04923c3e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
.\" -*- nroff -*-
.TH TEMPFILE 1 "3 June 2007" "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
.PP
.B tempfile
creates a temporary file in a safe manner.  It uses
.BR tempnam (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:
.IP a)
The directory specified by the environment variable
.BR TMPDIR ,
if it exists.
.IP b)
The directory specified by the
.B --directory
argument, if given.
.IP c)
The directory
.IR /tmp .
.PP
See
.BR tempnam (3)
for the actual steps involved in directory selection.
.SH OPTIONS
.TP
.BI "-d, --directory " DIR
Place the file in DIR.
.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
.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
.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.
.SH "SEE ALSO"
.BR tempnam (3)
.BR mktemp (1)