From 53bf3a2c099192d483bf4108772297b6fc215140 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Tue, 25 Sep 2018 19:21:19 +0200 Subject: better options --- custom/uucp-mediaserver/scripts/queue | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) (limited to 'custom/uucp-mediaserver/scripts') diff --git a/custom/uucp-mediaserver/scripts/queue b/custom/uucp-mediaserver/scripts/queue index 1644bd2d..49c7a3bc 100755 --- a/custom/uucp-mediaserver/scripts/queue +++ b/custom/uucp-mediaserver/scripts/queue @@ -46,29 +46,13 @@ suffix=${base##*.} force=0 noCall=false prepend=false -while getopts "frp" OPT; do - case $OPT in - r) - noCall=true - ;; - f) - if [[ ${@:$OPTIND} =~ ^[0-9]+$ ]];then - force=${@:$OPTIND} - OPTIND=$((OPTIND+1)) - else - force=1 - fi - ;; - p) - prepend=true - ;; - \?) - echo "Invalid option -${OPTARG}" >&2 - exit 2 - ;; - esac -done -shift $((OPTIND-1)) + +typeset -A opts +zparseopts -A opts -- r p f:: + +force=${opts[-f]:-${+opts[-f]}} +[[ -v opts[-p] ]] && prepend=true +[[ -v opts[-r] ]] && noCall=true printf "force: %d, noCall: %s, prepend: %s\n" ${force} ${noCall} ${prepend} | debug -- cgit v1.2.3