Fix broken range code, patch from Charles Steinkuehler
[clinton/abcde.git] / abcde
diff --git a/abcde b/abcde
index 2358c1f..6cb9600 100755 (executable)
--- a/abcde
+++ b/abcde
@@ -13,7 +13,7 @@
 #
 # $Id$
 
-VERSION='2.3.99-$Revision$'
+VERSION='2.3.99.8'
 
 usage ()
 {
@@ -390,7 +390,7 @@ diffentries ()
                if [ $PARSECHOICE1 -lt 1 ] || [ $PARSECHOICE1 -gt $CDDBDIFFCHOICES ] || \
                   [ $PARSECHOICE2 -lt 1 ] || [ $PARSECHOICE2 -gt $CDDBDIFFCHOICES ] || \
                   [ $PARSECHOICE1 -eq $PARSECHOICE2 ]; then 
-                       echo "Invalid diff range. Please select two coma-separated numbers between 1 and $CDDBDIFFCHOICES" >&2
+                       echo "Invalid diff range. Please select two comma-separated numbers between 1 and $CDDBDIFFCHOICES" >&2
                else
                        # We parse the 2 choices to diff, store them in temporary files and diff them.
                        for PARSECHOICE in $(echo $CDDBDIFFCHOICE | tr , \ ); do
@@ -1883,11 +1883,11 @@ do_discid ()
                        exit 1
                fi
                echo -n .
-               # It's a directory, let's see if it's owned by us
-               if [ ! -O "$ABCDETEMPDIR" ]; then
+               # It's a directory, let's see if it's writable by us
+               if [ ! -r "$ABCDETEMPDIR" ] || [ ! -w "$ABCDETEMPDIR" ] || [ ! -x "$ABCDETEMPDIR" ]; then
                        # Nope, complain and exit
                        echo >&2
-                       echo "abcde: directory $ABCDETEMPDIR already exists and is not owned by you." >&2
+                       echo "abcde: directory $ABCDETEMPDIR already exists and is not writeable." >&2
                        echo "Please investigate, remove it, and rerun abcde." >&2
                        exit 1
                fi
@@ -2417,7 +2417,7 @@ do_cddbedit ()
                                                                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
+                                                                       echo "Invalid diff range. Please select two comma-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
@@ -3131,7 +3131,7 @@ fi
 
 if [ "$HTTPGETOPTS" = "" ] ; then
        case $HTTPGET in
-               wget) HTTPGETOPTS="-q -nv -O -";;
+               wget) HTTPGETOPTS="-q -nv -e timestamping=off -O -";;
                curl) HTTPGETOPTS="-f -s";;
                fetch)HTTPGETOPTS="-q -o -";;
                ftp)  HTTPGETOPTS="-a -V -o - ";;
@@ -3291,14 +3291,17 @@ if [ "$ONETRACK" = "y" ]; then
 else
        while [ $# -gt 0 ]; do
                # Range parsing code courtesy of Vincent Ho
-               RSTART=$(echo $1 | cut -f1 -d-)
-               REND=$(echo $1 | cut -f2 -d-)
-               if [ "$RSTART" = "$REND" ]; then
-                       NEWTRACKS="$RSTART"
-               else
-                       NEWTRACKS=$(f_seq_line $RSTART $REND)
-               fi
-               TRACKQUEUE=$(echo "$TRACKQUEUE" "$NEWTRACKS")
+               # Cleaned up to use shell built-ins by Charles Steinkuehler
+               if [ "${1#*[^0-9-]}" != "$1" ]; then
+                       log error "syntax error while processing track numbers"
+               else
+                       RSTART=${1%%-*}
+                       REND=${1##*-}
+                       while [ ${RSTART:=1} -le ${REND:=0} ] ; do
+                               TRACKQUEUE="$TRACKQUEUE $RSTART"
+                               RSTART=$(( $RSTART + 1 ))
+                       done
+               fi
                shift
        done
 fi
@@ -3594,6 +3597,7 @@ case "$FLACENCODERSYNTAX" in
                FLACENCODER="$FLAC"     
                if [ "$DOREPLAYGAIN" = "y" ]; then
                        FLACENCODEROPTS="${FLACENCODEROPTS} --replay-gain"
+               fi
                # FLAC streams can be encapsulated on a Ogg transport layer
                if echo "$FLACENCODEROPTS" | egrep -- "(^| )--ogg($| )" > /dev/null 2>&1 ;then
                        log error "FLAC on an Ogg container is not yet supported"
@@ -3633,9 +3637,9 @@ else
        TAGGEROPTS="$ID3V2OPTS"
 fi
 
-# Specific for NOGAP is the use of lame. Another encoder fails...
+# NOGAP is specific to lame. Other encoders fail ...
 if [ "$NOGAP" = "y" ] && [ ! "$MP3ENCODER" = "lame" ]; then
-       log warning "the NOGAP option is specific of lame. Deactivating..."
+       log warning "the NOGAP option is specific to lame. Deactivating..."
        NOGAP=n
 fi