-
Notifications
You must be signed in to change notification settings - Fork 136
Introduce exit! command #851
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
Conversation
|
Calling exit exit! I think the solution should also maintain this behaviour while saving the history. |
16227dd to
8d10566
Compare
5044edc to
0990055
Compare
6b2f950 to
3178435
Compare
6f0843f to
77146ff
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're pretty close, just want to clarify 2 changes.
77146ff to
bb382ea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR ❤️
(ruby/irb#851) * Added failing test for when writing history on exit * Save history on exit * Exit early when calling Kernel.exit * use status 0 for kernel.exit * Added test for nested sessions * Update lib/irb.rb --------- ruby/irb@c0a5f31679 Co-authored-by: Stan Lo <stan001212@gmail.com>
|
This added a new warning during the test. |
Problem
Currently,
exit!does not save the history of the console' input like the following exampleOpen another session and type up-arrow to check the above history
irb(main):001:0> b = 2 # (history is saved!)If we run the same for
exit!, the history isn't saved.Closes #612
Solution
I extended the command
exit!and used a new classExitForcedAction. Note that we can't useExit!as the class name since!isn't allowed.This will call the
irb_exit!method, which will throw the same exception as exit (throw :IRB_EXIT) and the main methodruncatches it and calls `save_history``.Demo
In the following example, I test that the history is saved and
Kernel.exit!exits the console even when the session is nested.Screen.Recording.2024-02-02.at.2.36.03.PM.mov