From 4a5a042583ca8fe6a90a396e1b568dd8e1617294 Mon Sep 17 00:00:00 2001 From: codesoap Date: Wed, 6 Jan 2021 17:15:27 +0100 Subject: [PATCH] cmd/age: decouple output buffer and output denial decision Co-authored-by: Filippo Valsorda --- cmd/age/age.go | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/cmd/age/age.go b/cmd/age/age.go index dc4c6aa1..cf9593d0 100644 --- a/cmd/age/age.go +++ b/cmd/age/age.go @@ -182,13 +182,16 @@ func main() { buf := &bytes.Buffer{} defer func() { io.Copy(os.Stdout, buf) }() out = buf - } else if decryptFlag && name != "-" { - // TODO: buffer the output and check it's printable. - } else if name != "-" { - // If the output wouldn't be armored, refuse to send binary to the - // terminal unless explicitly requested with "-o -". - logFatalf("Error: refusing to output binary to the terminal.\n" + - `Did you mean to use -a/--armor? Force with "-o -".`) + } + if name != "-" { + if decryptFlag { + // TODO: buffer the output and check it's printable. + } else if !armorFlag { + // If the output wouldn't be armored, refuse to send binary to + // the terminal unless explicitly requested with "-o -". + logFatalf("Error: refusing to output binary to the terminal.\n" + + `Did you mean to use -a/--armor? Force with "-o -".`) + } } }