From ca935219c8c7b503f926a0e6b5f12e391882b8de Mon Sep 17 00:00:00 2001 From: Urban Modig Date: Wed, 1 Oct 2025 11:28:25 +0200 Subject: [PATCH] fix set -e --- download.sh | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/download.sh b/download.sh index bf00655..97112a9 100755 --- a/download.sh +++ b/download.sh @@ -317,15 +317,13 @@ done (( DEBUG )) && { log "Debug mode enabled"; set -x; } # Enforce mutual exclusivity between -c, -p, -f -set -- "$collection" "$post" "$file" +# (avoid set -e pitfalls by not looping over empty args) count=0 -for x in "$@"; do - if [[ -n $x ]]; then - ((count++)) - fi -done -# Ensure a zero exit status here to avoid set -e exiting if the last test was false -true +[[ -n $collection ]] && ((count++)) +[[ -n $post ]] && ((count++)) +[[ -n $file ]] && ((count++)) + +log "Arg summary: collection='${collection:-}' post='${post:-}' file='${file:-}' (count=$count)" if (( count != 1 )); then usage die "Options -c, -p och -f kan inte användas samtidigt (exakt en krävs)."