summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2010-05-19 20:57:08 (GMT)
committerGeorg Brandl <georg@python.org>2010-05-19 20:57:08 (GMT)
commit8569e582f85e8a44bf34238f6a1809eb6e001de9 (patch)
tree330faf435a111cf1229b9c87f014873da7ba25ae /Lib
parent7d79b8b7714b5e7d8a0582a07b5625c280c879c0 (diff)
downloadcpython-8569e582f85e8a44bf34238f6a1809eb6e001de9.zip
cpython-8569e582f85e8a44bf34238f6a1809eb6e001de9.tar.gz
cpython-8569e582f85e8a44bf34238f6a1809eb6e001de9.tar.bz2
Merged revisions 80030,80067,80069,80080-80081,80084,80432-80433,80465-80470,81059,81065-81067 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r80030 | georg.brandl | 2010-04-13 08:43:54 +0200 (Di, 13 Apr 2010) | 1 line Get rid of multi-row cells. ........ r80067 | georg.brandl | 2010-04-14 10:53:38 +0200 (Mi, 14 Apr 2010) | 1 line #5341: typo. ........ r80069 | georg.brandl | 2010-04-14 15:50:31 +0200 (Mi, 14 Apr 2010) | 1 line Add an x-ref to where the O_ constants are documented and move the SEEK_ constants after lseek(). ........ r80080 | georg.brandl | 2010-04-14 21:16:38 +0200 (Mi, 14 Apr 2010) | 1 line #8399: add note about Windows and O_BINARY. ........ r80081 | georg.brandl | 2010-04-14 23:34:44 +0200 (Mi, 14 Apr 2010) | 1 line #5250: document __instancecheck__ and __subclasscheck__. I hope the part about the class/metaclass distinction is understandable. ........ r80084 | georg.brandl | 2010-04-14 23:46:45 +0200 (Mi, 14 Apr 2010) | 1 line Fix missing. ........ r80432 | georg.brandl | 2010-04-24 10:56:58 +0200 (Sa, 24 Apr 2010) | 1 line Markup fixes. ........ r80433 | georg.brandl | 2010-04-24 11:08:10 +0200 (Sa, 24 Apr 2010) | 1 line #7507: quote "!" in pipes.quote(); it is a special character for some shells. ........ r80465 | georg.brandl | 2010-04-25 12:29:17 +0200 (So, 25 Apr 2010) | 1 line Remove LaTeXy index entry syntax. ........ r80466 | georg.brandl | 2010-04-25 12:54:42 +0200 (So, 25 Apr 2010) | 1 line Patch from Tim Hatch: Better cross-referencing in socket and winreg docs. ........ r80467 | georg.brandl | 2010-04-25 12:55:16 +0200 (So, 25 Apr 2010) | 1 line Patch from Tim Hatch: Remove reference to winreg being the fabled high-level registry interface. ........ r80468 | georg.brandl | 2010-04-25 12:55:58 +0200 (So, 25 Apr 2010) | 1 line Patch from Tim Hatch: Minor spelling changes to _winreg docs. ........ r80469 | georg.brandl | 2010-04-25 12:56:41 +0200 (So, 25 Apr 2010) | 1 line Fix code example to have valid syntax so that it can be highlighted. ........ r80470 | georg.brandl | 2010-04-25 12:57:15 +0200 (So, 25 Apr 2010) | 1 line Patch from Tim Hatch: Make socket setblocking <-> settimeout examples symmetric. ........ r81059 | georg.brandl | 2010-05-10 23:02:51 +0200 (Mo, 10 Mai 2010) | 1 line #8642: fix wrong function name. ........ r81065 | georg.brandl | 2010-05-10 23:46:50 +0200 (Mo, 10 Mai 2010) | 1 line Fix reference direction. ........ r81066 | georg.brandl | 2010-05-10 23:50:57 +0200 (Mo, 10 Mai 2010) | 1 line Consolidate deprecation messages. ........ r81067 | georg.brandl | 2010-05-10 23:51:33 +0200 (Mo, 10 Mai 2010) | 1 line Fix typo. ........
Diffstat (limited to 'Lib')
-rw-r--r--Lib/pipes.py17
-rw-r--r--Lib/test/test_pipes.py9
2 files changed, 10 insertions, 16 deletions
diff --git a/Lib/pipes.py b/Lib/pipes.py
index deab815..51666a8 100644
--- a/Lib/pipes.py
+++ b/Lib/pipes.py
@@ -249,11 +249,11 @@ def makepipeline(infile, steps, outfile):
# Reliably quote a string as a single argument for /bin/sh
-_safechars = string.ascii_letters + string.digits + '!@%_-+=:,./' # Safe unquoted
-_funnychars = '"`$\\' # Unsafe inside "double quotes"
+# Safe unquoted
+_safechars = frozenset(string.ascii_letters + string.digits + '@%_-+=:,./')
def quote(file):
- ''' return a shell-escaped version of the file string '''
+ """Return a shell-escaped version of the file string."""
for c in file:
if c not in _safechars:
break
@@ -261,11 +261,6 @@ def quote(file):
if not file:
return "''"
return file
- if '\'' not in file:
- return '\'' + file + '\''
- res = ''
- for c in file:
- if c in _funnychars:
- c = '\\' + c
- res = res + c
- return '"' + res + '"'
+ # use single quotes, and put single quotes into double quotes
+ # the string $'b is then quoted as '$'"'"'b'
+ return "'" + file.replace("'", "'\"'\"'") + "'"
diff --git a/Lib/test/test_pipes.py b/Lib/test/test_pipes.py
index 9ce137e..3d31fce 100644
--- a/Lib/test/test_pipes.py
+++ b/Lib/test/test_pipes.py
@@ -70,9 +70,10 @@ class SimplePipeTests(unittest.TestCase):
self.assertEqual(open(TESTFN).read(), d)
def testQuoting(self):
- safeunquoted = string.ascii_letters + string.digits + '!@%_-+=:,./'
- unsafe = '"`$\\'
+ safeunquoted = string.ascii_letters + string.digits + '@%_-+=:,./'
+ unsafe = '"`$\\!'
+ self.assertEqual(pipes.quote(''), "''")
self.assertEqual(pipes.quote(safeunquoted), safeunquoted)
self.assertEqual(pipes.quote('test file name'), "'test file name'")
for u in unsafe:
@@ -80,9 +81,7 @@ class SimplePipeTests(unittest.TestCase):
"'test%sname'" % u)
for u in unsafe:
self.assertEqual(pipes.quote("test%s'name'" % u),
- '"test\\%s\'name\'"' % u)
-
- self.assertEqual(pipes.quote(''), "''")
+ "'test%s'\"'\"'name'\"'\"''" % u)
def testRepr(self):
t = pipes.Template()