Fix ANSI escapes (on Windows) not being interpreted after using GPG pinentry

This commit is contained in:
2024-07-17 18:54:29 -04:00
parent 1bf72332df
commit df5f10d188
7 changed files with 32 additions and 10 deletions
+5
View File
@@ -13,11 +13,16 @@ import (
func DecryptGPG(targetLocation string) []string {
cmd := exec.Command("gpg", "--pinentry-mode", "loopback", "-q", "-d", targetLocation)
output, err := cmd.Output()
// ensure ANSI escape sequences are interpreted properly on Windows
enableVirtualTerminalProcessing()
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")
return outputSlice
}