Use shift to simplify check for positional argument

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

24
tdrop

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

Loading…
Cancel
Save