aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/irb.rb4
-rw-r--r--lib/irb/cmd/exit.rb22
-rw-r--r--lib/irb/context.rb8
-rw-r--r--lib/irb/extend-command.rb18
4 files changed, 30 insertions, 22 deletions
diff --git a/lib/irb.rb b/lib/irb.rb
index daa0d64f28..4de8dda071 100644
--- a/lib/irb.rb
+++ b/lib/irb.rb
@@ -886,8 +886,8 @@ module IRB
end
# Quits irb
- def IRB.irb_exit(irb, ret)
- throw :IRB_EXIT, ret
+ def IRB.irb_exit(*)
+ throw :IRB_EXIT
end
# Aborts then interrupts irb.
diff --git a/lib/irb/cmd/exit.rb b/lib/irb/cmd/exit.rb
new file mode 100644
index 0000000000..415e555335
--- /dev/null
+++ b/lib/irb/cmd/exit.rb
@@ -0,0 +1,22 @@
+# frozen_string_literal: true
+
+require_relative "nop"
+
+module IRB
+ # :stopdoc:
+
+ module ExtendCommand
+ class Exit < Nop
+ category "IRB"
+ description "Exit the current irb session."
+
+ def execute(*)
+ IRB.irb_exit
+ rescue UncaughtThrowError
+ Kernel.exit
+ end
+ end
+ end
+
+ # :startdoc:
+end
diff --git a/lib/irb/context.rb b/lib/irb/context.rb
index c3690fcac7..10dab86179 100644
--- a/lib/irb/context.rb
+++ b/lib/irb/context.rb
@@ -573,14 +573,6 @@ module IRB
@inspect_method.inspect_value(@last_value)
end
- alias __exit__ exit
- # Exits the current session, see IRB.irb_exit
- def exit(ret = 0)
- IRB.irb_exit(@irb, ret)
- rescue UncaughtThrowError
- super
- end
-
NOPRINTING_IVARS = ["@last_value"] # :nodoc:
NO_INSPECTING_IVARS = ["@irb", "@io"] # :nodoc:
IDNAME_IVARS = ["@prompt_mode"] # :nodoc:
diff --git a/lib/irb/extend-command.rb b/lib/irb/extend-command.rb
index 072069d4c4..69d83080df 100644
--- a/lib/irb/extend-command.rb
+++ b/lib/irb/extend-command.rb
@@ -16,15 +16,6 @@ module IRB # :nodoc:
# See #install_alias_method.
OVERRIDE_ALL = 0x02
- # Quits the current irb context
- #
- # +ret+ is the optional signal or message to send to Context#exit
- #
- # Same as <code>IRB.CurrentContext.exit</code>.
- def irb_exit(ret = 0)
- irb_context.exit(ret)
- end
-
# Displays current configuration.
#
# Modifying the configuration is achieved by sending a message to IRB.conf.
@@ -35,14 +26,17 @@ module IRB # :nodoc:
@ALIASES = [
[:context, :irb_context, NO_OVERRIDE],
[:conf, :irb_context, NO_OVERRIDE],
- [:irb_quit, :irb_exit, OVERRIDE_PRIVATE_ONLY],
- [:exit, :irb_exit, OVERRIDE_PRIVATE_ONLY],
- [:quit, :irb_exit, OVERRIDE_PRIVATE_ONLY],
]
@EXTEND_COMMANDS = [
[
+ :irb_exit, :Exit, "cmd/exit",
+ [:exit, OVERRIDE_PRIVATE_ONLY],
+ [:quit, OVERRIDE_PRIVATE_ONLY],
+ [:irb_quit, OVERRIDE_PRIVATE_ONLY],
+ ],
+ [
:irb_current_working_workspace, :CurrentWorkingWorkspace, "cmd/chws",
[:cwws, NO_OVERRIDE],
[:pwws, NO_OVERRIDE],