aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils.rb
diff options
context:
space:
mode:
authorAdam Vandenberg2010-02-09 09:21:25 -0800
committerAdam Vandenberg2010-02-09 09:21:25 -0800
commit6671d6275de7bcb9733b20aca8ea930abb5013d9 (patch)
treeb97c9064d29765e99fa2a25e86344b537d9799c6 /Library/Homebrew/utils.rb
parent07adef4954f99295558faf9e13bc776ae5102b19 (diff)
downloadbrew-6671d6275de7bcb9733b20aca8ea930abb5013d9.tar.bz2
remove_make_var! should not leave an empty assignment
Diffstat (limited to 'Library/Homebrew/utils.rb')
-rw-r--r--Library/Homebrew/utils.rb12
1 files changed, 8 insertions, 4 deletions
diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb
index ae6ca50b9..3f89e187a 100644
--- a/Library/Homebrew/utils.rb
+++ b/Library/Homebrew/utils.rb
@@ -177,16 +177,20 @@ def archs_for_command cmd
end
end
+# String extensions added by inreplace below.
module HomebrewInreplaceExtension
# Looks for Makefile style variable defintions and replaces the
# value with "new_value", or removes the definition entirely.
- # See inreplace in utils.rb
- def change_make_var! flag, new_value=nil
- new_value = "#{flag}=#{new_value}" unless new_value == nil
+ def change_make_var! flag, new_value
+ new_value = "#{flag}=#{new_value}"
gsub! Regexp.new("^#{flag}\\s*=\\s*(.*)$"), new_value
end
+ # Removes variable assignments completely.
def remove_make_var! flags
- flags.each { |flag| change_make_var! flag, "" }
+ flags.each do |flag|
+ # Also remove trailing \n, if present.
+ gsub! Regexp.new("^#{flag}\\s*=(.*)$\n?"), ""
+ end
end
end