grass
grass copied to clipboard
[Feat] The --help flag should print to stdout, not stderr
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.
Fully agreed, the --help flag output to stderr rather than stdout is highly confusing.
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.