While working on our project, we have noticed that for `subprocess.Popen(command, ...)`, when `command` is a string that contains escaped double quote, for example, `command = '"path to executable" --flag arg'`, this works fine. However, when command is changed to `shlex.split(command, posix=False)`, the Popen command fails. Looking a bit into the source code, it seems that for the command above,
```
>>> shlex.split('"path to executable" --flag arg', posix=False)
['"path to executable"', '--flag', 'arg']
```
and when this array of strings gets passed into `Popen`, the escaped double quote gets escaped again, since `subprocess.list2cmdline` does not check if a pair of double quote or single quote are wrapping the entire string `arg`. And this is the same behavior for both py2 and py3, https://github.com/python/cpython/blob/master/Lib/subprocess.py#L508. As a result, upon execution the command becomes, `'"\\"path to executable\\"" --flag arg'`
example:
```
>>> sp.list2cmdline(['"do things"'])
'"\\"do things\\""'
>>> sp.list2cmdline(['do things'])
'"do things"'
>
```
|