From: Bastian Dehn Date: Thu, 3 Apr 2025 18:06:51 +0000 (+0200) Subject: change error logging X-Git-Tag: v1.0.6^2~3 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=180f411afcc926e707376075973219eb16afd4a3;p=scantopdf.git change error logging --- diff --git a/scantopdf b/scantopdf index 1e9e0ee..3fefa06 100755 --- a/scantopdf +++ b/scantopdf @@ -1,7 +1,5 @@ #!/bin/bash -@errlog.sh@ - @scanbasic.sh@ main() @@ -10,15 +8,11 @@ main() local output=$2 local basename=$3 - if [ -z "$pagecount" ]; then - errlog "no page count" - return 1 - fi - - if [ -z "$output" ]; then - errlog "no pdf file name" - return 1 - fi + command -v scanimage > /dev/null \ + || errlog "command scanimage not found" \ + || return $? + [ -n "$pagecount" ] || errlog "no page count" || return $? + [ -n "$output" ] || errlog "no pdf file name" || return $? scanimage --source=DocumentFeeder \ --mode=Color \ @@ -30,14 +24,16 @@ main() --batch-increment=1 \ --batch=scanned%03d.tiff \ || errlog "scan error" \ - || return 1 + || return $? if [ "$output" == "multi" ]; then - createmultipdfs $pagecount $basename || return 1 - exit 0 + createmultipdfs $pagecount $basename || return $? + return fi - createonepdf $output || return 1 + createonepdf $output || return $? } +echo "⭐ START: scantopdf" main $* +echo "✅ SUCCESS: scantopdf diff --git a/scantopdfbw b/scantopdfbw index 570508e..d682ece 100755 --- a/scantopdfbw +++ b/scantopdfbw @@ -1,7 +1,5 @@ #!/bin/bash -@errlog.sh@ - @scanbasic.sh@ main() @@ -10,15 +8,11 @@ main() local output=$2 local basename=$3 - if [ -z "$pagecount" ]; then - errlog "no page count" - return 1 - fi - - if [ -z "$output" ]; then - errlog "no pdf file name" - return 1 - fi + command -v scanimage > /dev/null \ + || errlog "command scanimage not found" \ + || return $? + [ -n "$pagecount" ] || errlog "no page count" || return $? + [ -n "$output" ] || errlog "no pdf file name" || return $? scanimage --source=DocumentFeeder \ --mode=BW \ @@ -30,14 +24,16 @@ main() --batch-increment=1 \ --batch=scanned%03d.tiff \ || errlog "scan error" \ - || return 1 + || return $? if [ "$output" == "multi" ]; then createmultipdfs $pagecount $basename || return 1 return fi - createonepdf $output || return 1 + createonepdf $output || return $? } +echo "⭐ START: scantopdfbw" main $* +echo "✅ SUCCESS: scantopdfbw diff --git a/scantopdfgray b/scantopdfgray index 5b6a6ad..da7749a 100755 --- a/scantopdfgray +++ b/scantopdfgray @@ -1,7 +1,5 @@ #!/bin/bash -@errlog.sh@ - @scanbasic.sh@ main() @@ -10,15 +8,11 @@ main() local output=$2 local basename=$3 - if [ -z "$pagecount" ]; then - errlog "no page count" - return 1 - fi - - if [ -z "$output" ]; then - errlog "no pdf file name" - return 1 - fi + command -v scanimage > /dev/null \ + || errlog "command scanimage not found" \ + || return $? + [ -n "$pagecount" ] || errlog "no page count" || return $? + [ -n "$output" ] || errlog "no pdf file name" || return $? scanimage --source=DocumentFeeder \ --mode=Gray \ @@ -30,14 +24,16 @@ main() --batch-increment=1 \ --batch=scanned%03d.tiff \ || errlog "scan error" \ - || return 1 + || return $? if [ "$output" == "multi" ]; then createmultipdfs $pagecount $basename || return 1 return fi - createonepdf $output || return 1 + createonepdf $output || return $? } +echo "⭐ START: scantopdfgray" main $* +echo "✅ SUCCESS: scantopdfgray