[GRASS-dev] Re: gis.m crashes on zoom to map existing in more than one mapset

Glynn Clements glynn at gclements.plus.com
Sat Jan 6 00:30:52 EST 2007


Paul Kelly wrote:

> Right. So catch isn't useful for GRASS commands then as in GRASS, a module 
> writing to stderr is not equivalent to an error condition.

It's useful insofar as it allows you to ignore the error and continue.

> Messages and 
> warnings also go to stderr, and we need to use something like grocat to 
> redirect these away from stderr and stop them making Tcl think there is an 
> error.

The problem with the "|& grocat" approach is that you then get stderr
output merged with normal module output. This isn't an issue if you're
just dumping everything to the gronsole for the user to read, but it
is an issue if you plan to parse the output.

Even if the parser silently ignores everything which it doesn't
understand, there's no guarantee that messages written to stderr won't
conform to the parsed syntax and thus be interpreted as "output".

I would suggest having a global variable which refers to a "sink" to
which stderr can be safely redirected in situations like this. Valid
values would be anything which can appear after "2>" in an exec (or
"open |...") command, e.g. @stderr (i.e. gis.m's stderr, typically a
terminal, although this may not be valid on non-Unix systems), the
name of a log file, or /dev/null (or NUL on Windows).

-- 
Glynn Clements <glynn at gclements.plus.com>




More information about the grass-dev mailing list