Skip to content

cmd2 now protects against GNU Readline bug when ANSI escapes in prompt#93

Merged
tleonhardt merged 5 commits intomasterfrom
gnureadline
May 12, 2017
Merged

cmd2 now protects against GNU Readline bug when ANSI escapes in prompt#93
tleonhardt merged 5 commits intomasterfrom
gnureadline

Conversation

@tleonhardt
Copy link
Copy Markdown
Member

The Python 3 input() or Python 2 raw_input() functions use the Python readline module under the hood, which in turn relies on OS-specific readline libraries.

On Linux and (sometimes) on Mac this underlying library is GNU Readline. GNU Readline has a bug in how the prompt length is calculated if there are "invisible" non-printable characters such as ANSI color escape codes. GNU Readline knows it has this bug and provides a way of escaping these invisible escape characters.

So as a convenience to end users who may want to use color in their prompts, cmd2 now automatically protects any ANSI escape characters in the prompt with GNU Readline escapes on non-Windows OSes.

This closes #92

The current version of gnureadline available in pip and conda has a malloc error, at least on Mac OS
GNU Readline has a bug in calculating prompt length when ANSI escape codes are present in the prompt.  It requires you to escape the escape codes to tell it where sections of invisible characters begin and end.

So before calling input(), cmd2 now makes the prompt safe by escaping any ANSI escape codes present.
@tleonhardt tleonhardt added this to the 0.7.1 milestone May 12, 2017
@tleonhardt tleonhardt self-assigned this May 12, 2017
@tleonhardt tleonhardt merged commit aa824fe into master May 12, 2017
@tleonhardt tleonhardt deleted the gnureadline branch May 12, 2017 02:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GNU Readline goes haywire if prompt contains ANSI color codes

3 participants