{"action":"created","issue":{"url":"https://api.github.com/repos/fabric/fabric/issues/1285","labels_url":"https://api.github.com/repos/fabric/fabric/issues/1285/labels{/name}","comments_url":"https://api.github.com/repos/fabric/fabric/issues/1285/comments","events_url":"https://api.github.com/repos/fabric/fabric/issues/1285/events","html_url":"https://github.com/fabric/fabric/issues/1285","id":59783705,"number":1285,"title":"Add escape=True parameter to fabric.contrib.sed","user":{"login":"brunato","id":2034665,"avatar_url":"https://avatars.githubusercontent.com/u/2034665?v=3","gravatar_id":"","url":"https://api.github.com/users/brunato","html_url":"https://github.com/brunato","followers_url":"https://api.github.com/users/brunato/followers","following_url":"https://api.github.com/users/brunato/following{/other_user}","gists_url":"https://api.github.com/users/brunato/gists{/gist_id}","starred_url":"https://api.github.com/users/brunato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brunato/subscriptions","organizations_url":"https://api.github.com/users/brunato/orgs","repos_url":"https://api.github.com/users/brunato/repos","events_url":"https://api.github.com/users/brunato/events{/privacy}","received_events_url":"https://api.github.com/users/brunato/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/fabric/fabric/labels/Contrib","name":"Contrib","color":"ededed"},{"url":"https://api.github.com/repos/fabric/fabric/labels/Feature","name":"Feature","color":"40a056"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-04T11:12:45Z","updated_at":"2015-03-24T13:54:34Z","closed_at":null,"body":"I tried **fabric.contrib.sed** to modify a line in a file, but the pattern that I have to replace includes some special chars like '+' and '=' and also some '/' chars. So I have to unescape some chars before **sed** calls to avoid a double escaping (eg. '+/' --> '\\\\+\\/' --> '\\\\+\\\\\\\\/') and a subsequent throwing of an exception.\r\n\r\nSo I ask, if it's not a problem, if it's possible adding an \"escape=True\" parameter to the **sed** method, that should be used like this:\r\n\r\n```\r\nif escape:\r\n    # Characters to be escaped in both\r\n    for char in \"/'\": \r\n         before = before.replace(char, r'\\%s' % char)\r\n         after = after.replace(char, r'\\%s' % char)\r\n    # Characters to be escaped in replacement only (they're useful in regexen\r\n    # in the 'before' part)\r\n    for char in \"()\":\r\n         after = after.replace(char, r'\\%s' % char)\r\n```\r\nThank You\r\n\r\nDavide"},"comment":{"url":"https://api.github.com/repos/fabric/fabric/issues/comments/85504371","html_url":"https://github.com/fabric/fabric/issues/1285#issuecomment-85504371","issue_url":"https://api.github.com/repos/fabric/fabric/issues/1285","id":85504371,"user":{"login":"brunato","id":2034665,"avatar_url":"https://avatars.githubusercontent.com/u/2034665?v=3","gravatar_id":"","url":"https://api.github.com/users/brunato","html_url":"https://github.com/brunato","followers_url":"https://api.github.com/users/brunato/followers","following_url":"https://api.github.com/users/brunato/following{/other_user}","gists_url":"https://api.github.com/users/brunato/gists{/gist_id}","starred_url":"https://api.github.com/users/brunato/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brunato/subscriptions","organizations_url":"https://api.github.com/users/brunato/orgs","repos_url":"https://api.github.com/users/brunato/repos","events_url":"https://api.github.com/users/brunato/events{/privacy}","received_events_url":"https://api.github.com/users/brunato/received_events","type":"User","site_admin":false},"created_at":"2015-03-24T13:54:34Z","updated_at":"2015-03-24T13:54:34Z","body":"It's not only related to escaping single quotes but also to other characters like round parentheses and slash ('/'). When I use *fabric.contrib.sed*, with a regex pattern that contains those characters, a skip of escaping could be useful to avoid redundant operations."}}