Jean-Marc Lasgouttes wrote:
> I think defining the variables at the top of the script would be a
> good first step.

I've applied this to cvs. Perhaps you could do the same for 1.3?

-- 
Angus
? lib/reLyX-safe
Index: lib/ChangeLog
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/ChangeLog,v
retrieving revision 1.397
diff -u -p -u -r1.397 ChangeLog
--- lib/ChangeLog	10 Mar 2003 09:46:23 -0000	1.397
+++ lib/ChangeLog	10 Mar 2003 16:06:21 -0000
@@ -1,5 +1,11 @@
 2003-03-10  Angus Leeming  <[EMAIL PROTECTED]>
 
+	* scripts/lyxpreview2bitmap.sh: use variables for the names of
+	'latex', 'dvips', 'gs' and 'pnmcrop' and move their definition to
+	the top of the script.
+
+2003-03-10  Angus Leeming  <[EMAIL PROTECTED]>
+
 	* images/graphics-insert.xpm: rename as
 	dialog-show-new-inset_graphics.xpm.
 
Index: lib/scripts/lyxpreview2bitmap.sh
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/lib/scripts/lyxpreview2bitmap.sh,v
retrieving revision 1.9
diff -u -p -u -r1.9 lyxpreview2bitmap.sh
--- lib/scripts/lyxpreview2bitmap.sh	6 Jan 2003 17:40:46 -0000	1.9
+++ lib/scripts/lyxpreview2bitmap.sh	10 Mar 2003 16:06:24 -0000
@@ -51,6 +51,14 @@
 #        \converter lyxpreview ${FORMAT} "lyxpreview2bitmap.sh" ""
 # where ${FORMAT} is either ppm or png.
 
+# These four programs are used by the script.
+# Adjust their names to suit your setup.
+LATEX=latex
+DVIPS=dvips
+GS=gs
+PNMCROP=pnmcrop
+readonly LATEX DVIPS GS PNMCROP
+
 # Three helper functions.
 FIND_IT ()
 {
@@ -65,7 +73,7 @@ FIND_IT ()
 BAIL_OUT ()
 {
 	# Remove everything except the original .tex file.
-	FILES=`ls ${BASE}* | sed -e "/${BASE}.tex/d"`
+	FILES=`ls ${BASE}* | sed -e "/${BASE}\.tex/d"`
 	rm -f ${FILES} texput.log
 	echo "Leaving ${BASE}.tex in ${DIR}"
 	exit 1
@@ -73,8 +81,10 @@ BAIL_OUT ()
 
 REQUIRED_VERSION ()
 {
+	test $# -eq 1 || exit 1
+
 	echo "We require preview.sty version 0.73 or newer. You're using"
-	grep 'Package: preview' ${LOGFILE}
+	grep 'Package: preview' $1
 }
 
 # Preliminary check.
@@ -101,9 +111,9 @@ else
 fi
 
 # We use latex, dvips and gs, so check that they're all there.
-FIND_IT latex
-FIND_IT dvips
-FIND_IT gs
+FIND_IT ${LATEX}
+FIND_IT ${DVIPS}
+FIND_IT ${GS}
 
 # Initialise some variables.
 TEXFILE=${BASE}.tex
@@ -111,12 +121,13 @@ LOGFILE=${BASE}.log
 DVIFILE=${BASE}.dvi
 PSFILE=${BASE}.ps
 METRICSFILE=${BASE}.metrics
+readonly TEXFILE LOGFILE DVIFILE PSFILE METRICSFILE
 
 # LaTeX -> DVI.
 cd ${DIR}
-latex ${TEXFILE} ||
+${LATEX} ${TEXFILE} ||
 {
-	echo "Failed: latex ${TEXFILE}"
+	echo "Failed: ${LATEX} ${TEXFILE}"
 	BAIL_OUT
 }
 
@@ -127,7 +138,7 @@ latex ${TEXFILE} ||
 grep -E 'Preview: [ST]' ${LOGFILE} > ${METRICSFILE} ||
 {
 	echo "Failed: grep -E 'Preview: [ST]' ${LOGFILE}"
-	REQUIRED_VERSION
+	REQUIRED_VERSION ${LOGFILE}
 	BAIL_OUT
 }
 
@@ -138,7 +149,7 @@ grep -E 'Preview: [ST]' ${LOGFILE} > ${M
 LINE=`grep 'Preview: Fontsize' ${LOGFILE}` ||
 {
 	echo "Failed: grep 'Preview: Fontsize' ${LOGFILE}"
-	REQUIRED_VERSION
+	REQUIRED_VERSION ${LOGFILE}
 	BAIL_OUT
 }
 # The sed script strips out everything that won't form a decimal number
@@ -166,9 +177,9 @@ RESOLUTION=`echo "scale=2; \
 	| bc`
 
 # DVI -> PostScript
-dvips -o ${PSFILE} ${DVIFILE} ||
+${DVIPS} -o ${PSFILE} ${DVIFILE} ||
 {
-	echo "Failed: dvips -o ${PSFILE} ${DVIFILE}"
+	echo "Failed: ${DVIPS} -o ${PSFILE} ${DVIFILE}"
 	BAIL_OUT
 }
 
@@ -185,12 +196,12 @@ if [ ${INT_RESOLUTION} -gt 150 ]; then
 	ALPHA=2
 fi
 
-gs -q -dNOPAUSE -dBATCH -dSAFER \
+${GS} -q -dNOPAUSE -dBATCH -dSAFER \
 	-sDEVICE=${GSDEVICE} -sOutputFile=${BASE}%d.${GSSUFFIX} \
 	-dGraphicsAlphaBit=${ALPHA} -dTextAlphaBits=${ALPHA} \
 	-r${RESOLUTION} ${PSFILE} ||
 {
-	echo "Failed: gs ${PSFILE}"
+	echo "Failed: ${GS} ${PSFILE}"
 	BAIL_OUT
 }
 
@@ -203,7 +214,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
-type 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.
@@ -211,8 +222,8 @@ type pnmcrop > /dev/null || CROP=0
 if [ ${CROP} -eq 1 -a "${GSDEVICE}" = "pnmraw" ]; then
 	for FILE in ${BASE}*.${GSSUFFIX}
 	do
-		if pnmcrop -left ${FILE} 2> /dev/null |\
-		   pnmcrop -right  2> /dev/null > ${BASE}.tmp; then
+		if ${PNMCROP} -left ${FILE} 2> /dev/null |\
+		   ${PNMCROP} -right  2> /dev/null > ${BASE}.tmp; then
 			mv ${BASE}.tmp ${FILE}
 		else
 			rm -f ${BASE}.tmp

Reply via email to