[issue36897] shlex doesn't differentiate escaped characters in output

Matthew Gamble report at bugs.python.org
Mon May 13 19:36:51 EDT 2019


Matthew Gamble <mgamble at fontis.com.au> added the comment:

The point is that it's not possible to use the output of shlex.shlex to try to match the behaviour of a POSIX-compliant shell by reliably splitting up a user's input into multiple commands. In the first case I presented (no escape character), the user entered two commands. In the second case, the user entered a single command with two arguments. However, there's no way to differentiate the two situations based on the output of shlex.

It's also worth noting that the output is the same with this too:

list(shlex.shlex('a \\; b', posix=True, punctuation_chars=True))

I tested this code on python 3.6.7 and 3.7.2, and didn't see any deprecation warnings at all. I also checked the history of shlex.py:

https://github.com/python/cpython/commits/master/Lib/shlex.py

The last commit was from 2017, and I don't see any usages of DeprecationWarning inside that file. I'm also not sure how r-strings are relevant, as I don't see any regular expressions used inside of the shlex class.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36897>
_______________________________________


More information about the Python-bugs-list mailing list