Re: [Distutils] Possible Distutils shell processing bug
![](https://secure.gravatar.com/avatar/1efc90ff6075b7654d8a8ce6e51a2cd3.jpg?s=120&d=mm&r=g)
"Brian Quinlan" <brian@sweetapp.com> writes:
Is it intended that users must escape their own strings, which are passed to the shell? As an example, if I wanted to define a string for the preprocessor, I would have to do something like this:
defines = [('VERSION',r'\"1.2.3\"')]
If I hadn't escaped the double quotes then the shell would have removed them*.
It took me a good five minutes to figure out this problem and I'm sure that others have hit this gotcha.
Hmm. What happens in this instance on Windows? We should probably try to make the behaviour consistent. But quoting in sh is a quick way to insanity. Cheers, M. -- I'm not sure that the ability to create routing diagrams similar to pretzels with mad cow disease is actually a marketable skill. -- Steve Levin -- http://home.xnet.com/~raven/Sysadmin/ASR.Quotes.html
![](https://secure.gravatar.com/avatar/08b0ead6cbf62f4939c1b0f22b12f174.jpg?s=120&d=mm&r=g)
Michael wrote:
Hmm. What happens in this instance on Windows? We should probably try to make the behaviour consistent.
But quoting in sh is a quick way to insanity.
cmd.exe and sh do the same thing: they collect quoted arguments into one command argument and remove the quotes. So the solution seems pretty simple: just replace all instances of " with \" Cheers, Brian
![](https://secure.gravatar.com/avatar/12362ecee4672f1dd2d641ce5b4eca14.jpg?s=120&d=mm&r=g)
Brian Quinlan wrote:
Michael wrote:
Hmm. What happens in this instance on Windows? We should probably try to make the behaviour consistent.
But quoting in sh is a quick way to insanity.
cmd.exe and sh do the same thing: they collect quoted arguments into one command argument and remove the quotes. So the solution seems pretty simple: just replace all instances of " with \"
I suppose we should add an API for shell quoting to util.py... provided we can come up with a sane standard for quoting. -- Marc-Andre Lemburg CEO eGenix.com Software GmbH ______________________________________________________________________ Company & Consulting: http://www.egenix.com/ Python Software: http://www.egenix.com/files/python/
participants (3)
-
Brian Quinlan
-
M.-A. Lemburg
-
Michael Hudson