Should the usage message which is printed with e.g.
command -?
of a Unix command go to stderr or stdout, and why? Should it go to the same place if the user makes a mistake with an option?
|
Should the usage message which is printed with e.g.
of a Unix command go to stderr or stdout, and why? Should it go to the same place if the user makes a mistake with an option? |
||||
|
It should go to stdout, so you can type:
This is also recommended by the Gnu Coding Standards on On the other hand, the usage message that you get when you use an invalid option or omit a required argument should go to stderr, because it's an error message, and you don't want it to feed into the next command in a pipeline. When you use When you say |
|||||||||||||
|
touch -- -l; ls -?— you actually get a long listing as if you'd passed-lto ls. – mattdm♦ Mar 8 '11 at 12:56-hoption for other thing than a help message, then'-?'(with the quotes) or-:give you a good chance to get an error (and usage) message since:and?can't be valid options for anything usinggetopt(3). – Stephane Chazelas Feb 8 at 22:40