diff options
Diffstat (limited to 'Library/Homebrew/debrew/irb.rb')
| -rw-r--r-- | Library/Homebrew/debrew/irb.rb | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/Library/Homebrew/debrew/irb.rb b/Library/Homebrew/debrew/irb.rb new file mode 100644 index 000000000..c81e3cf4b --- /dev/null +++ b/Library/Homebrew/debrew/irb.rb @@ -0,0 +1,33 @@ +require 'irb' + +module IRB + @setup_done = false + + def IRB.start_within(binding) + unless @setup_done + # make IRB ignore our command line arguments + saved_args = ARGV.shift(ARGV.size) + IRB.setup(nil) + ARGV.concat(saved_args) + @setup_done = true + end + + workspace = WorkSpace.new(binding) + irb = Irb.new(workspace) + + @CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC] + @CONF[:MAIN_CONTEXT] = irb.context + + trap("SIGINT") do + irb.signal_handle + end + + begin + catch(:IRB_EXIT) do + irb.eval_input + end + ensure + irb_at_exit + end + end +end |
