Red Hat Bugzilla – Bug 304181
Readline initialization outputs escape sequence
Last modified: 2012-09-05 13:01:37 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
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
Possibly readline should behave differently if stdin or stdout is a file or pipe?
$ cat readline.c
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
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.
Closing as NOTABUG. Please reopen if you think this should be fixed in readline.