From 1d876fd2b1d4305789cfa9fb84daf4c3374043c8 Mon Sep 17 00:00:00 2001 From: Stefan Huber Date: Fri, 13 Dec 2013 13:38:27 +0100 Subject: [PATCH] git pre-commit hook for tex checking --- git/pre-commit-texcheck | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100755 git/pre-commit-texcheck 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 -- 2.30.2