summaryrefslogtreecommitdiff
path: root/Doc/library/subprocess.rst
diff options
context:
space:
mode:
authorMartin Panter <vadmium+py@gmail.com>2016-07-26 11:18:21 +0200
committerMartin Panter <vadmium+py@gmail.com>2016-07-26 11:18:21 +0200
commit1050d2d0c7730c6c533246bb2404937739a7775c (patch)
tree68d901cd196aead4df7c3b074ebf2df6e85678e7 /Doc/library/subprocess.rst
parent87ec85f4208bf329e6454fd3e2639c613b2b61af (diff)
downloadcpython-git-1050d2d0c7730c6c533246bb2404937739a7775c.tar.gz
Issue #26462: Doc: reduce literal_block warnings, fix syntax highlighting.
Patch by Julien Palard.
Diffstat (limited to 'Doc/library/subprocess.rst')
-rw-r--r--Doc/library/subprocess.rst21
1 files changed, 14 insertions, 7 deletions
diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst
index f469107cba..356605f76c 100644
--- a/Doc/library/subprocess.rst
+++ b/Doc/library/subprocess.rst
@@ -950,20 +950,23 @@ been imported from the :mod:`subprocess` module.
Replacing /bin/sh shell backquote
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-::
+.. code-block:: bash
output=`mycmd myarg`
- # becomes
- output = check_output(["mycmd", "myarg"])
+becomes::
+
+ output = check_output(["mycmd", "myarg"])
Replacing shell pipeline
^^^^^^^^^^^^^^^^^^^^^^^^
-::
+.. code-block:: bash
output=`dmesg | grep hda`
- # becomes
+
+becomes::
+
p1 = Popen(["dmesg"], stdout=PIPE)
p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE)
p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits.
@@ -973,10 +976,14 @@ The p1.stdout.close() call after starting the p2 is important in order for p1
to receive a SIGPIPE if p2 exits before p1.
Alternatively, for trusted input, the shell's own pipeline support may still
-be used directly::
+be used directly:
+
+.. code-block:: bash
output=`dmesg | grep hda`
- # becomes
+
+becomes::
+
output=check_output("dmesg | grep hda", shell=True)