On Mon, May 24, 2010 at 07:46:32AM -0700, Bill Janssen wrote: > I'm kind of surprised to see that the subprocess module doesn't have a > documented function for calling to properly quote command-line > arguments. Nor does it seem to do so automatically -- at least on Unix.
Bill, I may be about to reveal my profound ignorance here, but... do you need to quote arguments passed as a list on UNIX? My impression was that if shell=False, then it wasn't needed. > It *does* have an undocumented function called "list2cmdline" (refered > to in passing in the docs as a "method"), which is called automatically > if the "args" parameter to the Popen() initializer is a sequence, and > the platform is Windows, but not otherwise. No similar quoting of args > is done for Unix. > > On the other hand, the "pipes" module has another undocumented function > called "quote", which seems to perform similar quoting, but for sh. > "Pipes" is documented to work only under Unix -- which is a bit strange, > as cmd.exe supports pipes on Windows as well. > > Given that Python, even 3, ships with os.system() and os.popen() and > subprocess and pipes and perhaps others that I don't know about, > exposing a quoting mechanism that appropriately quotes for either sh or > cmd.exe, depending on platform, wouldn't be a bad idea. And perhaps > pipes should be eliminated, or re-written in terms of subprocess to be > cross-platform. Yeah, this whole part of the stdlib is a small horror show. (I didn't even know the 'pipes' module existed... wow.) --titus -- C. Titus Brown, c...@msu.edu _______________________________________________ stdlib-sig mailing list stdlib-sig@python.org http://mail.python.org/mailman/listinfo/stdlib-sig