#!/bin/sh

echo " --> running cdbtags"
$HOME/local/bin/cdbtags $1
if ! [ $? = 0 ]; then
   echo "cdbtags encountered an error"
   echo "Try running $1.texp through cdbtags at the command line."
   exit 1
fi

echo " --> running cdbpstproc"
$HOME/local/bin/cdbpstproc $1 keep-tags
if ! [ $? = 0 ]; then
   echo "cdbpstproc encountered an error"
   echo "Try running $1.tex through cdbpstproc at the command line."
   exit 1
fi

mv $1.notag $1.tex

echo " --> running latex"
pdflatex -halt-on-error -interaction=batchmode $1 > /dev/null
if ! [ $? = 0 ]; then
   echo "LaTeX encountered an error"
   echo "Try running $1.tex through LaTeX at the command line."
   exit 1
fi

rm -rf $1.log
