Shell quoting as part of the standard library?
David M. Wilson
dw-google.com at botanicus.net
Sun Dec 14 14:17:40 EST 2003
Oren Tirosh <oren-py-l at hishome.net> wrote...
> The best solution is often to bypass the shell (os.system) and execute
> the external command you want directly with os.spawnv. In this case the
> arguments are passed as a list of strings rather than a space-separated
> string and therefore need no quoting.
That would be a fine solution, except again it does not solve my
problem. In the latest application of shell quoting, I needed to
insert filenames into a shell excerpt provided by a user who is
knowledgeable in shell.
They could write, for instance:
process_app %(input_filename) || something %(blah)
[ -s %(output_filename) ] && ...
But it would be above them to express that in Python, so bypassing the
shell is not an option. Thanks,
David.
More information about the Python-list
mailing list