#!/bin/sh # Runs LaTeX and converts its messages into GNU standard message format # # Copyright (C) 1999-2008 Frank Heckenbach # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, version 2. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License # for more details. # # You should have received a copy of the GNU General Public License # along with this program; see the file COPYING. If not, write to # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, # MA 02111-1307, USA. # This script requires bash. Since bash cannot be assumed to be in # /bin, /usr/bin or any other certain place, we cannot use it in the # first line. So we use /bin/sh, which can be assumed to exist. Then # we check if it's actually bash, and if not, try to re-run the # script with bash. if [ x"$BASH" = x ]; then if [ x"$RERUN_BASH_TRIED" != x ]; then echo "`basename $0`: cannot run, \`bash' is either not bash or a very old version" >&2 exit 1 else RERUN_BASH_TRIED=1; export RERUN_BASH_TRIED exec bash $0 "$@" echo "`basename $0`: cannot run bash" >&2 exit 1 fi fi RERUN_BASH_TRIED="" LATEXPREFIX=""; EXT=".dvi" if [ x"$1" = x"-p" ]; then LATEXPREFIX="pdf"; EXT=".pdf"; shift; fi if [ $# -ne 1 ]; then { echo "Usage: `basename $0` [-p] filename"; echo "Options:"; echo " -p: use pdflatex instead of latex"; } >&2; exit 1; fi AWK=gawk; "$AWK" --version > /dev/null 2>&1 || AWK=awk BASENAME="`echo "$1" | sed -e "s,.*/,,;s/\.\(tex\|ltx\)$//"`" rerun=1; while [ $rerun -gt 0 ]; do rm -f "$BASENAME$EXT" "$LATEXPREFIX${LATEX:-latex}" "\nonstopmode \input $1" 2>&1 | "$AWK" ' BEGIN { skip = 0; msg == ""; fc = 0; fn = f[0] = ""; rerun = 0 } { gsub ("\\? *", "") } /[Rr]erun/ { rerun = 1 } /^