summaryrefslogtreecommitdiff
path: root/localgpgcleankeyring
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2015-08-06 13:48:16 +0200
committerJonas Smedegaard <dr@jones.dk>2015-08-06 13:48:16 +0200
commitdbc3b2a2bb0be2958d3bc6a55b895662399da0b3 (patch)
tree839416b4135d62802383acf7f0e56ceee9d265d4 /localgpgcleankeyring
parenta19c756b54921230b0cd82847454d2ac2183fabc (diff)
Keep all keys with secret key.
Diffstat (limited to 'localgpgcleankeyring')
-rwxr-xr-xlocalgpgcleankeyring10
1 files changed, 5 insertions, 5 deletions
diff --git a/localgpgcleankeyring b/localgpgcleankeyring
index ade8e47..9245f9e 100755
--- a/localgpgcleankeyring
+++ b/localgpgcleankeyring
@@ -3,10 +3,10 @@
# origin: https://scruss.com/blog/2013/05/12/clean-up-your-gnupg-keyring/
-# my key should probably be the first secret key listed
-mykey=$(gpg --list-secret-keys --with-colons | grep '^sec' | cut -d: -f5 | head -1)
+# my keys are those with a corresponding secret key
+mykeys=$(gpg --list-secret-keys --with-colons | grep '^sec' | cut -d: -f5)
if
- [ -z "$mykey" ]
+ [ -z "$mykeys" ]
then
# exit if no key string
echo "Can't get user's key ID"
@@ -14,10 +14,10 @@ then
fi
# all of the people who have signed my key
-mysigners=$(gpg --list-sigs --with-colons $mykey | grep '^sig' | cut -d: -f5 | sort -u)
+mysigners=$(gpg --list-sigs --with-colons $mykeys | grep '^sig' | cut -d: -f5 | sort -u)
# keep all of the signers, plus my key (if I haven't self-signed)
-keepers=$(echo $mykey $mysigners | tr ' ' '\012' | sort -u)
+keepers=$(echo $mykeys $mysigners | tr ' ' '\012' | sort -u)
# the keepers list in egrep syntax: ^(key|key|…)
keepers_egrep=$(echo $keepers | sed 's/^/^(/; s/$/)/; s/ /|/g;')