From e828256d51492869a3f1010cc80d2dd469dd2cdb Mon Sep 17 00:00:00 2001 From: Adam Vandenberg Date: Mon, 1 Feb 2010 21:57:16 -0800 Subject: Let change_make_var! append to existing value. To existing flag value can be specified with "\\1". To append values to a flag, call with: s.change_make_var! "THE_FLAG", "\\1 more-flag-values" The same trick can be used to prepend or surround values as well. --- Library/Homebrew/utils.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Library') diff --git a/Library/Homebrew/utils.rb b/Library/Homebrew/utils.rb index a1a40e95f..ae6ca50b9 100644 --- a/Library/Homebrew/utils.rb +++ b/Library/Homebrew/utils.rb @@ -181,9 +181,9 @@ 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 - new_value = "#{flag}=#{new_value}" unless new_value.to_s.empty? - gsub! Regexp.new("^#{flag}\\s*=.*$"), new_value.to_s + def change_make_var! flag, new_value=nil + new_value = "#{flag}=#{new_value}" unless new_value == nil + gsub! Regexp.new("^#{flag}\\s*=\\s*(.*)$"), new_value end def remove_make_var! flags flags.each { |flag| change_make_var! flag, "" } -- cgit v1.2.3