pdflatex.sh, a script for creating pdfs from tex
authorColin Patrick Mccabe <cmccabe@alumni.cmu.edu>
Thu, 23 Aug 2012 17:53:12 +0000 (10:53 -0700)
committerColin Patrick Mccabe <cmccabe@alumni.cmu.edu>
Thu, 23 Aug 2012 17:53:58 +0000 (10:53 -0700)
Signed-off-by: Colin McCabe <cmccabe@alumni.cmu.edu>

pdflatex.sh [new file with mode: 0755]

diff --git a/pdflatex.sh b/pdflatex.sh
new file mode 100755 (executable)
index 0000000..6c8b769
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/bash
+
+die() {
+    echo $@
+    exit 1
+}
+
+which pdflatex &> /dev/null || die "you must have pdflatex installed"
+
+[ $# -eq 1 ] || die "you must give exactly one argument: the \
+name of the tex file to use as input."
+
+TMPDIR=`mktemp -d -t pdfgrep.XXXXXXXXXX` || exit 1
+trap "rm -rf ${TMPDIR}; exit" INT TERM EXIT
+
+INPUT_FNAME=$1
+shift
+pdflatex -output-directory "${TMPDIR}" < "${INPUT_FNAME}" || die "ERROR: pdflatex failed!"
+mv -f ${TMPDIR}/*.pdf "${INPUT_FNAME}.pdf" || die "ERROR: couldn't find pdf output file"