Changeset 285 in tailor


Ignore:
Timestamp:
05/07/05 03:01:24 (8 years ago)
Author:
lele@…
Hash name:
20050507010124-97f81-0da6df928335f21dfc0f3e0ce99fd1eba78e70fb
Message:

Escape some more characters
Escape also regexp metachars: maybe I should use another function to
escape the patch names that darcs treats as regular expressions, but
this seems enough for now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vcpx/shwrap.py

    r282 r285  
    1212 
    1313def shrepr(str): 
     14    """ 
     15    Escape an arbitrary string so that it is safe to pass it as 
     16    argument to a shell command. 
     17    """ 
     18     
    1419    str = '\\\\'.join(str.split('\\')) 
    1520    str = '\\"'.join(str.split('"')) 
     
    1823    str = '\\?'.join(str.split('?')) 
    1924    str = '\\`'.join(str.split('`')) 
     25    str = '\\('.join(str.split('(')) 
     26    str = '\\)'.join(str.split(')')) 
     27    str = '\\['.join(str.split('[')) 
     28    str = '\\]'.join(str.split(']')) 
    2029     
    2130    return '"' + str + '"' 
Note: See TracChangeset for help on using the changeset viewer.