Martin Landa wrote:

> beside remaining compilation errors [1], wingrass 71 still (after
> weeks!!!) even doesn't start...

Does anyone want to test the attached patch?

In particular, it needs to be tested with a Python script invoking an
exe with arguments containing characters which are likely to be
meaningful to the shell, including:

        " | < > % ^

d.text or r.support may be useful as test cases.

But in the longer term, should we be claiming to support a platform
for which we appear to have no active developers?

-- 
Glynn Clements <gl...@gclements.plus.com>

Index: lib/python/script/core.py
===================================================================
--- lib/python/script/core.py   (revision 61080)
+++ lib/python/script/core.py   (working copy)
@@ -41,8 +41,26 @@
 
 
 class Popen(subprocess.Popen):
-    pass
+    _builtin_exts = set(['.com', '.exe', '.bat', '.cmd'])
 
+    @staticmethod
+    def _escape_for_shell(arg):
+        # TODO: what are cmd.exe's parsing rules?
+        return arg
+
+    def __init__(self, args, **kwargs):
+        if ( sys.platform == 'win32'
+             and isinstance(args, list)
+             and not kwargs.get('shell', False)
+             and kwargs.get('executable') is None ):
+            cmd = shutil_which(args[0])
+            args = [cmd] + args[1:]
+            name, ext = os.path.splitext(cmd)
+            if ext.lower() not in self._builtin_exts:
+                kwargs['shell'] = True
+                args = [self._escape_for_shell(arg) for arg in args]
+        subprocess.Popen.__init__(self, args, **kwargs)
+
 PIPE = subprocess.PIPE
 STDOUT = subprocess.STDOUT
 
_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev

Reply via email to