2 ms·
Sure, but adding --help to a command means that the output of help is not exceptional, thus you're expecting it in stdout. If on the other hand you invoke the c
by figmert 3y ago
Sure, but adding --help to a command means that the output of help is not exceptional, thus you're expecting it in stdout. If on the other hand you invoke the command incorrectly, and the author decides the best thing to do is print out the help in such cases, then yes, it should be stderr.
- dingosity 3y agoLet's take the cut command for instance. If you read the man page you discover it's job is to parse fields out of each line of input. Printing a usage message into STDOUT is not part of its documented behaviour. It is therefore an exceptional event.
- rahimnathwani 3y agocut does the right thing: - if you run cut with no input and no parameters, it outputs an error message to STDERR - if you run cut --help it outputs usage info to STDOUT This is what I'd expect based on the man page. Running cut with no parameters is undefined, hence the output to STDERR. Running cut --help is defined, so the output goes to STDERR. I think people get confused because some tools, when run without any input, output the full help info to STDERR, instead of suggesting the user run foo --help*. So foo* and foo --help* appear to be equivalent. Until you pipe into less*.