[GRASS-dev] QGIS winGRASS blank space problem

Paul Kelly paul-grass at stjohnspoint.co.uk
Mon Jun 4 11:46:16 EDT 2007


On Mon, 4 Jun 2007, Markus Neteler wrote:

> Hi,
>
> a friend told me that with the latest QGIS release candidate,
> there is a winGRASS problem:
>
> $ v.rast.stats vector=CEA_riserve raster=CEA_slope colprefix=delete
> c:/Programmi/Quantum: c:/Programmi/Quantum: No such file or directory
>
> He uses a path with space:
> c:/Programmi/Quantum GIS/
>                    ^
>
> Is that a GRASS problem? Where to fix? To me it looks like

OK I've looked into this a bit more and it seems there is indeed a problem 
but I don't think it's GRASS. More to do with the way the Msys shell 
interprets the path to the script passed to it by the Windows _spawnlp() 
function. It reminds me strongly of what Glynn was saying about the 
difference between a list of strings, and one string with spaces used as 
separators: http://grass.itc.it/pipermail/grass-dev/2007-May/031394.html

I wonder if something like that is going on with the way the Msys shell is 
interpreting its command-line arguments, or with the way Windows is 
passing them to it. As proof of concept, the patch below seems to make it 
work, but putting quotes in when they shouldn't be needed is very ugly and 
might break it for non-Msys shells so I don't want to fix that.

Paul

Index: general/g.parser/main.c
===================================================================
RCS file: /home/grass/grassrepository/grass6/general/g.parser/main.c,v
retrieving revision 2.15
diff -u -r2.15 main.c
--- main.c      8 Mar 2007 17:42:51 -0000       2.15
+++ main.c      4 Jun 2007 15:45:52 -0000
@@ -412,10 +412,13 @@
         /* _spawnlp ( _P_OVERLAY, "sh", "sh", filename, "@ARGS_PARSED@", NULL ); */
         int ret;
         char *shell = getenv("GRASS_SH");
+       char *quotedfile;
+
+       G_asprintf(&quotedfile, "\"%s\"", filename);

         if( shell == NULL )
             shell = "sh";
-       ret = _spawnlp ( _P_WAIT, shell, shell, filename, "@ARGS_PARSED@", NULL);
+       ret = _spawnlp ( _P_WAIT, shell, shell, quotedfile, "@ARGS_PARSED@", NULL );
         G_debug ( 1, "ret = %d", ret );
         if ( ret == -1 )
         {




More information about the grass-dev mailing list