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


Groups > gnu.bash.bug > #11304

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 "Nellis, Kenneth" <Kenneth.Nellis@xerox.com>
Newsgroups gnu.bash.bug
Subject RE: Ctrl-U doesn't clear read -ep prompt input properly
Date Fri, 7 Aug 2015 19:21:23 +0000
Lines 36
Approved bug-bash@gnu.org
Message-ID <mailman.7951.1438975301.904.bug-bash@gnu.org> (permalink)
References <0D835E9B9CD07F40A48423F80D3B5A702E90C868@USA7109MB022.na.xerox.net> <55C5007B.2030005@case.edu>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset="utf-8"
Content-Transfer-Encoding base64
X-Trace usenet.stanford.edu 1438975302 15343 208.118.235.17 (7 Aug 2015 19:21:42 GMT)
X-Complaints-To action@cs.stanford.edu
To "chet.ramey@case.edu" <chet.ramey@case.edu>, "bug-bash@gnu.org" <bug-bash@gnu.org>
Envelope-to bug-bash@gnu.org
Thread-Topic Ctrl-U doesn't clear read -ep prompt input properly
Thread-Index AdDRFd18t91bb7jLQx62YAkulZgEpAAV3pqAAAoEthA=
In-Reply-To <55C5007B.2030005@case.edu>
Accept-Language en-US
Content-Language en-US
X-MS-Has-Attach
X-MS-TNEF-Correlator
x-originating-ip [13.41.230.87]
X-detected-operating-system by eggs.gnu.org: Genre and OS details not recognized.
X-Received-From 13.24.230.18
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:11304

Show key headers only | View raw


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


Thread

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