Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #11301

Ctrl-U doesn't clear read -ep prompt input properly

From "Nellis, Kenneth" <Kenneth.Nellis@xerox.com>
Newsgroups gnu.bash.bug
Subject Ctrl-U doesn't clear read -ep prompt input properly
Date 2015-08-07 13:36 +0000
Message-ID <mailman.7934.1438956061.904.bug-bash@gnu.org> (permalink)

Show all headers | View raw


Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: cygwin
Compiler: gcc
Compilation CFLAGS:  -DPROGRAM='bash.exe' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='cygwin' -DCONF_MACHTYPE='x86_64-unknown-cygwin' -DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -DRECYCLES_PIDS   -I.  -I/usr/src/bash-4.3.39-2.x86_64/src/bash-4.3 -I/usr/src/bash-4.3.39-2.x86_64/src/bash-4.3/include -I/usr/src/bash-4.3.39-2.x86_64/src/bash-4.3/lib  -DWORDEXP_OPTION -ggdb -O2 -pipe -Wimplicit-function-declaration -fdebug-prefix-map=/usr/src/bash-4.3.39-2.x86_64/build=/usr/src/debug/bash-4.3.39-2 -fdebug-prefix-map=/usr/src/bash-4.3.39-2.x86_64/src/bash-4.3=/usr/src/debug/bash-4.3.39-2
uname output: CYGWIN_NT-6.1 COR900GFY5 2.2.0(0.289/5/3) 2015-08-03 12:51 x86_64 Cygwin
Machine Type: x86_64-unknown-cygwin

Bash Version: 4.3
Patch Level: 39
Release Status: release

Description:
Pressing CTRL-U after entering data in response to a read -ep prompt should work as does the PS1 bash prompt.
Consider a custom PS1 bash prompt containing ansi escape sequences, for example, to display
the prompt in color. To get proper CTRL-U clearing of input typed at the prompt, bash
recognizes special \ [ and \ ] delimiters in the prompt string. Here is my PS1, for example:
\ [ ESC [ 3 2 m \ ] $ SP \ [ ESC ( B ESC [ m \ ] LF
which displays a "$ " prompt in green.
Without \ [ and \ ] in the prompt, CTRL-U doesn't clear the line properly, so it's a necessary feature.

read -ep prompt, however, does not support the \ [ and \ ] delimiters. Consequently, for prompts containing
ansi escape sequences, CTRL-U doesn't clear the line properly.

Repeat-By:
The following example demonstrates the problem.
$ prompt="$(tput setaf 2)test>$(tput sgr0) "
$ read -ep "$prompt" answer
test> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<CTRL-U>

Note that all the x's are not cleared.

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Ctrl-U doesn't clear read -ep prompt input properly "Nellis, Kenneth" <Kenneth.Nellis@xerox.com> - 2015-08-07 13:36 +0000

csiph-web