Open qistoph opened 3 years ago
Thanks for the great bug report! I haven't needed Term::ShellUI in years so probably won't work on this any time soon. I am happy to review and merge a patch if you look into it.
On inspection it seems it's an issue rather with Term::Readline.
It hangs on this line in Term::ShellUI https://github.com/bronson/Term-ShellUI/blob/master/lib/Term/ShellUI.pm#L788
Ok, was maybe a little quick on closing the issue. This fix/work-around seems to fix the issue:
diff --git a/lib/Term/ShellUI.pm b/lib/Term/ShellUI.pm
index 7d36ba9..63fe7c5 100644
--- a/lib/Term/ShellUI.pm
+++ b/lib/Term/ShellUI.pm
@@ -1557,6 +1557,9 @@ sub completion_function
my $twice = ($self->{completeline} eq $line);
$self->{completeline} = $line;
+ $line =~ s/([^\\])\\$/\1/g; # Strip uneven backslash at end
+ $line =~ s/^\\$//g; # Strip if it's only backslash
+
my($tokens, $tokno, $tokoff) = $self->{parser}->parse_line($line,
messages=>0, cursorpos=>$cursor, fixclosequote=>1);
return unless defined($tokens);
Found another issue, with a double backslash at the end though :-)
ShellUI hangs when completing a command that ends with in incomplete escape sequence; just a backslash.
Example:
Then enter
\<tab>
, ShellUI hangs and CPU usage soars to 100%