[pass] [PATCH 2/2] reencrypt_path: change to a more robust way of getting current keys

duncankburke at gmail.com duncankburke at gmail.com
Sat Sep 20 08:58:35 CEST 2014


From: Duncan Burke <duncankburke at gmail.com>

Empty lines were being left in the output of current_keys, which
would break the equality check. This was replaced with sed, which
removes non-matching lines. Unfortunately, gpg -v --list-only does
not support --with-colons, so this still isn't guaranteed to work for
all versions of gpg.

Signed-off-by: Duncan Burke <duncankburke at gmail.com>
---
 src/password-store.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/password-store.sh b/src/password-store.sh
index cf57fd3..a0b8dc3 100755
--- a/src/password-store.sh
+++ b/src/password-store.sh
@@ -123,7 +123,7 @@ reencrypt_path() {
 			done
 			gpg_keys="$(printf "%s\n" ${gpg_keys[*]} | LC_ALL=C sort -u)"
 		fi
-		current_keys="$($GPG -v --no-secmem-warning --no-permission-warning --list-only --keyid-format long "$passfile" 2>&1 | cut -d ' ' -f 5 | LC_ALL=C sort -u)"
+		current_keys="$($GPG -v --no-secmem-warning --no-permission-warning --list-only --keyid-format long "$passfile" 2>&1 | sed -n "s/^.*public key is \\(.*\\)$/\\1/p" | LC_ALL=C sort -u)"
 
 		if [[ $gpg_keys != "$current_keys" ]]; then
 			echo "$passfile_display: reencrypting to ${gpg_keys//$'\n'/ }"
-- 
2.0.0



More information about the Password-Store mailing list