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 robodan
Recipients eric.araujo, eric.smith, robodan
Date 2010-09-03.18:42:26
SpamBayes Score 1.32295e-11
Marked as misclassified No
Message-id <>
In-reply-to <>
It's been a while since I looked at this.  I'm not really in a
position to contribute code/tests right now; but I can comment.

I don't think POSIX mode existed when I first reported this, but
that's where it makes sense.  I think all POSIX shells (borne, C,
korne), will behave the same way for the issues mentioned.

There are really two cases in one bug.

The first part is that the shell will split tokens at characters that
shlex doesn't.  The handling of &, |, ;, >, and < could be done by
adjusting the definition of shlex.wordchars.  The shell may also
understands things like: &&, ||, |&, and >&.  The exact definition of
these depends on the shell, so maybe it's best to just split them out
as separate tokens and let the user figure out the compound meanings.

The proper handling of quotes/escapes requires some kind of new
interface.  You need to distinguish between tokens that were modified
by the quote/escape rules and those that were not.  One suggestion is
to add a new method as such:

   Return a tuple of the token and the original text of the token
(including quotes and escapes).  Otherwise, this is the same as

Comparing the two values for equality (or maybe identity) would tell
you if something special was going on.  You can always pass the second
value to a reconstructed command line without losing any of the
original parsing information.


On Fri, Sep 3, 2010 at 10:27 AM, Éric Araujo <> wrote:
> Éric Araujo <> added the comment:
> Thanks for the report. Would you like to work on a patch, or translate your examples into unit tests?
> The docs do not mention “&” at all, and platform discrepancies have to be taken into account too, so I really don’t know if this is a bug fix for the normal mode, the POSIX mode, or a feature request requiring a new argument to the shlex function to preserve compatibility.
> ----------
> nosy: +eric.araujo, eric.smith
> _______________________________________
> Python tracker <>
> <>
> _______________________________________
Date User Action Args
2010-09-03 18:42:28robodansetrecipients: + robodan, eric.smith, eric.araujo
2010-09-03 18:42:27robodanlinkissue1521950 messages
2010-09-03 18:42:26robodancreate