[BACK]Return to mktemp.1 CVS log [TXT][DIR] Up to [local] / src / usr.bin / mktemp

Diff for /src/usr.bin/mktemp/mktemp.1 between version 1.11 and 1.12

version 1.11, 1999/07/02 20:11:45 version 1.12, 1999/08/05 09:19:35
Line 53 
Line 53 
 .Ql X Ns s  .Ql X Ns s
 appended  appended
 to it, for example  to it, for example
 .Pa /tmp/temp.XXXXXX .  .Pa /tmp/temp.XXXXXXXXXX .
 The trailing  The trailing
 .Ql X Ns s  .Ql X Ns s
 are replaced with the current process number and/or a  are replaced with the current process number and/or a
Line 120 
Line 120 
 where the script should quit if it cannot get a safe  where the script should quit if it cannot get a safe
 temporary file.  temporary file.
 .Bd -literal -offset indent  .Bd -literal -offset indent
 TMPFILE=`mktemp /tmp/$0.XXXXXX` || exit 1  TMPFILE=`mktemp /tmp/$0.XXXXXXXXXX` || exit 1
 echo "program output" >> $TMPFILE  echo "program output" >> $TMPFILE
 .Ed  .Ed
 .Pp  .Pp
 In this case, we want the script to catch the error itself.  In this case, we want the script to catch the error ourselves.
 .Bd -literal -offset indent  .Bd -literal -offset indent
 TMPFILE=`mktemp -q /tmp/$0.XXXXXX`  TMPFILE=`mktemp -q /tmp/$0.XXXXXXXXXX`
 if [ $? -ne 0 ]; then  if [ $? -ne 0 ]; then
         echo "$0: Can't create temp file, exiting..."          echo "$0: Can't create temp file, exiting..."
         exit 1          exit 1
 fi  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  .Ed
 .Sh SEE ALSO  .Sh SEE ALSO
 .Xr mkdtemp 3 ,  .Xr mkdtemp 3 ,

Legend:
Removed from v.1.11  
changed lines
  Added in v.1.12