[GRASS5] More Mac OS X Tcltkgrass Tweaks

Glynn Clements glynn.clements at virgin.net
Mon Apr 28 04:14:35 EDT 2003

Jeshua Lacock wrote:

> >> At this point, I propose that a new configure switch is added for
> >> enabling the native Mac OS X version of the Tcl/Tk interface (some
> >> folks on Mac OS X may want to use the traditional *nix version of the
> >> interface and those using Darwin without the Aqua interface). Then the
> >> set of Mac OS X patches could be applied at configure time and the
> >> auxiliary Mac OS X support programs could be built. I would be happy 
> >> to
> >> do most of the work and be responsible for it's maintenance. Any
> >> thoughts/comments?
> >
> > I would rather this was determined at run time.
> >
> > Most of the things that configure is used for are compile-time issues.
> > However, Tcl/Tk is interpreted, so there isn't a "compile time".
> Well there are some Carbon C programs that I have written, currently: 
> "launchURL" and "wishToFront"; which do require compiling (and a couple 
> shell scripts which do not need compiling). They could be pre-compiled, 
> however that seems to defeat the purpose distributing source code. I 
> guess the Mac OS X specific binaries could be built on any detected 
> Darwin build, and the Tcltkgrass changes could be determined at runtime.

OK; I didn't realise that you were suggesting including those
utilities with GRASS. If we were to do that, then it would be
configure's job to enable their compilation.

> > Actually, the choice of browser should be more general; it should be
> > possible to use something other than netscape on other platforms.
> Sure, like I stated that is the case with the Mac OS X solution.
> Can't the user can change the netscape option via 
> "Config->Options->Configure"?

Right; although I'm not sure that it will actually work with anything
other than netscape:

	set cmd [list exec $html(netscape) -remote openURL\($url,new-window,$html(raise)\)]

This will only work with programs which support the command-line
syntax which is used; which is probably just netscape.

A more portable approach would be to just have the entire command as a
single parameter.

Also, I suspect that making the URL prefix configurable is
unnecessary; AFAICT, it should always be "file://".

> >> Also, I am trying to eliminate the Mac OS X "console1" bug. and the
> >> following line in gui.tcl is the culprit:
> >>
> >>      set name "| $name 2>@ stdout"
> >>
> >> If I try to reproduce the problem in a new wish file, everything 
> >> works.
> >> Since I can't reproduce the problem outside of Grass, it seems to me
> >> that something in the Tcl scripts must be breaking stdout (which very
> >> well could be a wish bug). It is really odd because the problem only
> >> occurs when the GUI is launched from Init.sh and not when tcltkgrass 
> >> is
> >> launched manually from the Grass terminal. Any ideas? I would be
> >> willing to pay for some help. I was preparing a post for the MacTcl
> >> mail list, but I stopped short of posting it when I was not able to
> >> reproduce the error in a blank wish shell.
> >
> > The fact that it only occurs when tcltkgrass is launched from Init.sh
> > suggests a Mac issue. Have you tried this with a test case? I.e.
> > running a simple Tcl/Tk script which uses "open | ... 2>@ stdout" from
> > a shell script. Does it matter whether the script is run in the
> > background?
> When I run the following wish script manually from a terminal window:
>      #!/bin/wish
>      puts stdout "fooMAR"
> fooMAR appears in the terminal.

What if you run it from a shell script? I.e.:


What if it's run in the background? I.e.

	/path/to/foomar.tcl &

This should mimic the way that tcltkgrass is run from Init.sh.

> When I add the same line to gui.tcl, right where the "set name... >@ 
> stdout" offending line:
>      puts stdout "fooMAR"
> fooMAR will not appear when launched from Init.sh and the console1 
> error appears, but does functions normally and without error when I 
> launch the GUI manually from the Terminal.
> I also tried:
>      open | d.rast map=spot.comp < /dev/null 2>@ stdout r
> And, it seems as if the syntax is not quite right. To be honest, I am 
> not entirely sure what the syntax should look like. It seems the pipe 
> should not be there. Does that look right?

The entire command (starting with the pipe character) should be a
single argument to open, i.e.

	open {|d.rast map=spot.comp < /dev/null 2>@ stdout} r

> Also, I am able to successfully run in a test file:
>     open ~/.tcltkgrass r
> But, if in the same test file I instead try;
>      open ~/.tcltkgrass < /dev/null 2>@ stdout r
> I get there error:
>      Error in startup script: wrong # args: should be "open fileName 
> ?access? ?permissions?"

Same problem; the "r" should be the second argument, and everything
else should be the first argument.

Glynn Clements <glynn.clements at virgin.net>

More information about the grass-dev mailing list