summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKr1ss <kr1ss.x@yandex.com>2019-05-15 20:19:55 +0200
committerKr1ss <kr1ss.x@yandex.com>2019-05-15 20:19:55 +0200
commit49d2e12125f7881e43ebc57895c8eb8a13a8706c (patch)
treeb0d5a121667b97c5be1a808e2c93dc62bfedfa98
parentbc3cceaf77cbf8bd87d7a6284ef37de8f8c9bca6 (diff)
check if .gpg-id is in the pass store on startup
The current test did not terminate the script in cases when the user already has a private GPG key, but they'd not initialized the password store. This leads to an infinite loop in the `getpass()` function. The commit fixes https://github.com/LukeSmithxyz/mutt-wizard/issues/204
-rwxr-xr-xbin/mw6
1 files changed, 5 insertions, 1 deletions
diff --git a/bin/mw b/bin/mw
index 636a837..a415f0e 100755
--- a/bin/mw
+++ b/bin/mw
@@ -1,6 +1,10 @@
#!/bin/sh
command -V gpg >/dev/null 2>&1 && GPG="gpg" || GPG="gpg2"
-! "$GPG" --list-secret-keys $(cat "$HOME/.password-store/.gpg-id") >/dev/null 2>&1 && printf "\`pass\` must be installed and initialized to encrypt passwords.\\nBe sure it is installed and run \`pass init <yourgpgemail>\`.\\nIf you don't have a GPG public private key pair, run \`$GPG --full-gen-key\` first.\\n" && exit
+[ -r "$HOME/.password-store/.gpg-id" ] &&
+ "$GPG" --list-secret-keys $(cat "$HOME/.password-store/.gpg-id") >/dev/null 2>&1 || {
+ printf "\`pass\` must be installed and initialized to encrypt passwords.\\nBe sure it is installed and run \`pass init <yourgpgemail>\`.\\nIf you don't have a GPG public private key pair, run \`$GPG --full-gen-key\` first.\\n"
+ exit
+ }
! command -v mbsync >/dev/null && printf "\`mbsync\` must be installed to run mutt-wizard.\\n" && exit
if [[ "$OSTYPE" == "darwin"* ]]; then