Bug #167
closedbatctl outputs errors to stdout
0%
Description
Calls of batctl like "batctl if foo" output error messages to stdout instead of stderr.
This is important for scrips so that errors messages can be filtered out.
In short; "batctl if foo 2> /dev/null" doesn't work. :)
Files
Updated by M W almost 12 years ago
Another but very minor thing. "batctl -h" should exit with status code 0, not 1.
Updated by Marek Lindner almost 12 years ago
Hey, how about you provide a patch for these "minor things" ? If you need an idea how to do the stderr thingy take a look at the batctl td code. There, I already made similar changes.
Updated by M W almost 12 years ago
I can pick that lower hanging fruit and make a patch.
But I niticed that that there are a lot of printf("Error [...]")
calls in other places than main.c. Is it ok to fix
them in one go?
Updated by Antonio Quartulli almost 12 years ago
well, if all the changes can be grouped under the subject "print errors to stderr", I think it is doable.
Updated by M W almost 12 years ago
- File errors_to_stderr.patch errors_to_stderr.patch added
I have made a preliminary patch - see attachment.
At the moment the usage information is printed
in cases of an error (atm. to stdout still).
So the question arises if the usage should be redirected
to stderr as well in case it is displayed because of an error.
Or we remove the usage display and only display it when -h
is used. Imo, this approach would make the error output less cluttered.
Updated by Marek Lindner almost 12 years ago
The patch looks pretty good!
IMHO, you can always direct the usage to stderr. If somebody calls the help on purpose he won't redirect the error output to /dev/null ?
Personally, I like having the help displayed in case of an error. Most people don't know how to continue if something does not work as expected.
Updated by M W almost 12 years ago
- File errors_to_stderr.patch errors_to_stderr.patch added
Here is the complete patch.
If it looks alright I can send it to the mailing list.
Is there a specific patch format required?
Updated by Marek Lindner almost 12 years ago
Feel free to send it to the list. For the format please check the "submitting patches" section here: Contribute