summaryrefslogtreecommitdiff
path: root/lib/irb/extend-command.rb
diff options
context:
space:
mode:
authorStan Lo <stan001212@gmail.com>2024-01-06 17:15:12 +0000
committergit <svn-admin@ruby-lang.org>2024-01-06 17:15:16 +0000
commit4bdfc9070cf626db4553a6cd15dbae19604180cf (patch)
tree824e481e6292adc93bc67f39ee5bf2d124825a50 /lib/irb/extend-command.rb
parentd96fe5e4f8dd09bdbcb730b90382ab35e0be03d1 (diff)
[ruby/irb] Refactor exit command
(https://github.com/ruby/irb/pull/835) * Remove unnecessary code from the exit command's implementation 1. The parameters of `IRB.irb_exit` were never used. But there are some libraries seem to call it with arguments + it's declared on the top-level IRB constant. So I changed the params to anonymous splat instead of removing them. 2. `Context#exit` was completely unnecessary as `IRB.irb_exit` doesn't use the `@irb` instance it passes. And since it's (or should be treated as) a private method, I simply removed it. 3. The `exit` command doesn't use the status argument it receives at all. But to avoid raising errors on usages like `exit 1`, I changed the argument to anonymous splat instead removing it. * Make exit an actual command * Update readme https://github.com/ruby/irb/commit/452b543a65
Diffstat (limited to 'lib/irb/extend-command.rb')
-rw-r--r--lib/irb/extend-command.rb18
1 files changed, 6 insertions, 12 deletions
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],