Skip to content

Commit 6f0843f

Browse files
use status 0 for kernel.exit
1 parent 0990055 commit 6f0843f

File tree

3 files changed

+14
-16
lines changed

3 files changed

+14
-16
lines changed

lib/irb.rb

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff 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

lib/irb/cmd/exit_forced_action.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

test/irb/test_debug_cmd.rb

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
# frozen_string_literal: true
2-
32
require "tempfile"
43
require "tmpdir"
54

@@ -257,12 +256,12 @@ def test_exit
257256

258257
def test_forced_exit
259258
write_ruby <<~'ruby'
260-
puts "first line"
261-
binding.irb
262-
puts "second line"
259+
puts "First line"
260+
puts "Second line"
263261
binding.irb
264-
puts "third"
262+
puts "Third line"
265263
binding.irb
264+
puts "Fourth line"
266265
ruby
267266

268267
output = run_ruby_file do
@@ -271,10 +270,12 @@ def test_forced_exit
271270
type "exit!"
272271
end
273272

273+
assert_match(/First line\r\n/, output)
274+
assert_match(/Second line\r\n/, output)
274275
assert_match(/irb\(main\):001> 123/, output)
275276
assert_match(/irb\(main\):002> 456/, output)
276-
assert_match(/irb\(main\):003> exit!/, output)
277-
output.end_with?("003> exit!")
277+
refute_match(/Third line\r\n/, output)
278+
refute_match(/Fourth line\r\n/, output)
278279
end
279280

280281
def test_quit

0 commit comments

Comments
 (0)