bash like expansion

bill bill.pursell at gmail.com
Fri May 13 01:50:45 EDT 2005


Quick glance at the reference manual, and I think that pipes.Template
may do exactly what I want.  Is that what you're referring to?

I realized when I woke up that I have another slight irritant:
I need to be able to intelligently parse a command line.  ie
I need to correctly parse each of the following strings:

"echo foo"
"/bin/echo 'the cat'"
"$(which echo) foo"

and generate the list:
["/bin/echo", arg] where arg is either "foo" or "the cat"

I believe that Template will help me with this as well.  I'll look into
it today, after the dogs are walked...(note, shlex becomes annoying
here, as it will correctly tokenize "the cat" for me, but it splits
/bin/echo up into 4 tokens, which I now have to parse)

My current solution is to use os.system(a), but I'd much rather parse a
and use an exec function.

I'm not too concerned about portability accross different shells, as
long as it works in (ba)sh.  Also, I'm constrained to python 2.2, so I
have no doubt that there is a "shInterpret" module in 2.3 or 2.4!!




More information about the Python-list mailing list