[GRASS-dev] another not quiet GRASS command

Michael Barton michael.barton at asu.edu
Tue Sep 4 23:55:53 EDT 2007




On 9/3/07 10:06 AM, "Paul Kelly" <paul-grass at stjohnspoint.co.uk> wrote:

> On Mon, 3 Sep 2007, Michael Barton wrote:
> 
>> The problem in this and other cases is that the warning is sent to stderr
>> when the command operates and exits properly. Error messages are sent to
>> stderr when the command does not operate properly and/or exits with an
>> error. There is no easy way (maybe no way in many cases) for a script to
>> tell the difference.
> 
> I think Tcl's deficiencies are confusing you. Tcl cannot tell the
> difference and this is IMHO a major bug in Tcl. But it is a single
> exception. Operating systems and probably almost all other scripting
> languages use the exit code of the program: a zero exit code indicates it
> exited successfully; a non-zero exit code indicates it exited with an
> error.

You're probably right. I'm trying to work out a reasonable error trap
function. Not very difficult in general, though replacing all the individual
error traps will be tedious.


> 
> In any case Maris seems to have found a workaround to Tcl's deficiency:
> check the global variable errorcode after running an external command. I'm
> waiting to see if anybody comes up with a problem with this approach.

I looked at this and tried it out. I found that it doesn't work as expected.
The reason is that all or most of the error codes returned by Tcl seem to
potentially be ones we'd need to trap. See docs at
<http://aspn.activestate.com/ASPN/docs/ActiveTcl/8.4/tcl/TclCmd/tclvars.htm#
M18>. 

For example, I tried giving an incorrect module name in a menu to get a file
not found error. In this case, Tcl_errorCode returns POSIX rather than
CHILDSTATUS 

The generic error trap will allow for global formatting change in the
future, but I don't see any way around the confusion of real error messages
and other messages sent to stderr in Tcltk.

Michael



__________________________________________
Michael Barton, Professor of Anthropology
Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics & Complexity
Arizona State University

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton





More information about the grass-dev mailing list