Skip Menu |

This queue is for tickets about the Term-ReadLine-Gnu CPAN distribution.

Maintainer(s)' notes

When you report a bug, please provide the following information;

- output of
	perl -V
	perl Makefile.PL verbose
	make test TEST_VERBOSE=1
	perl -Mblib t/00checkver.t
	echo $TERM
- terminal emulator which you are using
- compiler which is used to compile the GNU Readline Library (libreadline.a) if you can know.
Read INSTALL in the distribution for more details.

Report information
The Basics
Id: 123398
Status: resolved
Priority: 0/
Queue: Term-ReadLine-Gnu

People
Owner: HAYASHI [...] cpan.org
Requestors: fsfs [...] debian.org
Cc: gregoa [...] cpan.org
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.35
Fixed in: 1.36



Subject: backspace(?) not recognized when running from emacs shell buffer
Hi, today I was looking at a bug that has been lying in the Debian BTS for a decade and a half: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=166987 Unfortunately I was still able to reproduce it, so I guess it's about time to forward it to you... In short: Show quoted text
> perl -e 'use Term::ReadLine; my $term = new Term::ReadLine("foo"); $ret = $term->readline("foo? ", 1); open (LOG, ">log");print LOG "GOT>>$ret<<\n"' > > It seems that this perl command, on a system with Term::ReadLine::GNU > installed, in an emacs shell buffer, logs "12", if I backspace over the > 1 it displays as the default value, and type a "2".
The above command works fine when I run it in an xterm (log contains "GOT>>2<<"), but when using a current emacs25 to start an interactive shell (M-x shell, where M can be typed as Esc), $TERM is 'dumb' and log contains "GOT>>12<<" Please tell me if this is not enough to reproduce the bug and you need more details on the environment.
Hi, Thank you for your report. --- foo.c --- #include <stdio.h> #include <readline/readline.h> static int set_deftext () { rl_insert_text ("1"); return 0; } int main () { char *temp; rl_startup_hook = set_deftext; temp = readline ("foo? "); printf ("GOT>>%s<<\n", temp); } ----------- $ gcc foo.c -o foo -lreadline -ltermcap $ ./foo This has the same behavior in Emacs shell-mode. I have no idea if this is a bug of GNU Readline Library or Emacs shell-mode.
Hi, Show quoted text
> This has the same behavior in Emacs shell-mode. > I have no idea if this is a bug of GNU Readline Library or Emacs shell-mode.
I've committed a fix for this issue. By this fix, if TERM is set to dumb, emacs, or unknown, 'use Term::ReadLine;' does not use Term::ReadLine::Gnu. This will be included in the next release. --- a/trunk/Gnu.pm +++ b/trunk/Gnu.pm @@ -79,6 +79,11 @@ the Term::ReadLine documentation for more information. END } +} +# use Term::ReadLine::Stub on a dumb terminal. +# https://rt.cpan.org/Ticket/Display.html?id=123398 +BEGIN { + croak "dumb terminal." if($ENV{TERM} =~ /^(dumb|emacs|unknown)$/); } { ----------- $ echo $TERM dumb $ perl -Mblib -e 'use Term::ReadLine; my $term = new Term::ReadLine("xx"); print $term->ReadLine, "\n"; $ret = $term->readline("foo? ", "xxx"); print "GOT>>$ret<<\n"' Term::ReadLine::Stub foo? abc Show quoted text
GOT>>abc<<
$
From: fsfs [...] debian.org
Show quoted text
> --- a/trunk/Gnu.pm > +++ b/trunk/Gnu.pm > @@ -79,6 +79,11 @@ > the Term::ReadLine documentation for more information. > END > } > +} > +# use Term::ReadLine::Stub on a dumb terminal. > +# https://rt.cpan.org/Ticket/Display.html?id=123398 > +BEGIN { > + croak "dumb terminal." if($ENV{TERM} =~ > /^(dumb|emacs|unknown)$/); > } > > { > > > ----------- > > $ echo $TERM > dumb > $ perl -Mblib -e 'use Term::ReadLine; my $term = new > Term::ReadLine("xx"); print $term->ReadLine, "\n"; $ret = $term-
> >readline("foo? ", "xxx"); print "GOT>>$ret<<\n"'
> Term::ReadLine::Stub > foo? abc
> GOT>> abc<<
> $
Thanks a lot for the quick fix, which I'll upload to Debian in a minute.
Hi, we have another similar bug report in the Debian bug tracker: https://bugs.debian.org/895157 where Steve Langasek notices that the warnings caused by an unset TERM environment variable cause problems in some situations, and proposes to treat a missing ENV{TERM} like a dumb terminal: -+ croak "dumb terminal." if($ENV{TERM} =~ /^(dumb|emacs|unknown)$/); ++ croak "dumb terminal." if(!exists $ENV{TERM} || $ENV{TERM} =~ /^(dumb|emacs|unknown)$/); (Full patch attached as well.) I wonder if we should put this in a separate line with a different error message, and if we should also handle a set but empty TERM; but for now this patch seems to make sense to me. - What do you think? Cheers, gregor, Debian Perl Group
Subject: 50dumbterm.patch
Description: Do not use Term::ReadLine::Gnu on dumb terminals or emacs Origin: https://rt.cpan.org/Public/Bug/Display.html?id=123398 Author: Hiroo HAYASHI <hayashi@cpan.org> Author: Steve Langasek <steve.langasek@ubuntu.com> Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=166987 Bug-Debian: https://bugs.debian.org/895157 Last-Modified: 2018-04-07 --- a/Gnu.pm +++ b/Gnu.pm @@ -80,6 +80,11 @@ END } } +# use Term::ReadLine::Stub on a dumb terminal. +# https://rt.cpan.org/Ticket/Display.html?id=123398 +BEGIN { + croak "dumb terminal." if(!exists $ENV{TERM} || $ENV{TERM} =~ /^(dumb|emacs|unknown)$/); +} { use Exporter ();
Hi, Show quoted text
> -+ croak "dumb terminal." if($ENV{TERM} =~ > /^(dumb|emacs|unknown)$/); > ++ croak "dumb terminal." if(!exists $ENV{TERM} || $ENV{TERM} =~ > /^(dumb|emacs|unknown)$/);
This fix sounds good to me. Thanks.
The fix is in Term::ReadLine::Gnu-1.36 released today.
Subject: Re: [rt.cpan.org #123398] backspace(?) not recognized when running from emacs shell buffer
Date: Mon, 14 Jan 2019 19:29:15 +0100
To: Hiroo_HAYASHI via RT <bug-Term-ReadLine-Gnu [...] rt.cpan.org>
From: gregor herrmann <gregoa [...] debian.org>
On Mon, 14 Jan 2019 09:41:19 -0500, Hiroo_HAYASHI via RT wrote: Show quoted text
> The fix is in Term::ReadLine::Gnu-1.36 released today.
Thanks, uploaded to Debian/unstable. Cheers, gregor -- .''`. https://info.comodo.priv.at -- Debian Developer https://www.debian.org : :' : OpenPGP fingerprint D1E1 316E 93A7 60A8 104D 85FA BB3A 6801 8649 AA06 `. `' Member VIBE!AT & SPI Inc. -- Supporter Free Software Foundation Europe `-
Download signature.asc
application/pgp-signature 963b

Message body not shown because it is not plain text.