Tim Roberts <t...@probo.com> wrote: > Bill Janssen wrote: > > Anyone know if the quote() function in the "pipes" module does the right > > thing for cmd.exe pipes? > > > > No, it doesn't. It uses sh rules, which aren't the same. > > > If not, what is the right thing? > > Unfortunately, command line parsing in Windows is not centralized in the > shell. To satisfy cmd.exe, you can safely surround each file name in > double quotes. Whether the application knows how to handle that or not > is up to the application (although most do it correctly). Remember that > this is only necessary when passing names to the command shell. The > Windows APIs don't want the quotes.
I'm actually not passing file names. I'm passing argument strings, which may contain spaces, quotes, and other things. For instance, myprogram --title="That's the game! says Mike "Hammer" Brotsky" --file=... "myprogram" is a Python program, and expects to get the whole "--title" argument as a single element of sys.argv. On Unix, I use arg = "--title=%s" % pipes.quote(title) to achieve that effect. What's the equivalent on Windows? Since cmd.exe also supports pipelines, I'd sort of expect it to do the right thing on Windows, too. Bill _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32