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.

classification
Title: Don't use a list argument together with shell=True in subprocess' docs
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: akira, cvrebert, docs@python, eric.araujo, python-dev, r.david.murray
Priority: normal Keywords: patch

Created on 2014-04-24 19:08 by akira, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
docs-subprocess-dont_use_list_with_shell_true.patch akira, 2014-04-24 19:08 review
Messages (4)
msg217136 - (view) Author: Akira Li (akira) * Date: 2014-04-24 19:08
*Popen(["something"], shell=True)* works but it is similar to
*Popen(["something", "arg"], shell=True)* that passes "arg" to /bin/sh on POSIX systems instead of "something".

It is best to always use a string if `shell=True` is necessary.

It is a common confusion #20344, msg98732, #7839

http://stackoverflow.com/questions/21029154/understanding-python-subprocess-check-outputs-first-argument-and-shell-true
http://stackoverflow.com/questions/20787712/start-openoffice-process-with-python-to-use-with-pyuno-using-subprocess
http://stackoverflow.com/questions/17880847/python-subprocess-error-in-using-cp
http://stackoverflow.com/questions/17226912/why-does-simple-echo-in-subprocess-not-working
http://stackoverflow.com/questions/15109665/subprocess-call-using-string-vs-using-list
http://stackoverflow.com/questions/20128114/pythons-subprocess-does-not-interpret-as-expected-on-cygwin
http://stackoverflow.com/questions/16840427/python-on-linux-subprocess-popen-works-weird-with-shell-true
...
msg217760 - (view) Author: Akira Li (akira) * Date: 2014-05-02 17:08
I've checked the same documentation patch applies to both default (3.5) and 2.7 branches.

There are no more instances of the misleading usage left (after applying the patch).
msg218533 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-05-14 14:10
New changeset 5ef9a2c711f5 by R David Murray in branch '2.7':
#21347: use string not list in shell=True example.
http://hg.python.org/cpython/rev/5ef9a2c711f5

New changeset 3b27f3acf0c4 by R David Murray in branch '3.4':
#21347: use string not list in shell=True example.
http://hg.python.org/cpython/rev/3b27f3acf0c4

New changeset 217006c5455f by R David Murray in branch 'default':
Merge: #21347: use string not list in shell=True example.
http://hg.python.org/cpython/rev/217006c5455f
msg218534 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2014-05-14 14:11
Thanks, Akira.
History
Date User Action Args
2022-04-11 14:58:02adminsetgithub: 65546
2014-05-14 14:11:07r.david.murraysetstatus: open -> closed

nosy: + r.david.murray
messages: + msg218534

resolution: fixed
stage: resolved
2014-05-14 14:10:37python-devsetnosy: + python-dev
messages: + msg218533
2014-05-02 17:08:01akirasetmessages: + msg217760
2014-05-02 16:46:42cvrebertsetnosy: + cvrebert
2014-04-25 19:22:50eric.araujosetnosy: + eric.araujo

versions: + Python 2.7, Python 3.4
2014-04-24 19:08:42akiracreate