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
- pushd .
+ pushd . > /dev/null
cd $(dirname $f)
if ! pdflatex -output-directory "$tmpdir" $(basename $f) < /dev/null > /dev/null; then
cleanup
exit 1
fi
- popd
+ popd > /dev/null
done
cleanup