diff options
author | Greg Ward <gward@python.net> | 2000-03-07 03:25:20 (GMT) |
---|---|---|
committer | Greg Ward <gward@python.net> | 2000-03-07 03:25:20 (GMT) |
commit | e2b4452d0c3cc869d27e382100fda4466d39314b (patch) | |
tree | daf4310a7c253eac218ca98402a5895b0e7ac142 /Lib | |
parent | 73447411179f8da468eeb9c59b6d0c991bbb8476 (diff) | |
download | cpython-e2b4452d0c3cc869d27e382100fda4466d39314b.zip cpython-e2b4452d0c3cc869d27e382100fda4466d39314b.tar.gz cpython-e2b4452d0c3cc869d27e382100fda4466d39314b.tar.bz2 |
Added '_nt_quote_args()' to deal with whitespace in command-line arguments
in a rather half-assed, but probably effective, way.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/distutils/spawn.py | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/Lib/distutils/spawn.py b/Lib/distutils/spawn.py index 847346c..ae3d09f 100644 --- a/Lib/distutils/spawn.py +++ b/Lib/distutils/spawn.py @@ -42,11 +42,28 @@ def spawn (cmd, # spawn () -def _spawn_nt ( cmd, - search_path=1, - verbose=0, - dry_run=0): +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, + search_path=1, + verbose=0, + dry_run=0): + executable = cmd[0] + cmd = _nt_quote_args (cmd) if search_path: paths = string.split( os.environ['PATH'], os.pathsep) base,ext = os.path.splitext(executable) @@ -60,7 +77,7 @@ def _spawn_nt ( cmd, # the file exists, we have a shot at spawn working executable = f if verbose: - print string.join ( [executable] + cmd[1:], ' ') + print string.join ([executable] + cmd[1:], ' ') if not dry_run: # spawn for NT requires a full path to the .exe try: |