mirror of
https://github.com/python/cpython.git
synced 2025-12-09 10:37:17 +00:00
Added '_nt_quote_args()' to deal with whitespace in command-line arguments
in a rather half-assed, but probably effective, way.
This commit is contained in:
parent
7344741117
commit
e2b4452d0c
1 changed files with 22 additions and 5 deletions
|
|
@ -42,11 +42,28 @@ def spawn (cmd,
|
||||||
# spawn ()
|
# spawn ()
|
||||||
|
|
||||||
|
|
||||||
|
def _nt_quote_args (args):
|
||||||
|
"""Obscure quoting command line arguments on NT.
|
||||||
|
Simply quote every argument which contains blanks."""
|
||||||
|
|
||||||
|
# XXX this doesn't seem very robust to me -- but if the Windows guys
|
||||||
|
# say it'll work, I guess I'll have to accept it. (What if an arg
|
||||||
|
# contains quotes? What other magic characters, other than spaces,
|
||||||
|
# have to be escaped? Is there an escaping mechanism other than
|
||||||
|
# quoting?)
|
||||||
|
|
||||||
|
for i in range (len (args)):
|
||||||
|
if string.find (args[i], ' ') == -1:
|
||||||
|
args[i] = '"%s"' % args[i]
|
||||||
|
|
||||||
|
|
||||||
def _spawn_nt (cmd,
|
def _spawn_nt (cmd,
|
||||||
search_path=1,
|
search_path=1,
|
||||||
verbose=0,
|
verbose=0,
|
||||||
dry_run=0):
|
dry_run=0):
|
||||||
|
|
||||||
executable = cmd[0]
|
executable = cmd[0]
|
||||||
|
cmd = _nt_quote_args (cmd)
|
||||||
if search_path:
|
if search_path:
|
||||||
paths = string.split( os.environ['PATH'], os.pathsep)
|
paths = string.split( os.environ['PATH'], os.pathsep)
|
||||||
base,ext = os.path.splitext(executable)
|
base,ext = os.path.splitext(executable)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue