I don't like getopts. Don't know why. I just don't.
This commit is contained in:
parent
3d148e6b4a
commit
07d1805d13
65
zpac
65
zpac
|
@ -177,37 +177,50 @@ main() {
|
|||
source "$HOME/.config/zpac.rc.sh"
|
||||
fi
|
||||
|
||||
while getopts 'sASdw:f' opt
|
||||
do
|
||||
case "$opt" in
|
||||
(h) usage; return 0;;
|
||||
while (( $# )); do
|
||||
case "$1" in
|
||||
(--) shift; break;;
|
||||
|
||||
(s) action='search';;
|
||||
(A)
|
||||
action='search'
|
||||
flag_search_aur=1;;
|
||||
(S)
|
||||
action='search'
|
||||
flag_search_syncdb=1;;
|
||||
(-*)
|
||||
while read -n1 c
|
||||
do
|
||||
case "$c" in
|
||||
(-|'') :;;
|
||||
|
||||
(d)
|
||||
if [[ "$action" == 'get' ]]; then
|
||||
flag_get_deps=1
|
||||
else
|
||||
action='get'
|
||||
fi
|
||||
(h) usage; return 0;;
|
||||
|
||||
(s) action='search';;
|
||||
(A)
|
||||
action='search'
|
||||
flag_search_aur=1;;
|
||||
(S)
|
||||
action='search'
|
||||
flag_search_syncdb=1;;
|
||||
|
||||
(d)
|
||||
if [[ "$action" == 'get' ]]; then
|
||||
flag_get_deps=1
|
||||
else
|
||||
action='get'
|
||||
fi
|
||||
;;
|
||||
|
||||
(w) cfg_workdir="$OPTARG";;
|
||||
(f) flag_force=1;;
|
||||
|
||||
(*)
|
||||
err "Unknown key: $OPTARG"
|
||||
usage
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
;;
|
||||
|
||||
(w) cfg_workdir="$OPTARG";;
|
||||
(f) flag_force=1;;
|
||||
|
||||
(\?)
|
||||
err "Unknown key: $OPTARG"
|
||||
usage
|
||||
return 1
|
||||
;;
|
||||
(*) shift; break;;
|
||||
esac
|
||||
done shift $(( OPTIND - 1 ))
|
||||
shift
|
||||
done
|
||||
|
||||
(( flag_search_aur && flag_search_syncdb )) && {
|
||||
unset flag_search_aur flag_search_syncdb
|
||||
|
|
Loading…
Reference in New Issue
Block a user