views:

139

answers:

5

I think stdout, so you can easily grep, what do you think?

+3  A: 

Always stdout, makes it easier to pipe to less, grep it etc.

If you are showing the help text because there was a problem with parsing the command line arguments, then you might use stderr.

Paul Dixon
Well, (s)he specifically said "app --help" so I assume that "--help" is recognized as a command line argument.
Deniz Dogan
I was just suggesting a case where you might send help to stderr
Paul Dixon
+1  A: 

It's not an error, so I'd say stdout....

Greg
+3  A: 

Well, it's an explicit request for help so it's output. If for some reason you can't output the help or the user mis-spells "help" then, by all means, send that to error :-)

Users that know what they're doing can use the infamous "2>&1" if they want errors on standard output.

paxdiablo
+6  A: 

Only errors go to stderr. This is in no way an error, it does exactly what the user had in mind, which is print usage information.

Deniz Dogan
A: 

netcat is the only application I can think of that would redirect -h to stderr, and I can't for the life of me fathom why.

I suppose if you're outputting the help information because someone used improper arguments, you might want to redirect it to stderr, but personally even then I wouldn't use stderr because I don't think spamming error logs with fullblown help text is useful - I'd rather just output a single error pointing out the arguments were malformed to stderr. If someone is explicitly calling your application using -h or --help, then you really shouldn't redirect it to stderr.

Coding With Style