Michael Barton
2007-11-14 22:56:52 UTC
Split the command into a list by spaces. I realize that this is a problem
for any command with spaces in the arguments, but I know of no better way to
do this in this context outside of making users type any command as a Python
list. If we made people type ['g.region', 'rast=mymap', 'res=30'] instead of
g.region rast=mymap res=30, I don't think anyone would want to use the CLI.
This is one case where shell=True *is* legitimate. At least with afor any command with spaces in the arguments, but I know of no better way to
do this in this context outside of making users type any command as a Python
list. If we made people type ['g.region', 'rast=mymap', 'res=30'] instead of
g.region rast=mymap res=30, I don't think anyone would want to use the CLI.
shell, the user can use quotes or backslashes to include spaces in
arguments. Or you could implement equivalent functionality yourself.
class and would have to do a custom version of Popen. Then I'd have to send
them through a different processing path rather than the RunCmd method that
everything else uses.
Michael
The latter is more work, but you can choose exactly which shell
functionality you want, e.g. allowing spaces (and other
metacharacters) without the other shell behaviour (sequences,
pipelines, redirection, variables, ....).
__________________________________________functionality you want, e.g. allowing spaces (and other
metacharacters) without the other shell behaviour (sequences,
pipelines, redirection, variables, ....).
Michael Barton, Professor of Anthropology and Director of Graduate Studies
School of Human Evolution & Social Change
Center for Social Dynamics and Complexity
Arizona State University
phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton