From 4f8fc74c0c09ba9d0798859441a3e04c85b01670 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Tue, 6 Apr 2021 09:40:43 +0300 Subject: [PATCH] update extract-and-generate --- IV/extract-and-generate | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/IV/extract-and-generate b/IV/extract-and-generate index d32a7b6..40b23a3 100755 --- a/IV/extract-and-generate +++ b/IV/extract-and-generate @@ -2,13 +2,15 @@ set -euo pipefail dir=$(mktemp -d) src=${1:-mj-msc-full.pdf} -dst=${2:-mj-msc.pdf} + +readonly dst=mj-msc.pdf +readonly log="$dir/make.log" echo "Extracting $src to $dir/" && pdfdetach -saveall -o "$dir" "$src" chmod a+x "$dir/db" -echo "Generating $dir/$dst ..." -make -j $(nproc) -C "$dir" "$dst" &> "$dir/make.log" || { - echo "Generation failed. Log extract:" && tail -20 "$dir/make.log" +echo "Generating $dir/$dst, logs in $log ..." +make -j "$(nproc)" -C "$dir" "$dst" &> "$log" || { + echo "Failed to generate. $log extract:" && tail -20 "$dir/make.log" exit 1 } echo "Opening $dir/$dst ..." && xdg-open "$dir/$dst" -echo "File has been closed. Removing $dir" && rm -fr "$dir" +echo "$dir/$dst was closed. Removing $dir" && rm -fr "$dir"