Add an Interrupt plugin for better handling of ^C
Sartak [Fri, 2 Nov 2007 02:30:39 +0000 (02:30 +0000)]
git-svn-id: http://dev.catalyst.perl.org/repos/bast/trunk/Devel-REPL@3850 bd8105ee-0ff8-0310-8827-fb3f25b6796d

lib/Devel/REPL/Plugin/Interrupt.pm [new file with mode: 0644]

diff --git a/lib/Devel/REPL/Plugin/Interrupt.pm b/lib/Devel/REPL/Plugin/Interrupt.pm
new file mode 100644 (file)
index 0000000..1d79bd8
--- /dev/null
@@ -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;
+