+ multiple)
+ echo "Processing multiple matching CDDB entries..." > "$ABCDETEMPDIR/cddblocalchoices"
+ X=0
+ echo "$CDDBLOCALRESULTS" | while read RESULT ; do
+ X=$(expr $X + 1)
+ # List out disc title/author and contents
+ CDDBLOCALREAD="$ABCDETEMPDIR/cddblocalread.$X"
+ cat "$RESULT" > "${CDDBLOCALREAD}"
+ {
+ echo -n "#$X: "
+ do_cddbparse "${CDDBLOCALREAD}"
+ echo ""
+ ##FIXME## QUICK HACK !!!!
+ if [ ! "$INTERACTIVE" = "y" ]; then break ; fi
+ } >> "$ABCDETEMPDIR/cddblocalchoices"
+ done
+ if [ $(cat "$ABCDETEMPDIR/cddblocalchoices" | wc -l) -ge 24 ] && [ "$INTERACTIVE" = "y" ]; then
+ page "$ABCDETEMPDIR/cddblocalchoices"
+ else
+ # It's all going to fit in one page, cat it
+ cat "$ABCDETEMPDIR/cddblocalchoices" >&2
+ fi
+ CDDBLOCALCHOICES=$( echo "$CDDBLOCALRESULTS" | wc -l )
+ # Setting the choice to an impossible integer to avoid errors in the numeric comparisons
+ CDDBLOCALCHOICENUM=-1
+ if [ "$INTERACTIVE" = "y" ]; then
+ while [ $CDDBLOCALCHOICENUM -lt 0 ] || [ $CDDBLOCALCHOICENUM -gt $CDDBLOCALCHOICES ]; do
+ echo -n "Locally cached CDDB entries found. Which one would you like to use (0 for none)? [0-$CDDBLOCALCHOICES]: " >&2
+ read CDDBLOCALCHOICE
+ [ x"$CDDBLOCALCHOICE" = "x" ] && CDDBLOCALCHOICE="1"
+ # FIXME # Introduce diff's
+ if echo $CDDBLOCALCHOICE | egrep "[[:space:]]*[[:digit:]]+,[[:digit:]]+[[:space:]]*" > /dev/null 2>&1 ; then
+ diffentries cddblocalread "$CDDBLOCALCHOICES" "$CDDBLOCALCHOICE"
+ elif echo $CDDBLOCALCHOICE | egrep "[[:space:]]*[[:digit:]]+[[:space:]]*" > /dev/null 2>&1 ; then
+ # Make sure we get a valid choice
+ CDDBLOCALCHOICENUM=$(echo $CDDBLOCALCHOICE | xargs printf %d 2>/dev/null)
+ if [ $CDDBLOCALCHOICENUM -lt 0 ] || [ $CDDBLOCALCHOICENUM -gt $CDDBLOCALCHOICES ]; then
+ echo "Invalid selection. Please choose a number between 0 and $CDDBLOCALCHOICES." >&2
+ fi
+ fi
+ done
+ else
+ ### FIXME ###
+ #echo "Selected ..."
+ CDDBLOCALRESP=y
+ CDDBLOCALCHOICENUM=1
+ fi
+ if [ ! "$CDDBLOCALCHOICENUM" = "0" ]; then
+ #echo "Using local copy of CDDB data"
+ echo "# DO NOT ERASE THIS LINE! Added by abcde to imitate cddb output" > "$ABCDETEMPDIR/cddbread.1"
+ cat "$ABCDETEMPDIR/cddblocalread.$CDDBLOCALCHOICENUM" >> "$ABCDETEMPDIR/cddbread.1"
+ echo 999 > "$ABCDETEMPDIR/cddbquery" # Assuming 999 isn't used by CDDB
+ echo cddb-readcomplete >> "$ABCDETEMPDIR/status"
+ do_cddbparse "$ABCDETEMPDIR/cddbread.1" > "$ABCDETEMPDIR/cddbchoices"
+ echo cddb-choice=1 >> "$ABCDETEMPDIR/status"
+ CDDBLOCALSTATUS="found"
+ else
+ #echo "Not using local copy of CDDB data"
+ CDDBLOCALSTATUS="notfound"
+ fi
+ ;;