Alex Rivera | Logout

'app --help' should go to stdout or stderr?

Asked 2009-07-01T08:45:40.447
20

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

Edit
Report

2 Answers

16

stdout if the user requested it with --help for example, makes it easier to pipe to less, grep it etc.

stderr if you are showing the help text because there was a problem, e.g. parsing the command line arguments.

answered 2009-07-01T08:47:21.113
0

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.

answered 2009-07-01T08:59:14.647

Your Answer