File tree Expand file tree Collapse file tree 3 files changed +14
-15
lines changed Expand file tree Collapse file tree 3 files changed +14
-15
lines changed Original file line number Diff line number Diff line change @@ -886,11 +886,11 @@ def IRB.start(ap_path = nil)
886886
887887 # Quits irb
888888 def IRB . irb_exit ( *)
889- throw :IRB_EXIT
889+ throw :IRB_EXIT , false
890890 end
891891
892892 def IRB . irb_exit! ( *)
893- throw :IRB_EXIT!
893+ throw :IRB_EXIT , true
894894 end
895895
896896 # Aborts then interrupts irb.
@@ -986,19 +986,16 @@ def run(conf = IRB.conf)
986986 begin
987987 @forced_exit = false
988988
989- catch ( :IRB_EXIT ) do
990- catch ( :IRB_EXIT! ) do
991- eval_input
992- end
993- @forced_exit = true
989+ @forced_exit = catch ( :IRB_EXIT ) do
990+ eval_input
994991 end
995992 ensure
996993 trap ( "SIGINT" , prev_trap )
997994 conf [ :AT_EXIT ] . each { |hook | hook . call }
998995
999996 if @forced_exit
1000997 context . io . save_history if supports_history_saving
1001- Kernel . exit!
998+ Kernel . exit! ( 0 )
1002999 else
10031000 context . io . save_history if save_history
10041001 end
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ class ExitForcedAction < Nop
1313 def execute ( *)
1414 IRB . irb_exit!
1515 rescue UncaughtThrowError
16- Kernel . exit
16+ Kernel . exit ( 0 )
1717 end
1818 end
1919 end
Original file line number Diff line number Diff line change @@ -257,12 +257,12 @@ def test_exit
257257
258258 def test_forced_exit
259259 write_ruby <<~'ruby'
260- puts "first line"
260+ puts "First line"
261+ puts "Second line"
261262 binding . irb
262- puts "second line"
263- binding . irb
264- puts "third"
263+ puts "Third line"
265264 binding . irb
265+ puts "Fourth line"
266266 ruby
267267
268268 output = run_ruby_file do
@@ -271,10 +271,12 @@ def test_forced_exit
271271 type "exit!"
272272 end
273273
274+ assert_match ( /First line\r \n / , output )
275+ assert_match ( /Second line\r \n / , output )
274276 assert_match ( /irb\( main\) :001> 123/ , output )
275277 assert_match ( /irb\( main\) :002> 456/ , output )
276- assert_match ( /irb \( main \) :003> exit! /, output )
277- output . end_with? ( "003> exit!" )
278+ refute_match ( /Third line \r \n /, output )
279+ refute_match ( /Fourth line \r \n / , output )
278280 end
279281
280282 def test_quit
You can’t perform that action at this time.
0 commit comments