[Python-Dev] subprocess shell=True on Windows doesn't escape ^ character (original) (raw)
anatoly techtonik techtonik at gmail.com
Sat Jun 14 21:54:01 CEST 2014
- Previous message: [Python-Dev] subprocess shell=True on Windows doesn't escape ^ character
- Next message: [Python-Dev] subprocess shell=True on Windows doesn't escape ^ character
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Fri, Jun 13, 2014 at 2:55 AM, Ryan Gonzalez <rymg19 at gmail.com> wrote:
SHELLS ARE NOT CROSS-PLATFORM!!!! Seriously, there are going to be differences. If you really must:
escape = lambda s: s.replace('^', '^^') if os.name == 'nt' else s
It is not about generic shell problem, it is about specific behavior that on Windows Python already uses cmd.exe shell hardcoded in its sources. So for crossplatform behavior on Windows, it should escape symbols on command passed to cmd.exe that are special to this shell to avoid breaking Python scripts. What you propose is a bad workaround, because it assumes that all Python users who use subprocess to execute hg or git should possess apriori knowledge about default subprocess behaviour with default shell on Windows and implement workaround for that.
anatoly t. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.python.org/pipermail/python-dev/attachments/20140614/9f23e89d/attachment.html>
- Previous message: [Python-Dev] subprocess shell=True on Windows doesn't escape ^ character
- Next message: [Python-Dev] subprocess shell=True on Windows doesn't escape ^ character
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]