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