[GRASS-dev] Re: [GRASS GIS] #604: /usr/lib/grass64/etc/grass-run.sh does not work properly when called by gis.m to execute in a external xterm

GRASS GIS trac at osgeo.org
Mon May 18 13:01:11 EDT 2009


#604: /usr/lib/grass64/etc/grass-run.sh does not work properly when called by
gis.m to execute in a external xterm
-----------------------+----------------------------------------------------
  Reporter:  frankie   |       Owner:  grass-dev at lists.osgeo.org
      Type:  defect    |      Status:  new                      
  Priority:  critical  |   Milestone:  6.4.0                    
 Component:  Tcl       |     Version:  6.4.0 RCs                
Resolution:            |    Keywords:  xterm                    
  Platform:  Linux     |         Cpu:  Unspecified              
-----------------------+----------------------------------------------------
Comment (by glynn):

 > > If you change Gronsole::run_xterm to treat $cmd as a list, then the
 string will be interpreted according to Tcl list syntax, i.e. spaces
 separate arguments, but you can provide an argument which contains spaces
 by using braces or backslashes.
 >
 > hmmm, I had tried that, but it didn't seem to work. (again, I'm no tcl
 expert).
 >
 > As I see it we have two choices:
 >
 > 1) use `eval "$@"` which may be technically wrong but it seems to work
 for all cases and means that the quoting works as the user expects using
 DOS or Bourne syntax. i.e. just quietly walk away.
 >
 > 2) treat it as a tcl list, figure out how to implement that, and
 document somewhere that the user has to use {} instead of quotes.

 grass-xterm-wrapper is supposed to be invoked in the same manner as xterm,
 i.e. the -e switch is followed by a command and its arguments, not a
 command string. The bug is in Gronsole::run_xterm; this should be fixed,
 rather than introducing an equal and opposite bug elsewhere.

 If you were to use option 1) above, any Tcl code which needed to invoke a
 command with arguments via grass-xterm-wrapper would need to construct the
 command according to Bourne shell syntax.

 Tcl doesn't have a function to do this, and doing it manually is error
 prone. The obvious risk is the the code just concatenates the arguments
 with spaces in between, which breaks if any of the arguments contain any
 shell metacharacters, e.g. spaces.

 OTOH, Tcl has several functions to construct Tcl lists from individual
 elements and/or lists, as well as invoking a command with a list of
 arguments.

 If, for some reason, Tcl needs to execute a "command" which is already
 using Bourne shell syntax, the correct mechanism is {{{exec /bin/sh -c
 $cmd}}}. Similarly, to execute a command using DOS syntax use {{{exec
 $env(COMSPEC) /c $cmd}}}.

-- 
Ticket URL: <https://trac.osgeo.org/grass/ticket/604#comment:17>
GRASS GIS <http://grass.osgeo.org>


More information about the grass-dev mailing list