Bug 304181 - Readline initialization outputs escape sequence
Readline initialization outputs escape sequence
Product: Fedora
Classification: Fedora
Component: readline (Show other bugs)
All Linux
low Severity low
: ---
: ---
Assigned To: Miroslav Lichvar
Fedora Extras Quality Assurance
Depends On:
  Show dependency treegraph
Reported: 2007-09-24 18:03 EDT by Orion Poplawski
Modified: 2012-09-05 13:01 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2007-10-31 05:57:54 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)

  None (edit)
Description Orion Poplawski 2007-09-24 18:03:57 EDT
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 09:38:49 EDT
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 05:57:54 EDT
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.