File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 6161 ENV [ "PATH" ] = path . to_s
6262
6363 require "commands"
64+ require "warnings"
6465
6566 internal_cmd = Commands . valid_internal_cmd? ( cmd ) || Commands . valid_internal_dev_cmd? ( cmd ) if cmd
6667
9697 begin
9798 Homebrew . public_send Commands . method_name ( cmd )
9899 rescue NoMethodError => e
99- case_error = "undefined method `#{ cmd . downcase } ' for module Homebrew"
100- odie "Unknown command: brew #{ cmd } " if e . message == case_error
100+ converted_cmd = cmd . downcase . tr ( "-" , "_" )
101+ case_error = "undefined method `#{ converted_cmd } ' for module Homebrew"
102+ private_method_error = "private method `#{ converted_cmd } ' called for module Homebrew"
103+ odie "Unknown command: brew #{ cmd } " if [ case_error , private_method_error ] . include? ( e . message )
101104
102105 raise
103106 end
Original file line number Diff line number Diff line change @@ -8,7 +8,15 @@ module Kernel
88 def require? ( path )
99 return false if path . nil?
1010
11- require path
11+ if defined? ( Warnings )
12+ # Work around require warning when done repeatedly:
13+ # https://bugs.ruby-lang.org/issues/21091
14+ Warnings . ignore ( /already initialized constant/ , /previous definition of/ ) do
15+ require path
16+ end
17+ else
18+ require path
19+ end
1220 true
1321 rescue LoadError => e
1422 # we should raise on syntax errors but not if the file doesn't exist.
You can’t perform that action at this time.
0 commit comments