On 12/5/11 12:15 AM, Clark J. Wang wrote: > On Mon, Dec 5, 2011 at 11:42, Chet Ramey <chet.ra...@case.edu > <mailto:chet.ra...@case.edu>> wrote: > > On 12/4/11 10:26 PM, Clark J. Wang wrote: > > On Mon, Dec 5, 2011 at 11:10, Chet Ramey <chet.ra...@case.edu > <mailto:chet.ra...@case.edu> > > <mailto:chet.ra...@case.edu <mailto:chet.ra...@case.edu>>> wrote: > > > > > > I still can't reproduce it on Mac OS X or RHEL 5.7: > > > > > > It's weird. :) Any other settings can affect this? What can I do to > debug more? > > Well, if it were me, I'd fire up gdb and set a breakpoint in > pcomplete.c:gen_shell_function_matches. I wonder if you've got something > filtering out or ignoring those matches. > > Chet > -- > ``The lyf so short, the craft so long to lerne.'' - Chaucer > ``Ars longa, vita brevis'' - Hippocrates > Chet Ramey, ITS, CWRU c...@case.edu <mailto:c...@case.edu> > http://cnswww.cns.cwru.edu/~chet/ <http://cnswww.cns.cwru.edu/%7Echet/> > > > After more investigation I found that it's caused by "set > completion-ignore-case on". After turning completion-ignore-case off it > works fine. You can give it a try.
Yes, it's the case-ignoring code. It looks like you're the first person to hit this since the code went in over ten years ago. The original code doesn't handle the case where the text the user typed is longer than the replacement text well. The attached patch fixes the issue. It will be in the next bash release. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, ITS, CWRU c...@case.edu http://cnswww.cns.cwru.edu/~chet/
*** ../bash-4.2-patched/lib/readline/complete.c 2011-01-16 15:32:57.000000000 -0500 --- lib/readline/complete.c 2011-12-06 15:54:16.000000000 -0500 *************** *** 1148,1151 **** --- 1174,1178 ---- register int i, c1, c2, si; int low; /* Count of max-matched characters. */ + int lx; char *dtext; /* dequoted TEXT, if needed */ #if defined (HANDLE_MULTIBYTE) *************** *** 1265,1283 **** si = strlen (text); ! if (si <= low) ! { ! for (i = 1; i <= matches; i++) ! if (strncmp (match_list[i], text, si) == 0) ! { ! strncpy (match_list[0], match_list[i], low); ! break; ! } ! /* no casematch, use first entry */ ! if (i > matches) ! strncpy (match_list[0], match_list[1], low); ! } ! else ! /* otherwise, just use the text the user typed. */ ! strncpy (match_list[0], text, low); FREE (dtext); --- 1292,1309 ---- si = strlen (text); ! lx = (si <= low) ? si : low; /* check shorter of text and matches */ ! /* Try to preserve the case of what the user typed in the presence of ! multiple matches: check each match for something that matches ! what the user typed taking case into account; use it up to common ! length of matches if one is found. If not, just use first match. */ ! for (i = 1; i <= matches; i++) ! if (strncmp (match_list[i], text, lx) == 0) ! { ! strncpy (match_list[0], match_list[i], low); ! break; ! } ! /* no casematch, use first entry */ ! if (i > matches) ! strncpy (match_list[0], match_list[1], low); FREE (dtext);