From: Bastian Dehn Date: Sun, 6 Jul 2025 09:28:20 +0000 (+0200) Subject: change all commands check availibility X-Git-Tag: v1.1.0~1^2~5 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=643a23524f0644e2d51bad8c8001cc3183e74a04;p=scantopdf.git change all commands check availibility --- diff --git a/src/scanbasic.sh b/src/scanbasic.sh index b7d7692..3352d96 100644 --- a/src/scanbasic.sh +++ b/src/scanbasic.sh @@ -8,17 +8,40 @@ errlog() return $lastexit } +check_commands() +{ + command -v scanimage > /dev/null \ + || errlog "command scanimage not found" \ + || return $? + command -v qpdf > /dev/null \ + || errlog "command qpdf not found" \ + || return $? + command -v ocrmypdf > /dev/null \ + || errlog "command ocrmypdf not found" \ + || return $? + command -v tiff2pdf > /dev/null \ + || errlog "command tiff2pdf not found" \ + || return $? + command -v pdftk > /dev/null \ + || errlog "command pdftk not found" \ + || return $? + command -v zbarimg > /dev/null \ + || errlog "command zbarimg not found" \ + || return $? + command -v tiff2pdf > /dev/null \ + || errlog "command tiff2pdf not found" \ + || return $? +} + optimize() { local input="$1" local output="$input-out" - command -v qpdf > /dev/null \ - || errlog "command qpdf not found" \ - || return $? [ -n "$input" ] \ || errlog "missing input" \ || return $? + qpdf --linearize $input $output \ || errlog "could not linearize $input" \ || return $? @@ -32,9 +55,6 @@ addocr() local input="$1" local output="$input-out" - command -v ocrmypdf > /dev/null \ - || errlog "command ocrmypdf not found" \ - || return $? [ -n "$input" ] \ || errlog "missing input" \ || return $? @@ -57,12 +77,6 @@ createonepdf() { local output=$1 - command -v tiff2pdf > /dev/null \ - || errlog "command tiff2pdf not found" \ - || return $? - command -v pdftk > /dev/null \ - || errlog "command pdftk not found" \ - || return $? [ -n "$output" ] \ || errlog "missing output" \ || return $? @@ -100,9 +114,6 @@ createpdf() local pdfs=() basename=${basename:="out"} - command -v pdftk > /dev/null \ - || errlog "command pdftk not found" \ - || return $? [ -n "$start" ] \ || errlog "missing start" \ || return $? @@ -135,9 +146,6 @@ detectsplit() local pdf=$1 local trenn= - command -v zbarimg > /dev/null \ - || errlog "command zbarimg not found" \ - || return $? [ -n "$pdf" ] \ || errlog "missing pdf" \ || return $? @@ -157,9 +165,6 @@ createmultipdfs() local startcount=1 local endcount=1 - command -v tiff2pdf > /dev/null \ - || errlog "command tiff2pdf not found" \ - || return $? [ -n "$basename" ] \ || errlog "missing basename" \ || return $? @@ -197,8 +202,7 @@ scantopdf() { local pagecount="$2" local output="$3" - command -v scanimage > /dev/null \ - || errlog "command scanimage not found" \ + check_commands \ || return $? [ -n "$mode" ] \ || errlog "missing mode" \