about summary refs log tree commit diff
path: root/converter
diff options
context:
space:
mode:
authorgiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2020-06-25 20:34:14 +0000
committergiraffedata <giraffedata@9d0c8265-081b-0410-96cb-a4ca84ce46f8>2020-06-25 20:34:14 +0000
commit613c8b713fab7516632db31a9ba207ffdc85cb44 (patch)
treee831db31d77f0e7ebf5c92d3905b587b2f614d59 /converter
parentc6079f29cad2ece6125f42487d13a912c0c35d7e (diff)
downloadnetpbm-mirror-613c8b713fab7516632db31a9ba207ffdc85cb44.tar.gz
netpbm-mirror-613c8b713fab7516632db31a9ba207ffdc85cb44.tar.xz
netpbm-mirror-613c8b713fab7516632db31a9ba207ffdc85cb44.zip
Better generation of temp files, /bin/bash instead of /bin/sh
git-svn-id: http://svn.code.sf.net/p/netpbm/code/trunk@3867 9d0c8265-081b-0410-96cb-a4ca84ce46f8
Diffstat (limited to 'converter')
-rwxr-xr-xconverter/ppm/hpcdtoppm/pcdovtoppm12
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