Sha256: 826c1e0619db8b459ff6851bb524eb26ace08da752273041692d5142d46f59ed

Contents?: true

Size: 1.14 KB

Versions: 15

Compression:

Stored size: 1.14 KB

Contents

# -*- coding: binary -*-
module Rex
module Ui
module Text

###
#
# This class wraps the creation of an IRB shell.
#
###
class IrbShell

  @@IrbInitialized = false

  def initialize(binding)
    @binding_ctx = binding
  end

  #
  # Runs the IRB shell until completion.  The binding parameter initializes
  # IRB to the appropriate binding context.
  #
  def run
    # Initialize IRB by setting up its internal configuration hash and
    # stuff.
    if (@@IrbInitialized == false)
      load('irb.rb')

      IRB.setup(nil)
      IRB.conf[:PROMPT_MODE]  = :SIMPLE

      @@IrbInitialized = true
    end

    # Create a new IRB instance
    irb = IRB::Irb.new(IRB::WorkSpace.new(@binding_ctx))

    # Set the primary irb context so that exit and other intrinsic
    # commands will work.
    IRB.conf[:MAIN_CONTEXT] = irb.context

    # Trap interrupt
    old_sigint = trap("SIGINT") do
      begin
        irb.signal_handle
      rescue RubyLex::TerminateLineInput
        irb.eval_input
      end
    end

    # Keep processing input until the cows come home...
    catch(:IRB_EXIT) do
      irb.eval_input
    end

    trap("SIGINT", old_sigint)
  end

end
end
end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
rex-2.0.13 lib/rex/ui/text/irb_shell.rb
rex-2.0.12 lib/rex/ui/text/irb_shell.rb
rex-2.0.11 lib/rex/ui/text/irb_shell.rb
rex-2.0.10 lib/rex/ui/text/irb_shell.rb
rex-2.0.9 lib/rex/ui/text/irb_shell.rb
rex-2.0.8 lib/rex/ui/text/irb_shell.rb
rex-2.0.7 lib/rex/ui/text/irb_shell.rb
rex-2.0.5 lib/rex/ui/text/irb_shell.rb
rex-2.0.4 lib/rex/ui/text/irb_shell.rb
dstruct-0.0.1 lib/rex/ui/text/irb_shell.rb
rex-2.0.3 lib/rex/ui/text/irb_shell.rb
librex-0.0.999 lib/rex/ui/text/irb_shell.rb
rex-2.0.2 lib/rex/ui/text/irb_shell.rb
librex-0.0.71 lib/rex/ui/text/irb_shell.rb
librex-0.0.70 lib/rex/ui/text/irb_shell.rb