[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
Fri May 15 13:15:29 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):

 Replying to [comment:4 hamish]:
 > Ok, found it. It was gis.m/grass-run.sh trying to execute the command in
 full (spaces, args, and all) quoted instead of breaking it down into a
 $cmd and $args.

 That's incorrect; the shell handles {{{"$@"}}} specially.

 > it would seem that the problem is on this line of lib/init/grass-
 run.src:
 >
 {{{
 > # run command
 > "$@"
 }}}

 The {{{"$@"}}} syntax evaluates to the argument list broken into words
 according to argument boundaries, rather than broken by spaces. If you use
 {{{$@}}} without quotes, the argument list is re-parsed, so any arguments
 which contain spaces will be split into multiple arguments.

 > which was introduced, somewhat ironically, in r20416.
 > The point of r20416 was to allow commands with spaces like:
 {{{
 >   # (maybe not the best example, but..)
 >   v.db.select roads where="label ~ 'highway'"
 }}}
 >
 > ... to function correctly.

 Yep.

 > but it looks like it is backfiring.

 No, the script itself is correct. How is it being called?

 > not sure how to fix it in sh, in Tcl at least we can use a list of
 strings. some magic with "shift" perhaps?

 What is the exact command being passed to the script?

 Add:
 {{{
 /path/to/args "$@"
 }}}

 to the beginning of the script, after compiling and installing the
 following program as "/path/to/args":

 {{{
 #include <stdio.h>
 int main(int argc, char ** argv)
 {
         int i;
         for (i = 0; i < argc; i++)
                 printf("argv[%2d] = '%s'\n", i, argv[i]);
         return 0;
 }
 }}}

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


More information about the grass-dev mailing list