[GRASS5] Mac OS X Tcl fix and Startup Errors
Jeshua Lacock
jeshua at openosx.com
Sun Apr 13 20:14:42 EDT 2003
On Tuesday, April 8, 2003, at 05:59 AM, Glynn Clements wrote:
>
> Jeshua Lacock wrote:
>
>> Mac OS X allows the use of special/reserved characters in file names
>> such as the exclamation mark ("!") and the space character (" ").
>>
>> This was causing gis_set.tcl and other Tcl scripts to choke using the
>> native Aqua Tcl/Tk interface when encountering a file with illegal
>> unix
>> characters.
>>
>> It turns out the most elegant solution I could come up with was to
>> create a wrapper for the "ls" command to escape the exclamation marks
>> and to wrap the filename in quotes to compensate for spaces and other
>> special characters.
>>
>> The wrapper is a shell script using awk and sed, and then I simply
>> changed occurrences of "ls -a" with "lsWrap -a" and so on. I can
>> supply
>> patches if anyone is interested.
>
> A better fix would be to just not use "ls", but to implement the
> functionality in Tcl, using the "glob" command.
>
>> I am also trying to fix these errors:
>> Starting GRASS ...
>> : command not foundtc/Init.sh:
>> : command not foundtc/Init.sh:
>> : command not foundtc/Init.sh:
>>
>> These errors are being caused by:
>>
>> puts stdout "GISDBASE='$database'; export GISDBASE;"
>> puts stdout "LOCATION_NAME='$location'; export LOCATION_NAME;"
>> puts stdout "MAPSET='$mapset'; export MAPSET;"
>
> Do you have any idea how is this code causing the above errors? I'm
> not doubting that it is, but I can't see any possible mechanism.
The semi-colons appear to be the culprit.
Also. strangely, the line:
puts stdout "exit"
Generates the message:
: command not foundtc/Init.sh: exit
And yet, when I type in the shell "exit" <enter> everything works.
Any ideas?
>> If I change stdout to stderr, everything looks normal:
>>
>> set GISDBASE='/Users/jeshua'; export GISDBASE;
>
> The strings aren't meant to be displayed on the terminal; they're
> meant to be interpreted by Init.sh. Using stderr won't work.
Yes, I was just making sure it was not garbled.
>> I don't get any errors when I remove the export part such as:
>> puts stdout "GISDBASE='$database'"
>
> The export commands are unnecessary. So are the settings for GISDBASE
> and MAPSET; only LOCATION_NAME (and the OLD_* variables a bit lower
> down) are actually used by Init.sh.
>
>> If I include the semicolon, I get the error:
>> : command not foundtc/Init.sh:
>>
>> I suppose this is a bug with the Aqua port of Tcl/Tk 8.4.2.
>
> Or with the Mac's /bin/sh. In any case, you can remove the semicolon
> and the export statement.
Cool.
>> What is the grass tcltk script trying to accomplish here? Just setting
>> the environment variables and exporting them?
>
> It's returning the data back to the Init.sh script:
>
> [snip]
>
>
> gis_set.tcl is meant to write some Bourne shell code to stdout, which
> Init.sh then evaluates via a combination of backquotes ( `...` ) and
> the "eval" command. Backquotes only capture stdout, not stderr.
Thanks.
>> Also I am getting:
>>
>> ERROR: Invalid return code from gis_set.tcl.
>> Please advise GRASS developers of this error.
>> Welcome to GRASS 5.0.1 (January 2003)
>>
>> The 'gis_set' result is 127. Everything seems to work fine, do you
>> think the error is anything to be concerned about?
>
> Maybe; anything other than zero normally indicates some type of error.
> Init.sh should probably treat everything other than zero as an error
> (i.e. use text mode instead; it certainly shouldn't just carry on
> regardless). Of course, this would force you to fix whatever is
> causing gis_set.tcl to return a non-zero exit code.
>
> BTW, programs should avoid using code 127, as this is what system()
> returns if it fails to execute /bin/sh; normally, system() returns the
> program's exit code.
Hmm, I wonder if /bin/sh is failing to execute somewhere? I will
attempt to trace the result.
Thanks again,
Jeshua Lacock __________________________
Programmer/Owner Phone: 760.935.4736
http://OpenOSX.com Fax: 760.935.4845
-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_
More information about the grass-dev
mailing list