aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/extend/string.rb
diff options
context:
space:
mode:
authorJack Nagel2012-02-23 21:05:49 -0600
committerJack Nagel2012-02-25 22:37:29 -0600
commita3edec8b88a3490477f5a60b3262fb4ceb2f8166 (patch)
tree6d8e0c1b7a5c5d12c4e07facd459430d8da178ff /Library/Homebrew/extend/string.rb
parent93b4a131d025c409d2a1d95f819487173c2bb766 (diff)
downloadbrew-a3edec8b88a3490477f5a60b3262fb4ceb2f8166.tar.bz2
inreplace: warn if no substitutions were made
Signed-off-by: Jack Nagel <jacknagel@gmail.com>
Diffstat (limited to 'Library/Homebrew/extend/string.rb')
-rw-r--r--Library/Homebrew/extend/string.rb6
1 files changed, 4 insertions, 2 deletions
diff --git a/Library/Homebrew/extend/string.rb b/Library/Homebrew/extend/string.rb
index 3238f97df..a0cd4d635 100644
--- a/Library/Homebrew/extend/string.rb
+++ b/Library/Homebrew/extend/string.rb
@@ -17,7 +17,8 @@ module StringInreplaceExtension
# value with "new_value", or removes the definition entirely.
def change_make_var! flag, new_value
new_value = "#{flag}=#{new_value}"
- gsub! Regexp.new("^#{flag}[ \\t]*=[ \\t]*(.*)$"), new_value
+ sub = gsub! Regexp.new("^#{flag}[ \\t]*=[ \\t]*(.*)$"), new_value
+ opoo "inreplace: changing '#{flag}' to '#{new_value}' failed" if sub.nil?
end
# Removes variable assignments completely.
@@ -26,7 +27,8 @@ module StringInreplaceExtension
flags = [flags] unless flags.kind_of? Array
flags.each do |flag|
# Also remove trailing \n, if present.
- gsub! Regexp.new("^#{flag}[ \\t]*=(.*)$\n?"), ""
+ sub = gsub! Regexp.new("^#{flag}[ \\t]*=(.*)$\n?"), ""
+ opoo "inreplace: removing '#{flag}' failed" if sub.nil?
end
end