irb
irb copied to clipboard
Support do and pre keywords in binding.irb
enhancement for #1083
Implemented the ability for users to automatically execute commands like do and pre in the debug gem.
Note: I tried using the debug gem to see what happens when pre and do are specified at the same time. It seems that pre is given priority, and do is not executed, so that is the specification.
➜ ruby -v
ruby 3.4.3 (2025-04-14 revision d0b7e5b6a0) +PRISM [arm64-darwin24]
➜ rdbg -v
rdbg 1.10.0
➜ rdbg --nonstop --no-sigint-hook do_pre.rb
[1, 9] in do_pre.rb
1|
2| def foo
3| @a = 'hello'
4| @b = 'world'
=> 5| binding.b(pre: "p @a", do: "p @b")
6| end
7|
8| foo
9|
=>#0 Object#foo at do_pre.rb:5
#1 <main> at do_pre.rb:8
(rdbg:#debugger) p @a
=> "hello"
(rdbg)
Thank you for maintaining this great Ruby feature.