=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/mktemp/mktemp.1,v retrieving revision 1.11 retrieving revision 1.12 diff -c -r1.11 -r1.12 *** src/usr.bin/mktemp/mktemp.1 1999/07/02 20:11:45 1.11 --- src/usr.bin/mktemp/mktemp.1 1999/08/05 09:19:35 1.12 *************** *** 1,4 **** ! .\" $OpenBSD: mktemp.1,v 1.11 1999/07/02 20:11:45 aaron Exp $ .\" .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. --- 1,4 ---- ! .\" $OpenBSD: mktemp.1,v 1.12 1999/08/05 09:19:35 millert Exp $ .\" .\" Copyright (c) 1989, 1991, 1993 .\" The Regents of the University of California. All rights reserved. *************** *** 53,59 **** .Ql X Ns s appended to it, for example ! .Pa /tmp/temp.XXXXXX . The trailing .Ql X Ns s are replaced with the current process number and/or a --- 53,59 ---- .Ql X Ns s appended to it, for example ! .Pa /tmp/temp.XXXXXXXXXX . The trailing .Ql X Ns s are replaced with the current process number and/or a *************** *** 120,136 **** where the script should quit if it cannot get a safe temporary file. .Bd -literal -offset indent ! TMPFILE=`mktemp /tmp/$0.XXXXXX` || 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` if [ $? -ne 0 ]; then echo "$0: Can't create temp file, exiting..." exit 1 fi .Ed .Sh SEE ALSO .Xr mkdtemp 3 , --- 120,149 ---- where the script should quit if it cannot get a safe temporary file. .Bd -literal -offset indent ! TMPFILE=`mktemp /tmp/$0.XXXXXXXXXX` || exit 1 echo "program output" >> $TMPFILE .Ed .Pp ! In this case, we want the script to catch the error ourselves. .Bd -literal -offset indent ! TMPFILE=`mktemp -q /tmp/$0.XXXXXXXXXX` if [ $? -ne 0 ]; then echo "$0: Can't create temp file, exiting..." exit 1 fi + .Ed + .Pp + Or perhaps you don't want to exit if + .Nm + is unable to create the file. In this case you can protect the + part of the script thusly. + .Bd -literal -offset indent + TMPFILE=`mktemp /tmp/$0.XXXXXXXXXX` && { + # Safe to use $TMPFILE in this block + echo data > $TMPFILE + ... + rm -f $TMPFILE + } .Ed .Sh SEE ALSO .Xr mkdtemp 3 ,