log=y
unset pretend printfile
-while [ "${1:0:1}" = - ]; do
- a="$1"
- shift
- case "$a" in
- -h)
- echo "usage: planime [-fdhtCL] [-A PLAYER-ARGS... ;] [-s PAR VAL] [--] [NAME-QUAL] [EP|.] [TYPE-QUAL]" >&2
+usage() {
+ echo "usage: planime [-fdhtCL] [-A PLAYER-ARGS... ;] [-s PAR=VAL] [--] [NAME-QUAL] [EP|.] [TYPE-QUAL]"
+}
+
+while getopts hdtCLA:s:fv opt; do
+ case "$opt" in
+ h)
+ usage
exit 0
;;
- -d)
+ d)
debug=y
;;
- -t)
+ t)
cmdline=("${cmdline[@]}" -audio-device 'alsa/hdmi:CARD=PCH,DEV=0')
DISPLAY=:1
chwp=y
;;
- -C)
+ C)
pretend=y
;;
- -L)
+ L)
log=
;;
- -A)
- while :; do
- if [ $# -lt 1 ]; then
+ A)
+ while [ "$OPTARG" != \; ]; do
+ cmdline+=("$OPTARG")
+ if [ "$OPTIND" -gt $# ]; then
echo "planime: unterminated argument list" >&2
exit 1
fi
- a="$1"
- shift
- if [ "$a" = \; ]; then
- break;
- fi
- cmdline=("${cmdline[@]}" "$a")
+ OPTARG="${!OPTIND}"
+ let OPTIND++
done
;;
- -s)
- savepar="$1"
- shift
- saveval="$1"
- shift
+ s)
+ p="$(expr index "$OPTARG" =)"
+ if [ "$p" -le 0 ]; then
+ usage >&2
+ exit 1
+ fi
+ savepar="${OPTARG:0:p}"
+ let p++
+ saveval="${OPTARG:p}"
;;
- -f)
+ f)
printfile=y
;;
- -v)
- cmdline=("${cmdline[@]}" -v)
- ;;
- --)
- break
+ v)
+ cmdline+=(-v)
;;
*)
- echo "planime: unknown option \`$a'"
+ usage >&2
exit 1
;;
esac
done
+shift $((OPTIND - 1))
dirbase="$(basename "$(pwd)")"
base=.