[Python-Dev] subprocess shell=True on Windows doesn't escape ^ character (original) (raw)

Tim Golden mail at timgolden.me.uk
Sun Jun 15 10:58:32 CEST 2014


On 15/06/2014 08:54, Paul Moore wrote:

On 15 June 2014 00:15, Greg Ewing <greg.ewing at canterbury.ac.nz> wrote:

However, it says the Windows version uses CreateProcess, which doesn't use PATH. Huh? CreateProcess uses PATH:

Just to be precise:

CreateProcess doesn't use PATH if you pass an lpApplicationName parameter. It does use PATH if you pass a lpCommandLine parameter without an lpApplicationName parameter. It's possible to do either via the subprocess module, but the latter is the default.

If you call:

subprocess.Popen(['program.exe', 'a', 'b'])

or

subprocess.Popen('program.exe a b'])

Then CreateProcess will be called with a lpCommandLine but no lpApplicationName and PATH will be searched.

If, however, you call:

subprocess.Popen(['a', 'b'], executable="program.exe")

then CreateProcess will be called with lpApplicationName="program.exe" and lpCommandLine="a b" and the PATH will not be searched.

TJG



More information about the Python-Dev mailing list