From 84191ff1dd858f9266eb8a59463345c70ee764e1 Mon Sep 17 00:00:00 2001 From: Alban Gebler <alban.gebler@idiv.de> Date: Tue, 23 Jan 2024 14:12:41 +0100 Subject: [PATCH] check for existence of pdftk --- pdfform.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/pdfform.sh b/pdfform.sh index aa986da..7b2746e 100644 --- a/pdfform.sh +++ b/pdfform.sh @@ -9,6 +9,7 @@ ## v2 23-12-23 alban: add help text and error message ## v3 24-01-15 alban: add acceptance for wildcard * ## v4 24-01-17 alban: add file type check +## v5 24-01-23 alban: add binary check ## @@ -17,6 +18,18 @@ helptext () { } ## check for binaries needed +## give needed binaries as space-seperated entries in variable $progs2check +## +progs2check="pdftk" +## +for prog in $progs2check; do + if ! which "$prog" > /dev/null; then + echo "\n ERROR: Couldn't find the program $prog. \n" + exit 1 + fi +done + +## help request as parameter # TBD ## no parameter @@ -25,9 +38,6 @@ if [ -z "$1" ]; then helptext exit 0 fi -## help request as parameter -# TBD - ## set internal field separator (IFS) because of possible spaces in file names IFS=" -- GitLab