2021-05-19 22:57:46 +03:00
|
|
|
#!/bin/bash
|
|
|
|
set -euo pipefail
|
|
|
|
dir=$(mktemp -d)
|
2021-05-19 22:57:46 +03:00
|
|
|
src=${1:-mj-msc.pdf}
|
|
|
|
dst=${2:-mj-msc-full.pdf}
|
2021-05-19 22:57:46 +03:00
|
|
|
echo "Extracting $src to $dir/" && pdfdetach -saveall -o "$dir" "$src"
|
|
|
|
echo "Generating $dir/$dst ..."
|
|
|
|
make -j $(nproc) -C "$dir" "$dst" &> "$dir/make.log" || {
|
2021-05-19 22:57:46 +03:00
|
|
|
echo "Generation failed. Log extract:" && tail -20 "$dir/make.log"
|
2021-05-19 22:57:46 +03:00
|
|
|
exit 1
|
2021-05-19 22:57:46 +03:00
|
|
|
}
|
2021-05-19 22:57:46 +03:00
|
|
|
echo "Opening $dir/$dst ..." && xdg-open "$dir/$dst"
|
2021-05-19 22:57:46 +03:00
|
|
|
echo "File has been closed. Removing $dir" && rm -fr "$dir"
|