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


Groups > gnu.bash.bug > #11303

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

Path csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!usenet.stanford.edu!not-for-mail
From Chet Ramey <chet.ramey@case.edu>
Newsgroups gnu.bash.bug
Subject Re: Ctrl-U doesn't clear read -ep prompt input properly
Date Fri, 7 Aug 2015 15:01:15 -0400
Lines 38
Approved bug-bash@gnu.org
Message-ID <mailman.7949.1438974088.904.bug-bash@gnu.org> (permalink)
References <0D835E9B9CD07F40A48423F80D3B5A702E90C868@USA7109MB022.na.xerox.net>
Reply-To chet.ramey@case.edu
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 7bit
X-Trace usenet.stanford.edu 1438974088 14941 208.118.235.17 (7 Aug 2015 19:01:28 GMT)
X-Complaints-To action@cs.stanford.edu
Cc chet.ramey@case.edu
To "Nellis, Kenneth" <Kenneth.Nellis@xerox.com>, "bug-bash@gnu.org" <bug-bash@gnu.org>
Envelope-to bug-bash@gnu.org
X-Enigmail-Draft-Status N1110
User-Agent Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Thunderbird/38.0.1
In-Reply-To <0D835E9B9CD07F40A48423F80D3B5A702E90C868@USA7109MB022.na.xerox.net>
X-Junkmail-Status score=10/50, host=mpv5.cwru.edu
X-Junkmail-Whitelist YES (by domain whitelist at mpv1.tis.cwru.edu)
X-detected-operating-system by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic]
X-Received-From 129.22.105.36
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.14
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <http://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
Xref csiph.com gnu.bash.bug:11303

Show key headers only | View raw


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/

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


Thread

Re: Ctrl-U doesn't clear read -ep prompt input properly Chet Ramey <chet.ramey@case.edu> - 2015-08-07 15:01 -0400

csiph-web