Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor exit command #835

Merged
merged 3 commits into from
Jan 6, 2024
Merged

Refactor exit command #835

merged 3 commits into from
Jan 6, 2024

Conversation

st0012
Copy link
Member

@st0012 st0012 commented Jan 6, 2024

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
55 checks passed
@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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants