Remove unwanted output when binary is unavailable

This commit is contained in:
Thomas Dehaeze 2020-01-28 21:28:01 +01:00
parent 8a637eb45a
commit 7a42fac34d

View File

@ -111,9 +111,9 @@ The requirement is to have =pdftk= or =stapler= installed.
#+begin_src bash #+begin_src bash
if [[ -f $1 && $1 == *.pdf ]]; then if [[ -f $1 && $1 == *.pdf ]]; then
# Argument if a file # Argument if a file
if type stapler > /dev/null; then if type stapler > /dev/null 2>&1; then
stapler del "$1" 1 /tmp/pdftk_out.pdf && mv /tmp/pdftk_out.pdf "$1" stapler del "$1" 1 /tmp/pdftk_out.pdf && mv /tmp/pdftk_out.pdf "$1"
elif type pdftk > /dev/null; then elif type pdftk > /dev/null 2>&1; then
pdftk "$1" cat 2-end output /tmp/pdftk_out.pdf && mv /tmp/pdftk_out.pdf "$1" pdftk "$1" cat 2-end output /tmp/pdftk_out.pdf && mv /tmp/pdftk_out.pdf "$1"
else else
echo "Neither pdftk nor stapler are installed" echo "Neither pdftk nor stapler are installed"