Skip to content

Refactor exit command - #835

Merged
tompng merged 3 commits into
masterfrom
refactor-exit-command
Jan 6, 2024
Merged

tompng merged 3 commits into
masterfrom
refactor-exit-command

Conversation

@st0012

@st0012 st0012 commented Jan 6, 2024

Copy link
Copy Markdown
Member

I did 2 changes around the exit command, though none of them should change its behaviour:

  1. I removed unnecessary code/declaration around its implementation:
    1. The parameters of IRB.irb_exit were never used. But there are some
      libraries seem to call it with arguments (example) + 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.
  2. I converted exit to an official command so it's now listed in the help message too.

st0012 added 3 commits January 6, 2024 15:24
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.
@tompng
tompng merged commit 452b543 into master Jan 6, 2024
@tompng
tompng deleted the refactor-exit-command branch January 6, 2024 17:15
matzbot pushed a commit to ruby/ruby that referenced this pull request Jan 6, 2024
(ruby/irb#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

ruby/irb@452b543a65
@st0012 st0012 mentioned this pull request Jan 20, 2024
4 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants