--- /dev/null
+#!/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