stud/IV/extract-and-generate
2021-04-25 10:16:57 +03:00

15 lines
420 B
Bash
Executable File

#!/bin/bash
set -euo pipefail
s=${1:-mj-msc-full.pdf}
d=$(mktemp -d)
readonly f=mj-msc.pdf
readonly l="$d/make.log"
echo "Extracting $s to workdir $d/"; pdfdetach -saveall -o "$d" "$s"
echo "Logs in $l ..."; make -j "$(nproc)" -C "$d" "$f" &> "$l" || {
echo "Failed to generate. $l extract:" && tail -20 "$l"
exit 1
}
echo "Opening $d/$f ..."; xdg-open "$d/$f"
echo "$d/$f was closed. Removing $d"; rm -fr "$d"