Don't clobber STDIN.
[utils.git] / planime
diff --git a/planime b/planime
index fbc543b..62c01a4 100755 (executable)
--- a/planime
+++ b/planime
@@ -95,7 +95,9 @@ if [ "$nextep" = y -a -r nextep ]; then
        exit 1
     fi
 fi
-file="$(findfile "$base - " "$ep" "$qual")"
+if [ -z "$file" ]; then
+    file="$(findfile "$base - " "$ep" "$tqual")"
+fi
 
 if [ -z "$file" -o ! -r "$file" ]; then
     echo "planime: no matching file found" >&2
@@ -111,22 +113,31 @@ case "${file##*.}" in
        ;;
 esac
 
-ifile=".${ep}.info"
+ifile=".${file}.info"
 
 if [ -n "$savepar" ]; then
     if [ -r "$ifile" ]; then
-       egrep -v "^${savepar}:" "$ifile" >"$ifile.new"
+       egrep -v "^${savepar} " "$ifile" >"$ifile.new"
        mv -f "$ifile.new" "$ifile"
     fi
-    echo "$savepar: $saveval" >>"$ifile"
+    echo "$savepar $saveval" >>"$ifile"
     exit 0
 fi
 
 unset delay
 
 if [ -r "$ifile" ]; then
-    delay="$(sed -n 's/delay *: *\([^ ]*\)$/\1/p' <"$ifile")"
-    cmdline=("${cmdline[@]}" -delay "$delay")
+    exec 3<&0
+    exec 0<"$ifile"
+    while read par arg; do
+       if [ "$par" = delay ]; then
+           cmdline=("${cmdline[@]}" -delay "$arg")
+       elif [ "$par" = aspect ]; then
+           cmdline=("${cmdline[@]}" -aspect "$arg")
+       fi
+    done
+    exec 0<&3
+    exec 3<&-
 else
     cmdline=("${cmdline[@]}" "${defopts[@]}")
 fi
@@ -157,9 +168,12 @@ if [ "$nextep" = y ]; then
            ;;
     esac
     if [ "$save" = y ]; then
-       echo "$(($ep + 1))" >nextep
+       let ep++
+       echo "$ep" >nextep
     fi
     if [ "$cont" = y ]; then
        exec "${origargs[@]}"
+    else
+       echo "nextep is $ep"
     fi
 fi