a="$1"
shift
case "$a" in
+ -h)
+ echo "usage: planime [-ht] [-s PAR VAL] [NAME-QUAL] [EP|.] [TYPE-QUAL]" >&2
+ exit 0
+ ;;
-t)
cmdline=("${cmdline[@]}" -ao oss:/dev/dsp1)
;;
esac
done
-if [ $# -lt 1 ]; then
- echo "usage: planime [QUAL] EPNUM" >&2
- exit 1
-fi
-if [ $# -eq 1 ]; then
- ep="$1"
- unset qual
+base="$(basename "$(pwd)")"
+nextep=n
+file=
+tqual=
+if [ $# -eq 0 ]; then
+ nextep=y
+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
+ fi
elif [ $# -eq 2 ]; then
- qual="$1"
+ if findfile "$base - " "$1" "$2" >/dev/null; then
+ ep="$1"
+ tqual="$2"
+ else
+ base="$base $1"
+ ep="$2"
+ fi
+else
+ base="$base $1"
ep="$2"
+ tqual="$3"
+fi
+if [ "$ep" = . ]; then nextep=y; fi
+if [ "$nextep" = y -a -r nextep ]; then
+ ep="$(<nextep)"
+ if ! isnum "$ep"; then
+ echo "planime: nextep is non-numeric" >&2
+ exit 1
+ fi
fi
+file="$(findfile "$base - " "$ep" "$qual")"
+
+if [ -z "$file" ]; then
+ echo "planime: no matching file found" >&2
+ exit 1
+fi
+
+echo "$file"
+exit 0
if [ ! -r "$ep" ]; then
if [ -z "$qual" ]; then