Skip to content

Commit

Permalink
[ruby/irb] Add disable_irb command to disable debug of binding.irb
Browse files Browse the repository at this point in the history
(ruby/irb#898)

* Add disable_irb command to disable debug of binding.irb

* disable_irb doesn't override Kernel.exit

Kernel.exit call is removed because disable_irb does not override Kernel.exit
and workaround to https://bugs.ruby-lang.org/issues/18234 is not needed.

ruby/irb@29901e4f21
  • Loading branch information
hogelog authored and matzbot committed Mar 14, 2024
1 parent 83618f2 commit 3822ca9
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/irb/command.rb
Expand Up @@ -196,7 +196,12 @@ def irb_context
:irb_history, :History, "command/history",
[:history, NO_OVERRIDE],
[:hist, NO_OVERRIDE],
]
],

[
:irb_disable_irb, :DisableIrb, "command/disable_irb",
[:disable_irb, NO_OVERRIDE],
],
]


Expand Down
19 changes: 19 additions & 0 deletions lib/irb/command/disable_irb.rb
@@ -0,0 +1,19 @@
# frozen_string_literal: true

module IRB
# :stopdoc:

module Command
class DisableIrb < Base
category "IRB"
description "Disable binding.irb."

def execute(*)
::Binding.define_method(:irb) {}
IRB.irb_exit
end
end
end

# :startdoc:
end

0 comments on commit 3822ca9

Please sign in to comment.