Bug 304181 - Readline initialization outputs escape sequence
Summary: Readline initialization outputs escape sequence
Alias: None
Product: Fedora
Classification: Fedora
Component: readline
Version: 7
Hardware: All
OS: Linux
Target Milestone: ---
Assignee: Miroslav Lichvar
QA Contact: Fedora Extras Quality Assurance
Depends On:
TreeView+ depends on / blocked
Reported: 2007-09-24 22:03 UTC by Orion Poplawski
Modified: 2018-11-28 19:18 UTC (History)
0 users

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Last Closed: 2007-10-31 09:57:54 UTC
Type: ---

Attachments (Terms of Use)

Description Orion Poplawski 2007-09-24 22:03:57 UTC
Description of problem:

Starting with Fedora 7, the xterm terminfo description added the "smm" attribute:

infocmp xterm | grep smm
        smir=\E[4h, smkx=\E[?1h\E=, smm=\E[?1034h, smso=\E[7m,

man terminfo describes this as:

       meta_on                        smm         mm         turn on meta mode
                                                             (8th-bit on)

Apparently, the readline library emits this at initialization.  This can cause
problems with certain configure scripts that attempt to obtain version
information from program via methods like:

version=`echo "disp(OCTAVE_VERSION)" | octave -qf`

as the escape sequence gets embedded.

I'm not really sure if there is anything to fix in readline/ncurses to address
this or just tell people to write better configure scripts, but it is certainly
surprising behavior.

Possibly readline should behave differently if stdin or stdout is a file or pipe?

Test code:

$ cat readline.c
#include <stdio.h>
#include <readline/readline.h>

main() {
       char *ans = readline (">");
$ gcc -o readline readline.c  -l readline
$ echo blah | ./readline  > out
$ od -a out
0000000 esc   [   ?   1   0   3   4   h   >   b   l   a   h  nl

Comment 1 Miroslav Lichvar 2007-10-10 13:38:49 UTC
Readline (and ncurses) doesn't care much if stdout is not a tty. I think that's
good as you can use readline with redirected output and input. octave should use
fgets() or similar when it's not in interactive mode. octave --no-line-editing
doesn't seem to help.

`echo "disp(OCTAVE_VERSION)" | TERM=dumb octave -qf` gives the correct output.

Comment 2 Miroslav Lichvar 2007-10-31 09:57:54 UTC
Closing as NOTABUG. Please reopen if you think this should be fixed in readline.

Note You need to log in before you can comment on or make changes to this bug.