[GRASS5] stdout and stderr

Glynn Clements glynn.clements at virgin.net
Wed Oct 20 12:33:22 EDT 2004


Paul Kelly wrote:

> I suppose that for modules that only write output to another file in the 
> GIS database, having information messages printed to stdout wouldn't 
> result in mixing up, but still I was under the (possibly mistaken) 
> impression that writing to stderr ensured the messages would always appear 
> where the user could see them and act on them, regardless of where stdout 
> was appearing (e.g. in a future GUI perhaps the stdout would be placed in 
> a pretty 'results' window to be stored while stderr could be kept out of 
> the way).
> 
> Any thoughts?

Any output which you might want to save to a file or pipe to another
program should go to stdout. Anything which should go to the terminal
even when stdout is redirected should go to stderr.

Prompts, progress indicators etc should always go to stderr. 
Meaningful data (e.g. r.info, g.region -p, etc) should always go to
stdout. For anything else, consider the stdout-to-file/stderr-to-terminal
scenario and try to decide whether stdout or stderr is more appropriate.

In any case, many GRASS programs are far more "talkative" than they
should be, IMHO. We should probably have an environment variable to
determine whether "progress" messages (i.e. G_percent(), messages
indicating the processing "phase" etc) should be generated. With a
"quiet" setting, most programs would generate no output whatsoever
unless there's an error.

-- 
Glynn Clements <glynn.clements at virgin.net>




More information about the grass-dev mailing list