In article <[EMAIL PROTECTED]>,
 "bill" <[EMAIL PROTECTED]> wrote:

> Consider:
> >>> import shlex
> >>> shlex.split('$(which sh)')
> ['$(which', 'sh)']
> 
> Is this behavior correct?  It seems that I should
> either get one token, or the list
> ['$','(','which','sh',')'],
> but certainly breaking it the way it does is
> erroneous.  
> 
> Can anyone explain why the string is being split
> that way?

Python 2.3.5 (#1, Mar 20 2005, 20:38:20) 
[GCC 3.3 20030304 (Apple Computer, Inc. build 1809)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import shlex
>>> print shlex.__doc__
A lexical analyzer class for simple shell-like syntaxes.


This has a little potential to mislead.  Bourne shell
syntax is naturally "shell-like", but it is not "simple" -
as grammars go, it's a notorious mess.  In theory, someone
could certainly write Python code to accurately parse Bourne
shell statements, but that doesn't appear to have been the
intention here.  The "Parsing Rules" section of the documentation
describes what you can expect, and right off hand I don't see
how the result you got was erroneous.

   Donn Cave, [EMAIL PROTECTED]
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to