*** ../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);