From: "Ara.T.Howard" Date: 2004-05-04T23:03:56+09:00 Subject: Re: Can a program be made to drop into irb? On Tue, 4 May 2004, Gavin Sinclair wrote: > I'd like to be able to write a program that, halfway through > execution, stops what it's doing and opens an irb session with the > current state. This would be an excellent tool for debugging. > > Does anyone know if it's possible? My instinct says it's probably > not. If that's the case, I'd like to if some modification to Ruby > could make it possible, to feed into a potential RCR. > > Cheers, > Gavin ~ > cat a.rb require 'irb' a, b = 4, 2 begin c = 42 syntax_error rescue Exception => e IRB.setup nil IRB::Irb.new(IRB::WorkSpace.new(binding),nil).eval_input end ~ > ruby a.rb irb(main):001:0> p a,b,c 4 2 42 => nil i confess i have no idea how this works, but it seems to... you need to type ctrl-D to get out (end STDIN), i'm not sure how to get back into the program... perhaps someone else could figure it out... a shorthand for this would be immensely useful - something like ret = IRB.debug .... -a -- =============================================================================== | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov | PHONE :: 303.497.6469 | ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328 | URL :: http://www.ngdc.noaa.gov/stp/ | TRY :: for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done ===============================================================================