Handle arguments with getopt: it supports arguments with spaces.
This commit is contained in:
parent
c8b1f67bdd
commit
3d148e6b4a
37
zpac
37
zpac
|
@ -22,6 +22,7 @@ usage() {
|
|||
-A Search only in AUR. Implies -s.
|
||||
-d Get the package sources (default).
|
||||
Set twice to also get the dependencies.
|
||||
-f Force downloading package sources even if they are already present in the working directory.
|
||||
EOF
|
||||
}
|
||||
|
||||
|
@ -81,14 +82,14 @@ aur.get() {
|
|||
|
||||
cd "$cfg_workdir"
|
||||
|
||||
echo "Downloading ${cfg_aur_url}${tarball_path}"
|
||||
echo "Working in ${cfg_workdir}"
|
||||
|
||||
echo "Downloading ${pkg_base}"
|
||||
{ curl -skL "${cfg_aur_url}${tarball_path}" | gzip -d | tar x; } || {
|
||||
err "Fail!"
|
||||
return 1
|
||||
}
|
||||
|
||||
echo ": ${cfg_workdir}/${pkg_base}"
|
||||
|
||||
if (( flag_get_deps )); then
|
||||
unset depends makedepends
|
||||
|
||||
|
@ -104,6 +105,8 @@ aur.get() {
|
|||
aur_deps_count=$( jshon -e resultcount <<< "$aur_deps_api_data" )
|
||||
|
||||
if (( aur_deps_count )); then
|
||||
echo "Getting dependencies for ${pkg_base}."
|
||||
|
||||
aur_deps=( $( jshon -e results -a -e Name -u <<< "$aur_deps_api_data" ) )
|
||||
|
||||
for i in "${aur_deps[@]}"; do
|
||||
|
@ -174,19 +177,20 @@ main() {
|
|||
source "$HOME/.config/zpac.rc.sh"
|
||||
fi
|
||||
|
||||
while (( $# )); do
|
||||
case "$1" in
|
||||
(-h) usage; return 0;;
|
||||
while getopts 'sASdw:f' opt
|
||||
do
|
||||
case "$opt" in
|
||||
(h) usage; return 0;;
|
||||
|
||||
(-s) action='search';;
|
||||
(-A)
|
||||
(s) action='search';;
|
||||
(A)
|
||||
action='search'
|
||||
flag_search_aur=1;;
|
||||
(-S)
|
||||
(S)
|
||||
action='search'
|
||||
flag_search_syncdb=1;;
|
||||
|
||||
(-d)
|
||||
(d)
|
||||
if [[ "$action" == 'get' ]]; then
|
||||
flag_get_deps=1
|
||||
else
|
||||
|
@ -194,19 +198,16 @@ main() {
|
|||
fi
|
||||
;;
|
||||
|
||||
(-f) flag_force=1;;
|
||||
(w) cfg_workdir="$OPTARG";;
|
||||
(f) flag_force=1;;
|
||||
|
||||
(--) shift; break;;
|
||||
(-*)
|
||||
err "Unknown key: $1"
|
||||
(\?)
|
||||
err "Unknown key: $OPTARG"
|
||||
usage
|
||||
return 1
|
||||
;;
|
||||
|
||||
*) break;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
done shift $(( OPTIND - 1 ))
|
||||
|
||||
(( flag_search_aur && flag_search_syncdb )) && {
|
||||
unset flag_search_aur flag_search_syncdb
|
||||
|
|
Loading…
Reference in New Issue
Block a user