Content-Length: 324924 | pFad | http://github.com/python/cpython/commit/e2b4452d0c3cc869d27e382100fda4466d39314b

74 Added '_nt_quote_args()' to deal with whitespace in command-line argu… · python/cpython@e2b4452 · GitHub
Skip to content

Commit e2b4452

Browse files
committed
Added '_nt_quote_args()' to deal with whitespace in command-line arguments
in a rather half-assed, but probably effective, way.
1 parent 7344741 commit e2b4452

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

Lib/distutils/spawn.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff 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:

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/python/cpython/commit/e2b4452d0c3cc869d27e382100fda4466d39314b

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy