[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

From: Nellis, Kenneth
Subject: Ctrl-U doesn't clear read -ep prompt input properly
Date: Fri, 7 Aug 2015 13:36:50 +0000

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' 
-I/usr/src/bash-4.3.39-2.x86_64/src/bash-4.3/lib  -DWORDEXP_OPTION -ggdb -O2 
-pipe -Wimplicit-function-declaration 
uname output: CYGWIN_NT-6.1 COR900GFY5 2.2.0(0.289/5/3) 2015-08-03 12:51 x86_64 
Machine Type: x86_64-unknown-cygwin

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

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.

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.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]