diff --git a/src/offline/gpg.go b/src/offline/gpg.go index 4ab5c89..2a8025b 100644 --- a/src/offline/gpg.go +++ b/src/offline/gpg.go @@ -1,6 +1,8 @@ package offline import ( + "fmt" + "os" "os/exec" "strings" ) @@ -11,7 +13,11 @@ import ( // DecryptGPG decrypts a GPG-encrypted file and returns the contents as a slice of (trimmed) strings func DecryptGPG(targetLocation string) []string { cmd := exec.Command("gpg", "--pinentry-mode", "loopback", "-q", "-d", targetLocation) - output, _ := cmd.CombinedOutput() + output, err := cmd.CombinedOutput() + if err != nil { + fmt.Println(AnsiError + "Failed to decrypt \"" + targetLocation + "\" - ensure it is a valid GPG-encrypted file and that you entered your passphrase correctly" + AnsiReset) + os.Exit(1) + } outputSlice := strings.Split(string(output), "\n") for i, lineData := range outputSlice { outputSlice[i] = strings.TrimRight(lineData, " \t") // remove trailing whitespace