See also 28391: Multiple occurances of: Closing quotes separate words
The issue 28391 is accepted, as it is defined:
Quotes *within* words are ignored, only a leading quoted string will result in a separate word. (That's recursive: try '"Do""This""Separate).
So I implement for compatibility mode your proposal.
But the example does not seem to work as expected, so seems to hint to a bug. Thus openning a seperate issue:
snip-->
import shlex
sopts = """-a "Do""This""Separate" """
resx = ["-a", '"Do"', 'ThisSeparate', ]
res=shlex.split(sopts,posix=False)
print "sopts ="+str(sopts)
print "resx ="+str(resx)
print "res ="+str(res)
assert res == resx
"""
Results in:
sopts =-a "Do""This""Separate"
resx =['-a', '"Do"', 'ThisSeparate']
res =['-a', '"Do"', '"This"', '"Separate"']
Traceback (most recent call last):
File "shlex_demo.py", line 52, in <module>
assert res == resx
AssertionError
"""
<--snip
I also checked the variant with a trailing quoted word for completeness, which is not enclosed. Does not split at all:
sopts =-a Do"SeparateThis"
resx =['-a', 'Do', '"SeparateThis"']
res =['-a', 'Do"SeparateThis"']
|