stud/IV/extract-and-generate
2021-04-01 17:27:49 +03:00

13 lines
444 B
Bash
Executable File

#!/bin/bash
set -euo pipefail
dir=$(mktemp -d)
fname=${1:-mj-msc-all.pdf}
echo "Extracting $fname to $dir/" && pdfdetach -saveall -o "$dir" "$fname"
echo "Generating $dir/$fname ..."
make -j $(nproc) -C "$dir" "$fname" &> "$dir/make.log" || {
echo "Generation failed. Log extract:" && tail -20 "$dir/make.log"
exit 1
}
echo "Opening $dir/$fname ..." && xdg-open "$dir/$fname"
echo "File has been closed. Removing $dir" && rm -fr "$dir"