On May 25, 2010, at 2:54 PM, Paul Moore wrote: > On 25 May 2010 13:22, Eric Smith <e...@trueblade.com> wrote: >> Keep in mind that these routines typically only work on Unix-like systems, >> where the shell has a set of well defined rules for quoting and parsing. On >> Windows, each executable is in charge of parsing its own parameters from a >> string. This is usually (but certainly not always) done by the C runtime >> startup. But different runtimes have different rules. Sadly, you sometimes >> have to know which executable you're calling before you can know how to >> escape its arguments. > > However, on Windows the rules used by the C runtime are a pretty good > baseline to work to. That's what subprocess does, and it's a good > practical solution. It's not perfect, but practicality beats purity > and all that....
> I'd say that this is a classic case where a library encapsulating > cross-platform differences [1] is extremely useful. If the stdlib > contained a cross-platform shell-quoting module, I'm pretty sure it > could replace a big chunk of adhoc application code. I'd also like to see both uses, splitting and joining posix/windows command lines cleaned up into a separate module. The interface to shlex can be a little daunting to deal with, with it's odd non-posix mode that isn't actually for the Windows shell. Plus it's complicated by the fact that it's also intended to be used as a generic parser. There's already a ticket requesting the ability to parse a Windows command line: http://bugs.python.org/issue1724822 -- Philip Jenvey _______________________________________________ stdlib-sig mailing list stdlib-sig@python.org http://mail.python.org/mailman/listinfo/stdlib-sig