[GRASS5] [bug #2488] (grass) GRASS 5.7 WISH - improve string reading ability in g.parser

Glynn Clements glynn.clements at virgin.net
Tue Aug 3 22:37:16 EDT 2004

Hamish wrote:

> > It may (or may not) also be related to NVIZ not starting from the
> > autogenerated GUI. Currently, you have to start NVIZ from the command
> > line using the -q switch, then add data after it is running. That is,
> > you can't specify initial raster, vector, ect. files in the startup
> > GUI dialog. If you try to start NVIZ this way, it will crash.
> still broken:
> can not find channel named "couldn't execute "nviz2.2_script": no such
> file or directory"

Oh. That *is* a Tcl issue.

The immediate error arises from this code in G_gui():

 	catch {open $cmd r} msg
	fconfigure $msg -blocking 0
	fileevent $msg readable [ list prnout $msg  ]

If the open command succeeds, catch will set msg to the result from
the command (i.e. the channel ID) and return 0. If the command fails,
catch will set msg to the error message and return non-zero.

IOW, msg will only contain a valid channel ID if catch returns zero,
so the above code should probably look something like:

	if {[catch {open $cmd r} msg]} {
		error $msg
	} {
		fconfigure $msg -blocking 0
		fileevent $msg readable [ list prnout $msg  ]

[Or even just omit the call to catch, so that any errors are
propagated via Tcl's normal error handling mechanism.]

At least, that will handle errors correctly.

As for the actual error, that's because G_gui() is using the value of
argv[0] from G_parser(), and argv[0] is "nviz2.2_script", which isn't
an executable file.

For G_gui() to work correctly, NVWISH2.2 needs to call G_parser() with
argv[0] set to "nviz".

> > I don't remember running into this in 5.3,
> It was a problem in 5.3, but without the SQL queries it only affects the
> d.text modules AFAIK. Fixed in CVS. Both the 5.3 and 5.7 changes make
> the shell command preview un-cut&paste-able for things with spaces in
> them, but this never worked before either.. some fancy formatting before
> printing the text string could probably move & replace the {}s to "s if
> someone was keen to try.

	set string {}
	foreach word $cmd {
		regsub -all -- {'} $word {'\''} newword
		append string {'} $newword {' }

Glynn Clements <glynn.clements at virgin.net>

More information about the grass-dev mailing list