should these be fixed for python 2.4?

Nick Craig-Wood nick at craig-wood.com
Sat Oct 2 06:30:15 EDT 2004


Andrew Dalke <adalke at mindspring.com> wrote:
>  I end up making a lot of system() and popen*() calls.  Looking
>  through the 30 or so cases (our of about 6800 LOC) I see that most
>  of them use hard coded parameters that don't need escaping.
>  Some of them do you commands.mkarg

Interesting command!

It doesn't (under 2.3) seem to do the right thing under windows
though, eg

>>> os.system("echo hello")
hello
0
>>> os.system("echo"+commands.mkarg("a"))
'a'
0
>>> os.system("echo"+commands.mkarg("a b '\""))
"a b '\""
0

Wheras if you run that under linux you get what I was expecting

>>> os.system("echo hello")
hello
0
>>> os.system("echo"+commands.mkarg("a"))
a
0
>>> os.system("echo"+commands.mkarg("a b '\""))
a b '"
0

My experiences lead me to believe Windows is big on " -> "" escaping
in the shell...

-- 
Nick Craig-Wood <nick at craig-wood.com> -- http://www.craig-wood.com/nick



More information about the Python-list mailing list