X-Git-Url: https://git.sthu.org/?a=blobdiff_plain;f=git%2Fpre-commit-texcheck;h=8d47a5ebe3ef566e066cdded54f4914960618a82;hb=874fac4e15be441861de05fca98ac714bb679ae3;hp=dae2418a129913c5bee48a49fa847894814bd6d7;hpb=bf071c211651c1e81d6e8a91ddd9234ba80a4986;p=shutils.git diff --git a/git/pre-commit-texcheck b/git/pre-commit-texcheck index dae2418..8d47a5e 100755 --- a/git/pre-commit-texcheck +++ b/git/pre-commit-texcheck @@ -2,19 +2,21 @@ 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 @@ -23,7 +25,7 @@ for f in $(find -name "*.tex"); do cleanup exit 1 fi - popd + popd > /dev/null done cleanup