<commit_before># typed: true
# frozen_string_literal: true

require "irb"

# @private
module IRB
  def self.parse_opts(argv: nil); end

  def self.start_within(binding)
    unless @setup_done
      setup(nil, argv: [])
      @setup_done = true
    end

    workspace = WorkSpace.new(binding)
    irb = Irb.new(workspace)

    @CONF[:IRB_RC]&.call(irb.context)
    @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<commit_msg>debrew/irb: fix trap handling<commit_after># typed: true
# frozen_string_literal: true

require "irb"

# @private
module IRB
  def self.start_within(binding)
    unless @setup_done
      setup(nil, argv: [])
      @setup_done = true
    end

    workspace = WorkSpace.new(binding)
    irb = Irb.new(workspace)

    @CONF[:IRB_RC]&.call(irb.context)
    @CONF[:MAIN_CONTEXT] = irb.context

    prev_trap = trap("SIGINT") do
      irb.signal_handle
    end

    begin
      catch(:IRB_EXIT) do
        irb.eval_input
      end
    ensure
      trap("SIGINT", prev_trap)
      irb_at_exit
    end
  end
end
{'fraction_non_alphanumeric': 0.10379746835443038, 'fraction_numerical': 0.0, 'mean_word_length': 2.6269113149847096, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7033282', 'n_tokens_mistral': 441, 'n_tokens_neox': 437, 'n_words': 89}