diff options
author | Sean Whitton <spwhitton@spwhitton.name> | 2020-04-15 11:14:25 -0700 |
---|---|---|
committer | Sean Whitton <spwhitton@spwhitton.name> | 2020-04-15 11:14:25 -0700 |
commit | 1d745b677908ac23c6a97d929a28d6232639155a (patch) | |
tree | 2c0a0a942bcc09a464b02e21e9c86cad36110007 /perl5 | |
parent | 6f013e63128209c949500d9b8f617d3be2ce22c8 (diff) | |
download | dotfiles-1d745b677908ac23c6a97d929a28d6232639155a.tar.gz |
avoid copying output around so much
Diffstat (limited to 'perl5')
-rw-r--r-- | perl5/Local/Interactive.pm | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/perl5/Local/Interactive.pm b/perl5/Local/Interactive.pm index 0c634091..df6cdc32 100644 --- a/perl5/Local/Interactive.pm +++ b/perl5/Local/Interactive.pm @@ -221,7 +221,7 @@ sub _sysptycap_pty { exec @_; } $pty->close; - my $output; + my $return = {}; while (1) { my $rin = ""; vec($rin, fileno $slave, 1) = 1; @@ -229,7 +229,7 @@ sub _sysptycap_pty { my $nbytes = sysread $slave, my $bytes, 8192; last if defined $nbytes and $nbytes == 0; print $bytes; - $output .= $bytes; + $return->{output} .= $bytes; } else { # Since there was no new output, see if child needs # reaping, and end the loop if all children have died. @@ -248,9 +248,10 @@ sub _sysptycap_pty { # since sysread was raw bytes, want to decode if possible my $codeset = eval { langinfo CODESET }; - $output = decode $codeset, $output if $codeset; + $return->{output} = decode $codeset, $return->{output} if $codeset; - return { exit => $? >> 8, output => $output }; + $return->{exit} = $? >> 8; + return $return; } =head prompt($prompt) |