Fix code handling $NUM_CDDB_MATCHES in do_cddb_read
authorSteve McIntyre <steve@einval.com>
Sun, 25 Feb 2018 00:20:22 +0000 (00:20 +0000)
committerSteve McIntyre <steve@einval.com>
Sun, 25 Feb 2018 00:20:22 +0000 (00:20 +0000)
The code here is in a sub-shell, so modifications to $NUM_CDDB_MATCHES
do not persist in the parent. Yay shell. Work around this.

abcde

diff --git a/abcde b/abcde
index cb82926..9e4e1fa 100755 (executable)
--- a/abcde
+++ b/abcde
@@ -2721,6 +2721,8 @@ do_cddb_read ()
                        # Multiple exact, (possibly multiple) inexact matches
                        vecho -n "Retrieving multiple matches... "
                        grep -v ^[.]$ "${SOURCE_WORKDIR}/cddbquery" | (
+                               # IN A SUB-SHELL - VARIABLES MODIFIED
+                               # HERE DO NOT PERSIST IN THE PARENT
                                read DISCINFO # eat top line
                                while read DISCINFO
                                do
@@ -2732,6 +2734,10 @@ do_cddb_read ()
                                                echo cddb-read-${NUM_CDDB_MATCHES}-complete >> "$ABCDETEMPDIR/status"
                                        fi
                                done )
+                       # Need to re-count the entries here to be able
+                       # to incrememnt $NUM_CDDB_MATCHES in the
+                       # parent
+                       NUM_CDDB_MATCHES=$(($NUM_CDDB_MATCHES + $(ls -1 ${SOURCE_WORKDIR}/datasource.* | wc -l)))
                        vecho "done."
                        ;;
                999)