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

anatoly techtonik techtonik at gmail.com
Thu Jun 12 00:53:20 CEST 2014


On Thu, Jun 12, 2014 at 1:30 AM, Chris Angelico <rosuav at gmail.com> wrote:

On Thu, Jun 12, 2014 at 7:58 AM, Ryan <rymg19 at gmail.com> wrote: > In all seriousness, to me this is obvious. When you pass a command to the > shell, naturally, certain details are shell-specific.

On Windows cmd.exe is used by default: http://hg.python.org/cpython/file/38a325c84564/Lib/subprocess.py#l1108 so it makes sense to make default behavior cross-platform.

> -10000. Bad idea. Very bad idea. If you want the ^ to be escaped, do it > yourself. Or better yet, don't pass shell=True.

Definitely the latter. Why pass shell=True when executing a single command? I don't get it.

This is a complete use case using Rietveld upload script: http://techtonik.rainforce.org/2013/07/code-review-with-rietveld-and-mercurial.html

I am interested to know how to modify upload script without kludges: https://code.google.com/p/rietveld/source/browse/upload.py#1056 I expect many people are facing with the same problem trying to wrap Git and HG with Python scripts.

anatoly t. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20140612/c6320701/attachment-0001.html>



More information about the Python-Dev mailing list