Skip to content

Commit

Permalink
cmd/age: decouple output buffer and output denial decision
Browse files Browse the repository at this point in the history
Co-authored-by: Filippo Valsorda <[email protected]>
  • Loading branch information
codesoap and FiloSottile committed Jan 7, 2021
1 parent 6fc7950 commit 4a5a042
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions cmd/age/age.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 -".`)
}
}
}

Expand Down

0 comments on commit 4a5a042

Please sign in to comment.