]> git.lyx.org Git - lyx.git/blobdiff - lib/scripts/lyxpreview2bitmap.sh
Try and make convertDefault a little more robust.
[lyx.git] / lib / scripts / lyxpreview2bitmap.sh
index 6d9cbde07a0fb5be3a654b97ab1c8e34c1425365..7e4ece1f96a1914b1a98720a6404f6fc72ff8a9d 100644 (file)
 # where ${FORMAT} is either ppm or png.
 
 # Three helper functions.
-FIND_IT () {
-       which ${EXECUTABLE} > /dev/null ||
-       {
-               echo "Unable to find \"${EXECUTABLE}\". Please install."
+FIND_IT ()
+{
+       test $# -eq 1 || exit 1
+
+       type $1 > /dev/null || {
+               echo "Unable to find \"$1\". Please install."
                exit 1
        }
 }
 
-BAIL_OUT () {
+BAIL_OUT ()
+{
        # Remove everything except the original .tex file.
        FILES=`ls ${BASE}* | sed -e "/${BASE}.tex/d"`
        rm -f ${FILES} texput.log
@@ -68,7 +71,8 @@ BAIL_OUT () {
        exit 1
 }
 
-REQUIRED_VERSION () {
+REQUIRED_VERSION ()
+{
        echo "We require preview.sty version 0.73 or newer. You're using"
        grep 'Package: preview' ${LOGFILE}
 }
@@ -97,9 +101,9 @@ else
 fi
 
 # We use latex, dvips and gs, so check that they're all there.
-EXECUTABLE=latex; FIND_IT
-EXECUTABLE=dvips; FIND_IT
-EXECUTABLE=gs;    FIND_IT
+FIND_IT latex
+FIND_IT dvips
+FIND_IT gs
 
 # Initialise some variables.
 TEXFILE=${BASE}.tex
@@ -199,7 +203,7 @@ rm -f ${FILES} texput.log
 # The bitmap files can have large amounts of whitespace to the left and
 # right. This can be cropped if so desired.
 CROP=1
-which pnmcrop > /dev/null || CROP=0
+type pnmcrop > /dev/null || CROP=0
 
 # There's no point cropping the image if using PNG images. If you want to
 # crop, use PPM.