From e65fcde85abf6617508f2d6b77020e24b8ca6f6b Mon Sep 17 00:00:00 2001 From: Marco Buttu Date: Thu, 27 Apr 2017 14:23:34 +0200 Subject: bpo-27200: Fix several doctests (GH-604) --- Doc/library/shlex.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'Doc/library/shlex.rst') 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 ~'"] -- cgit v1.2.1