repo-add: move command invocation out of arg parsing loop
Signed-off-by: Dave Reisner <d@falconindy.com>
This commit is contained in:
parent
6f5a90edb3
commit
122b4c2187
1 changed files with 14 additions and 11 deletions
|
@ -531,9 +531,10 @@ trap 'trap_exit "$(gettext "TERM signal caught. Exiting...")"' TERM HUP QUIT
|
||||||
trap 'trap_exit "$(gettext "Aborted by user! Exiting...")"' INT
|
trap 'trap_exit "$(gettext "Aborted by user! Exiting...")"' INT
|
||||||
trap 'trap_exit "$(gettext "An unknown error has occured. Exiting...")"' ERR
|
trap 'trap_exit "$(gettext "An unknown error has occured. Exiting...")"' ERR
|
||||||
|
|
||||||
|
declare -a args
|
||||||
success=0
|
success=0
|
||||||
# parse arguments
|
# parse arguments
|
||||||
while [[ $# > 0 ]]; do
|
while (( $# )); do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
-q|--quiet) QUIET=1;;
|
-q|--quiet) QUIET=1;;
|
||||||
-d|--delta) DELTA=1;;
|
-d|--delta) DELTA=1;;
|
||||||
|
@ -564,21 +565,23 @@ while [[ $# > 0 ]]; do
|
||||||
VERIFY=1
|
VERIFY=1
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
if [[ -z $REPO_DB_FILE ]]; then
|
args+=("$1")
|
||||||
REPO_DB_FILE="$1"
|
|
||||||
LOCKFILE="$REPO_DB_FILE.lck"
|
|
||||||
check_repo_db
|
|
||||||
else
|
|
||||||
case "$cmd" in
|
|
||||||
repo-add) add $1 && success=1 ;;
|
|
||||||
repo-remove) remove $1 && success=1 ;;
|
|
||||||
esac
|
|
||||||
fi
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
REPO_DB_FILE=${args[0]}
|
||||||
|
LOCKFILE=$REPO_DB_FILE.lck
|
||||||
|
check_repo_db
|
||||||
|
|
||||||
|
for arg in "${args[@]:1}"; do
|
||||||
|
case "$cmd" in
|
||||||
|
repo-add) add "$arg" ;;
|
||||||
|
repo-remove) remove "$arg" ;;
|
||||||
|
esac && success=1
|
||||||
|
done
|
||||||
|
|
||||||
# if at least one operation was a success, re-zip database
|
# if at least one operation was a success, re-zip database
|
||||||
if (( success )); then
|
if (( success )); then
|
||||||
msg "$(gettext "Creating updated database file '%s'")" "$REPO_DB_FILE"
|
msg "$(gettext "Creating updated database file '%s'")" "$REPO_DB_FILE"
|
||||||
|
|
Loading…
Add table
Reference in a new issue