This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eric.smith
Recipients Matthew Gamble, eric.smith
Date 2019-05-14.00:38:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1557794337.0.0.390798247199.issue36897@roundup.psfhosted.org>
In-reply-to
Content
Run 3.7 with -Wd:

$ python3 -Wd
Python 3.7.3 (default, Mar 29 2019, 13:03:53)
[GCC 7.4.0] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 'a \; b'
<stdin>:1: DeprecationWarning: invalid escape sequence \;
'a \\; b'
>>>

The deprecation is in relation to invalid escape sequences, not shlex.

My point is just that you should use r'a \; b' or 'a \\;b', and not rely on invalid escape sequences. For one reason, I can never remember how they're interpreted, and had to look it up. r-strings don't have anything to do with regular expressions per-se, they're a way of changing how python interprets stings, no matter what they're used for.

> 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.

My question is: can a posix-compliant shell tell the difference? I don't know, it's an honest question. Can you show some shell code where it can tell the difference?
History
Date User Action Args
2019-05-14 00:38:57eric.smithsetrecipients: + eric.smith, Matthew Gamble
2019-05-14 00:38:56eric.smithsetmessageid: <1557794337.0.0.390798247199.issue36897@roundup.psfhosted.org>
2019-05-14 00:38:56eric.smithlinkissue36897 messages
2019-05-14 00:38:56eric.smithcreate