Use shift to simplify check for positional argument

long-opts
noctuid 9 years ago
parent 7442bf9b31
commit b472eda261

10
tdrop

@ -111,11 +111,11 @@ do
*) print_help illegal_opt;; *) print_help illegal_opt;;
esac esac
done done
program=${*:0-1} shift "$((OPTIND-1))"
program=$1
# ensure that positional argument exists # ensure that positional argument exists
if [[ -z $program ]] || [[ $program =~ ^- ]] || \ if [[ -z $program ]]; then
[[ ${*:0-2:1} =~ ^-[b-ln-z]$ ]]; then
echo "1 positional argument is required." \ echo "1 positional argument is required." \
"For help use -h or --help or see the manpage." | \ "For help use -h or --help or see the manpage." | \
tee -a /tmp/tdrop/log tee -a /tmp/tdrop/log
@ -718,7 +718,6 @@ auto_show() {
# Main # Main
# #
if [[ -n $1 ]]; then
if $auto_detect_wm; then if $auto_detect_wm; then
wm=$(get_window_manager) wm=$(get_window_manager)
wm_autoset_for_all wm_autoset_for_all
@ -739,8 +738,5 @@ if [[ -n $1 ]]; then
else else
wid_toggle wid_toggle
fi fi
else
print_help illegal_opt
fi
# vim is dumb # vim is dumb
# vim: set ft=sh noet: # vim: set ft=sh noet:

Loading…
Cancel
Save