[Python-Dev] subprocess shell=True on Windows doesn't escape ^ character (original) (raw)
R. David Murray rdmurray at bitdance.com
Thu Jun 12 01:00:29 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 ]
Also notice that using a list with shell=True is using the API incorrectly. It wouldn't even work on Linux, so that torpedoes the cross-platform concern already :)
This kind of confusion is why I opened http://bugs.python.org/issue7839.
On Wed, 11 Jun 2014 16:58:30 -0500, Ryan <rymg19 at gmail.com> wrote:
Of course! And, why not escape everything else, too?
abc -> ^a^b^c echo %PATH% -> ^e^c^h^o^ ^%^P^A^T^H^% In all seriousness, to me this is obvious. When you pass a command to the shell, naturally, certain details are shell-specific. -10000. Bad idea. Very bad idea. If you want the ^ to be escaped, do it yourself. Or better yet, don't pass shell=True. anatoly techtonik <techtonik at gmail.com> wrote: >I am banned from tracker, so I post the bug here: > >Normal Windows behavior: > > >hg status --rev ".^1" > M mercurial\commands.py > ? pysptest.py > > >hg status --rev .^1 > abort: unknown revision '.1'! > >So, ^ is an escape character. See >http://www.tomshardware.co.uk/forum/35565-45-when-special-command-line > > >But subprocess doesn't escape it, making cross-platform command fail on >Windows. > >---[cut pysptest.py]-- >import subprocess as sp > ># this fails with ># abort: unknown revision '.1'! >cmd = ['hg', 'status', '--rev', '.^1'] ># this works >#cmd = 'hg status --rev ".^1"' ># this works too >#cmd = ['hg', 'status', '--rev', '.^^1'] > >try: > print sp.checkoutput(cmd, stderr=sp.STDOUT, shell=True) >except Exception as e: > print e.output >------------------------------ > >-- >anatoly t. > > >------------------------------------------------------------------------ > >_______________________ >Python-Dev mailing list >Python-Dev at python.org >https://mail.python.org/mailman/listinfo/python-dev >Unsubscribe: >https://mail.python.org/mailman/options/python-dev/rymg19%40gmail.com -- Sent from my Android phone with K-9 Mail. Please excuse my brevity.
Python-Dev mailing list Python-Dev at python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/rdmurray%40bitdance.com
- 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 ]