summaryrefslogtreecommitdiff
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/pipes.py3
-rw-r--r--Lib/test/test_pipes.py2
2 files changed, 5 insertions, 0 deletions
diff --git a/Lib/pipes.py b/Lib/pipes.py
index 6dcc997b4c..25e99159b8 100644
--- a/Lib/pipes.py
+++ b/Lib/pipes.py
@@ -267,10 +267,13 @@ _safechars = string.ascii_letters + string.digits + '!@%_-+=:,./' # Safe unquote
_funnychars = '"`$\\' # Unsafe inside "double quotes"
def quote(file):
+ ''' return a shell-escaped version of the file string '''
for c in file:
if c not in _safechars:
break
else:
+ if not file:
+ return "''"
return file
if '\'' not in file:
return '\'' + file + '\''
diff --git a/Lib/test/test_pipes.py b/Lib/test/test_pipes.py
index 0eca8edf10..dd1cc9e952 100644
--- a/Lib/test/test_pipes.py
+++ b/Lib/test/test_pipes.py
@@ -74,6 +74,8 @@ class SimplePipeTests(unittest.TestCase):
self.assertEqual(pipes.quote("test%s'name'" % u),
'"test\\%s\'name\'"' % u)
+ self.assertEqual(pipes.quote(''), "''")
+
def testRepr(self):
t = pipes.Template()
self.assertEqual(repr(t), "<Template instance, steps=[]>")