aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/utils.rb')
-rw-r--r--Library/Homebrew/utils.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index 976adaa3a..6ce87f190 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -122,3 +122,17 @@ def arch_for_command cmd
return archs
end
+
+
+# replaces before with after for the file path
+def inreplace path, before, after
+ before=Regexp.escape before.to_s
+ before.gsub! "/", "\\/" # I guess not escaped as delimiter varies
+ after=after.to_s
+ after.gsub! "\\", "\\\\"
+ after.gsub! "/", "\\/"
+ after.gsub! "$", "\\$"
+
+ # FIXME use proper Ruby for teh exceptions!
+ safe_system "/usr/bin/perl", "-pi", "-e", "s/#{before}/#{after}/g", path
+end