[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[abcde] Bug#93395: [PATCH] checkstatus problem93395@bugs.debian.org
Package: abcde
Version: 1.9.9-1
I notice that the current checkstatus function matches, for example,
"foo" even when status contains "foobar". This is problematic when
status lines end in track numbers like "1" and "15".
Also, every instance of checkstatus use is a match on the start of the
string (^). Perhaps that should just be the *behaviour* of
checkstatus.
Below is a patch that's been working for me, but it probably should
get more testing...
-itai
--- abcde-1.9.9.orig/abcde Tue Mar 13 10:49:24 2001
+++ abcde-1.9.9/abcde Sun Apr 8 22:59:24 2001
@@ -60,26 +60,20 @@
checkstatus ()
{
# Take the last line in the status file if there's multiple matches
- BLURB="$(grep $1 $ABCDETEMPDIR/status | tail -1)"
- grep $1 $ABCDETEMPDIR/status >/dev/null
- case "$?" in
- 0)
+ PATTERN="^$1(=.*)?$"
+ BLURB="$(egrep $PATTERN $ABCDETEMPDIR/status | tail -1)"
+
+ if [ -z "$BLURB" ]; then
+ # No matches found
+ return 1
+ else
# Matches found
# See if there's a = in it
if [ "$(echo $BLURB | grep -c =)" != "0" ]; then
echo "$(echo $BLURB | cut -f2- -d=)"
fi
return 0
- ;;
- 1)
- # No matches found
- return 1
- ;;
- 2)
- # Grep failed
- return 2
- ;;
- esac
+ fi
}
# relpath() and slash() are Copyright (c) 1999 Stuart Ballard and
@@ -450,7 +444,7 @@
do_cddbquery ()
{
# Perform CDDB query if it hasn't already been done
- if checkstatus ^cddb-querycomplete; then :; else
+ if checkstatus cddb-querycomplete; then :; else
if [ "$CDDBAVAIL" = "n" ]; then
ERRORCODE=no_query
else
@@ -484,7 +478,7 @@
{
# If it's not to be used, generate a template.
# Then, display it (or them) and let the user choose/ edit it
- if checkstatus ^cddb-readcomplete; then :; else
+ if checkstatus cddb-readcomplete; then :; else
# If CDDB is to be used, interpret the query results and read all
# the available entries.
rm -f "$ABCDETEMPDIR/cddbchoices"
@@ -494,7 +488,7 @@
200)
# One exact match, retrieve it
# 200 [section] [discid] [artist] / [title]
- if checkstatus ^cddb-read-1-complete; then :; else
+ if checkstatus cddb-read-1-complete; then :; else
echo -n "Retrieving 1 CDDB match..." >> "$ABCDETEMPDIR/cddbchoices"
$CDDBTOOL read $CDDBURL $CDDBUSER $CDDBHOST $(cut -f2,3 -d' ' "$ABCDETEMPDIR/cddbquery") > "$ABCDETEMPDIR/cddbread.1"
echo "done." >> "$ABCDETEMPDIR/cddbchoices"
@@ -543,7 +537,7 @@
while read DISCINFO
do
X=$(expr $X + 1)
- if checkstatus ^cddb-read-$X-complete; then :; else
+ if checkstatus cddb-read-$X-complete; then :; else
$CDDBTOOL read $CDDBURL $CDDBUSER $CDDBHOST $(echo $DISCINFO | cut -f1,2 -d' ') > "$ABCDETEMPDIR/cddbread.$X"
echo cddb-read-$X-complete >> $ABCDETEMPDIR/status
fi
@@ -569,7 +563,7 @@
# Display the $ABCDETEMPDIR/cddbchoices file created above
# Pick a pager so that if the tracks overflow the screen the user can still view everything
if [ -r "$ABCDETEMPDIR/cddbchoices" ]; then
- if checkstatus ^cddb-choice >/dev/null; then
+ if checkstatus cddb-choice >/dev/null; then
# Make sure user sees this so they can edit it if they want to
cat "$ABCDETEMPDIR/cddbchoices"
else
@@ -616,7 +610,7 @@
else
# We're noninteractive - pick the first choice.
if [ -r "$ABCDETEMPDIR/cddbchoices" ]; then
- if checkstatus ^cddb-choice >/dev/null; then
+ if checkstatus cddb-choice >/dev/null; then
cat "$ABCDETEMPDIR/cddbchoices"
fi
CDCHOICENUM=1
@@ -626,11 +620,11 @@
fi
# sanity check
- if checkstatus ^cddb-choice >/dev/null; then :; else
+ if checkstatus cddb-choice >/dev/null; then :; else
echo "abcde: internal error: cddb-choice not recorded." >&2
exit 1
fi
- CDDBDATA="$ABCDETEMPDIR/cddbread.$(checkstatus ^cddb-choice)"
+ CDDBDATA="$ABCDETEMPDIR/cddbread.$(checkstatus cddb-choice)"
echo -n "Edit selected CDDB data? [y/n] (n): " >&2
if [ "$INTERACTIVE" = "y" ]; then
@@ -1051,7 +1045,7 @@
for UTRACKNUM in $TRACKQUEUE
do
if [ "$DOREAD" = "y" ]; then
- if checkstatus ^readtrack-$UTRACKNUM; then :; else do_cdread $UTRACKNUM; fi
+ if checkstatus readtrack-$UTRACKNUM; then :; else do_cdread $UTRACKNUM; fi
echo NEXTTRACK # Get the encoder machine churning again
if [ "$LOWDISK" = "y" ] && [ "$DOENCODE" = "y" ]; then
until checkstatus encodetrack-$UTRACKNUM; do sleep 2; done
@@ -1092,12 +1086,12 @@
do
for LOCATION in $ENCODELOCATIONS
do
- PREVIOUSTRACK="$(checkstatus ^encodetracklocation-$LOCATION)"
+ PREVIOUSTRACK="$(checkstatus encodetracklocation-$LOCATION)"
# check first if a track has ever been assigned to this location
if [ "$PREVIOUSTRACK" = "" ]; then PROCEED=y; break; fi
# We're still here, this location must have been previously assigned,
# check if it's done with the previous track yet
- if checkstatus ^encodetrack-$PREVIOUSTRACK; then PROCEED=y; break; fi
+ if checkstatus encodetrack-$PREVIOUSTRACK; then PROCEED=y; break; fi
done
# all locations are working, wait and try again later
if [ \! $PROCEED ]; then sleep 5; fi
@@ -1113,26 +1107,26 @@
fi
if [ "$LOCATION" = "%local%" ]; then
if [ "$DOENCODE" = "y" ]; then
- if checkstatus ^encodetrack-$UTRACKNUM; then :; else do_encode $UTRACKNUM $LOCATION; fi
+ if checkstatus encodetrack-$UTRACKNUM; then :; else do_encode $UTRACKNUM $LOCATION; fi
fi
if [ "$DOTAG" = "y" ]; then
- if checkstatus ^tagtrack-$UTRACKNUM; then :; else do_tag $UTRACKNUM; fi
+ if checkstatus tagtrack-$UTRACKNUM; then :; else do_tag $UTRACKNUM; fi
fi
if [ "$DOMOVE" = "y" ]; then
- if checkstatus ^movetrack-$UTRACKNUM; then :; else do_move $UTRACKNUM; fi
+ if checkstatus movetrack-$UTRACKNUM; then :; else do_move $UTRACKNUM; fi
fi
else
# You can't tag a file before it's finished encoding -
# thus all of this is backgrounded together
(
if [ "$DOENCODE" = "y" ]; then
- if checkstatus ^encodetrack-$UTRACKNUM; then :; else do_encode $UTRACKNUM $LOCATION; fi
+ if checkstatus encodetrack-$UTRACKNUM; then :; else do_encode $UTRACKNUM $LOCATION; fi
fi
if [ "$DOTAG" = "y" ]; then
- if checkstatus ^tagtrack-$UTRACKNUM; then :; else do_tag $UTRACKNUM; fi
+ if checkstatus tagtrack-$UTRACKNUM; then :; else do_tag $UTRACKNUM; fi
fi
if [ "$DOMOVE" = "y" ]; then
- if checkstatus ^movetrack-$UTRACKNUM; then :; else do_move $UTRACKNUM; fi
+ if checkstatus movetrack-$UTRACKNUM; then :; else do_move $UTRACKNUM; fi
fi
) &
fi
@@ -1146,10 +1140,10 @@
PROCEED=y
for LOCATION in $ENCODELOCATIONS
do
- CHECKTRACK="$(checkstatus ^encodetracklocation-$LOCATION)"
+ CHECKTRACK="$(checkstatus encodetracklocation-$LOCATION)"
# Nothing to see here please go quietly back to your homes
if [ "$CHECKTRACK" = "" ]; then continue; fi
- if checkstatus ^encodetrack-$CHECKTRACK; then :; else PROCEED=; break; fi
+ if checkstatus encodetrack-$CHECKTRACK; then :; else PROCEED=; break; fi
done
# hold up
if [ \! $PROCEED ]; then sleep 5; fi
To unsubscribe: echo unsubscribe | mail abcde-request@whimsica.lly.org