aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorMike McQuaid2015-09-23 14:55:22 +0100
committerMike McQuaid2015-09-23 15:17:35 +0100
commitf154f4898a31a3243003a06732091beda9086eb6 (patch)
treeaa79af83d974fa4fba5450184594c560214d591c /Library/Homebrew
parent322a93bce0a7d592ba5f5be87731a7f9db22fafd (diff)
downloadbrew-f154f4898a31a3243003a06732091beda9086eb6.tar.bz2
bottle: output maximum number of strings matches.
`brew bottle --verbose` outputs all the matches for a string found in the files inside the Cellar. Instead of outputting all of these just output the first 100. Closes Homebrew/homebrew#44266. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/cmd/bottle.rb19
1 files changed, 15 insertions, 4 deletions
diff --git a/Library/Homebrew/cmd/bottle.rb b/Library/Homebrew/cmd/bottle.rb
index 7774a568f..c63c5ae06 100644
--- a/Library/Homebrew/cmd/bottle.rb
+++ b/Library/Homebrew/cmd/bottle.rb
@@ -32,6 +32,8 @@ BOTTLE_ERB = <<-EOS
end
EOS
+MAXIMUM_STRING_MATCHES = 100
+
module Homebrew
def keg_contains(string, keg, ignores)
@put_string_exists_header, @put_filenames = nil
@@ -72,6 +74,8 @@ module Homebrew
end
end
+ text_matches = []
+
# Use strings to search through the file for each string
Utils.popen_read("strings", "-t", "x", "-", file.to_s) do |io|
until io.eof?
@@ -82,11 +86,18 @@ module Homebrew
next if linked_libraries.include? match # Don't bother reporting a string if it was found by otool
result = true
+ text_matches << [match, offset]
+ end
+ end
- if ARGV.verbose?
- print_filename string, file
- puts " #{Tty.gray}-->#{Tty.reset} match '#{match}' at offset #{Tty.em}0x#{offset}#{Tty.reset}"
- end
+ if ARGV.verbose? && text_matches.any?
+ print_filename string, file
+ text_matches.first(MAXIMUM_STRING_MATCHES).each do |match, offset|
+ puts " #{Tty.gray}-->#{Tty.reset} match '#{match}' at offset #{Tty.em}0x#{offset}#{Tty.reset}"
+ end
+
+ if text_matches.size > MAXIMUM_STRING_MATCHES
+ puts "Only the first #{MAXIMUM_STRING_MATCHES} matches were output"
end
end
end