Fix example.

PR:		18953
Submitted by:	Mark Ovens <mark@ukug.uk.freebsd.org>
This commit is contained in:
asmodai 2000-06-04 09:11:22 +00:00
parent 8403edd8c6
commit 84e7a035aa

View File

@ -150,19 +150,22 @@ fragment illustrates a simple use of
where the script should quit if it cannot get a safe
temporary file.
.Bd -literal -offset indent
TMPFILE=`mktemp /tmp/$0.XXXXXX` || exit 1
tempfoo=`basename $0`
TMPFILE=`mktemp /tmp/${tempfoo}.XXXXXX` || exit 1
echo "program output" >> $TMPFILE
.Ed
.Pp
To allow the use of $TMPDIR:
.Bd -literal -offset indent
TMPFILE=`mktemp -t $0` || exit 1
tempfoo=`basename $0`
TMPFILE=`mktemp -t ${tempfoo}` || exit 1
echo "program output" >> $TMPFILE
.Ed
.Pp
In this case, we want the script to catch the error itself.
.Bd -literal -offset indent
TMPFILE=`mktemp -q /tmp/$0.XXXXXX`
tempfoo=`basename $0`
TMPFILE=`mktemp -q /tmp/${tempfoo}.XXXXXX`
if [ $? -ne 0 ]; then
echo "$0: Can't create temp file, exiting..."
exit 1