aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/utils.rb
diff options
context:
space:
mode:
authorAdam Vandenberg2010-02-01 21:57:16 -0800
committerAdam Vandenberg2010-02-02 08:57:56 -0800
commite828256d51492869a3f1010cc80d2dd469dd2cdb (patch)
treea1a8ea8d3dc3322ec9467ffd1978159f326943d6 /Library/Homebrew/utils.rb
parentd75aed1bea3d07b07083aec8ee6566df62c63b33 (diff)
downloadhomebrew-e828256d51492869a3f1010cc80d2dd469dd2cdb.tar.bz2
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.
Diffstat (limited to 'Library/Homebrew/utils.rb')
-rw-r--r--Library/Homebrew/utils.rb6
1 files changed, 3 insertions, 3 deletions
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, "" }