Matthew Gamble added the comment:
My apologies, I didn't realise you were talking about the invalid escape
sequence. Thanks for letting me know about the fact that it's deprecated, I'll
definitely be keeping that in mind going forward.
In a bash shell with the find command available, run the
Eric V. Smith added the comment:
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'
:1: DeprecationWarning: invalid escape sequence \;
'a \\; b'
>>>
The depreca
Matthew Gamble 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 entere
Eric V. Smith added the comment:
The goal is to match posix shell semantics. Can you provide a concrete example
where shlex.shlex does something different from a posix-compliant shell? With
all the escaping, it's going to be tough.
Note also that your code raises a DeprecationWarning in 3.7,
New submission from Matthew Gamble :
The output of the following invocations are exactly the same:
list(shlex.shlex('a ; b', posix=True, punctuation_chars=True))
list(shlex.shlex('a \; b', posix=True, punctuation_chars=True))
They both output the following:
['a', ';', 'b']
This makes it imp