I don't like getopts. Don't know why. I just don't.

This commit is contained in:
Jack L. Frost 2015-02-06 13:40:27 +03:00
parent 3d148e6b4a
commit 07d1805d13

65
zpac
View File

@ -177,37 +177,50 @@ main() {
source "$HOME/.config/zpac.rc.sh" source "$HOME/.config/zpac.rc.sh"
fi fi
while getopts 'sASdw:f' opt while (( $# )); do
do case "$1" in
case "$opt" in (--) shift; break;;
(h) usage; return 0;;
(s) action='search';; (-*)
(A) while read -n1 c
action='search' do
flag_search_aur=1;; case "$c" in
(S) (-|'') :;;
action='search'
flag_search_syncdb=1;;
(d) (h) usage; return 0;;
if [[ "$action" == 'get' ]]; then
flag_get_deps=1 (s) action='search';;
else (A)
action='get' action='search'
fi 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";; (*) shift; break;;
(f) flag_force=1;;
(\?)
err "Unknown key: $OPTARG"
usage
return 1
;;
esac esac
done shift $(( OPTIND - 1 )) shift
done
(( flag_search_aur && flag_search_syncdb )) && { (( flag_search_aur && flag_search_syncdb )) && {
unset flag_search_aur flag_search_syncdb unset flag_search_aur flag_search_syncdb