+ [ X"$CDDBCHOICE" = "X" ] && CDDBCHOICE=1
+ if echo $CDDBCHOICE | egrep -q "[[:digit:]]+,[[:digit:]]+" ; then
+ if [ ! X"$DIFF" = "X" ]; then
+ PARSECHOICE1=$(echo $CDDBCHOICE | cut -d"," -f1)
+ PARSECHOICE2=$(echo $CDDBCHOICE | cut -d"," -f2)
+ if [ $PARSECHOICE1 -lt 1 ] || [ $PARSECHOICE1 -gt $CDDBCHOICES ] || \
+ [ $PARSECHOICE2 -lt 1 ] || [ $PARSECHOICE2 -gt $CDDBCHOICES ] || \
+ [ $PARSECHOICE1 -eq $PARSECHOICE2 ]; then
+ echo "Invalid diff range. Please select two coma-separated numbers between 1 and $CDDBCHOICES" >&2
+ else
+
+ # We parse the 2 choices to diff, store them in temporary files and diff them.
+ for PARSECHOICE in $(echo $CDDBCHOICE | tr , \ ); do
+ do_cddbparse "$ABCDETEMPDIR/cddbread.$PARSECHOICE" > "$ABCDETEMPDIR/cddbread.parsechoice.$PARSECHOICE"
+ done
+ echo "Showing diff between choices $PARSECHOICE1 and $PARSECHOICE2..." > "$ABCDETEMPDIR/cddbread.diff"
+ $DIFF $DIFFOPTS "$ABCDETEMPDIR/cddbread.parsechoice.$PARSECHOICE1" "$ABCDETEMPDIR/cddbread.parsechoice.$PARSECHOICE2" >> "$ABCDETEMPDIR/cddbread.diff"
+ if [ $(cat "$ABCDETEMPDIR/cddbread.diff" | wc -l) -ge 24 ]; then
+ page "$ABCDETEMPDIR/cddbread.diff"
+ else
+ cat "$ABCDETEMPDIR/cddbread.diff" >&2
+ fi
+ fi
+ else
+ echo "The diff program was not found in your path. Please choose a number between 0 and $CDDBCHOICES." >&2
+ fi
+ else
+ if [ $CDCHOICENUM -lt 0 ] || [ $CDCHOICENUM -gt $CDDBCHOICES ]; then
+ # Make sure we get a valid choice
+ CDCHOICENUM=$(echo $CDDBCHOICE | xargs printf %d 2>/dev/null)
+ echo "Invalid selection. Please choose a number between 0 and $CDDBCHOICES." >&2
+ fi
+ fi