planime: Added base aliases.
authorFredrik Tolf <fredrik@dolda2000.com>
Fri, 19 Dec 2014 22:18:22 +0000 (23:18 +0100)
committerFredrik Tolf <fredrik@dolda2000.com>
Fri, 19 Dec 2014 22:18:22 +0000 (23:18 +0100)
planime

diff --git a/planime b/planime
index a25761e..b6e27cd 100755 (executable)
--- a/planime
+++ b/planime
@@ -14,12 +14,25 @@ scorefile() {
     fi
 }
 
+findbase() {
+    if [ -r aliases ]; then
+       while read alias rest; do
+           if [ "$alias" = "$1" ]; then
+               echo "$rest"
+               return
+           fi
+       done <aliases
+    fi
+    echo "$1"
+}
+
 findfile() {
     if [ -n "$debug" ]; then echo "finding base='$1', ep='$2', qual='$3'" >&2; fi
-    local file tail eq eqt m matches max score
+    local base file tail eq eqt m matches max score
     matches=()
-    for file in "$1"*; do
-       tail="${file#"$1"}"
+    base="$(findbase "$1")"
+    for file in "$base"*; do
+       tail="${file#"$base"}"
        eq="${tail%.*}"
        m=n
        if [ "${eq%% *}" -eq "$2" ] 2>/dev/null; then
@@ -152,7 +165,7 @@ if [ -z "$file" ]; then
            curser=
        fi
     else
-       curser="$base"
+       curser="$(findbase "$base")"
     fi
     if [ -n "$curser" ]; then
        file="$(findfile "$dirbase $curser - " "$ep" "$tqual")" || \