diff -r 4e7ea18f171a Doc/library/shlex.rst --- a/Doc/library/shlex.rst Fri Dec 09 17:15:43 2016 +0100 +++ b/Doc/library/shlex.rst Mon Jan 02 18:02:19 2017 +0100 @@ -382,7 +382,9 @@ this is short of a full parser for shells (which would be out of scope for the standard library, given the multiplicity of shells out there), it does allow you to perform processing of command lines more easily than you could -otherwise. To illustrate, you can see the difference in the following snippet:: +otherwise. To illustrate, you can see the difference in the following snippet: + +.. testcode:: import shlex @@ -395,10 +397,12 @@ s = shlex.shlex(text, punctuation_chars=punct) print('%s: %s' % (message, list(s))) -which prints out:: +which prints out: - Old: ['a', '&', '&', 'b', ';', 'c', '&', '&', 'd', '|', '|', 'e', ';', 'f', '>', "'abc'", ';', '(', 'def', '"ghi"', ')'] - New: ['a', '&&', 'b', ';', 'c', '&&', 'd', '||', 'e', ';', 'f', '>', "'abc'", ';', '(', 'def', '"ghi"', ')'] +.. testoutput:: + + New: ['a', '&', '&', 'b', ';', 'c', '&', '&', 'd', '|', '|', 'e', ';', 'f', '>', "'abc'", ';', '(', 'def', '"ghi"', ')'] + Old: ['a', '&&', 'b', ';', 'c', '&&', 'd', '||', 'e', ';', 'f', '>', "'abc'", ';', '(', 'def', '"ghi"', ')'] Of course, tokens will be returned which are not valid for shells, and you'll need to implement your own error checks on the returned tokens.