summaryrefslogtreecommitdiff
path: root/Doc/library/shlex.rst
diff options
context:
space:
mode:
authorMarco Buttu <marco.buttu@gmail.com>2017-04-27 14:23:34 +0200
committerBerker Peksag <berker.peksag@gmail.com>2017-04-27 15:23:34 +0300
commite65fcde85abf6617508f2d6b77020e24b8ca6f6b (patch)
tree8cc02a1cb4906417c52bf720c72a1de65ed56048 /Doc/library/shlex.rst
parent6fde770e4e940c19cd62de0b6aeb77840690843e (diff)
downloadcpython-git-e65fcde85abf6617508f2d6b77020e24b8ca6f6b.tar.gz
bpo-27200: Fix several doctests (GH-604)
Diffstat (limited to 'Doc/library/shlex.rst')
-rw-r--r--Doc/library/shlex.rst6
1 files changed, 4 insertions, 2 deletions
diff --git a/Doc/library/shlex.rst b/Doc/library/shlex.rst
index 55012f80e8..fb335c6900 100644
--- a/Doc/library/shlex.rst
+++ b/Doc/library/shlex.rst
@@ -43,15 +43,16 @@ The :mod:`shlex` module defines the following functions:
string that can safely be used as one token in a shell command line, for
cases where you cannot use a list.
- This idiom would be unsafe::
+ This idiom would be unsafe:
>>> filename = 'somefile; rm -rf ~'
>>> command = 'ls -l {}'.format(filename)
>>> print(command) # executed by a shell: boom!
ls -l somefile; rm -rf ~
- :func:`quote` lets you plug the security hole::
+ :func:`quote` lets you plug the security hole:
+ >>> from shlex import quote
>>> command = 'ls -l {}'.format(quote(filename))
>>> print(command)
ls -l 'somefile; rm -rf ~'
@@ -61,6 +62,7 @@ The :mod:`shlex` module defines the following functions:
The quoting is compatible with UNIX shells and with :func:`split`:
+ >>> from shlex import split
>>> remote_command = split(remote_command)
>>> remote_command
['ssh', 'home', "ls -l 'somefile; rm -rf ~'"]