[pacman-dev] [PATCH 3/4] pacman-key: check only a single operation has been specified
Allan McRae
allan at archlinux.org
Fri Jul 8 21:59:29 EDT 2011
Follow the example of gpg and only allow a single operation to be
specified each time. Prevents having to deal with conflicting
variable names and potential issues due to the order in which the
operations are run.
Signed-off-by: Allan McRae <allan at archlinux.org>
---
scripts/pacman-key.sh.in | 16 ++++++++++++++++
1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/scripts/pacman-key.sh.in b/scripts/pacman-key.sh.in
index 5be627f..55c2abe 100644
--- a/scripts/pacman-key.sh.in
+++ b/scripts/pacman-key.sh.in
@@ -308,6 +308,22 @@ PACMAN_KEYRING_DIR=${PACMAN_KEYRING_DIR:- at sysconfdir@/pacman.d/gnupg}
GPG_PACMAN="gpg --homedir ${PACMAN_KEYRING_DIR} --no-permission-warning"
+# check only a single operation has been given
+numopt=$(( ADD + DELETE + EDITKEY + EXPORT + FINGER + LIST + RECEIVE + RELOAD + UPDATEBD ))
+
+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
+
(( ADD )) && ${GPG_PACMAN} --quiet --batch --import "${KEYFILES[@]}"
(( DELETE )) && ${GPG_PACMAN} --quiet --batch --delete-key --yes "${KEYIDS[@]}"
--
1.7.6
More information about the pacman-dev
mailing list