]> git.lyx.org Git - features.git/commitdiff
Don't use "if [ $? -ne 0 ]"; personally, I blame JMarc ;-)
authorAngus Leeming <leeming@lyx.org>
Thu, 21 Nov 2002 17:09:22 +0000 (17:09 +0000)
committerAngus Leeming <leeming@lyx.org>
Thu, 21 Nov 2002 17:09:22 +0000 (17:09 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@5693 a592a061-630c-0410-9148-cb99ea01b6c8

lib/ChangeLog
lib/scripts/lyxpreview2bitmap.sh
src/frontends/xforms/ChangeLog
src/frontends/xforms/FormSpellchecker.C
src/frontends/xforms/forms/fdfix.sh
src/graphics/ChangeLog
src/graphics/GraphicsConverter.C

index 60684ab49578349c4290c5f4069667e4d18ca4f9..a85bf2b27b50fbe57c4a3779db64251efd266871 100644 (file)
@@ -1,3 +1,7 @@
+2002-11-21  Angus Leeming  <leeming@lyx.org>
+
+       * scripts/lyxpreview2bitmap.sh: Don't use "if [ $? -ne 0 ]; then..."
+
 2002-11-20  John Levon  <levon@movementarian.org>
 
        * images/math/: implement missing math icons
index 119f1df88a115325ad705014ba3f35527a87ca01..6d9cbde07a0fb5be3a654b97ab1c8e34c1425365 100644 (file)
 
 # Three helper functions.
 FIND_IT () {
-       which ${EXECUTABLE} > /dev/null
-       if [ $? -ne 0 ]; then
+       which ${EXECUTABLE} > /dev/null ||
+       {
                echo "Unable to find \"${EXECUTABLE}\". Please install."
                exit 1
-       fi
+       }
 }
 
 BAIL_OUT () {
@@ -110,33 +110,33 @@ METRICSFILE=${BASE}.metrics
 
 # LaTeX -> DVI.
 cd ${DIR}
-latex ${TEXFILE}
-if [ $? -ne 0 ]; then
+latex ${TEXFILE} ||
+{
        echo "Failed: latex ${TEXFILE}"
        BAIL_OUT
-fi
+}
 
 # Parse ${LOGFILE} to obtain bounding box info to output to
 # ${METRICSFILE}.
 # This extracts lines starting "Preview: Tightpage" and
 # "Preview: Snippet".
-grep -E 'Preview: [ST]' ${LOGFILE} > ${METRICSFILE}
-if [ $? -ne 0 ]; then
+grep -E 'Preview: [ST]' ${LOGFILE} > ${METRICSFILE} ||
+{
        echo "Failed: grep -E 'Preview: [ST]' ${LOGFILE}"
        REQUIRED_VERSION
        BAIL_OUT
-fi
+}
 
 # Parse ${LOGFILE} to obtain ${RESOLUTION} for the gs process to follow.
 # 1. Extract font size from a line like "Preview: Fontsize 20.74pt"
 # Use grep for speed and because it gives an error if the line is
 # not found.
-LINE=`grep 'Preview: Fontsize' ${LOGFILE}`
-if [ $? -ne 0 ]; then
+LINE=`grep 'Preview: Fontsize' ${LOGFILE}` ||
+{
        echo "Failed: grep 'Preview: Fontsize' ${LOGFILE}"
        REQUIRED_VERSION
        BAIL_OUT
-fi
+}
 # The sed script strips out everything that won't form a decimal number
 # from the line. It bails out after the first match has been made in
 # case there are multiple lines "Preview: Fontsize". (There shouldn't
@@ -148,11 +148,11 @@ LATEXFONT=`echo "${LINE}" | sed 's/[^0-9\.]//g; 1q'`
 # "Preview: Magnification 2074"
 # If no such line found, default to MAGNIFICATION=1000.
 LINE=`grep 'Preview: Magnification' ${LOGFILE}`
-if [ $? -ne 0 ]; then
-       MAGNIFICATION=1000
-else
+if LINE=`grep 'Preview: Magnification' ${LOGFILE}`; then
        # Strip out everything that won't form an /integer/.
        MAGNIFICATION=`echo "${LINE}" | sed 's/[^0-9]//g; 1q'`
+else
+       MAGNIFICATION=1000
 fi
 
 # 3. Compute resolution.
@@ -162,11 +162,11 @@ RESOLUTION=`echo "scale=2; \
        | bc`
 
 # DVI -> PostScript
-dvips -o ${PSFILE} ${DVIFILE}
-if [ $? -ne 0 ]; then
+dvips -o ${PSFILE} ${DVIFILE} ||
+{
        echo "Failed: dvips -o ${PSFILE} ${DVIFILE}"
        BAIL_OUT
-fi
+}
 
 # PostScript -> Bitmap files
 # Older versions of gs have problems with a large degree of
@@ -184,12 +184,11 @@ fi
 gs -q -dNOPAUSE -dBATCH -dSAFER \
        -sDEVICE=${GSDEVICE} -sOutputFile=${BASE}%d.${GSSUFFIX} \
        -dGraphicsAlphaBit=${ALPHA} -dTextAlphaBits=${ALPHA} \
-       -r${RESOLUTION} ${PSFILE}
-
-if [ $? -ne 0 ]; then
+       -r${RESOLUTION} ${PSFILE} ||
+{
        echo "Failed: gs ${PSFILE}"
        BAIL_OUT
-fi
+}
 
 # All has been successful, so remove everything except the bitmap files
 # and the metrics file.
@@ -200,11 +199,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
-if [ $? -ne 0 ]; then
-       CROP=0
-fi
+which pnmcrop > /dev/null || CROP=0
 
 # There's no point cropping the image if using PNG images. If you want to
 # crop, use PPM.
@@ -212,8 +207,8 @@ fi
 if [ ${CROP} -eq 1 -a "${GSDEVICE}" = "pnmraw" ]; then
        for FILE in ${BASE}*.${GSSUFFIX}
        do
-               pnmcrop -left ${FILE} | pnmcrop -right > ${BASE}.tmp
-               if [ $? -eq 0 ]; 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
@@ -221,3 +216,5 @@ if [ ${CROP} -eq 1 -a "${GSDEVICE}" = "pnmraw" ]; then
        done
        rm -f ${BASE}.tmp
 fi
+
+echo "Previews generated!"
index bd5c721bb438a2d1df79eb7b81a91f72df2adccf..ac4a9719d3aad9c753843d8ee92a2b7c5d626517 100644 (file)
@@ -1,5 +1,7 @@
 2002-11-21  Angus Leeming  <leeming@lyx.org>
 
+       * forms/fdfix.sh: Don't use "if [ $? -ne 0 ]; then..."
+
        * FormSpellchecker.C (updateState): new method, replacing Black Magic.
        Should also resolve Darren Freeman's redraw of the status bar problem.
 
index d667b05f150e0c5a939efdd8e02fbc046d1ca70b..7590294d0384ea64dfe818b4314a007aa59fc142 100644 (file)
@@ -109,7 +109,6 @@ void FormSpellchecker::updateState(State state)
 
                double const wordcount = controller().getCount();
 
-               // set slider 'finished' status
                fl_set_slider_bounds(dialog_->slider_progress, 0.0, wordcount);
                fl_set_slider_value(dialog_->slider_progress, wordcount);
                fl_set_object_label(dialog_->slider_progress, "100 %");
index 93709d96ec657b0de5bc45a1245587500ffe7b2c..1c106032009807854c5b0c1e7c6d8319c7497778 100644 (file)
@@ -36,26 +36,28 @@ EOF
 #===============
 # Initial checks
 if [ ! -f $1 ]; then
-    echo "Input file does not exist. Cannot continue"
-    exit 1
+       echo "Input file does not exist. Cannot continue"
+       exit 1
 fi
 
 DIRNAME=`dirname $1`
 BASENAME=`basename $1 .fd`
 
 if [ $1 = ${BASENAME} ]; then
-    echo "Input file is not a .fd file. Cannot continue"
-    exit 1
+       echo "Input file is not a .fd file. Cannot continue"
+       exit 1
 fi
 
 #===================================
 # Create the initial .c and .h files
 FDESIGN=fdesign
 FDFILE=${BASENAME}.fd
-if (cd ${DIRNAME} && ${FDESIGN} -convert ${FDFILE}); then : ; else
-    echo "\"${FDESIGN} -convert ${FDFILE}\" failed. Please investigate."
-    exit 1
-fi
+
+(cd ${DIRNAME} && ${FDESIGN} -convert ${FDFILE}) ||
+{
+       echo "\"${FDESIGN} -convert ${FDFILE}}\" failed. Please investigate."
+       exit 1
+}
 
 #==================================
 # Modify the .h file for use by LyX
@@ -87,8 +89,8 @@ rm -f ${EXTERN_FUNCS}
 
 # Patch the .h file if a patch exists
 if [ -f "${HPATCH}" ] ; then
-    echo "Patching ${HOUT} with ${HPATCH}"
-    patch -s ${HOUT} < ${HPATCH}
+       echo "Patching ${HOUT} with ${HPATCH}"
+       patch -s ${HOUT} < ${HPATCH}
 fi
 
 # Clean up, to leave the finished .h file. We can be a little tricky here
@@ -99,14 +101,13 @@ fi
 rm -f ${HIN}
 MOVE_H_FILE=1
 if [ -r ${BASENAME}.h ]; then
-    if cmp -s ${HOUT} ${BASENAME}.h; then
-       MOVE_H_FILE=0
-    fi
+       cmp -s ${HOUT} ${BASENAME}.h && MOVE_H_FILE=0
 fi
+
 if [ ${MOVE_H_FILE} -eq 1 ]; then
-    mv ${HOUT} ${BASENAME}.h
+       mv ${HOUT} ${BASENAME}.h
 else
-    rm -f ${HOUT}
+       rm -f ${HOUT}
 fi
 
 #==================================
@@ -124,16 +125,15 @@ echo "#include <config.h>" >> ${COUT}
 echo "#include \"forms_gettext.h\"" >> ${COUT}
 echo "#include \"gettext.h\"" >> ${COUT}
 
-if grep bmtable ${CIN} > /dev/null; then
-    echo "#include \"bmtable.h\"" >> ${COUT}
-fi
+grep bmtable ${CIN} > /dev/null &&
+       echo "#include \"bmtable.h\"" >> ${COUT}
 
 sed -f ${FDFIXC} < ${CIN} >> ${COUT}
 
 # Patch the .C file if a patch exists
 if [ -f "${CPATCH}" ] ; then
-    echo "Patching ${COUT} with ${CPATCH}"
-    patch -s ${COUT} < ${CPATCH}
+       echo "Patching ${COUT} with ${CPATCH}"
+       patch -s ${COUT} < ${CPATCH}
 fi
 
 # Clean up, to leave the finished .C file
index 390680e43d10ffd812ea95bb7720dbbcd6a35a1c..de8aa113d660e346b1cf4749edb9e679c8bff049 100644 (file)
@@ -1,3 +1,8 @@
+2002-11-21  Angus Leeming  <leeming@lyx.org>
+
+       * GraphicsConverter.C (build_script, move_file):
+       Don't use "if [ $? -ne 0 ]; then..."
+
 2002-11-04  Lars Gullik Bjønnes  <larsbj@gullik.net>
 
        * PreviewLoader.C (IncrementedFileName): STRCONV
index c8fda70f563892b7a0ebb7a003881ecd26b5d073..d03270b7d2a1fbd6757c6884683ae1c0ea684ca0 100644 (file)
@@ -242,14 +242,14 @@ string const move_file(string const & from_file, string const & to_file)
        ostringstream command;
        command << "fromfile=" << from_file << "\n"
                << "tofile="   << to_file << "\n\n"
-               << "'mv' -f ${fromfile} ${tofile}\n"
-               << "if [ $? -ne 0 ]; then\n"
-               << "\t'cp' -f ${fromfile} ${tofile}\n"
-               << "\tif [ $? -ne 0 ]; then\n"
+               << "'mv' -f ${fromfile} ${tofile} ||\n"
+               << "{\n"
+               << "\t'cp' -f ${fromfile} ${tofile} ||\n"
+               << "\t{\n"
                << "\t\texit 1\n"
-               << "\tfi\n"
+               << "\t}\n"
                << "\t'rm' -f ${fromfile}\n"
-               << "fi\n";
+               << "}\n";
 
        return STRCONV(command.str());
 }
@@ -320,14 +320,14 @@ bool build_script(string const & from_file,
                command = LibScriptSearch(command);
 
                // Store in the shell script
-               script << "\n" << command << "\n\n";
+               script << "\n" << command << " ||\n";
 
                // Test that this was successful. If not, remove
                // ${outfile} and exit the shell script
-               script << "if [ $? -ne 0 ]; then\n"
+               script << "{\n"
                       << "\t'rm' -f ${outfile}\n"
                       << "\texit 1\n"
-                      << "fi\n\n";
+                      << "}\n\n";
 
                // Test that the outfile exists.
                // ImageMagick's convert will often create ${outfile}.0,