This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author eryksun
Recipients docs@python, eryksun, iMath, r.david.murray
Date 2017-04-16.05:14:03
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1492319643.32.0.769540885822.issue30079@psf.upfronthosting.co.za>
In-reply-to
Content
In Unix, passing an args list with shell=True makes the first element the -c command. The remaining elements are arguments for the shell itself, which makes them $N variables. For example:

    >>> subprocess.call(['echo $0, $1', 'spam', 'eggs'], shell=True)
    spam, eggs

In Windows, subprocess.list2cmdline assumes VC++ rules for creating a command line from a list. cmd's parsing rules are very different -- e.g. '^' is the escape character, and double quotes also escape special characters, except not '%'. (Shockingly there is no way to escape '%' on the cmd.exe command line -- only in batch files by doubling it. If you think '^' escapes it, you're wrong. cmd looks for an environment variable containing the '^' character. By luck it's usually not found.) cmd's parsing is convoluted, to say the least. Now combine that with having to pass command lines for external programs in way that they survive cmd's parsing without also breaking how the external program parses its command line. This problem is intractable. Just use a string. For anything complicated you may have to experiment a few times to figure out some permutation that works. The best option is to not use the shell at all.
History
Date User Action Args
2017-04-16 05:14:03eryksunsetrecipients: + eryksun, r.david.murray, docs@python, iMath
2017-04-16 05:14:03eryksunsetmessageid: <1492319643.32.0.769540885822.issue30079@psf.upfronthosting.co.za>
2017-04-16 05:14:03eryksunlinkissue30079 messages
2017-04-16 05:14:03eryksuncreate