[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-readline] Bug report: Unwanted output on stdout from rl_initial

From: Chet Ramey
Subject: Re: [Bug-readline] Bug report: Unwanted output on stdout from rl_initialize()
Date: Fri, 22 Apr 2011 11:21:57 -0400
User-agent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv: Gecko/20110303 Thunderbird/3.1.9

On 4/22/11 8:19 AM, Miroslav Lichvar wrote:
> (resurrecting an old thread)
> On Thu, Aug 02, 2007 at 11:45:26AM +1000, Glen Coates wrote:
>> $ python test.py | od -tc
>> 0000000 033   [   ?   1   0   3   4   h   H   e   l   l   o  \n
>> By recompiling python, I managed to trace the output to rl_initialize():
>> <test.c>
>> #include <stdio.h>
>> #include <readline/readline.h>
>> #include <readline/history.h>
>> int main()
>> {
>>      rl_initialize();
>>      printf( "hello\n" );
>>      return 0;
>> }
>> $ ./test | od -tc
>> 0000000 033   [   ?   1   0   3   4   h   h   e   l   l   o  \n
>> Could you please confirm whether or not this is a bug in readline,
>> or rl_initialize() is being used incorrectly and thus a bug report
>> should be made to the Python project?
> This is caused by the _rl_enable_meta_key() which prints the mm/smm
> sequence from termcap/terminfo. In recent readline versions it can be
> disabled by the enable-meta-key variable.
> Do you think the python readline module should avoid calling
> rl_initialize() or would it be possible to delay printing of the string
> in readline until readline() is called?

Readline will call rl_initialize() on each invocation of readline(), so
you could avoid it in python.  I'm not sure why you're calling it anyway,
though bash uses it to add bindable command names so they're available when
readline parses the inputrc files and adds shell key bindings after
readline sets its defaults.  You could do something like

        rl_variable_bind ("enable-meta-key", "off");
        /* set other defaults like rl_instream, rl_outstream */
        rl_initialize ();
        /* add python-specific overrides to readline defaults */

> Also, if the smm string is printed, perhaps the rmm string should be
> printed after readline() is done? I remember this was causing some
> problems with xterm and the eightBitInput resource.

This is a good idea, thanks.

``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/

reply via email to

[Prev in Thread] Current Thread [Next in Thread]