File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -42,11 +42,28 @@ def spawn (cmd,
4242# spawn ()
4343
4444
45- def _spawn_nt ( cmd ,
46- search_path = 1 ,
47- verbose = 0 ,
48- dry_run = 0 ):
45+ def _nt_quote_args (args ):
46+ """Obscure quoting command line arguments on NT.
47+ Simply quote every argument which contains blanks."""
48+
49+ # XXX this doesn't seem very robust to me -- but if the Windows guys
50+ # say it'll work, I guess I'll have to accept it. (What if an arg
51+ # contains quotes? What other magic characters, other than spaces,
52+ # have to be escaped? Is there an escaping mechanism other than
53+ # quoting?)
54+
55+ for i in range (len (args )):
56+ if string .find (args [i ], ' ' ) == - 1 :
57+ args [i ] = '"%s"' % args [i ]
58+
59+
60+ def _spawn_nt (cmd ,
61+ search_path = 1 ,
62+ verbose = 0 ,
63+ dry_run = 0 ):
64+
4965 executable = cmd [0 ]
66+ cmd = _nt_quote_args (cmd )
5067 if search_path :
5168 paths = string .split ( os .environ ['PATH' ], os .pathsep )
5269 base ,ext = os .path .splitext (executable )
@@ -60,7 +77,7 @@ def _spawn_nt ( cmd,
6077 # the file exists, we have a shot at spawn working
6178 executable = f
6279 if verbose :
63- print string .join ( [executable ] + cmd [1 :], ' ' )
80+ print string .join ([executable ] + cmd [1 :], ' ' )
6481 if not dry_run :
6582 # spawn for NT requires a full path to the .exe
6683 try :
You can’t perform that action at this time.
0 commit comments