X-Git-Url: https://git.sthu.org/?a=blobdiff_plain;f=git%2Fpre-commit-texcheck;h=8d47a5ebe3ef566e066cdded54f4914960618a82;hb=e2db5d1581339bf6f891b81879130d5e1f3298fc;hp=29547feaf9464894aac500d0e39a7a425162218f;hpb=1d876fd2b1d4305789cfa9fb84daf4c3374043c8;p=shutils.git diff --git a/git/pre-commit-texcheck b/git/pre-commit-texcheck index 29547fe..8d47a5e 100755 --- a/git/pre-commit-texcheck +++ b/git/pre-commit-texcheck @@ -2,23 +2,30 @@ set -e -[ "$#" > "0" ] && cd "$1" +[ "$#" -gt "0" ] && cd "$1" tmpdir=$(mktemp -d) cleanup() { - rm -r "$tmpdir" + if [ -n "$tmpdir" ]; then + rm -r "$tmpdir" + fi } for f in $(find -name "*.tex"); do # Only main tex files are interesting grep -q "\documentclass" "$f" || continue - if ! pdflatex -output-directory "$tmpdir" $f < /dev/null > /dev/null; then + pushd . > /dev/null + cd $(dirname $f) + + if ! pdflatex -output-directory "$tmpdir" $(basename $f) < /dev/null > /dev/null; then + popd echo >&2 "pdflatex failed on '$f'." cleanup exit 1 fi + popd > /dev/null done cleanup