Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #11304
| From | "Nellis, Kenneth" <Kenneth.Nellis@xerox.com> |
|---|---|
| Newsgroups | gnu.bash.bug |
| Subject | RE: Ctrl-U doesn't clear read -ep prompt input properly |
| Date | 2015-08-07 19:21 +0000 |
| Message-ID | <mailman.7951.1438975301.904.bug-bash@gnu.org> (permalink) |
| References | <0D835E9B9CD07F40A48423F80D3B5A702E90C868@USA7109MB022.na.xerox.net> <55C5007B.2030005@case.edu> |
On Friday, August 07, 2015 3:01 PM, Chet Ramey wrote: > On 8/7/15 9:36 AM, Nellis, Kenneth wrote: > > 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. > > You're correct. The prompt given to read -p prompt is not expanded like > the PSn variables. It never has been, and it's not documented to do so. > As such, using invisible characters in the read -p prompt string is not > supported. > > Since you're adding the non-visible characters to the prompt, you can > try bracketing them with \001 and \002, but you have to do that yourself. > > -- > ``The lyf so short, the craft so long to lerne.'' - Chaucer > ``Ars longa, vita brevis'' - Hippocrates > Chet Ramey, ITS, CWRU chet@case.edu > http://cnswww.cns.cwru.edu/~chet/ Hey, that works! Thanx! Didn't see it in the documentation. My bad? —Ken
Back to gnu.bash.bug | Previous | Next | Find similar
RE: Ctrl-U doesn't clear read -ep prompt input properly "Nellis, Kenneth" <Kenneth.Nellis@xerox.com> - 2015-08-07 19:21 +0000
csiph-web