Paul Kelly wrote:

> > 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.

Ah.
        http://msdn2.microsoft.com/en-us/library/20y988d2(VS.80).aspx

        Arguments for the Spawned Process
        
        To pass arguments to the new process, give one or more pointers to
        character strings as arguments in the _spawn call. These character
        strings form the argument list for the spawned process. The combined
        length of the strings forming the argument list for the new process
        must not exceed 1024 bytes. The terminating null character ('\0') for
        each string is not included in the count, but space characters
        (automatically inserted to separate arguments) are included.
        
        Note
        
        Spaces embedded in strings may cause unexpected behavior; for example,
        passing _spawn the string "hi there" will result in the new process
        getting two arguments, "hi" and "there". If the intent was to have the
        new process open a file named "hi there", the process would fail. You
        can avoid this by quoting the string: "\"hi there\"".

Needless to say, it doesn't say what happens (or what to do) if the
argument itself contains quotes.

Does anyone want to dig into the source code for Python's subprocess
module to see how they handle this?

-- 
Glynn Clements <[EMAIL PROTECTED]>

_______________________________________________
grass-dev mailing list
[email protected]
http://grass.itc.it/mailman/listinfo/grass-dev

Reply via email to