summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorDave Reisner <dreisner@archlinux.org>2011-09-25 21:24:53 +0200
committerDan McGee <dan@archlinux.org>2011-09-26 23:02:19 +0200
commit507b01b912d77f0cc5422e689623f1b19c208525 (patch)
tree26923aaf2b4a3f78a62dd8cce44dee3d5222f127 /scripts
parentb6ccae2d182899eaf199e868963646b3a14f7e8b (diff)
downloadpacman-507b01b912d77f0cc5422e689623f1b19c208525.tar.gz
pacman-507b01b912d77f0cc5422e689623f1b19c208525.tar.xz
pacman-key: allow get_from to return a default value
Keep the non-zero return val to let the caller know that the key wasn't found. Signed-off-by: Dave Reisner <dreisner@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/pacman-key.sh.in6
1 files changed, 4 insertions, 2 deletions
diff --git a/scripts/pacman-key.sh.in b/scripts/pacman-key.sh.in
index cf63be87..212d0fe1 100644
--- a/scripts/pacman-key.sh.in
+++ b/scripts/pacman-key.sh.in
@@ -95,7 +95,8 @@ There is NO WARRANTY, to the extent permitted by law.\n")"
# read the config file "$1" which has key=value pairs, and return the key which
# matches "$2". the equals sign between pairs may be surrounded by any amount
-# of whitespace.
+# of whitespace. Optionally, "$3" can be specified which is the default value
+# when no key is found.
get_from() {
while IFS='=' read -r key value; do
[[ -z $key || ${key:0:1} = '#' ]] && continue
@@ -105,6 +106,7 @@ get_from() {
return 0
fi
done < "$1"
+ printf '%s\n' "$3"
return 1
}
@@ -437,7 +439,7 @@ fi
# if PACMAN_KEYRING_DIR isn't assigned, try to get it from the config
# file, falling back on a hard default
-PACMAN_KEYRING_DIR=${PACMAN_KEYRING_DIR:-$(get_from "$CONFIG" "GPGDir" || echo "@sysconfdir@/pacman.d/gnupg")}
+PACMAN_KEYRING_DIR=${PACMAN_KEYRING_DIR:-$(get_from "$CONFIG" "GPGDir" "@sysconfdir@/pacman.d/gnupg")}
GPG_PACMAN=(gpg --homedir ${PACMAN_KEYRING_DIR} --no-permission-warning)
if [[ -n ${KEYSERVER} ]]; then