Changeset 388 for python/vendor/current/Lib/pipes.py
- Timestamp:
- Mar 19, 2014, 11:11:30 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/vendor/current/Lib/pipes.py
r2 r388 55 55 To create a new template object initialized to a given one: 56 56 t2 = t.clone() 57 58 For an example, see the function test() at the end of the file.59 57 """ # ' 60 58 … … 264 262 # Reliably quote a string as a single argument for /bin/sh 265 263 266 _safechars = string.ascii_letters + string.digits + '!@%_-+=:,./'# Safe unquoted267 _ funnychars = '"`$\\' # Unsafe inside "double quotes"264 # Safe unquoted 265 _safechars = frozenset(string.ascii_letters + string.digits + '@%_-+=:,./') 268 266 269 267 def quote(file): 270 ''' return a shell-escaped version of the file string '''268 """Return a shell-escaped version of the file string.""" 271 269 for c in file: 272 270 if c not in _safechars: … … 276 274 return "''" 277 275 return file 278 if '\'' not in file: 279 return '\'' + file + '\'' 280 res = '' 281 for c in file: 282 if c in _funnychars: 283 c = '\\' + c 284 res = res + c 285 return '"' + res + '"' 276 # use single quotes, and put single quotes into double quotes 277 # the string $'b is then quoted as '$'"'"'b' 278 return "'" + file.replace("'", "'\"'\"'") + "'"
Note:
See TracChangeset
for help on using the changeset viewer.