From nobody@FreeBSD.org  Fri Jul 20 20:23:11 2007
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 3933316A417
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 20 Jul 2007 20:23:11 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (unknown [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id 24AA013C457
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 20 Jul 2007 20:23:11 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.1/8.14.1) with ESMTP id l6KKNAFc053582
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 20 Jul 2007 20:23:10 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.1/8.14.1/Submit) id l6KKNA79053580;
	Fri, 20 Jul 2007 20:23:10 GMT
	(envelope-from nobody)
Message-Id: <200707202023.l6KKNA79053580@www.freebsd.org>
Date: Fri, 20 Jul 2007 20:23:10 GMT
From: Joe Peterson <lavajoe@gentoo.org>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Incorrect cursor behavior during command line editing in bash shell using UTF-8
X-Send-Pr-Version: www-3.0

>Number:         114782
>Category:       ports
>Synopsis:       shells/bash - Incorrect cursor behavior during command line editing in bash shell using UTF-8
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    obrien
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jul 20 20:30:02 GMT 2007
>Closed-Date:    Fri Mar 13 02:21:04 UTC 2009
>Last-Modified:  Fri Mar 13 02:21:04 UTC 2009
>Originator:     Joe Peterson
>Release:        6.2
>Organization:
>Environment:
FreeBSD crater 6.2-RELEASE FreeBSD Gentoo 6.2-r1 #1: Sat Jul  7 15:24:52 MDT 2007     joe@crater:/usr/src/sys-6.2-r1/i386/compile/GENERIC  i386
>Description:
In the bash shell, if you have LANG set to en_US.UTF-8 (or any UTF-8 variant) and you use the right arrow to move the cursor "past" the end of a command line (i.e. if you try to go even farther than the end - the cursor will not actually appear to go past the end), subsequently hitting left arrow the first time does nothing, whereas hitting it again will go back one - it is as if there is an invisible char at the end or something.  Other manifestations of this will have the cursor go back and forth repeatedly (left, right, left, right) as you hit right arrow at the end of the line.  Also, if you have "gone past the end", typing any characters will have not effect and will not be seen, which can be confusing.  Specific behaviors can differ slightly either randomly or if done on different previous command lines (i.e. up-arrow through history).

Note that I am using Gentoo/FreeBSD, but Frank J. Lazlo (laszlof@FreeBSD.org) has reproduced this for me on standard FreeBSD.  It never seems to happen in Linux.
>How-To-Repeat:
1) Enter bash
2) Type: "export LANG=en_US.UTF-8"
3) Type a couple of characters, and then hit right arrow (or ctrl-f) followed
by left arrow (ctrl-b).  If the cursor doesn't move back one on the first
left-arrow, but does on the second, you are seeing the issue.

>Fix:


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->obrien 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Fri Jul 20 22:24:43 UTC 2007 
Responsible-Changed-Why:  
Over to maintainer 

http://www.freebsd.org/cgi/query-pr.cgi?pr=114782 
State-Changed-From-To: open->suspended 
State-Changed-By: obrien 
State-Changed-When: Tue Aug 21 02:21:01 UTC 2007 
State-Changed-Why:  
I'm sorry, but I'm very challened when it comes to locale. 
I've never run with LANG set to anything, and I use VI mode vs. Emacs. 
I tried the arrow keys to see if it could see what you're refering to, 
but I couldn't.  This could be due to my only knowing what is normal for 
bash/readline in VI mode. 

Are you able to reproduce this using some other binary that is 
linked against libreadline in the base FreeBSD? 

Or can you further debug this to something more actionable by me? 

http://www.freebsd.org/cgi/query-pr.cgi?pr=114782 

From: Joe Peterson <lavajoe@gentoo.org>
To: bug-followup@FreeBSD.org
Cc: "Frank J. Laszlo" <laszlof@FreeBSD.org>
Subject: Re: ports/114782: shells/bash - Incorrect cursor behavior during
 command line editing in bash shell using UTF-8
Date: Tue, 21 Aug 2007 09:13:37 -0600

 Yep, I just tried "vi" mode in bash with LANG=en_US.UTF-8, and indeed I
 cannot make it happen there.  I do not have bash on my current regular
 FreeBSD installation (it does not have the ports tree; not much disk
 space), but I do know that Frank Laszlo reproduced it in regular
 FreeBSD.  Perhaps he can give you better step-by-step instructions that
 will enable you to see the problem.
 
 Note that the problem doesn't really involve using "emacs" features.
 Just using arrows on the command line (which work almost the same in vi
 mode) will let you see the issue.  If you "export LANG=en_US.UTF-8", up
 arrow, and right arrow to the end (and then a few more right arrows for
 good measure - in non-vi mode the cursor will not be just to the right
 of the last char), one left arrow should always position the cursor on
 top of the last character, one position back, but it takes two with
 UTF-8.  My theory is that is has something to do with bash and/or
 readline not calculating the character width (since UTF-8 chars can be
 more than one byte) correctly.  Funny thing is that I've only been using
 ASCII chars, so it's gotta be some glitch.  As for why the behavior is
 only in FreeBSD, I don't know...

From: "Frank J. Laszlo" <laszlof@FreeBSD.org>
To: Joe Peterson <lavajoe@gentoo.org>
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/114782: shells/bash - Incorrect cursor behavior during
 command line editing in bash shell using UTF-8
Date: Thu, 23 Aug 2007 15:29:20 -0400

 -----BEGIN PGP SIGNED MESSAGE-----
 Hash: SHA1
 
 I just commited a patch to the devel/readline port for some new vender
 patches. I noticed that patch 003[1] may be applicable to this issue.
 Perhaps someone who manages readline in base should take a look at
 these, or we should have the bash port depend on devel/readline.
 
 - -Frank
 
 [1]ftp://ftp.cwru.edu/pub/bash/readline-5.2-patches/readline52-003
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1.4.5 (GNU/Linux)
 Comment: Using GnuPG with SUSE - http://enigmail.mozdev.org
 
 iD8DBQFGzeAQYU4ZKpC6LyARAomVAJ428IWhqW6nQP3qmT4yX6rlk0oa3QCgnt9B
 tF1wRQuRLcvacfh8NO9KC5U=
 =dUDm
 -----END PGP SIGNATURE-----
 

From: Joe Peterson <joe@skyrush.com>
To: bug-followup@FreeBSD.org,  laszlof@FreeBSD.org
Cc:  
Subject: Re: ports/114782: shells/bash - Incorrect cursor behavior during
 command line editing in bash shell using UTF-8
Date: Sun, 26 Aug 2007 06:49:22 -0600

 This does indeed sound potentially related.  However, I did test the
 issue with a completely generic environment (i.e. "bash --noprofile
 --norc") and prompt set to a simple character, and the bug still
 appeared, so I am a bit pesimistic.  If you are able to test the new
 patch set, however, it's worth seeing if it makes a difference.
 
 						Thanks, Joe
 
State-Changed-From-To: suspended->closed 
State-Changed-By: obrien 
State-Changed-When: Fri Mar 13 02:20:39 UTC 2009 
State-Changed-Why:  
Closing for now - against Bash version 3.  Hopefully this isn't an issue 
with Bash 4. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=114782 
>Unformatted:
