2 # usage: retex [--bibtex] CMD INPUTNAME (without .tex)
6 # Add a bibtex option for the streaming notes.
7 # Since the bibtex needs to be part of the fixed-pointing, I unfortunately don't
8 # see a better way to handle it than as part of retex. - Matt 2008-09-02
9 if [ "$1" == --bibtex ]; then
15 echo >&2 'usage: retex [--bibtex] CMD INPUTNAME (without .tex)'
23 # Just Work if passed `foo.tex'.
24 if [ "$in" != "${in%.tex}" ]; then
29 if [ $bibtex ] && [ -r "$in.aux" ]; then
30 echo "[$iter] Running bibtex..."
32 # Work around \href commands getting line-broken in places that
33 # break things ~ Matt 2010-12-17
34 sed -i -e '/%$/{N; s/%\n//}; /\\href$/{N; s/\n/ /}' "$in.bbl"
36 echo "[$iter] Running $2..."
37 "$cmd" -file-line-error -halt-on-error "$in"
41 echo "Comparing files..."
43 # ignore pdfs because they have a nonreproducible "ID" at the end
44 # and logs because they have a less-reproducible time; neither are read
45 if [ "$f" == "${f#$in.retex-keep.}" ] && [ "$f" == "${f%.pdf}" ] && [ "$f" == "${f%.log}" ]; then
47 cmp "$in.retex-keep.$suf" "$in.$suf" || return $?
50 echo "Reached a fixed point."
54 echo "Keeping files..."
56 if [ "$f" == "${f#$in.retex-keep.}" ]; then
58 cp "$in.$suf" "$in.retex-keep.$suf"
64 echo "Cleaning up kept files..."
65 rm -f "$in.retex-keep."*
74 if [ $iter -ge $limit ]; then
75 echo "Did not reach a fixed point in $limit tries."