Bug 304181

Summary: Readline initialization outputs escape sequence
Product: [Fedora] Fedora Reporter: Orion Poplawski <orion>
Component: readlineAssignee: Miroslav Lichvar <mlichvar>
Status: CLOSED NOTABUG QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: low Docs Contact:
Priority: low    
Version: 7   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2007-10-31 09:57:54 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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 (">");
       puts(ans);
}
$ 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
0000016

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.