help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] `read -e -p`, colors, and invisible chars


From: Mike Frysinger
Subject: Re: [Help-bash] `read -e -p`, colors, and invisible chars
Date: Wed, 26 Aug 2015 22:06:24 -0400

On 26 Aug 2015 20:42, Dennis Williamson wrote:
> On Aug 26, 2015 8:06 PM, "Mike Frysinger" wrote:
> > now i hit the classic invisible char problem when readline tries to
> > redraw the prompt (just hold up on the arrow key to draw many lines
> > from your history).  normally i'd leverage \[ and \], but bash does
> > not seem to support that w/the read builtin -- they get rendered in
> > the output directly instead of being consumed.
> >   $ prompt=$(printf '%bfoo>%b ' '\[\033[1;33m\]' '\[\033[0m\]')
> >   $ read -e -p "${prompt}"
> >   \[\]foo>\[\]
> > (yes, moving the \[ and \] to the printf string yields same behavior)
> 
> Use \001 and \002 instead of \[ and \].

thanks ... didn't realize bash was changing \[ and \] into SOH and STX
and those are the magic bytes readline uses to mark things
-mike

Attachment: signature.asc
Description: Digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]