[Bps-public-commit] r15283 - in Prophet/trunk: .

sartak at bestpractical.com sartak at bestpractical.com
Wed Aug 20 07:32:46 EDT 2008


Author: sartak
Date: Wed Aug 20 07:32:45 2008
New Revision: 15283

Modified:
   Prophet/trunk/   (props changed)
   Prophet/trunk/lib/Prophet/CLI/Command/Shell.pm

Log:
 r69858 at onn:  sartak | 2008-08-20 07:32:33 -0400
 Protect against Term::ReadLine subclasses without history support


Modified: Prophet/trunk/lib/Prophet/CLI/Command/Shell.pm
==============================================================================
--- Prophet/trunk/lib/Prophet/CLI/Command/Shell.pm	(original)
+++ Prophet/trunk/lib/Prophet/CLI/Command/Shell.pm	Wed Aug 20 07:32:45 2008
@@ -69,6 +69,9 @@
 }
 
 # make the REPL history persistent
+# we use eval here because only some Term::ReadLine subclasses support
+# persistent history. it also seems that ->can doesn't work because of AUTOLOAD
+# trickery. :(
 around run => sub {
     my $orig = shift;
     my $self = shift;
@@ -77,14 +80,20 @@
             || (($ENV{HOME} || (getpwuid($<))[7]) . "/.prophetreplhist");
     my $len = $ENV{PROPHET_HISTLEN} || 100;
 
-    $self->term->stifle_history($len);
-    $self->term->ReadHistory($hist)
-        if -f $hist;
+    eval {
+        local $SIG{__DIE__};
+        $self->term->stifle_history($len);
+        $self->term->ReadHistory($hist)
+            if -f $hist;
+    };
 
     $self->$orig(@_);
 
-    $self->term->WriteHistory($hist)
-        or warn "Unable to write to shell history file $hist";
+    eval {
+        local $SIG{__DIE__};
+        $self->term->WriteHistory($hist)
+            or warn "Unable to write to shell history file $hist";
+    };
 };
 
 __PACKAGE__->meta->make_immutable;



More information about the Bps-public-commit mailing list