Hmmm,  the following session causes me some concern:
>>> print a
$(which sh) ${HOME/b/k} 'the dog'
>>> print b
/bin/sh /home/kill the dog
>>> shlex.split(a)
['$(which', 'sh)', '${HOME/b/k}', 'the dog']
>>> shlex.split(b)
['/bin/sh', '/home/kill', 'the', 'dog']

I started with a, which contains the 3 cases that I'm worried about:
expanding $(), variable expansion, and a token containing white space.
b was generated using commands.getoutput('echo ' +a).  So b has most of
the right stuff, but it loses the parens and 'the dog' is split by
shlex.  But shlex breaks up $(which sh).  Is that correct behavior from
shlex?  It feels like shlex should return '$(which sh)' as a single
token.

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to