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: 96569
Status: resolved
Priority: 0/
Queue: Term-ReadLine-Gnu

People
Owner: HAYASHI [...] cpan.org
Requestors: ssb [...] umn.edu
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 1.24
Fixed in: 1.26



Subject: sends prompt to /dev/tty, sends Meta-Enable escape to STDOUT
"output of" preliminaries coming in followup. When using the module with STDOUT diverted on Linux, the prompt correctly goes to /dev/tty, but for terminals with a meta_on capability it sends the character sequence to STDOUT rather than to /dev/tty: PERL_RL=GNU perl -e 'use Term::ReadLine; $term = Term::ReadLine->new("blah"); $line = $term->readline("answer: "); exit 0' | od -c answer: 0000000 033 [ ? 1 0 3 4 h 0000010 Ran into this with TERM=xterm. If I switch to dumb or if I switch to Term::ReadLine::Perl, the escape sequence goes away.
- output of perl -V Summary of my perl5 (revision 5 version 14 subversion 2) configuration: Platform: osname=linux, osvers=2.6.32-131.12.1.el6.x86_64, archname=x86_64-linux uname='linux wbob-sv-03.ggnet.umn.edu 2.6.32-131.12.1.el6.x86_64 #1 smp sun jul 31 16:44:56 edt 2011 x86_64 x86_64 x86_64 gnulinux ' config_args='-de -Dprefix=/swadm' hint=recommended, useposix=true, d_sigaction=define useithreads=undef, usemultiplicity=undef useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=define, use64bitall=define, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O2', cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include' ccversion='', gccversion='4.4.5 20110214 (Red Hat 4.4.5-6)', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='cc', ldflags =' -fstack-protector -L/usr/local/lib' libpth=/usr/local/lib /lib/../lib64 /usr/lib/../lib64 /lib /usr/lib /lib64 /usr/lib64 /usr/local/lib64 libs=-lnsl -ldl -lm -lcrypt -lutil -lc perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc libc=/lib/libc-2.12.so, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='2.12' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector' Characteristics of this binary (from libperl): Compile-time options: PERL_DONT_CREATE_GVSV PERL_MALLOC_WRAP PERL_PRESERVE_IVUV USE_64_BIT_ALL USE_64_BIT_INT USE_LARGE_FILES USE_PERLIO USE_PERL_ATOF Built under linux Compiled at Oct 28 2011 18:19:29 %ENV: PERL_LWP_SSL_VERIFY_HOSTNAME="0" @INC: /swadm/lib/perl5/site_perl/5.14.2/x86_64-linux /swadm/lib/perl5/site_perl/5.14.2 /swadm/lib/perl5/5.14.2/x86_64-linux /swadm/lib/perl5/5.14.2 . perl Makefile.PL verbose Found `/usr/lib/../lib64/libtermcap.so'. cc -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_STRING_H rlver.c -o rlver -fstack-protector -L/usr/local/lib -lreadline -ltermcap It seems that you have the GNU Readline Library version 6.0. cc -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DHAVE_STRING_H -DTRG_READLINE_VERSION=0x0600 rlmalloc.c -o rlmalloc -fstack-protector -L/usr/local/lib -lreadline -ltermcap ABSTRACT_FROM => q[Gnu.pm] AUTHOR => [q[Hiroo HAYASHI <hiroo.hayashi@computer.org>]] BUILD_REQUIRES => { } CONFIGURE_REQUIRES => { } DEFINE => q[-DHAVE_STRING_H -DTRG_READLINE_VERSION=0x0600] EXE_FILES => [q[eg/perlsh]] INC => q[] LDDLFLAGS => q[ -shared -O2 -L/usr/local/lib -fstack-protector] LIBS => [q[ -lreadline -ltermcap]] LICENSE => q[perl] META_MERGE => { resources=>{ repository=>q[https://sourceforge.net/p/perl-trg/code/HEAD/tree/], homepage=>q[http://sourceforge.net/projects/perl-trg/], bugtracker=>q[http://rt.cpan.org/Public/Dist/Term-ReadLine-Gnu], license=>q[http://dev.perl.org/licenses/] } } MIN_PERL_VERSION => q[5.008000] NAME => q[Term::ReadLine::Gnu] PREREQ_PM => { } TEST_REQUIRES => { } VERSION_FROM => q[Gnu.pm] clean => { FILES=>q[rlver.c rlver rlmalloc.c rlmalloc] } dist => { COMPRESS=>q[gzip -9f], SUFFIX=>q[gz] } dynamic_lib => { OTHERLDFLAGS=>q[] } Using PERL=/swadm/bin/perl Potential libraries are '-lreadline -ltermcap': readline not found in /usr/local/lib '-lreadline' found at /lib/../lib64/libreadline.so.6.0 termcap not found in /usr/local/lib '-ltermcap' found at /lib/../lib64/libtermcap.so.2.0.8 Writing Makefile for Term::ReadLine::Gnu Writing MYMETA.yml and MYMETA.json make test TEST_VERBOSE=1 Skip blib/lib/Term/ReadLine/Gnu.pm (unchanged) Skip blib/lib/Term/ReadLine/Gnu/XS.pm (unchanged) cc -c -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -O2 -DVERSION=\"1.24\" -DXS_VERSION=\"1.24\" -fPIC "-I/swadm/lib/perl5/5.14.2/x86_64-linux/CORE" -DHAVE_STRING_H -DTRG_READLINE_VERSION=0x0600 Gnu.c Running Mkbootstrap for Term::ReadLine::Gnu () chmod 644 Gnu.bs rm -f blib/arch/auto/Term/ReadLine/Gnu/Gnu.so LD_RUN_PATH="/lib/../lib64" cc -shared -O2 -L/usr/local/lib -fstack-protector Gnu.o -o blib/arch/auto/Term/ReadLine/Gnu/Gnu.so \ -lreadline -ltermcap \ chmod 755 blib/arch/auto/Term/ReadLine/Gnu/Gnu.so cp Gnu.bs blib/arch/auto/Term/ReadLine/Gnu/Gnu.bs chmod 644 blib/arch/auto/Term/ReadLine/Gnu/Gnu.bs cp eg/perlsh blib/script/perlsh /swadm/bin/perl -MExtUtils::MY -e 'MY->fixin(shift)' -- blib/script/perlsh PERL_DL_NONLAZY=1 /swadm/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(1, 'blib/lib', 'blib/arch')" t/*.t t/00checkver.t .. 1..4 # Running under perl version 5.014002 for linux # Current time local: Thu Jun 19 18:16:33 2014 # Current time GMT: Thu Jun 19 23:16:33 2014 # Using Test.pm version 1.26 # I'm testing Term::ReadLine::Gnu version 1.24 ok 1 ok 2 ok 3 # OS: linux # Perl version: 5.014002 # GNU Readline Library version: 6.0, 0x600 # $TERM=xterm ok 4 ok t/callback.t .... 1..7 ok 1 loading ok 2 ok 3 ok 4 use Tk ok 5 callback_read_char ok 6 callback_handler_install ok 7 ok t/history.t ..... 1..84 ok 1 ok 2 ok 3 ok 4 ok 5 ok 6 ok 7 ok 8 ok 9 ok 10 ok 11 ok 12 ok 13 ok 14 ok 15 ok 16 ok 17 ok 18 ok 19 ok 20 ok 21 ok 22 ok 23 ok 24 ok 25 ok 26 ok 27 ok 28 ok 29 ok 30 ok 31 ok 32 ok 33 ok 34 ok 35 ok 36 ok 37 ok 38 ok 39 ok 40 ok 41 ok 42 ok 43 ok 44 ok 45 ok 46 ok 47 ok 48 ok 49 ok 50 ok 51 ok 52 ok 53 ok 54 ok 55 ok 56 ok 57 ok 58 ok 59 ok 60 ok 61 ok 62 ok 63 ok 64 ok 65 ok 66 ok 67 ok 68 ok 69 ok 70 ok 71 ok 72 ok 73 get_history_event ok 74 ok 75 ok 76 ok 77 ok 78 ok 79 ok 80 ok 81 ok 82 ok 83 ok 84 ok t/readline.t .... 1..140 ok 1 loading ok Try `/swadm/bin/perl -Mblib t/readline.t verbose', if you will. ok 2 new ok 3 ReadLine method ok 4 Features method ok 5 Attrib method ok 6 readline_version ok 7 rl_version ok 8 ok 9 ok 10 ok 11 ok 12 ok 13 num_chars_to_read ok 14 pending_input ok 15 dispatching ok 16 ok 17 ok 18 display_prompt ok 19 already_prompted ok 20 gnu_readline_p ok 21 ok 22 readline_name ok 23 prefer_envwin_size ok 24 ok 25 startup_hook ok 26 ok 27 ok 28 ok 29 ok 30 ok 31 ok 32 ok 33 ok 34 executing_keymap ok 35 binding_keymap ok 36 executing_macro ok 37 executing_key ok 38 executing_keyseq ok 39 key_sequence_length ok 40 readline_state ok 41 explicit_arg ok 42 numeric_arg ok 43 editing_mode ok 44 add_defun ok 45 ok 46 ok 47 ok 48 bind_key ok 49 ok 50 ok 51 ok 52 keymap binding ok 53 macro binding ok 54 function binding ok 55 rl_read_init_file ok 56 ok 57 ok 58 unbind_key ok 59 add_funmap_entry ok 60 invoking_keyseqs ok 61 catch_signals ok 62 catch_sigwinch ok 63 change_environment ok 64 set/get_screen_size ok 65 ok 66 ok 67 ok 68 ok 69 char_is_quoted_p ok 70 ok 71 ok 72 ok 73 ok 74 ok 75 ok 76 ok 77 ok 78 ok 79 ok 80 ok 81 ok 82 special_prefixes ok 83 ok 84 ok 85 ok 86 ok 87 ok 88 ok 89 ok 90 ok 91 ok 92 ok 93 ok 94 ok 95 completion_type ok 96 ok 97 ok 98 accept-line is bound to \C-m ok 99 forward-char is bound to \C-f ok 100 backward-char is bound to \C-b ok 101 forward-word is bound to \M-f ok 102 backward-word is bound to \M-b ok 103 end-of-line is bound to \C-e ok 104 beginning-of-line is bound to \C-a ok 105 backward-delete-char is bound to \C-h ok 106 delete-char is bound to \C-d ok 107 complete is bound to \C-i ok 108 self insert ok 109 cursor move ok 110 custom commands ok 111 undo ok 112 macro ok 113 ornaments ok 114 operate_and_get_next 1 ok 115 operate_and_get_next 2 ok 116 operate_and_get_next 3 ok 117 operate_and_get_next 4 ok 118 history 1 ok 119 history 2 ok 120 history 3 ok 121 insert completion ok 122 default completion ok 123 username completion ok 124 list completion ok 125 filename completion ok 126 null completion 1 ok 127 null completion 2 ok 128 list & file completion ok 129 ingore_some_completion ok 130 filename_quoting_function ok 131 filename_dequoting_function ok 132 directory_completion_hook ok 133 filename_list ok 134 startup_hook ok 135 pre_input_hook ok 136 redisplay_function ok 137 ok 138 ok 139 ok 140 ok All tests successful. Files=4, Tests=235, 0 wallclock secs ( 0.05 usr 0.01 sys + 0.25 cusr 0.03 csys = 0.34 CPU) Result: PASS perl -Mblib t/00checkver.t 1..4 # Running under perl version 5.014002 for linux # Current time local: Thu Jun 19 18:17:11 2014 # Current time GMT: Thu Jun 19 23:17:11 2014 # Using Test.pm version 1.26 # I'm testing Term::ReadLine::Gnu version 1.24 ok 1 ok 2 ok 3 # OS: linux # Perl version: 5.014002 # GNU Readline Library version: 6.0, 0x600 # $TERM=xterm ok 4 echo $TERM xterm (xterm-253-1.el6.x86_64) - terminal emulator which you are using ^ - compiler which is used to compile the GNU Readline Library (libreadline.a) if you can know. cc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4)
Trying to replicate the behavior using a small C program to call libreadline. Can't seem to get it to put the Meta-Enable to STDOUT but I'm probably missing some code because I can't follow the module all that well. It also appears that the Meta-Enable gets sent out by libreadline whether I call rl_prep_terminal with a 0 or non-zero argument which seems like a libreadline bug. Probably just not understanding how it's really a feature. This is somewhat off-topic for my real issue which is the fact that the Perl module sends the Meta-Enable sequence to stdout rather than to /dev/tty even though the prompt and the input switch to /dev/tty. My test program FWIW: #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <readline/readline.h> #include <readline/history.h> main() { char *cp; FILE *tty; if ((tty = fopen("/dev/tty", "r+")) == NULL) { perror("/dev/tty: "); exit(1); } rl_instream = tty; rl_outstream = tty; rl_prep_terminal(0); cp = readline ("answer: "); exit(0); }
Thank you for your reports. The following code reproduce the issue. #include <stdio.h> #include <stdlib.h> #include <fcntl.h> #include <readline/readline.h> main() { char *cp; FILE *tty; rl_initialize(); if ((tty = fopen("/dev/tty", "r+")) == NULL) { perror("/dev/tty: "); exit(1); } rl_instream = tty; rl_outstream = tty; exit(0); } rl_initialize() outputs some charactors to STDIO. The GNU Readline Library manual http://cnswww.cns.cwru.edu/php/chet/readline/readline.html says: Function: int rl_initialize (void) Initialize or re-initialize Readline's internal state. It's not strictly necessary to call this; readline() calls it before reading any input. Here is a quick fix. (This cause some errors in t/readline.t. They can be fixed.) --- Gnu.pm (revision 471) +++ Gnu.pm (working copy) @@ -247,7 +247,7 @@ $ENV{_TRL_DUMMY} = ''; # initialize the GNU Readline Library and termcap library - $self->initialize(); + #$self->initialize(); # enable ornaments to be compatible with perl5.004_05(?) $self->ornaments(1) unless ($ENV{PERL_RL} and $ENV{PERL_RL} =~ /\bo\w*=0/);
I've committed the fix into the SVN repository. It will be included in the next release. Probably it will be after GNU Readline 6.4 will be released.
After thinking about this issue more, I decided to leave rl_initialize() in new() to keep backward compatibility. --- Gnu.pm (revision 471) +++ Gnu.pm (working copy) @@ -246,9 +246,6 @@ # calls setenv() before the 1st assignment to $ENV{}. $ENV{_TRL_DUMMY} = ''; - # initialize the GNU Readline Library and termcap library - $self->initialize(); - # enable ornaments to be compatible with perl5.004_05(?) $self->ornaments(1) unless ($ENV{PERL_RL} and $ENV{PERL_RL} =~ /\bo\w*=0/); @@ -268,6 +265,11 @@ } $readline_version = $Attribs{readline_version}; + # initialize the GNU Readline Library and termcap library + # This is not necessary but is left to keep backward compatibility. + # https://rt.cpan.org/Ticket/Display.html?id=96569 + $self->initialize(); + $self; }
The fix is in Term-ReadLine-Gnu-1.25.
From: paul [...] city-fan.org
On Sat Dec 20 20:03:12 2014, HAYASHI wrote: Show quoted text
> The fix is in Term-ReadLine-Gnu-1.25.
This change appears to break operation with readline 5.1: $ make test TEST_VERBOSE=1 PERL_DL_NONLAZY=1 /usr/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(1, 'blib/lib', 'blib/arch')" t/*.t t/00checkver....1..4 # Running under perl version 5.008008 for linux # Current time local: Tue Dec 23 09:16:31 2014 # Current time GMT: Tue Dec 23 09:16:31 2014 # Using Test.pm version 1.25 # I'm testing Term::ReadLine::Gnu version 1.25 ok 1 dubious Test returned status 0 (wstat 139, 0x8b) DIED. FAILED tests 2-4 Failed 3/4 tests, 25.00% okay t/callback......dubious Test returned status 0 (wstat 139, 0x8b) t/history.......dubious Test returned status 0 (wstat 139, 0x8b) t/readline......dubious Test returned status 0 (wstat 139, 0x8b) Failed Test Stat Wstat Total Fail Failed List of Failed ------------------------------------------------------------------------------- t/00checkver.t 0 139 4 6 150.00% 2-4 t/callback.t 0 139 ?? ?? % ?? t/history.t 0 139 ?? ?? % ?? t/readline.t 0 139 ?? ?? % ?? Failed 4/4 test scripts, 0.00% okay. 3/4 subtests failed, 25.00% okay. make: *** [test_dynamic] Error 255 Reverting the change or updating to readline 5.2 fixes this.
Could you try the following patch? Thanks! --- Gnu.pm (revision 476) +++ Gnu.pm (working copy) @@ -246,9 +246,9 @@ # calls setenv() before the 1st assignment to $ENV{}. $ENV{_TRL_DUMMY} = ''; - # enable ornaments to be compatible with perl5.004_05(?) - $self->ornaments(1) unless ($ENV{PERL_RL} and $ENV{PERL_RL} =~ /\bo\w*=0/); - + # set tty before calling rl_initialize() not to output some + # charactores to STDIO. + # https://rt.cpan.org/Ticket/Display.html?id=96569 if (!@_) { my ($IN,$OUT) = $self->findConsole(); open(IN,"<$IN") || croak "Cannot open $IN for read"; @@ -263,13 +263,17 @@ $Attribs{instream} = shift; $Attribs{outstream} = shift; } - $readline_version = $Attribs{readline_version}; # initialize the GNU Readline Library and termcap library - # This is not necessary but is left to keep backward compatibility. - # https://rt.cpan.org/Ticket/Display.html?id=96569 + # This calls tgetent(). $self->initialize(); + # enable ornaments to be compatible with perl5.004_05(?) + # This calls tgetstr(). + $self->ornaments(1) unless ($ENV{PERL_RL} and $ENV{PERL_RL} =~ /\bo\w*=0/); + + $readline_version = $Attribs{readline_version}; + $self; }
The fix is in 1.26.