From: Bastian Dehn Date: Sun, 6 Jul 2025 10:00:10 +0000 (+0200) Subject: refactor if to one line X-Git-Tag: v1.1.0~1^2~4 X-Git-Url: https://gitweb.hhaalo.de/?a=commitdiff_plain;h=04407ffd9d2e91662fe8fabe90eeb264eccb104c;p=scantopdf.git refactor if to one line --- diff --git a/src/scanbasic.sh b/src/scanbasic.sh index 3352d96..b273fa6 100644 --- a/src/scanbasic.sh +++ b/src/scanbasic.sh @@ -226,10 +226,10 @@ scantopdf() { || errlog "scan error" \ || return $? - if [ "$output" == "multi" ]; then - createmultipdfs || return $? - return - fi + [ "$output" != "multi" ] \ + || createmultipdfs \ + && return 0 \ + || return $? createonepdf "$output" \ || return $? diff --git a/tests/scanbasic.bats b/tests/scanbasic.bats index 54bc515..069db78 100755 --- a/tests/scanbasic.bats +++ b/tests/scanbasic.bats @@ -286,3 +286,29 @@ setup() { assert_success } + +@test "should failure scantopdf with multi" { + scanimage() { + : + } + createmultipdfs() { + return 1 + } + + run scantopdf "Color" "1" "multi" + + assert_failure +} + +@test "should success scantopdf with multi" { + scanimage() { + : + } + createmultipdfs() { + : + } + + run scantopdf "Color" "1" "multi" + + assert_success +}