[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.16 and 1.17

version 1.16, 2000/03/28 23:40:05 version 1.17, 2000/06/26 02:43:31
Line 121 
Line 121 
 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.XXXXXXXXXX` || exit 1  CMD=`basename $0`
   TMPFILE=`mktemp /tmp/$CMD.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 ourselves.  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.XXXXXXXXXX`  CMD=`basename $0`
   TMPFILE=`mktemp -q /tmp/$CMD.XXXXXXXXXX`
 if [ $? -ne 0 ]; then  if [ $? -ne 0 ]; then
         echo "$0: Can't create temp file, exiting..."          echo "$CMD: Can't create temp file, exiting..."
         exit 1          exit 1
 fi  fi
 .Ed  .Ed
Line 139 
Line 141 
 is unable to create the file.  is unable to create the file.
 In this case you can protect the part of the script thusly.  In this case you can protect the part of the script thusly.
 .Bd -literal -offset indent  .Bd -literal -offset indent
 TMPFILE=`mktemp /tmp/$0.XXXXXXXXXX` && {  CMD=`basename $0`
   TMPFILE=`mktemp /tmp/$CMD.XXXXXXXXXX` && {
         # Safe to use $TMPFILE in this block          # Safe to use $TMPFILE in this block
         echo data > $TMPFILE          echo data > $TMPFILE
         ...          ...

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.17