Smarter args

Signed-off-by: fbt <fbt@fleshless.org>
This commit is contained in:
Jack L. Frost 2020-10-03 19:44:19 +03:00
parent b63ae67204
commit df4e1d0370
1 changed files with 17 additions and 10 deletions

27
ufw
View File

@ -290,7 +290,7 @@ set_argv() {
unset -v arg opt c unset -v arg opt c
case "$1" in case "$1" in
(--) argv+=( "$1" ); break;; (--) argv+=( "$1" ); shift; break;;
(--*) (--*)
IFS='=' read arg opt <<< "$1" IFS='=' read arg opt <<< "$1"
@ -315,6 +315,10 @@ set_argv() {
esac esac
shift shift
done done
if (( $# )); then
argv+=( "$@" )
fi
} }
main() { main() {
@ -396,11 +400,17 @@ main() {
return 1 return 1
;; ;;
*) break;; *) args+=( "$1" );;
esac esac
shift shift
done done
# Catch the args after --
if (( $# )); then
args+=( "$@" )
shift
fi
TEMPDIR="$cfg_tmp_dir" TEMPDIR="$cfg_tmp_dir"
for i in "$cfg_tmp_dir"; do for i in "$cfg_tmp_dir"; do
@ -410,20 +420,17 @@ main() {
case "${action:-upload}" in case "${action:-upload}" in
upload) upload)
get_token || return $? get_token || return $?
(( ${#args[@]} )) || return 1
if (( $# )); then for t in "${args[@]}"; do
for t in "$@"; do upload "$t"
upload "$t" done
done
else
upload
fi
;; ;;
url) url)
get_token || return $? get_token || return $?
for t in "$@"; do for t in "${args[@]}"; do
get_shortlink "$1" get_shortlink "$1"
done done
;; ;;