From: Stefan Huber Date: Fri, 13 Dec 2013 12:38:27 +0000 (+0100) Subject: git pre-commit hook for tex checking X-Git-Url: https://git.sthu.org/?a=commitdiff_plain;h=1d876fd2b1d4305789cfa9fb84daf4c3374043c8;p=shutils.git git pre-commit hook for tex checking --- diff --git a/git/pre-commit-texcheck b/git/pre-commit-texcheck new file mode 100755 index 0000000..29547fe --- /dev/null +++ b/git/pre-commit-texcheck @@ -0,0 +1,24 @@ +#!/bin/sh + +set -e + +[ "$#" > "0" ] && cd "$1" + +tmpdir=$(mktemp -d) +cleanup() +{ + rm -r "$tmpdir" +} + +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 + echo >&2 "pdflatex failed on '$f'." + cleanup + exit 1 + fi +done + +cleanup