[Bug 14486] completion broken with multi-line prompts

bugzilla at busybox.net bugzilla at busybox.net
Wed Jan 5 17:04:23 UTC 2022


https://bugs.busybox.net/show_bug.cgi?id=14486

--- Comment #8 from Denys Vlasenko <vda.linux at googlemail.com> ---
lineedit.c:

 * lineedit does not know that the terminal escape sequences do not
 * take up space on the screen. The redisplay code assumes, unless
 * told otherwise, that each character in the prompt is a printable
 * character that takes up one character position on the screen.
 * You need to tell lineedit that some sequences of characters
 * in the prompt take up no screen space. Compatibly with readline,
 * use the \[ escape to begin a sequence of non-printing characters,
 * and the \] escape to signal the end of such a sequence. Example:
 *
 * PS1='\[\033[01;32m\]\u@\h\[\033[01;34m\] \w \$\[\033[00m\] '

Your PS1 has no such annotations and this what makes line editing code to
incorrectly conclude that line has wrapped when it did not. The very same PS1
also misbehaves in bash.
(This depends on terminal width, this is why it did not happen to me in a wider
terminal).

This PS1 would work:

PS1="\[$e[0;32m\]""v ""\[$e[0;95m\]""SUSE ""\[$e[33m\]""~
""\n\[$e[38;2;140;206;250m\]""rkitover""\[$e[1;97m\]""@""\[$e[0m$e[38;2;140;206;250m\]""comply
""\[$e[38;2;220;20;60m\]"">""\[$e[0m\] "


...but their .config has this:

# CONFIG_FEATURE_EDITING_FANCY_PROMPT is not set

which disables the \[ \] feature (and all other useful magic for PS1, such as
\u \w). It needs to be enabled...

-- 
You are receiving this mail because:
You are on the CC list for the bug.


More information about the busybox-cvs mailing list