Quellcode durchsuchen

init: support spaces in path for GRASS_BATCH_JOB (see https://trac.osgeo.org/grass/ticket/3170)

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@73261 15284696-431f-4ddb-bdfa-cd5b030d7da7
Vaclav Petras vor 6 Jahren
Ursprung
Commit
fb023f3f3b
1 geänderte Dateien mit 8 neuen und 0 gelöschten Zeilen
  1. 8 0
      lib/init/grass.py

+ 8 - 0
lib/init/grass.py

@@ -1549,9 +1549,17 @@ def run_batch_job(batch_job):
     """
     batch_job_string = batch_job
     if not isinstance(batch_job, string_types):
+        # for messages only
         batch_job_string = ' '.join(batch_job)
     message(_("Executing <%s> ...") % batch_job_string)
     if isinstance(batch_job, string_types):
+        # shell=True is keeping the original GRASS_BATCH_JOB behavior
+        def quote(string):
+            if '"' in string:
+                return "'%s'" % batch_job
+            else:
+                return '"%s"' % batch_job
+        batch_job = quote(batch_job)
         proc = Popen(batch_job, shell=True)
     else:
         try: