grass icon indicating copy to clipboard operation
grass copied to clipboard

[Feat] The --help flag should print to stdout, not stderr

Open wenzeslaus opened this issue 5 years ago • 2 comments

Is your feature request related to a problem?

In terminal, piping help into grep does nothing - it just gives whole help:

g.region --help | grep save

This is unexpected as, e.g.:

ls --help | grep context

gives:

-Z, --context   print any...

Same works for GDAL:

$ gdalinfo --help | grep json
...

It also fits with a guideline "stdout should give user what the user asked for".

Also within GRASS, module_name --script and --interface-description go to stdout, not stderr like --help.

Describe the solution you'd like

Output --help to standard output, not standard error output.

Describe alternatives you've considered

There is a workaround - redirecting the stderr to stdout, but why the modules should behave differently than other tools?

Additional context

This is similar to misuse of stderr for composing human readable outputs in #1129, but it is a separate issue.

wenzeslaus avatar Nov 30 '20 02:11 wenzeslaus

Fully agreed, the --help flag output to stderr rather than stdout is highly confusing.

neteler avatar Dec 05 '20 10:12 neteler

Option --help-text is output to stdout. It is undocumented. I had to dig though the code to find it. It should be documented, at a minimum.

BadAssassin avatar May 07 '22 06:05 BadAssassin