bug-bash
[Top][All Lists]
Advanced

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

Re: read -e bug


From: Chet Ramey
Subject: Re: read -e bug
Date: Thu, 28 May 2009 09:41:28 -0400
User-agent: Thunderbird 2.0.0.21 (Macintosh/20090302)

Chris F.A. Johnson wrote:
> On Thu, 28 May 2009, Chet Ramey wrote:
> 
>>> This is nothing new; it happens in all versions of bash:
>>>
>>> printf "Enter something: "
>>> read -e whatever
>>>
>>> Press a key, then cursor left (or ^A); the cursor moves to the
>>> beginning of the line, over "E" instead of over the character just
>>> entered.
>> This isn't a bug; that's where readline thinks the cursor is.
> 
>    Why would it think that? It's wrong.

Because readline doesn't and can't know where the cursor is in the
presence of arbitrary output already appearing on the same line.  It
assumes that it begins in column 0.

>>  If you want to use a prompt, use `read -p'.
> 
>    I like to write portable scripts; read -p is not portable.

If you like to write portable scripts, you shouldn't be using read -e,
either.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU    chet@case.edu    http://cnswww.cns.cwru.edu/~chet/




reply via email to

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