[ditz-talk] [PATCH] Exit cleanly when interrupting config creation, init or reconfigure

William Morgan wmorgan-ditz at masanjin.net
Mon Nov 10 00:20:48 EST 2008


Reformatted excerpts from Daniel Kalør's message of 2008-11-08:
> > Good idea. Can you refactor so that the begin/rescue stuff is a
> > separate method that we can just call, instead of duplicating it
> > three times?
> 
> Having just started, I'm not particularly well versed in Ruby, and can
> at the moment only come up with solutions that are even uglier.

Try something like:

  def die_gently
    begin
      yield
    rescue Interrupt
      puts
      exit 1
    end
  end

Then you can call

  die_gently { ... }

  die_gently do
    ...
  end

> Here is a related patch...

Applied, thanks!

(You might want to git config user.email to set your email address; it's
recorded as @float in the patch.)
-- 
William <wmorgan-ditz at masanjin.net>


More information about the ditz-talk mailing list