woo proper handling

This commit is contained in:
Jack L. Frost 2015-02-09 16:22:26 +03:00
parent 34775cfe97
commit bf18623e06

63
zpac
View File

@ -142,6 +142,41 @@ abs.get() {
svn checkout "svn://svn.archlinux.org/${svn_repo}/${1}/trunk" "${cfg_workdir}/${1}" svn checkout "svn://svn.archlinux.org/${svn_repo}/${1}/trunk" "${cfg_workdir}/${1}"
} }
args_norm() {
declare arg opt c
declare -g argv
while (( $# )); do
unset -v arg opt c
case "$1" in
(--) argv+=( "$1" ); break;;
(--*)
IFS='=' read arg opt <<< "$1"
argv+=( "$arg" )
[[ "$opt" ]] && {
argv+=( "$opt" )
}
;;
(-*)
while read -n1 c
do
case "$c" in
-|'') :;;
*) argv+=( "-$c" );;
esac
done <<< "$1"
;;
(*) argv+=( "$1" );;
esac
shift
done
}
main() { main() {
if [[ -f "$HOME/.config/zpac.rc.sh" ]]; then if [[ -f "$HOME/.config/zpac.rc.sh" ]]; then
source "$HOME/.config/zpac.rc.sh" source "$HOME/.config/zpac.rc.sh"
@ -151,23 +186,17 @@ main() {
case "$1" in case "$1" in
(--) shift; break;; (--) shift; break;;
(-*) (-h) usage; return 0;;
while read -n1 c
do
case "$c" in
(-|'') :;;
(h) usage; return 0;; (-s) action='search';;
(-A)
(s) action='search';;
(A)
action='search' action='search'
flag_search_aur=1;; flag_search_aur=1;;
(S) (-S)
action='search' action='search'
flag_search_syncdb=1;; flag_search_syncdb=1;;
(d) (-d)
if [[ "$action" == 'get' ]]; then if [[ "$action" == 'get' ]]; then
flag_get_deps=1 flag_get_deps=1
else else
@ -175,20 +204,17 @@ main() {
fi fi
;; ;;
(w) (-w)
cfg_workdir="$2" cfg_workdir="$2"
shift;; shift;;
(f) flag_force=1;; (-f) flag_force=1;;
(*) (-*)
err "Unknown key: $1" err "Unknown key: $1"
usage usage
return 1 return 1
;; ;;
esac
done <<< "$1"
;;
(*) break;; (*) break;;
esac esac
@ -273,4 +299,5 @@ main() {
esac esac
} }
main "$@" args_norm "$@"
main "${argv[@]}"