cmd/search: notification on attempted regex searches
Closes Homebrew/homebrew#38760. Signed-off-by: Mike McQuaid <mike@mikemcquaid.com>
This commit is contained in:
parent
3287c5f388
commit
d85f2dabca
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user