diff options
| author | Alex Dunn | 2015-08-31 00:23:30 -0700 |
|---|---|---|
| committer | Alex Dunn | 2015-08-31 07:54:59 -0700 |
| commit | 79ea14b73867f52a6016c97ca8e38f5c7f7672e9 (patch) | |
| tree | fc8446dd25200e31959f718e0f6f61558b34a36b /Library | |
| parent | 5dd0f089a38ba10e481f44d74e072ea98f0b3301 (diff) | |
| download | brew-79ea14b73867f52a6016c97ca8e38f5c7f7672e9.tar.bz2 | |
cmd/search: fix filtering of aliases in results
By directly modifying the results array with
`results[i] = "#{name} (installed)"`, it appeared on successive
iterations that the canonical name was no longer in the array, so
aliases were not removed.
See https://github.com/Homebrew/homebrew/commit/9efe5b554ce9cf6626d9794173725f5e063e5806#commitcomment-12969631
Closes Homebrew/homebrew#43433.
Diffstat (limited to 'Library')
| -rw-r--r-- | Library/Homebrew/cmd/search.rb | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb index 928ba9d7c..10e0a8269 100644 --- a/Library/Homebrew/cmd/search.rb +++ b/Library/Homebrew/cmd/search.rb @@ -143,15 +143,16 @@ module Homebrew aliases = Formula.aliases results = (Formula.full_names+aliases).grep(rx).sort - results.each_with_index do |name, i| + results.map do |name| canonical_name = Formulary.canonical_name(name) - # Remove 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_name) - results.delete_at(i) - # Notify the user if the formula is installed + next elsif (HOMEBREW_CELLAR/canonical_name).directory? - results[i] = "#{name} (installed)" + "#{name} (installed)" + else + name end - end + end.compact end end |
