Subject: | expect 1.21 interact()/interconnect() bug with EOF "escape" handling |
Date: | Tue, 27 Apr 2010 17:43:05 -0400 |
To: | bug-Expect [...] rt.cpan.org |
From: | Alexander Dupuy <alex.dupuy [...] mac.com> |
The "special" EOF "escape" is correctly used to handle an EOF. :-)
However, it will also match the string "EOF" in bytes read from an
expect object. :-(
The following patch (also as an attachment to protect from
line-wrapping) fixes this problem:
--- a/Expect/Expect.pm
+++ b/Expect/Expect.pm
@@ -1180,6 +1180,7 @@ sub interconnect {
$escape_character_buffer = '' unless defined
($escape_character_buffer);
$escape_character_buffer .= ${*$read_handle}{exp_Pty_Buffer};
foreach $escape_sequence (keys(%{${*$read_handle}{exp_Function}})) {
+ next if $escape_sequence eq "EOF";
print STDERR "Tested escape sequence $escape_sequence from
${*$read_handle}{exp_Pty_Handle}"if ${*$read_handle}{"exp_Debug"} > 1;
# Make sure it doesn't grow out of bounds.
$escape_character_buffer =
$read_handle->_trim_length($escape_character_buffer,${*$read_handle}{"exp_Max_Accum"})
if (${*$read_handle}{"exp_Max_Accum"});
diff --git a/Expect/Expect.pm b/Expect/Expect.pm
index b42283b..60fb772 100644
--- a/Expect/Expect.pm
+++ b/Expect/Expect.pm
@@ -1180,6 +1180,7 @@ sub interconnect {
$escape_character_buffer = '' unless defined ($escape_character_buffer);
$escape_character_buffer .= ${*$read_handle}{exp_Pty_Buffer};
foreach $escape_sequence (keys(%{${*$read_handle}{exp_Function}})) {
+ next if $escape_sequence eq "EOF";
print STDERR "Tested escape sequence $escape_sequence from ${*$read_handle}{exp_Pty_Handle}"if ${*$read_handle}{"exp_Debug"} > 1;
# Make sure it doesn't grow out of bounds.
$escape_character_buffer = $read_handle->_trim_length($escape_character_buffer,${*$read_handle}{"exp_Max_Accum"}) if (${*$read_handle}{"exp_Max_Accum"});