Bug #167
closed
batctl outputs errors to stdout
Added by M W almost 12 years ago.
Updated almost 8 years ago.
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
Another but very minor thing. "batctl -h" should exit with status code 0, not 1.
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.
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?
well, if all the changes can be grouped under the subject "print errors to stderr", I think it is doable.
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.
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.
Here is the complete patch.
If it looks alright I can send it to the mailing list.
Is there a specific patch format required?
Feel free to send it to the list. For the format please check the "submitting patches" section here: Contribute
- Status changed from New to Closed
- Target version set to 2013.0.0
Also available in: Atom
PDF