pacman-key: refactor post parse opt check into a case

This is a cleaner expression of the same information.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
Dave Reisner 2011-07-20 13:26:44 -04:00 committed by Dan McGee
parent 768d3589a3
commit 98073afe55
1 changed files with 11 additions and 12 deletions

View File

@ -350,18 +350,17 @@ GPG_PACMAN="gpg --homedir ${PACMAN_KEYRING_DIR} --no-permission-warning"
# check only a single operation has been given
numopt=$(( ADD + DELETE + EDITKEY + EXPORT + FINGER + INIT + LIST + RECEIVE + RELOAD + UPDATEDB + VERIFY ))
if (( ! numopt )); then
error "$(gettext "No operations specified")"
echo
usage
exit 1
fi
if (( numopt != 1 )); then
error "$(gettext "Multiple operations specified")"
printf "$(gettext "Please run %s with each operation separately\n")" "pacman-key"
exit 1
fi
case $numopt in
0)
error "$(gettext "no operation specified (use -h for help)")"
exit 1
;;
[!1])
error "$(gettext "Multiple operations specified")"
printf "$(gettext "Please run %s with each operation separately\n")" "pacman-key"
exit 1
;;
esac
(( ! INIT )) && check_keyring