Index: Lib/pipes.py =================================================================== --- Lib/pipes.py (Revision 77368) +++ Lib/pipes.py (Arbeitskopie) @@ -263,20 +263,15 @@ # 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): + if not file: + return "''" for c in file: if c not in _safechars: break else: return file - if '\'' not in file: - return '\'' + file + '\'' - res = '' - for c in file: - if c in _funnychars: - c = '\\' + c - res = res + c - return '"' + res + '"' + return "'" + file.replace("'", "'\"'\"'") + "'" Index: Lib/test/test_pipes.py =================================================================== --- Lib/test/test_pipes.py (Revision 77368) +++ Lib/test/test_pipes.py (Arbeitskopie) @@ -64,7 +64,7 @@ self.assertEqual(open(TESTFN).read(), d) def testQuoting(self): - safeunquoted = string.ascii_letters + string.digits + '!@%_-+=:,./' + safeunquoted = string.ascii_letters + string.digits + '@%_-+=:,./' unsafe = '"`$\\' self.assertEqual(pipes.quote(safeunquoted), safeunquoted) @@ -74,7 +74,7 @@ "'test%sname'" % u) for u in unsafe: self.assertEqual(pipes.quote("test%s'name'" % u), - '"test\\%s\'name\'"' % u) + "'test%s'\"'\"'name'\"'\"''" % u) def testRepr(self): t = pipes.Template()