Reinstate some uses of "eval" to allow for unpadding track numbers
authorSteve McIntyre <steve@einval.com>
Sat, 3 Mar 2018 15:32:55 +0000 (15:32 +0000)
committerSteve McIntyre <steve@einval.com>
Sat, 3 Mar 2018 15:33:42 +0000 (15:33 +0000)
Sigh - bash will interpret 0-padded numbers as octal

abcde

diff --git a/abcde b/abcde
index 28bb008..b9bf070 100755 (executable)
--- a/abcde
+++ b/abcde
@@ -553,7 +553,7 @@ do_replaygain()
                        REPLAYINDEX=0
                        for UTRACKNUM in $TRACKQUEUE
                        do
-                               CDDBTRACKNUM=$(("$UTRACKNUM" - 1))
+                               CDDBTRACKNUM=$(eval "$UTRACKNUM" - 1) # Unpad
                                getcddbinfo TRACKNAME
                                splitvarious
                                TRACKFILE="$(mungetrackname "$TRACKNAME")"
@@ -1832,7 +1832,7 @@ do_playlist ()
                        for UTRACKNUM in $TRACKQUEUE
                        do
                                # Shares some code with do_move since the filenames have to match
-                               CDDBTRACKNUM=$(($UTRACKNUM - 1))
+                               CDDBTRACKNUM=$(eval $UTRACKNUM - 1) # Unpad
                                getcddbinfo TRACKNAME
                                splitvarious
                                TRACKFILE="$(mungetrackname "$TRACKNAME")"
@@ -3452,7 +3452,7 @@ do_cdread ()
                # We need the first and last track for cdda2wav/icedax
                FIRSTTRACK=$2
                LASTTRACK=$(($3 + 0))
-               UTRACKNUM="$FIRSTTRACK"
+               UTRACKNUM=$FIRSTTRACK
                case "$CDROMREADERSYNTAX" in
                        flac) READTRACKNUMS="-" ;;
                        cdparanoia|libcdio)
@@ -3469,7 +3469,7 @@ do_cdread ()
        else
                UTRACKNUM=$1
        fi
-       CDDBTRACKNUM=$(($UTRACKNUM - 1))
+       CDDBTRACKNUM=$(eval $UTRACKNUM - 1) # Unpad
        if [ "$USEPIPES" = "y" ]; then
                TEMPARG="PIPERIPPER_$CDROMREADERSYNTAX"
                FILEARG="$( eval echo "\$$TEMPARG" )"
@@ -3501,7 +3501,7 @@ do_cdread ()
                ### FIXME ### Shall we just use -o $FILEARG ??
                flac)
                        # Avoid problems with math expressions by unpadding the given UTRACKNUM
-                       STRIPTRACKNUM=$(( $UTRACKNUM + 0 ))
+                       STRIPTRACKNUM=$(eval $UTRACKNUM + 0 )
                        nice $READNICE $FLAC -d -f --cue="${READTRACKNUMS:-$STRIPTRACKNUM.1-$(($STRIPTRACKNUM + 1)).0}" "$FILEARG" "$CDROM" ;;
                cdparanoia|libcdio)
                        if [ "$USEPIPES" = "y" ]; then
@@ -3546,7 +3546,7 @@ do_cdread ()
                ;;
                cddafs)
                        # Find the track's mounted path
-                       REALTRACKNUM=$(($UTRACKNUM + 0))
+                       REALTRACKNUM=$(eval $UTRACKNUM + 0) # Unpad
                        FILEPATH=$(mount | grep "$CDROM on" | sed 's/^[^ ]* on \(.*\) (.*/\1/')
                        FILEPATH=$(find "$FILEPATH" | grep "/$REALTRACKNUM ");
                        # If the file exists, copy it
@@ -5397,7 +5397,7 @@ do
                        splitvarious
                else
                        TRACKNUM="$UTRACKNUM"
-                       CDDBTRACKNUM=$(($UTRACKNUM - 1))
+                       CDDBTRACKNUM=$(eval $UTRACKNUM - 1) # Unpad
                        getcddbinfo TRACKNAME
                        splitvarious
                fi