planime: Improved series selection and curser handling.
authorFredrik Tolf <fredrik@dolda2000.com>
Tue, 20 Apr 2010 23:40:32 +0000 (01:40 +0200)
committerFredrik Tolf <fredrik@dolda2000.com>
Tue, 20 Apr 2010 23:40:32 +0000 (01:40 +0200)
planime

diff --git a/planime b/planime
index 3dab1dd..9c17459 100755 (executable)
--- a/planime
+++ b/planime
@@ -108,44 +108,31 @@ while [ "${1:0:1}" = - ]; do
     esac
 done
 
     esac
 done
 
-base="$(basename "$(pwd)")"
+dirbase="$(basename "$(pwd)")"
+base=.
 nextep=n
 file=
 tqual=
 if [ $# -eq 0 ]; then
     nextep=y
 nextep=n
 file=
 tqual=
 if [ $# -eq 0 ]; then
     nextep=y
-    if [ -r curser ]; then
-       base="$base $(<curser)"
-    fi
 elif [ $# -eq 1 ]; then
     if [ -r "$1" ]; then
        file="$1"
     else
 elif [ $# -eq 1 ]; then
     if [ -r "$1" ]; then
        file="$1"
     else
-       if findfile "$base - " "$1" >/dev/null; then
-           ep="$1"
-       else
-           nextep=y
-           base="$base $1"
-       fi
+       base=
+       ep="$1"
     fi
 elif [ $# -eq 2 ]; then
     fi
 elif [ $# -eq 2 ]; then
-    if findfile "$base - " "$1" "$2" >/dev/null; then
+    if findfile "$dirbase - " "$1" "$2" >/dev/null; then
+       base=""
        ep="$1"
        tqual="$2"
     else
        ep="$1"
        tqual="$2"
     else
-       if [ "$1" = . -a -r curser ]; then
-           base="$base $(<curser)"
-       else
-           base="$base $1"
-       fi
+       base="$1"
        ep="$2"
     fi
 else
        ep="$2"
     fi
 else
-    if [ "$1" = . -a -r curser ]; then
-       base="$base $(<curser)"
-    else
-       base="$base $1"
-    fi
+    base="$1"
     ep="$2"
     tqual="$3"
 fi
     ep="$2"
     tqual="$3"
 fi
@@ -158,7 +145,21 @@ if [ "$nextep" = y -a -r nextep ]; then
     fi
 fi
 if [ -z "$file" ]; then
     fi
 fi
 if [ -z "$file" ]; then
-    file="$(findfile "$base - " "$ep" "$tqual")"
+    if [ "$base" = . ]; then
+       if [ -r curser ]; then
+           curser="$(<curser)"
+       else
+           curser=
+       fi
+    else
+       curser="$base"
+    fi
+    if [ -n "$curser" ]; then
+       file="$(findfile "$dirbase $curser - " "$ep" "$tqual")" || \
+           file="$(findfile "$curser - " "$ep" "$tqual")"
+    else
+       file="$(findfile "$dirbase - " "$ep" "$tqual")"
+    fi
 fi
 
 if [ -z "$file" -o ! -r "$file" ]; then
 fi
 
 if [ -z "$file" -o ! -r "$file" ]; then