inreplace: Open the file as binary

Closes Homebrew/homebrew#22628.

Signed-off-by: Jack Nagel <jacknagel@gmail.com>
This commit is contained in:
Shaun Jackman 2013-09-17 11:44:27 -07:00 committed by Jack Nagel
parent 907ac79606
commit 91e6c993f8

View File

@ -2,7 +2,7 @@ module Utils
module Inreplace module Inreplace
def inreplace paths, before=nil, after=nil def inreplace paths, before=nil, after=nil
Array(paths).each do |path| Array(paths).each do |path|
f = File.open(path, 'r') f = File.open(path, 'rb')
s = f.read s = f.read
if before.nil? && after.nil? if before.nil? && after.nil?
@ -17,7 +17,7 @@ module Utils
end end
end end
f.reopen(path, 'w').write(s) f.reopen(path, 'wb').write(s)
f.close f.close
end end
end end