From: Chet Ramey Date: Tue, 13 Dec 2011 02:58:26 +0000 (-0500) Subject: commit bash-20100506 snapshot X-Git-Tag: bash-4.3-alpha~173 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cdb599a168978c2efeda1486fcdff98ded95d06c;p=thirdparty%2Fbash.git commit bash-20100506 snapshot --- diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index 5eec6dc3b..07585162e 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -9800,3 +9800,13 @@ lib/readline/text.c - make sure `dir' is in the valid range before searching in _rl_char_search_internal. Range checks in the code depend on it being non-zero + + 5/3 + --- +lib/readline/complete.c + - in rl_complete_internal, if show-all-if-ambiguous or + show-all-if-unmodified are set (what_to_do == '!' or '@', + respectively), and the common match prefix is shorter than the + text being completed, inhibit inserting the match. + The guess is that replacing text with a shorter match will not + be wanted diff --git a/lib/readline/complete.c b/lib/readline/complete.c index 5e362b1af..9d6de76c9 100644 --- a/lib/readline/complete.c +++ b/lib/readline/complete.c @@ -1784,6 +1784,9 @@ rl_complete_internal (what_to_do) int start, end, delimiter, found_quote, i, nontrivial_lcd; char *text, *saved_line_buffer; char quote_char; +#if 1 + int tlen, mlen; +#endif RL_SETSTATE(RL_STATE_COMPLETING); @@ -1811,6 +1814,10 @@ rl_complete_internal (what_to_do) /* nontrivial_lcd is set if the common prefix adds something to the word being completed. */ nontrivial_lcd = matches && strcmp (text, matches[0]) != 0; +#if 1 + if (what_to_do == '!' || what_to_do == '@') + tlen = strlen (text); +#endif free (text); if (matches == 0) @@ -1844,8 +1851,25 @@ rl_complete_internal (what_to_do) case '!': case '@': /* Insert the first match with proper quoting. */ +#if 0 if (*matches[0]) insert_match (matches[0], start, matches[1] ? MULT_MATCH : SINGLE_MATCH, "e_char); +#else + if (what_to_do == TAB) + { + if (*matches[0]) + insert_match (matches[0], start, matches[1] ? MULT_MATCH : SINGLE_MATCH, "e_char); + } + else if (*matches[0] && matches[1] == 0) + /* should we perform the check only if there are multiple matches? */ + insert_match (matches[0], start, matches[1] ? MULT_MATCH : SINGLE_MATCH, "e_char); + else if (*matches[0]) /* what_to_do != TAB && multiple matches */ + { + mlen = *matches[0] ? strlen (matches[0]) : 0; + if (mlen >= tlen) + insert_match (matches[0], start, matches[1] ? MULT_MATCH : SINGLE_MATCH, "e_char); + } +#endif /* If there are more matches, ring the bell to indicate. If we are in vi mode, Posix.2 says to not ring the bell.