Reduce footprint of readline hack

This commit is contained in:
Jack Nagel 2013-02-07 18:58:41 -06:00
parent 608fd55809
commit 0b425178ec

View File

@ -1,23 +1,18 @@
def can_use_readline?
not ENV['HOMEBREW_NO_READLINE']
end
require 'debrew/menu' require 'debrew/menu'
require 'debrew/raise_plus' require 'debrew/raise_plus'
require 'debrew/irb' if can_use_readline?
class Object unless ENV['HOMEBREW_NO_READLINE']
include RaisePlus
end
def has_debugger?
begin begin
require 'rubygems' require 'rubygems'
require 'ruby-debug' require 'ruby-debug'
true
rescue LoadError rescue LoadError
false end
end if can_use_readline?
require 'debrew/irb'
end
class Object
include RaisePlus
end end
def debrew(exception, formula=nil) def debrew(exception, formula=nil)
@ -34,7 +29,7 @@ def debrew(exception, formula=nil)
menu.choice(:debug) do menu.choice(:debug) do
puts "When you exit the debugger, execution will continue." puts "When you exit the debugger, execution will continue."
exception.restart { debugger } exception.restart { debugger }
end if has_debugger? end if Object.const_defined?(:Debugger)
menu.choice(:irb) do menu.choice(:irb) do
puts "When you exit this IRB session, execution will continue." puts "When you exit this IRB session, execution will continue."
exception.restart do exception.restart do
@ -46,7 +41,7 @@ def debrew(exception, formula=nil)
end end
} }
end end
end if can_use_readline? end if Object.const_defined?(:IRB)
menu.choice(:shell) do menu.choice(:shell) do
puts "When you exit this shell, you will return to the menu." puts "When you exit this shell, you will return to the menu."
interactive_shell formula interactive_shell formula