From kde-commits Tue Dec 17 09:23:19 2002 From: Michael Goffioul Date: Tue, 17 Dec 2002 09:23:19 +0000 To: kde-commits Subject: kdelibs/kdeprint/filters X-MARC-Message: https://marc.info/?l=kde-commits&m=104011704702506 CVS commit by goffioul: Removed bashism and support spaces in file name M +14 -7 imagetops 1.3 --- kdelibs/kdeprint/filters/imagetops #1.2:1.3 @@ -21,5 +21,5 @@ ARGS="$ARGS $FILE" FILE=`mktemp /tmp/imagetops.XXXXXX` || exit 1 - cat > $FILE + cat > "$FILE" temp=1 fi @@ -27,12 +27,14 @@ # check the file mime type, and set the command correspondingly cmd= -magic=`file -bi $FILE` -if [[ $magic != image/* ]] ; then +magic=`file -bi "$FILE"` +magicbase=`echo $magic | cut -f 1 -d "/"` +magictype=`echo $magic | cut -f 2- -d "/"` +if test "$magicbase" != "image" ; then echo "Not an image" exit 1; fi -case ${magic/image\//} in +case $magictype in jpeg) - cmd="djpeg -pnm" + cmd="jpegtopnm" ;; png|x-png) @@ -57,6 +59,11 @@ # executing command if [ "$GRAYSCALE" = "1" ]; then - exec $cmd $FILE | ppmtopgm | pnmtops $ARGS + exec $cmd "$FILE" | ppmtopgm | pnmtops $ARGS else - exec $cmd $FILE | pnmtops $ARGS + exec $cmd "$FILE" | pnmtops $ARGS +fi + +# removing temporary file +if test "$temp" = "1"; then + rm -f "$FILE" fi