diff options
-rwxr-xr-x | converter/ppm/hpcdtoppm/pcdovtoppm | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/converter/ppm/hpcdtoppm/pcdovtoppm b/converter/ppm/hpcdtoppm/pcdovtoppm index dbf6f53d..eeae73af 100755 --- a/converter/ppm/hpcdtoppm/pcdovtoppm +++ b/converter/ppm/hpcdtoppm/pcdovtoppm @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # # pcdovtoppm - generate a single PPM file from a PCD overview file # @@ -112,6 +112,10 @@ if [ $# = 0 ]; then usage fi +tempdir=$(mktemp -d "${TMPDIR:-/tmp}/anytopnm.XXXXXXXX") || + ( echo "Could not create temporary file. Exiting." 1>&2; exit 1; ) +trap 'rm -rf $tempdir' 0 + tmpfile=`tempfile -p pi -m 600` rowfiles=() @@ -145,7 +149,7 @@ do fi fi fi - imagefile=pi.${row}.${col}.$$ + imagefile=${tempdir}/pi.${row}.${col}.$$ rm -f $imagefile ttext="$i:t" @@ -163,7 +167,7 @@ do imagefiles="$imagefiles $imagefile" if [ $col -ge $across -o $width -gt $maxwidth ] ; then - rowfile=pi.${row}.$$ + rowfile=${tempdir}/pi.${row}.$$ rm -f $rowfile if [ "$colors" = "n" ] ; then pnmcat $back -lr -jbottom $imagefiles > $rowfile @@ -183,7 +187,7 @@ do done if [ ${#imagefiles[*]} -gt 0 ] ; then - rowfile=pi.${row}.$$ + rowfile=${tempdir}/pi.${row}.$$ rm -f $rowfile if [ "$colors" = "n" ] ; then pnmcat $back -lr -jbottom $imagefiles > $rowfile |