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 c...@case.edu http://cnswww.cns.cwru.edu/~chet/