cmd2 now protects against GNU Readline bug when ANSI escapes in prompt#93
Merged
tleonhardt merged 5 commits intomasterfrom May 12, 2017
Merged
cmd2 now protects against GNU Readline bug when ANSI escapes in prompt#93tleonhardt merged 5 commits intomasterfrom
tleonhardt merged 5 commits intomasterfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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