Path: csiph.com!xmission!news.glorb.com!usenet.stanford.edu!not-for-mail From: Linda Walsh Newsgroups: gnu.bash.bug Subject: Re: prompt with \w incl. long UTF string messes up command line Date: Thu, 26 Nov 2015 03:28:01 -0800 Lines: 65 Approved: bug-bash@gnu.org Message-ID: References: NNTP-Posting-Host: lists.gnu.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: quoted-printable X-Trace: usenet.stanford.edu 1448537303 32147 208.118.235.17 (26 Nov 2015 11:28:23 GMT) X-Complaints-To: action@cs.stanford.edu Cc: Ryo Furue To: bug-bash Envelope-to: bug-bash@gnu.org User-Agent: Thunderbird In-Reply-To: X-MIME-Autoconverted: from 8bit to quoted-printable by Ishtar.hs.tlinx.org id tAQBS0IX008392 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x (no timestamps) [generic] X-Received-From: 173.164.175.65 X-BeenThere: bug-bash@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Bug reports for the GNU Bourne Again SHell List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com gnu.bash.bug:11926 Your prompt might be too long. Your 'dir' string is awfully long... echo "$dir"|wc -c 270 --- I tried a shorter version on linux: sdir=3D'=E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3=E2= =96=B3=E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3_ >' pre=3D'Ishtar:/tmp/' ## prefix of my dir Ishtar:/tmp/=E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3= =E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3>=20 012345678901234567890123456 -bash: 012345678901234567890123456: command not found Ishtar:/tmp/=E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3= =E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3> echo ${#pre}+${#s= dir}=3D$[${#pre}+${#sdir}] 12+13=3D25 My cursor started in col 27 with 26 chars preceding it. As you can see above adding the length in chars of the prefix and the UTF chars together, I get 25, + the '>' at the end=3D26. and together : Ishtar:/tmp/=E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3= =E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3=E2=96=B3> echo "$pre$sdir>"= |wc -c 53 are only 53 bytes long. Ryo Furue wrote: > When PS1 includes \w and when \w contains long path including UTF > characters, the cursor position or the command line is messed up. >=20 > Repeat-By: > 1. Source the attached script: > $ . bash-prompt-bug.sh >=20 > 2.1. You'll find the prompt is messed up: shorter than the > real path name, garbage character at the top. > 2.2. If you use the tput commands, which are commented out > in bash-prompt-bug.sh, the prompt is fine, but the cursor > position is messed up. >=20 > 3. After 2.2, try to complete filenames by pressing TAB, > and sometimes you'll find the cursor position is > even more badly messed up. ---- Bash doesn't honor tabs as set on your terminal at all. It always expands them to '8' spaces and it's concept of where it is vs. using actual tab chars which would have output looking like what you typed. >=20 > I tested this both on the latest versions of iTerm and Terminal on Mac > OS 10.11.1 . ---- I tested this on bash 4.3.39. Maybe the MAC doesn't handle the expansions right?