[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'
-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.
- Ctrl-U doesn't clear read -ep prompt input properly,
Nellis, Kenneth <=