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)."