From d716cdbe8c579587f1d27734c755dfa39ab66b71 Mon Sep 17 00:00:00 2001 From: Raman Gupta Date: Fri, 6 Aug 2021 12:49:03 -0400 Subject: [PATCH] Fix the multi-output loop Resolves #33. Fixes the arithmetic comparison in the while loop being incorrect. Also, handles the situation in which there are more output files being specified than scans available, in addition to the already handled reverse situation. --- scan | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scan b/scan index 836f92a..bea5fb0 100755 --- a/scan +++ b/scan @@ -283,10 +283,10 @@ if [[ $numscans > 0 ]]; then echo "Truncated $TRUNCPAGE pages" fi if [[ $numscans > 1 && $USEARRAY == 1 ]]; then - echo "Naming pdfs based on output list..." output_count=${#OUTPUT[@]} + echo "Naming $numscans pdfs based on output list of $output_count names..." index=0 - while [[ "$index" < "$output_count" ]]; do + while (( $index < $output_count && $numscans > $index )); do let "scanno = $index + 1" if [[ -f "${OUTPUT[$index]}" ]]; then mv "${OUTPUT[$index]}" "${OUTPUT[$index]}.orig"