Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rtl_433 -h or rtl_433 -R help prints to stderr instead stdout #2542

Closed
devZer0 opened this issue Jun 24, 2023 · 5 comments
Closed

rtl_433 -h or rtl_433 -R help prints to stderr instead stdout #2542

devZer0 opened this issue Jun 24, 2023 · 5 comments
Labels
bug There is a defect in the code

Comments

@devZer0
Copy link
Contributor

devZer0 commented Jun 24, 2023

hello,

i found that the help page(s) of rtl_433 prints to stderr by default.

is this intentional ?

normally tools print to stdout what's not considered an error

@russinnes
Copy link

By piping messages for the user to stderr, the "real" output can stay with stdout, allowing it do be piped ( | ) easily into another program for further processing.

@gdt
Copy link
Collaborator

gdt commented Sep 25, 2023

Printing the output of -h/-R to stderr is a bug. When the user asks for it, it belongs on stdout and the program should exit with status 0. When it is printed because of bad or missing aguments on the command line, it should go to stderr and the program should exit with a non-zero status.

@gdt gdt added the bug There is a defect in the code label Sep 25, 2023
@zuckschwerdt
Copy link
Collaborator

zuckschwerdt commented Sep 25, 2023

Help to stdout might be expected, I see one doing rtl_433 -R | grep Bresser (has to be rtl_433 -R 2>&1 | grep Bresser currently).
But we also output help in error cases where stdout might be used otherwise, e.g. rtl_433 -R 999 -w OOK:-
This seems though to get right.

@gdt
Copy link
Collaborator

gdt commented Sep 25, 2023

As I understand the norms, if it is printed because of an error, leading to non-zero exit, stderr is appropriate. If it is printed because the user asked for it to be printed, and this does not lead to non-zero exit, stdout is appropriate.

If the user asks for help output and something else, then either:

  • they both go on stdout; they get what they want, or what they deserve :-(
  • asking for help and something else should be an error. I lean to this. This would be like any other invalid args.

@zuckschwerdt
Copy link
Collaborator

The trouble here is that we'd need to fit the chain of print functions with an additional flag where it should go. Not great. But basically we could change all those print functions to be something more like fprint and take the fd as first arg.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug There is a defect in the code
Projects
None yet
Development

No branches or pull requests

4 participants