Search by substring unless term is inside /../

This commit is contained in:
Andre Arko 2009-09-17 16:06:56 -07:00 committed by Max Howell
parent b9033700b6
commit 195e75c1b2
2 changed files with 6 additions and 2 deletions

View File

@ -88,7 +88,7 @@ Usage: brew [--verbose|-v]
Commands:
install formula ... [--debug|-d] [--interactive|-i] [--ignore-dependencies]
remove formula ...
search [regex]
search [/regex/] [substring]
list [--brewed] [--unbrewed] [formula] ...
link formula ...
unlink formula ...

View File

@ -52,7 +52,11 @@ begin
when 'search', '-S'
formulae = (HOMEBREW_PREFIX+'Library'+'Formula').children.sort.map{|f| f.basename('.rb') }
puts_columns formulae.grep(Regexp.new(ARGV.first || ''))
if ARGV.first =~ /^\/(.*)\/$/
puts_columns formulae.grep(Regexp.new($1))
else
puts_columns formulae.grep(/.*#{ARGV.first}.*/)
end
when 'edit'
if ARGV.named_empty?