aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorJason A. Donenfeld <Jason@zx2c4.com>2014-04-23 00:57:10 +0200
committerJason A. Donenfeld <Jason@zx2c4.com>2014-04-23 00:57:10 +0200
commit35935603e560e2c111ba436469ef320356f4e52e (patch)
tree53d5e397fbd2b03499cf1bebf568c635da85552c /src
parentElide variable declarations. (diff)
downloadpassword-store-35935603e560e2c111ba436469ef320356f4e52e.tar.xz
password-store-35935603e560e2c111ba436469ef320356f4e52e.zip
reencrypt: support bash 3
Diffstat (limited to 'src')
-rwxr-xr-xsrc/password-store.sh14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/password-store.sh b/src/password-store.sh
index ce1646f..b67ebc7 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -86,12 +86,7 @@ agent_check() {
}
reencrypt_path() {
local passfile passfile_dir passfile_display passfile_temp prev_gpg_recipients gpg_keys current_keys config
- local -A groups
- while read -r config; do
- [[ $config =~ cfg:group:* ]] || continue
- groups[$(cut -d : -f 3 <<<"$config")]="$(cut -d : -f 4 <<<"$config")"
- done < <($GPG --list-config --with-colons)
-
+ local groups="$($GPG --list-config --with-colons | grep ^cfg:group:.*)"
while read -r -d "" passfile; do
passfile_dir="${passfile%/*}"
passfile_dir="${passfile_dir#$PREFIX}"
@@ -103,10 +98,11 @@ reencrypt_path() {
set_gpg_recipients "$passfile_dir"
if [[ $prev_gpg_recipients != "${GPG_RECIPIENTS[@]}" ]]; then
for config in "${!GPG_RECIPIENTS[@]}"; do
- [[ ${groups[${GPG_RECIPIENTS[$config]}]} ]] || continue
+ local group="$(sed -n "s/^cfg:group:${GPG_RECIPIENTS[$config]}:\\(.*\\)$/\\1/p" <<<"$groups" | head -n 1)"
+ [[ -z $group ]] && continue
local saved_ifs="$IFS"
IFS=";"
- GPG_RECIPIENTS+=( ${groups[${GPG_RECIPIENTS[$config]}]} )
+ GPG_RECIPIENTS+=( $group )
IFS="$saved_ifs"
unset GPG_RECIPIENTS[$config]
done
@@ -120,7 +116,7 @@ reencrypt_path() {
mv "$passfile_temp" "$passfile" || rm -f "$passfile_temp"
fi
prev_gpg_recipients="${GPG_RECIPIENTS[@]}"
- done < <(find "$PREFIX" -iname '*.gpg' -print0)
+ done < <(find "$1" -iname '*.gpg' -print0)
}
check_sneaky_paths() {
for path in "$@"; do