Use shift to simplify check for positional argument

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

42
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,29 +718,25 @@ 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 if [[ $program == auto_show ]] || [[ $program == auto_hide ]]; then
if [[ $program == auto_show ]] || [[ $program == auto_hide ]]; then wm_autoset_for_hide_show
wm_autoset_for_hide_show
else
wm_autoset_for_dropdown
fi
fi
if $clearwid; then
> /tmp/tdrop/"$program$num"
elif [[ $program == toggle_auto_hide ]]; then
toggle_auto_hide
elif [[ $program == auto_hide ]]; then
auto_hide
elif [[ $program == auto_show ]]; then
auto_show
else else
wid_toggle wm_autoset_for_dropdown
fi fi
fi
if $clearwid; then
> /tmp/tdrop/"$program$num"
elif [[ $program == toggle_auto_hide ]]; then
toggle_auto_hide
elif [[ $program == auto_hide ]]; then
auto_hide
elif [[ $program == auto_show ]]; then
auto_show
else else
print_help illegal_opt wid_toggle
fi fi
# vim is dumb # vim is dumb
# vim: set ft=sh noet: # vim: set ft=sh noet:

Loading…
Cancel
Save