Runtime: Better handling of nested strings in spawn_subprocess commandline parsing svghmi
authorEdouard Tisserant
Thu, 29 Jul 2021 11:59:28 +0200
branchsvghmi
changeset 3293 d2b0c768755d
parent 3292 ef04cedee08b
child 3294 e3db472b0dfb
Runtime: Better handling of nested strings in spawn_subprocess commandline parsing
runtime/spawn_subprocess.py
--- a/runtime/spawn_subprocess.py	Thu Jul 29 08:25:26 2021 +0200
+++ b/runtime/spawn_subprocess.py	Thu Jul 29 11:59:28 2021 +0200
@@ -7,6 +7,7 @@
 from __future__ import absolute_import
 import os
 import signal
+import shlex
 import posix_spawn
 
 PIPE = "42"
@@ -104,9 +105,9 @@
     cmd = []
     if isinstance(args[0], str):
         if len(args) == 1:
-            # oversimplified splitting of arguments,
-            # TODO: care about use of simple and double quotes
-            cmd = args[0].split()
+            # splitting of arguments that cares about 
+            # use of simple and double quotes
+            cmd = shlex.split(args[0])
         else:
             cmd = args
     elif isinstance(args[0], list) and len(args) == 1: