Escape inreplace

This commit is contained in:
Max Howell 2009-05-22 00:15:28 +01:00
parent 5c62420d27
commit 8faa3a8920

View File

@ -151,7 +151,17 @@ end
def inreplace(path, before, after) def inreplace(path, before, after)
before=before.to_s
after=after.to_s
before.gsub! '"', '\"'
after.gsub! '"', '\"'
before.gsub! '|', '\|"'
after.gsub! '|', '\|"'
# we're not using Ruby because the perl script is more concise # we're not using Ruby because the perl script is more concise
#TODO the above escapes are worse, use a proper ruby script :P
#TODO optimise it by taking before and after as arrays
#Bah, just make the script writers do it themselves with a standard collect block
`perl -pi -e "s|#{before}|#{after}|g" "#{path}"` `perl -pi -e "s|#{before}|#{after}|g" "#{path}"`
end end