From: Fredrik Tolf Date: Fri, 19 Dec 2014 22:18:22 +0000 (+0100) Subject: planime: Added base aliases. X-Git-Url: http://git.dolda2000.com/gitweb/?a=commitdiff_plain;h=d67a5cdd8bfb438ed6ebf405fedb9879134b1de1;p=utils.git planime: Added base aliases. --- diff --git a/planime b/planime index a25761e..b6e27cd 100755 --- 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 &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")" || \