Skip to content

Commit

Permalink
Checking in changes prior to tagging of version 0.22.
Browse files Browse the repository at this point in the history
Changelog diff is:

diff --git a/Changes b/Changes
index 3eec96f..af084c3 100644
--- a/Changes
+++ b/Changes
@@ -2,6 +2,9 @@ Revision history for Shell-Carapace

 {{$NEXT}}

+0.22 2015-12-21T21:54:00Z
+    - Another attempt to deal with open2pty() failures correctly.
+
 0.21 2015-12-21T20:55:22Z
     - Retry if open2pty() fails and then die if it fails again.
  • Loading branch information
kablamo committed Dec 21, 2015
1 parent 72ba833 commit 8fbc104
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
3 changes: 3 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ Revision history for Shell-Carapace

{{$NEXT}}

0.22 2015-12-21T21:54:00Z
- Another attempt to deal with open2pty() failures correctly.

0.21 2015-12-21T20:55:22Z
- Retry if open2pty() fails and then die if it fails again.

Expand Down
2 changes: 1 addition & 1 deletion META.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"web" : "https://github.com/kablamo/p5-shell-carapace"
}
},
"version" : "0.21",
"version" : "0.22",
"x_authority" : "cpan:KABLAMO",
"x_contributors" : [
"Eric Johnson <github@iijo.org>"
Expand Down
2 changes: 1 addition & 1 deletion lib/Shell/Carapace.pm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package Shell::Carapace;
use Moo;

our $VERSION = "0.21";
our $VERSION = "0.22";

=head1 NAME
Expand Down
15 changes: 8 additions & 7 deletions lib/Shell/Carapace/SSH.pm
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ use Carp;
has callback => (is => 'rw', required => 1);
has host => (is => 'rw', required => 1);
has ssh_options => (is => 'rw', default => sub { {} });
has ssh => (is => 'rw', lazy => 1, builder => 1);
has connect_attempts => (is => 'rw', default => sub { 3 });
has ssh => (is => 'rw', lazy => 1, builder => 1, clearer => 1);

sub _build_ssh {
my $self = shift;
Expand All @@ -22,17 +21,19 @@ sub _build_ssh {
# force ssh builder to run so the connection occurs during object instantiation
sub BUILD { shift->ssh }

sub reconnect {
my $self = shift;
$self->clear_ssh;
$self->ssh;
}

sub run {
my ($self, @cmd) = @_;

$self->callback->('command', $self->_stringify(@cmd), $self->host);

my ($pty, $pid) = $self->ssh->open2pty(@cmd);
if (!$pty || $self->ssh->error) {
$self->clear_ssh; # force new connection to the server
($pty, $pid) = $self->ssh->open2pty(@cmd);
die $self->ssh->error if $self->ssh->error;
}
die $self->ssh->error if $self->ssh->error;

while (my $line = <$pty>) {
$line =~ s/([\r\n])$//g;
Expand Down

0 comments on commit 8fbc104

Please sign in to comment.