From: Sartak Date: Fri, 2 Nov 2007 02:30:39 +0000 (+0000) Subject: Add an Interrupt plugin for better handling of ^C X-Git-Tag: v1.003015~143 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=54d0f9a0eb9822d8d5973cc0e8aac52fab238245;p=p5sagit%2FDevel-REPL.git Add an Interrupt plugin for better handling of ^C git-svn-id: http://dev.catalyst.perl.org/repos/bast/trunk/Devel-REPL@3850 bd8105ee-0ff8-0310-8827-fb3f25b6796d --- diff --git a/lib/Devel/REPL/Plugin/Interrupt.pm b/lib/Devel/REPL/Plugin/Interrupt.pm new file mode 100644 index 0000000..1d79bd8 --- /dev/null +++ b/lib/Devel/REPL/Plugin/Interrupt.pm @@ -0,0 +1,18 @@ +package Devel::REPL::Plugin::Interrupt; + +use Moose::Role; +use namespace::clean -except => [ 'meta' ]; + +around 'eval' => sub { + my $orig = shift; + my ($self, $line) = @_; + + local $SIG{INT} = sub { + die "Interrupted.\n"; + }; + + return $self->$orig($line); +}; + +1; +