Add OS X adjustments and fix grep searches

Under OS X, the script uses now GNU grep ('ggrep') instead of BSD grep
and the 'open' command is now used to open resulting PDF documents
after compilations.

Compilation errors search has been improved.

Some output messages have been modified.

Since this version, the script is tested also under OS X, hence new
minor version number.
This commit is contained in:
mkalewski 2014-07-24 16:21:35 +02:00
parent 0760f71ed3
commit 74d9bfacd3
3 changed files with 128 additions and 96 deletions

View File

@ -1,4 +1,6 @@
Copyright (c) 2007-2012 Michal Kalewski <mkalewski at cs.put.poznan.pl> The MIT License (MIT)
Copyright (c) 2007-2014 Michal Kalewski <mkalewski at cs.put.poznan.pl>
Permission is hereby granted, free of charge, to any person obtaining a copy of Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in this software and associated documentation files (the "Software"), to deal in

View File

@ -3,14 +3,11 @@ pdflatex.sh
=========== ===========
:Author: Michał Kalewski :Author: Michał Kalewski
:Source: https://github.com/mkalewski/pdflatex.sh :Version: 3.2.0
:Version: 3.1.4 :License: MIT License
:Bug reports: https://github.com/mkalewski/pdflatex.sh/issues
Name
====
`pdflatex.sh` -- compile (La)TeX files and more.
Synopsis Synopsis
======== ========
:: ::
@ -24,37 +21,44 @@ Synopsis
Description Description
=========== ===========
A bash script to simplify (La)TeX files compilation with BibTeX, indices and A bash script to simplify (La)TeX files compilation with BibTeX, indices,
PSTricks if necessary. In the simplest case, the script is run as follows:: PSTricks, and more. In the simplest case, the script is run as follows::
$ pdflatex.sh file.tex $ pdflatex.sh file.tex
It can be also use to convert images to include them in (La)TeX files and to Then, the ``file.tex`` file will be compiled twice with the use of the
manipulate output PDF documents. The script also lets you check syntactic and ``pdflatex`` command and all auxiliary files will be removed after the
semantic correctness of (La)TeX source files, e.g. with the use of *ChkTeX*, compilation.
and create handouts from beamer slides. (See all options_.)
It is possible to customize programs (like PDF viewer) and its settings that The ``pdflatex.sh`` script can also be used to convert images to the PDF format
are used by the script in **Programs** and **Options** sections in the source and to manipulate output PDF documents. The script also lets you check
code. syntactic and semantic correctness of (La)TeX source files, e.g. with the use
of *ChkTeX*, and create handouts from beamer slides (for more information see
options_ and examples_).
It is possible to customize the programs (like PDF viewer), which are used by
the script in the **Programs** and **Options** sections in the source code.
.. note:: .. note::
If the script is run as `pdflatex.sh` then `pdflatex` command is used If the script is run as `pdflatex.sh`, then the `pdflatex` command is used
(producing PDF output file), otherwise `latex` command is used (producing DVI (producing PDF output files), otherwise the `latex` command is used
output file). Thus if necessary, the `latex.sh` symbolic link can be created (producing DVI output files). Thus, if necessary, a symbolic link, e.g.
to use the script easily. `latex.sh`, may be created to use the script easily.
**Arch Linux** users can use tdi's `AUR package **Arch Linux** users may use `tdi <https://github.com/tdi>`_'s `AUR package
<http://aur.archlinux.org/packages.php?ID=55739>`_ to obtain the script. <http://aur.archlinux.org/packages.php?ID=55739>`_ to obtain the script.
**OS X** users need to install GNU grep, i.e., ``ggrep``, which is required for
the script to work correctly.
Options Options
======= =======
``-2x1 FILE`` ``-2x1 FILE``
Put two pages of the PDF FILE on a single A4 sheet (the output will be in Put two pages of the PDF FILE on a single A4 sheet (the output will be in a
FILE-nup.pdf file). FILE-nup.pdf file).
``-2x2 FILE`` ``-2x2 FILE``
Put four pages of the PDF FILE on a single A4 sheet (the output will be in Put four pages of the PDF FILE on a single A4 sheet (the output will be in a
FILE-nup.pdf file). FILE-nup.pdf file).
``+3`` ``+3``
Run ``latex``/``pdflatex`` thrice (default is twice). Run ``latex``/``pdflatex`` thrice (default is twice).
@ -73,51 +77,56 @@ Options
``-rd DIR`` ``-rd DIR``
Convert DIA images in directory DIR recursively. Convert DIA images in directory DIR recursively.
``-h`` ``-h``
Print help message and exit. Print the help message and exit.
``+h`` ``+h``
Make handout from beamer presentation, i.e. without overlays, pauses, and Make a handout from a beamer presentation -- without overlays, pauses, and
other Beamer effects (the output will be in FILE-handout.pdf file). other Beamer effects (the output will be in a FILE-handout.pdf file).
``-i FILE`` ``-i FILE``
Make ONLY index (MakeIndex). Make ONLY index (MakeIndex).
``+i`` ``+i``
Make ALSO index (MakeIndex). Make ALSO index (MakeIndex).
``-k FILE`` ``-k FILE``
Run ``chktex`` command (if available). Run the ``chktex`` command (if available).
``-kk FILE`` ``-kk FILE``
The same as '``-k``' but only errors are shown. The same as '``-k``' but only errors are shown.
``-l [WIDTH] FILE`` ``-l [WIDTH] FILE``
Check maximum line width (by default ``WIDTH=80``). Check if the length of each line in FILE does not exceed the given width (by
default ``WIDTH=80``)
``-n FILE`` ``-n FILE``
Check non-breaking spaces. Check non-breaking spaces.
``-s FILE`` ``-s FILE``
Check sentence separators. Check sentence separators.
``+s`` ``+s``
Print a summary of problems (errors and warnings) after compilation. Print a summary of problems (errors and warnings) after the compilation.
``-ss FILE`` ``-ss FILE``
STRICTLY check sentence separators. STRICTLY check sentence separators.
``-sc [LANG] FILE`` ``-sc [LANG] FILE``
Run interactive spell checker (by default ``LANG="en_GB"`` and UTF-8 encoding Start the interactive ``aspell`` spell checker (by default ``LANG="en_GB"``
is used). and UTF-8 encoding is used).
``+sync`` ``+sync``
Enable synchronization between source file and the resulting DVI or PDF file. Enable the synchronization between the source file and the resulting DVI or
PDF file. (About the option see also `"Direct and reverse synchronization
with SyncTEX" <http://www.tug.org/TUGboat/tb29-3/tb93laurens.pdf>`_.)
``+o`` ``+o``
Open PDF (or DVI) file after compilation. Open the resulting PDF (or DVI) file after the compilation.
``+p`` ``+p``
Use ``ps4pdf`` instead of ``pdflatex``/``latex`` (PSTricks). Use ``ps4pdf`` instead of ``pdflatex``/``latex`` (PSTricks).
``-V`` ``-V``
Print script version. Print the script version.
(About `+sync` option see also `"Direct and reverse synchronization with
SyncTEX" <http://www.tug.org/TUGboat/tb29-3/tb93laurens.pdf>`_.)
Examples Examples
======== ========
* Compile ``file.tex`` source file:: * Compile a (La)TeX source file named ``file.tex`` (this example shows also the
script's output messages)::
$ pdflatex.sh file.tex $ pdflatex.sh file.tex
PDFLATEX... [done]
PDFLATEX... [done]
CLEANUP..................... [done]
* Compile ``file.tex`` with BibTeX and MakeIndex, and open PDF browser with the * Compile ``file.tex`` with BibTeX and MakeIndex, and open a PDF browser with
output file after compilation:: the output file after the compilation::
$ pdflatex.sh +b +i +o file.tex $ pdflatex.sh +b +i +o file.tex
@ -125,13 +134,13 @@ Examples
$ pdflatex.sh +p file.tex $ pdflatex.sh +p file.tex
* Compile ``beamer-presentation.tex`` beamer presentation file and make a * Compile a beamer presentation file named ``beamer-presentation.tex`` and make
handout of it (the output should be in ``beamer-presentation-handout.pdf`` a handout of it (the output should be in a file named
file):: ``beamer-presentation-handout.pdf``)::
$ pdflatex.sh +h beamer-presentation.tex $ pdflatex.sh +h beamer-presentation.tex
* Run ``chktex`` command but show only errors:: * Run the ``chktex`` command, but show errors only::
$ pdflatex.sh -kk file.tex $ pdflatex.sh -kk file.tex
@ -140,19 +149,15 @@ Examples
$ pdflatex.sh -gs img/ $ pdflatex.sh -gs img/
* Put two pages of the ``file.pdf`` on a single A4 sheet (the output should be * Put two pages of a file named ``file.pdf`` on a single A4 sheet (the output
in ``FILE-nup.pdf`` file):: should be in a file named ``file-nup.pdf``)::
$ pdflatex.sh -2x1 file.pdf $ pdflatex.sh -2x1 file.pdf
Reporting Bugs
==============
Bug reports: https://github.com/mkalewski/pdflatex.sh/issues
Copyright Copyright
========= =========
| (c) 2007-2012 Michal Kalewski <mkalewski at cs.put.poznan.pl> | (c) 2007-2014 Michal Kalewski <mkalewski at cs.put.poznan.pl>
| |
| This program comes with ABSOLUTELY NO WARRANTY. | This program comes with ABSOLUTELY NO WARRANTY.
| THIS IS FREE SOFTWARE, AND YOU ARE WELCOME TO REDISTRIBUTE IT UNDER THE TERMS | THIS IS FREE SOFTWARE, AND YOU ARE WELCOME TO REDISTRIBUTE IT UNDER THE TERMS

View File

@ -1,7 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# UTF-8 # UTF-8
# (c) 2007-2012 Michal Kalewski <mkalewski at cs.put.poznan.pl> # (c) 2007-2014 Michal Kalewski <mkalewski at cs.put.poznan.pl>
# #
# This program comes with ABSOLUTELY NO WARRANTY. # This program comes with ABSOLUTELY NO WARRANTY.
# THIS IS FREE SOFTWARE, AND YOU ARE WELCOME TO REDISTRIBUTE IT UNDER THE # THIS IS FREE SOFTWARE, AND YOU ARE WELCOME TO REDISTRIBUTE IT UNDER THE
@ -34,7 +34,7 @@
# VERSION # VERSION
# ======= # =======
VERSION=3.1.4 VERSION=3.2.0
# PROGRAMS # PROGRAMS
@ -102,6 +102,17 @@ txtcyn=$(tput setaf 6) # cyan
txtwht=$(tput setaf 7) # white txtwht=$(tput setaf 7) # white
txtrst=$(tput sgr0) # text reset txtrst=$(tput sgr0) # text reset
# OS X adjustments:
GREP="grep"
if [[ $OSTYPE == *darwin* ]] ; then
# PDF viewer
if [[ $PDF_VIEWER_PROGRAM == "evince" ]] ; then
PDF_VIEWER_PROGRAM="open"
fi
# Use GNU grep (i.e., ggrep) instead of BSD grep
GREP="ggrep"
fi
# FUNCTIONS # FUNCTIONS
# ========= # =========
@ -110,16 +121,16 @@ txtrst=$(tput sgr0) # text reset
function print_help() { function print_help() {
cat <<EOF cat <<EOF
${txtbld}PDFLATEX.SH${txtrst} $VERSION (c) 2007-2012\ ${txtbld}PDFLATEX.SH${txtrst} $VERSION (c) 2007-2014\
${txtbld}Michal Kalewski${txtrst} <mkalewski at cs.put.poznan.pl> ${txtbld}Michal Kalewski${txtrst} <mkalewski at cs.put.poznan.pl>
${txtund}A BASH SCRIPT TO SIMPLIFY TeX/LaTeX FILES COMPILATION AND\ ${txtund}A BASH SCRIPT TO SIMPLIFY TeX/LaTeX FILES COMPILATION AND\
MORE${txtrst} MORE${txtrst}
NOTE: If the script is run as 'pdflatex.sh' then 'pdflatex' command is used NOTE: If the script is run as 'pdflatex.sh', then the 'pdflatex' command is
(producing PDF output file), otherwise 'latex' command is used (producing DVI used (producing PDF output files), otherwise the 'latex' command is used
output file). Thus if necessary, the 'latex.sh' symbolic link can be created (producing DVI output files). Thus, if necessary, a symbolic link, e.g.
to use the script easily. 'latex.sh', may be created to use the script easily.
${txtbld}For more information, please visit${txtrst}: \ ${txtbld}For more information, please visit${txtrst}: \
<https://github.com/mkalewski/pdflatex.sh> <https://github.com/mkalewski/pdflatex.sh>
@ -143,9 +154,9 @@ ${txtbld}Usage${txtrst}:
${txtbld}Options${txtrst}: ${txtbld}Options${txtrst}:
-2x1 FILE put two pages of the PDF FILE on a single A4 sheet -2x1 FILE put two pages of the PDF FILE on a single A4 sheet
(the output will be in FILE-nup.pdf file) (the output will be in a FILE-nup.pdf file)
-2x2 FILE put four pages of the PDF FILE on a single A4 sheet -2x2 FILE put four pages of the PDF FILE on a single A4 sheet
(the output will be in FILE-nup.pdf file) (the output will be in a FILE-nup.pdf file)
+3 run 'latex'/'pdflatex' thrice (default is twice) +3 run 'latex'/'pdflatex' thrice (default is twice)
-b FILE make ONLY BibTeX -b FILE make ONLY BibTeX
+b make ALSO BibTeX +b make ALSO BibTeX
@ -155,26 +166,28 @@ ${txtbld}Options${txtrst}:
-gd DIR convert DIA images in directory DIR -gd DIR convert DIA images in directory DIR
-rd DIR convert DIA images in directory DIR recursively -rd DIR convert DIA images in directory DIR recursively
-h print (this) help message and exit -h print (this) help message and exit
+h make handout from beamer presentation, i.e. without +h make a handout from a beamer presentation, i.e., without
overlays, pauses, and other Beamer effects (the output overlays, pauses, and other Beamer effects (the output
will be in FILE-handout.pdf file) will be in a FILE-handout.pdf file)
-i FILE make ONLY index (MakeIndex) -i FILE make ONLY index (MakeIndex)
+i make ALSO index (MakeIndex) +i make ALSO index (MakeIndex)
-k FILE run 'chktex' command (if available) -k FILE run the 'chktex' command (if available)
-kk FILE the same as '-k' but only errors are shown -kk FILE the same as '-k' but only errors are shown
-l [WIDTH] FILE check maximum line width (by default WIDTH=80) -l [WIDTH] FILE check if the length of each line in FILE does not exceed
the given width (by default WIDTH=80)
-n FILE check non-breaking spaces -n FILE check non-breaking spaces
-s FILE check sentence separators -s FILE check sentence separators
+s print a summary of problems (errors and warnings) after +s print a summary of problems (errors and warnings) after
compilation the compilation
-ss FILE STRICTLY check sentence separators -ss FILE STRICTLY check sentence separators
-sc [LANG] FILE run interactive spell checker (by default LANG="en_GB" -sc [LANG] FILE start the interactive 'aspell' spell checker (by default
and UTF-8 encoding is used) LANG="en_GB" and UTF-8 encoding is used)
+sync enable synchronization between source file and the +sync enable the synchronization between the source file and
resulting DVI or PDF file the resulting DVI or PDF file
+o open PDF (or DVI) file after compilation +o open the resulting PDF (or DVI) file after the
compilation
+p use 'ps4pdf' instead of 'pdflatex'/'latex' (PSTricks) +p use 'ps4pdf' instead of 'pdflatex'/'latex' (PSTricks)
-V print script version -V print the script version
${txtbld}Examples${txtrst}: ${txtbld}Examples${txtrst}:
pdflatex.sh file.tex pdflatex.sh file.tex
@ -210,7 +223,7 @@ function die() {
mquit 1 mquit 1
} }
# Checks programs in the system # Checks programs availability in the system
function check_programs() { function check_programs() {
for PROGRAMNAME in $1 ; do for PROGRAMNAME in $1 ; do
local FILEPATH=`eval which $PROGRAMNAME 2>&-` local FILEPATH=`eval which $PROGRAMNAME 2>&-`
@ -280,10 +293,10 @@ function pdf_manipulation() {
if [[ -z $1 || -z $2 ]] ; then if [[ -z $1 || -z $2 ]] ; then
die "${txtylw}Too few arguments.${txtrst}" die "${txtylw}Too few arguments.${txtrst}"
fi fi
check_programs "$PDFNUP_PROGRAM" check_programs "$PDFNUP_PROGRAM $GREP"
echo -ne "${txtund}PDFJAM${txtrst}..." echo -ne "${txtund}PDFJAM${txtrst}..."
local ERR=`eval $PDFNUP_PROGRAM --nup $1 $PDFNUP_OPT $2 2>&1` local ERR=`eval $PDFNUP_PROGRAM --nup $1 $PDFNUP_OPT $2 2>&1`
local ERR=`echo $ERR | grep -i error` local ERR=`echo $ERR | $GREP -i error`
if [[ -n $ERR ]] ; then if [[ -n $ERR ]] ; then
echo -e\ echo -e\
"\t\t\t\t${txtred}[done] ${txtbld}(With errors! No output?)${txtrst}" "\t\t\t\t${txtred}[done] ${txtbld}(With errors! No output?)${txtrst}"
@ -309,9 +322,9 @@ function line_width() {
if [[ ! -e $FILENAME ]] ; then if [[ ! -e $FILENAME ]] ; then
die "Source file ${txtylw}$FILENAME${txtrst} missing." die "Source file ${txtylw}$FILENAME${txtrst} missing."
fi fi
while read LINE ; do while read -r LINE ; do
LINE_NUMBER=$(($LINE_NUMBER+1)) LINE_NUMBER=$(($LINE_NUMBER+1))
CHARS=`echo $LINE | wc -m` CHARS=`echo -n "$LINE" | wc -m | tr -d ' '`
if [[ $CHARS -gt $WIDTH ]] ; then if [[ $CHARS -gt $WIDTH ]] ; then
echo -e "${txtbld}$LINE_NUMBER${txtrst}:\t$CHARS" echo -e "${txtbld}$LINE_NUMBER${txtrst}:\t$CHARS"
fi fi
@ -328,10 +341,12 @@ function hardspaces() {
if [[ ! -e $FILE.tex ]] ; then if [[ ! -e $FILE.tex ]] ; then
die "Source file ${txtylw}$FILE.tex${txtrst} missing." die "Source file ${txtylw}$FILE.tex${txtrst} missing."
fi fi
grep -n\ check_programs "$GREP"
"\( [^ ] \)\|\( [^ ]$\)\|\(^[^ ] \)\|\( \$.\$ \)\|\( \$.\$$\)\|\(^\$.\$ \)"\ local EXP="\( [^ ] \)\|\( [^ ]$\)\|\(^[^ ] \)\|\( \$.\$ \)\|\( \$.\$$\)\|\(^\$.\$ \)"
"$FILE.tex"\ $GREP -n "$EXP" "$FILE.tex"\
| sort | uniq | sort -n | sed "s/:/\t/" | grep -P -v "^[0-9]+\t%" | sort | uniq | sort -n | awk -F: -v a=${txtbld} -v b=${txtrst}\
'{printf "%s%s%s%s\t%s\n", a, $1, b, ":", $2}'\
| $GREP -P -v "^[0-9]+\t%"
} }
# Checks sentences and periods # Checks sentences and periods
@ -343,14 +358,15 @@ function sentences() {
if [[ ! -e $FILE.tex ]] ; then if [[ ! -e $FILE.tex ]] ; then
die "Source file ${txtylw}$FILE.tex${txtrst} missing." die "Source file ${txtylw}$FILE.tex${txtrst} missing."
fi fi
check_programs "$GREP"
local EXP="\(^\.\)\|\([ ]\.[ ]\)\|\([ ]\.\)\|\(\.[ ][^ ]\)" local EXP="\(^\.\)\|\([ ]\.[ ]\)\|\([ ]\.\)\|\(\.[ ][^ ]\)"
if [[ $1 == "strict" ]] ; then if [[ $1 == "strict" ]] ; then
local EXP=$EXP"\|\([^\.][ ]+[[:upper:]]\)\|\(\.[^ \\;:]\)" local EXP=$EXP"\|\([^\.][ ]+[[:upper:]]\)\|\(\.[^ \\;:]\)"
fi fi
grep -n "$EXP"\ $GREP -n "$EXP" "$FILE.tex"\
"$FILE.tex"\ | sort | uniq | sort -n | awk -F: -v a=${txtbld} -v b=${txtrst}\
| sort | uniq | sort -n | sed "s/:/\t/" | grep -P -v "^[0-9]+\t%"\ '{printf "%s%s%s%s\t%s\n", a, $1, b, ":", $2}'\
| grep "\." --color=auto | $GREP -P -v "^[0-9]+\t%" | $GREP "\." --color=auto
} }
# Runs spell checker (aspell) # Runs spell checker (aspell)
@ -363,7 +379,8 @@ function spell_checker() {
die "Source file ${txtylw}$FILENAME.tex${txtrst} missing." die "Source file ${txtylw}$FILENAME.tex${txtrst} missing."
fi fi
$DETEX_PROGRAM "$FILENAME.tex" > "$FILENAME-tmp.txt" || die $DETEX_PROGRAM "$FILENAME.tex" > "$FILENAME-tmp.txt" || die
$ASPELL_PROGRAM $ASPELLOPT -c "$FILENAME-tmp.txt" 2>&- || die $ASPELL_PROGRAM $ASPELLOPT -c "$FILENAME-tmp.txt" 2>&- ||\
{ rm "$FILENAME-tmp.txt" ; die ; }
rm "$FILENAME-tmp.txt" || die rm "$FILENAME-tmp.txt" || die
if [[ -e $FILENAME-tmp.txt.new ]] ; then if [[ -e $FILENAME-tmp.txt.new ]] ; then
rm "$FILENAME-tmp.txt.new" || die rm "$FILENAME-tmp.txt.new" || die
@ -377,6 +394,7 @@ function spell_checker() {
# Runs (pdf)latex # Runs (pdf)latex
function run_pdflatex() { function run_pdflatex() {
check_programs "$GREP"
echo -ne "$TEXT..." echo -ne "$TEXT..."
if [[ -n $APPENDSYNCTEX ]] ; then if [[ -n $APPENDSYNCTEX ]] ; then
$LATEX_PROGRAM $PDFLATEX_SYNCTEX_OPT $LATEX_BATCHMODE_OPT \ $LATEX_PROGRAM $PDFLATEX_SYNCTEX_OPT $LATEX_BATCHMODE_OPT \
@ -384,7 +402,10 @@ function run_pdflatex() {
else else
$LATEX_PROGRAM $LATEX_BATCHMODE_OPT "$FILENAME" >&- 2>&- $LATEX_PROGRAM $LATEX_BATCHMODE_OPT "$FILENAME" >&- 2>&-
fi fi
local ERR=`grep -i error "$FILENAME".log | grep -v -i infwarerr` local ERR=`$GREP -i error "$FILENAME".log | $GREP -v -i infwarerr`
if [[ -z $ERR ]] ; then
local ERR=`$GREP -i "^\!" "$FILENAME".log`
fi
if [[ -n $ERR ]] ; then if [[ -n $ERR ]] ; then
echo -ne "\t\t\t\t${txtred}[done]" echo -ne "\t\t\t\t${txtred}[done]"
if [[ -n $USEPS4PDFARG ]] ; then if [[ -n $USEPS4PDFARG ]] ; then
@ -501,11 +522,11 @@ for X in `seq 1 $THRICE` ; do run_pdflatex ; done
# Bibtex # Bibtex
if [[ -n $MAKEBIBTEXARG || -n $MAKEONLYBIBTEXARG ]] ; then if [[ -n $MAKEBIBTEXARG || -n $MAKEONLYBIBTEXARG ]] ; then
check_programs "$BIBTEX_PROGRAM" check_programs "$BIBTEX_PROGRAM $GREP"
echo -ne "${txtund}BIBTEX${txtrst}..." echo -ne "${txtund}BIBTEX${txtrst}..."
rm -f "$FILENAME-bibtex.log" >&- 2>&- # old BibTeX log file rm -f "$FILENAME-bibtex.log" >&- 2>&- # old BibTeX log file
BIBOUT=`$BIBTEX_PROGRAM "$FILENAME" 2>&-` BIBOUT=`$BIBTEX_PROGRAM "$FILENAME" 2>&-`
BIBERR=`echo $BIBOUT | egrep -i "error|warning"` BIBERR=`echo $BIBOUT | $GREP -E -i "error|warning"`
if [[ -n $BIBERR ]] ; then if [[ -n $BIBERR ]] ; then
echo "$BIBOUT" > $FILENAME-bibtex.log echo "$BIBOUT" > $FILENAME-bibtex.log
echo -ne "\t\t\t\t${txtred}[done]" echo -ne "\t\t\t\t${txtred}[done]"
@ -552,10 +573,11 @@ for X in `seq 1 $THRICE` ; do
if [[ ! -e $FILENAME.tex ]] ; then if [[ ! -e $FILENAME.tex ]] ; then
die "Source file ${txtylw}$FILENAME${txtrst} missing." die "Source file ${txtylw}$FILENAME${txtrst} missing."
fi fi
check_programs "$GREP"
echo -ne "${txtund}PS4PDF${txtrst}...\t\t\t\t" echo -ne "${txtund}PS4PDF${txtrst}...\t\t\t\t"
$PS4PDF_PROGRAM "$FILENAME" >&- 2>&- $PS4PDF_PROGRAM "$FILENAME" >&- 2>&-
ERR=\ ERR=\
`egrep -i "error|emergency stop" "$FILENAME".log | grep -v -i infwarerr` `$GREP -E -i "error|emergency stop" "$FILENAME".log | $GREP -v -i infwarerr`
if [[ -n $ERR ]] ; then if [[ -n $ERR ]] ; then
echo -ne "${txtred}[done]" echo -ne "${txtred}[done]"
echo " ${txtbld}(With errors! See $FILENAME.log file.)${txtrst}" echo " ${txtbld}(With errors! See $FILENAME.log file.)${txtrst}"
@ -577,10 +599,11 @@ done
# Problems summary (part 1 of 2) # Problems summary (part 1 of 2)
if [[ -n $SHOWSUMMARY ]] ; then if [[ -n $SHOWSUMMARY ]] ; then
ERRORSNUM=`grep -c -i "^\!" "$FILENAME".log` check_programs "$GREP"
ERRORS=`grep -A2 -i "^\!" "$FILENAME".log` ERRORSNUM=`$GREP -c -i "^\!" "$FILENAME".log`
WARNINGS=`grep -i warning "$FILENAME".log | grep -v -i infwarerr` ERRORS=`$GREP -A2 -i "^\!" "$FILENAME".log`
WARNINGSNUM=`echo "$WARNINGS" | grep -c -i warning` WARNINGS=`$GREP -A2 -i warning "$FILENAME".log | $GREP -v -i infwarerr`
WARNINGSNUM=`echo "$WARNINGS" | $GREP -c -i warning`
fi fi
# Cleanup # Cleanup
@ -612,13 +635,15 @@ if [[ -n $SHOWSUMMARY && ( $ERRORSNUM > 0 || $WARNINGSNUM > 0 ) ]] ; then
echo \ echo \
"${txtund}${txtbld}SUMMARY: ${txtrst}" "${txtund}${txtbld}SUMMARY: ${txtrst}"
if [[ $ERRORSNUM > 0 ]] ; then if [[ $ERRORSNUM > 0 ]] ; then
echo -e "${txtcyn}${txtbld}Errors ($ERRORSNUM):${txtrst}" echo -e "${txtblu}${txtbld}Errors ($ERRORSNUM):${txtrst}"
echo "$ERRORS" | grep -A2 -i "^\!" --color=auto echo "$ERRORS" | $GREP -E -v "^[[:space:]]*$" |\
$GREP -A2 -i "^\!" --color=auto
echo "______________________________________________" echo "______________________________________________"
fi fi
if [[ $WARNINGSNUM > 0 ]] ; then if [[ $WARNINGSNUM > 0 ]] ; then
echo -e "${txtblu}${txtbld}Warnings ($WARNINGSNUM):${txtrst}" echo -e "${txtcyn}${txtbld}Warnings ($WARNINGSNUM):${txtrst}"
echo "$WARNINGS" | grep -i "warning" --color=auto echo "$WARNINGS" | $GREP -E -v "^[[:space:]]*$" |\
$GREP -A2 -i "warning" --color=auto
fi fi
fi fi