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 eric.smith, max, peter.otten
Date 2019-01-20.15:27:33
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1547998053.28.0.186120901198.issue35787@roundup.psfhosted.org>
In-reply-to
Content
I agree that the current behavior makes sense. I think "preserve the literal value of the next character" means the space won't be interpreted as a separator.

In the first example (I think better written as shlex.split(r'a \ b')), the first space is a separator. The second space is not a separator because of the backslash, so it's part of the second token ' b'.

In the second example (shlex.split(r'a \  b')), the first space is a separator, the second space is not a separator because of the backslash, and the third space is a separator. This explains why there's no space before the 'b'.

I assume peter.otten's example is bash. I can confirm with zsh:

[~]$ python3 -c 'import sys; print(sys.argv)' a   b
['-c', 'a', 'b']
[~]$ python3 -c 'import sys; print(sys.argv)' a \ b
['-c', 'a', ' b']
[~]$ python3 -c 'import sys; print(sys.argv)' a \  b
['-c', 'a', ' ', 'b']

I'm going to close this. But anyone wants to suggest a documentation patch, feel free to reopen this.

Also, changing this would no doubt break some code, so I'd recommend against changing it even if I didn't think it was doing the right thing.
History
Date User Action Args
2019-01-20 15:27:35eric.smithsetrecipients: + eric.smith, peter.otten, max
2019-01-20 15:27:33eric.smithsetmessageid: <1547998053.28.0.186120901198.issue35787@roundup.psfhosted.org>
2019-01-20 15:27:33eric.smithlinkissue35787 messages
2019-01-20 15:27:33eric.smithcreate