aboutsummaryrefslogtreecommitdiffstats
path: root/Library
diff options
context:
space:
mode:
authorAlex Dunn2015-04-17 12:07:45 -0700
committerMike McQuaid2015-04-21 10:54:29 +0100
commitd85f2dabcace10072c97cb5208e73a332c6b65ca (patch)
treede96b937d5258fc95b011252359ad10ebc62c550 /Library
parent3287c5f3882d0da22fd65ef5dc3470d1b57c2d98 (diff)
downloadbrew-d85f2dabcace10072c97cb5208e73a332c6b65ca.tar.bz2
cmd/search: notification on attempted regex searches
Closes Homebrew/homebrew#38760. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
Diffstat (limited to 'Library')
-rw-r--r--Library/Homebrew/cmd/search.rb11
1 files changed, 10 insertions, 1 deletions
diff --git a/Library/Homebrew/cmd/search.rb b/Library/Homebrew/cmd/search.rb
index d5a826eda..98031fe7b 100644
--- a/Library/Homebrew/cmd/search.rb
+++ b/Library/Homebrew/cmd/search.rb
@@ -61,7 +61,16 @@ module Homebrew
end
end
end
-
+ metacharacters = %w[\\ | ( ) [ ] { } ^ $ * + ? .]
+ bad_regex = metacharacters.any? do |char|
+ ARGV.any? do |arg|
+ arg.include?(char) && !arg.start_with?('/')
+ end
+ end
+ if ARGV.any? && bad_regex
+ ohai "Did you mean to perform a regular expression search?"
+ ohai "Surround your query with /slashes/ to search by regex."
+ end
raise SEARCH_ERROR_QUEUE.pop unless SEARCH_ERROR_QUEUE.empty?
end