Skip to content

Commit cb6134d

Browse files
committed
pp: fix help page when piping
"pp -help | less" would result in corrupted output because part would be output via stdout and part via stderr. Fix this.
1 parent 937f872 commit cb6134d

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

internal/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,14 @@ func Main() error {
211211
p := &defaultPalette
212212

213213
flag.CommandLine.Usage = func() {
214+
out = os.Stderr
214215
if *noColor && !*forceColor {
215216
p = &Palette{}
216217
} else {
217-
out = colorable.NewColorableStdout()
218+
out = colorable.NewColorableStderr()
218219
}
219220
fmt.Fprintf(out, "Usage of %s:\n", os.Args[0])
221+
flag.CommandLine.SetOutput(out)
220222
flag.CommandLine.PrintDefaults()
221223
fmt.Fprintf(out, "\nLegend:\n")
222224
fmt.Fprintf(out, " Type Exported Private\n")

0 commit comments

Comments
 (0)