#!/bin/bash
#
# Finale \Wurzel erstellen. Dazu .log-Datei und .mps-Dateien analysieren.
# 2007/11/30 by tf@wurzel.org
#
USAGE="\nSyntax: ${0/*\//} [-p] quelle[.tex]\n"
USAGE="$USAGE\n -p\t nach Beendigung auf Tastendruck warten\n";
#
PAUSE="FALSE";
if [ "$1" = "-p" ]; then PAUSE="TRUE"; shift 1; fi
if [ "$1" = "" ]; then
  echo -e "\nFEHLER: Keine Quelldatei angegeben!";
  echo -e $USAGE; exit;
else 
  INPUTFILE="${1%.tex}";
fi;
#
echo "========== PDFLATEX ${INPUTFILE} =========="
echo
pdflatex ${INPUTFILE}.tex
echo 
echo "**************************************************************"
echo "*************************  MELDUNGEN  ************************"
echo "**************************************************************"
echo
echo "========== METAPOST FARBRAUM =========="
echo
export GREP_COLOR='1;36'
grep "rgb\|1 1 1 1 setcmyk" -i --color *.mps
echo
echo "========== FONT WARNUNGEN =========="
echo
export GREP_COLOR='1;35'
cat ${INPUTFILE}.log | grep "font warning\|[.][/][[:print:]]*.tex" -i --color
echo
echo "========== ANDERE WARNUNGEN =========="
echo
export GREP_COLOR='1;31'
cat ${INPUTFILE}.log | grep -iv "font warning" | grep "warning\|[.][/][[:print:]]*.tex" -i --color 
echo
echo "========== OVER/UNDERFULL BOXES =========="
echo
export GREP_COLOR='1;34'
cat ${INPUTFILE}.log | grep  "overfull\|underfull\|[.][/][[:print:]]*.tex" -i --color
echo
echo "========== \\today &c. =========="
echo
export GREP_COLOR='1;33'
cat ${INPUTFILE}.tex | sed s/%.*/""/ | grep  "\\\\today\|\\\\day\|\\\\month\|\\\\year" -i --color
echo
if [ "$PAUSE" = "TRUE" ]; then
  echo "========== FERTIG. Bitte Taste druecken... =========="
  read
fi;
