search: don't fail because broken formulae

Fixes Homebrew/homebrew#44687.

Closes Homebrew/homebrew#44770.

Signed-off-by: Xu Cheng <xucheng@me.com>
This commit is contained in:
Xu Cheng 2015-10-09 15:24:27 +08:00
parent 1ae44d4429
commit 51a585e0b4

View File

@ -141,9 +141,13 @@ module Homebrew
results = (Formula.full_names+aliases).grep(rx).sort results = (Formula.full_names+aliases).grep(rx).sort
results.map do |name| results.map do |name|
formula = Formulary.factory(name) begin
canonical_name = formula.name formula = Formulary.factory(name)
canonical_full_name = formula.full_name canonical_name = formula.name
canonical_full_name = formula.full_name
rescue
canonical_name = canonical_full_name = name
end
# Ignore aliases from results when the full name was also found # Ignore aliases from results when the full name was also found
if aliases.include?(name) && results.include?(canonical_full_name) if aliases.include?(name) && results.include?(canonical_full_name)
next next