Author Topic: Help (--help) going to stderr  (Read 4597 times)

rsandstrom

  • Newbie
  • *
  • Posts: 5
Help (--help) going to stderr
« on: November 01, 2011, 10:05:59 AM »
I've noticed with bedops/bedmap that the default help message (no command line options)  and regular help text (--help) both output to stderr. 

It doesn't really bother me, but I'm used to having this type of output going to stdout.

Perhaps we could discuss some of the implications of changing it (or keeping it as is)?


AlexReynolds

  • Administrator
  • Jr. Member
  • *****
  • Posts: 72
Re: Help (--help) going to stderr
« Reply #1 on: November 01, 2011, 06:46:58 PM »
Starch and unstarch do this as well.

It would make sense to change this to stdout where the app exits immediately with EXIT_SUCCESS status (i.e. when calling --help).

Where the app exits with EXIT_FAILURE (for example, the wrong number of arguments are specified) it might make more sense for the usage statement to remain sent to stderr.

Shane, what do you think?

sjn

  • Administrator
  • Jr. Member
  • *****
  • Posts: 72
Re: Help (--help) going to stderr
« Reply #2 on: November 01, 2011, 07:22:11 PM »
I'm leaning that way.  Some typical utilities, such as tar, output things to stdout by default.  I haven't found anything that says this is a required/typical behavior for *nix type tools.  I agree that --help should go to stdout.  I think general errors, including no arguments to a program that requires 1 or more, should spit to stderr.
Let's see if anyone else chimes in before we make any updates.

AlexReynolds

  • Administrator
  • Jr. Member
  • *****
  • Posts: 72
Re: Help (--help) going to stderr
« Reply #3 on: November 02, 2011, 02:37:35 AM »
From the GNU coding standards document, available at http://www.gnu.org/prep/standards/html_node/_002d_002dhelp.html:

The standard --help option should output brief documentation for how to invoke the program, on standard output, then exit successfully. Other options and arguments should be ignored once this is seen, and the program should not perform its normal function.

sjn

  • Administrator
  • Jr. Member
  • *****
  • Posts: 72
Re: Help (--help) going to stderr
« Reply #4 on: November 02, 2011, 10:06:10 AM »
OK - well, we can go with this.   Let's make the update after the review cycle for BEDOPS is finished since it isn't essential.

rsandstrom

  • Newbie
  • *
  • Posts: 5
Re: Help (--help) going to stderr
« Reply #5 on: November 03, 2011, 03:15:50 PM »
Nice.  As mentioned, this isn't a huge deal, but I often pipe --help commands into head or less and that doesn't work so well with stderr.


sjn

  • Administrator
  • Jr. Member
  • *****
  • Posts: 72
Re: Help (--help) going to stderr
« Reply #6 on: January 03, 2012, 09:12:13 AM »
This issue is now resolved.