sharkdp / hexyl

A command-line hex viewer
Apache License 2.0
8.92k stars 227 forks source link

--version prints newline to stderr #131

Closed ehandal closed 3 years ago

ehandal commented 3 years ago

This is a bit weird, not sure if intentional:

~ $ hexyl --version
hexyl 0.8.0
~ $ hexyl --version > /dev/null

~ $ hexyl --version &> /dev/null
~ $
sharkdp commented 3 years ago

That is not intended, no. Thanks for reporting.

scimas commented 3 years ago

There isn't any newline in the version output. See clap-rs/clap#1960, clap-rs/clap#1972 which will actually (correctly) add new lines to the version output.

The reason hexyl is getting a newline on stderr is this: clap prints version for hexyl without the trailing newline (the PR I linked above isn't included in the clap version hexyl is built with). But then the eprint! in hexyl main calls the error formatting in clap which does a writeln! and so you get the newline in stderr.

For some reason the --help output is directed to stderr rather than stdout, so the issue isn't visible there.