aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/cmd/search.rb
diff options
context:
space:
mode:
Diffstat (limited to 'Library/Homebrew/cmd/search.rb')
-rw-r--r--Library/Homebrew/cmd/search.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb
index 204a178ae..b2febbdba 100644
--- a/Library/Homebrew/cmd/search.rb
+++ b/Library/Homebrew/cmd/search.rb
@@ -4,6 +4,12 @@ require 'utils'
require 'utils/json'
module Homebrew extend self
+
+ # A regular expession to capture the username (one or more char but no `/`,
+ # which has to be escaped like `\/`), repository, followed by an optional `/`
+ # and an optional query.
+ TAP_QUERY_REGEX = /^([^\/]+)\/([^\/]+)\/?(.+)?$/
+
def search
if ARGV.include? '--macports'
exec_browser "http://www.macports.org/ports.php?by=name&substr=#{ARGV.next}"
@@ -19,7 +25,7 @@ module Homebrew extend self
exec_browser "http://packages.ubuntu.com/search?keywords=#{ARGV.next}&searchon=names&suite=all&section=all"
elsif (query = ARGV.first).nil?
puts_columns Formula.names
- elsif ARGV.first =~ HOMEBREW_TAP_REGEX
+ elsif ARGV.first =~ TAP_QUERY_REGEX
# So look for user/repo/query or list all formulae by the tap
# we downcase to avoid case-insensitive filesystem issues.
user, repo, query = $1.downcase, $2.downcase, $3