mirror of
https://github.com/mistydemeo/tigerbrew.git
synced 2026-12-02 05:29:47 -05:00
Escape inreplace
This commit is contained in:
1 parent
5c62420d27
commit
8faa3a8920
1 file changed
+10
@@ -151,7 +151,17 @@ end
|
||||
|
||||
|
||||
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
|
||||
#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}"`
|
||||
end
|
||||
|
||||
|
||||
Reference in new issue
Block a user