command completion, key binding fixes

This commit is contained in:
Chet Ramey
2021-04-19 09:40:14 -04:00
parent fb4ddc2d2b
commit d128c3ddc1
5 changed files with 36 additions and 14 deletions
+21
View File
@@ -10000,3 +10000,24 @@ variables.c
----
doc/{bash.1,bashref.texi}
- add link to git master tar file as a place to get the current version
4/14
----
bashline.c
- attempt_shell_completion: use -1 as a sentinel value for
in_command_position indicating that we cannot be in a command position
(e.g., because we're the target of a redirection) and should not
check for a programmable command completion or tell the programmable
completion code to use command completion. Report and fix from
Marc Aurèle La France <tsi@tuyoix.net>
4/16
----
builtins/bind.def
- bind_builtin: reverse sense of strvec_search return value when
deciding whether or not to remove a unix-command binding from the
cmd keymap. Bug report by Dale Sedivec <dale@codefu.org>
lib/readline/doc/rltech.texi
- RL_PROMPT_{START,END}_IGNORE: document current values of \001 and
\002. Report from Mingye Wang <arthur200126@gmail.com>
+8 -8
View File
@@ -1618,7 +1618,7 @@ attempt_shell_completion (text, start, end)
in_command_position++;
if (check_redir (ti) == 1)
in_command_position = 0;
in_command_position = -1; /* sentinel that we're not the first word on the line */
}
else
{
@@ -1627,7 +1627,7 @@ attempt_shell_completion (text, start, end)
assignments. */
}
if (in_command_position && invalid_completion (text, ti))
if (in_command_position > 0 && invalid_completion (text, ti))
{
rl_attempted_completion_over = 1;
return ((char **)NULL);
@@ -1635,9 +1635,9 @@ attempt_shell_completion (text, start, end)
/* Check that we haven't incorrectly flagged a closed command substitution
as indicating we're in a command position. */
if (in_command_position && ti >= 0 && rl_line_buffer[ti] == '`' &&
if (in_command_position > 0 && ti >= 0 && rl_line_buffer[ti] == '`' &&
*text != '`' && unclosed_pair (rl_line_buffer, end, "`") == 0)
in_command_position = 0;
in_command_position = -1; /* not following a command separator */
/* Special handling for command substitution. If *TEXT is a backquote,
it can be the start or end of an old-style command substitution, or
@@ -1645,8 +1645,8 @@ attempt_shell_completion (text, start, end)
succeed. Don't bother if readline found a single quote and we are
completing on the substring. */
if (*text == '`' && rl_completion_quote_character != '\'' &&
(in_command_position || (unclosed_pair (rl_line_buffer, start, "`") &&
unclosed_pair (rl_line_buffer, end, "`"))))
(in_command_position > 0 || (unclosed_pair (rl_line_buffer, start, "`") &&
unclosed_pair (rl_line_buffer, end, "`"))))
matches = rl_completion_matches (text, command_subst_completion_function);
#if defined (PROGRAMMABLE_COMPLETION)
@@ -1654,7 +1654,7 @@ attempt_shell_completion (text, start, end)
have_progcomps = prog_completion_enabled && (progcomp_size () > 0);
iw_compspec = progcomp_search (INITIALWORD);
if (matches == 0 &&
(in_command_position == 0 || text[0] == '\0' || (in_command_position && iw_compspec)) &&
(in_command_position == 0 || text[0] == '\0' || (in_command_position > 0 && iw_compspec)) &&
current_prompt_string == ps1_prompt)
{
int s, e, s1, e1, os, foundcs;
@@ -1776,7 +1776,7 @@ attempt_shell_completion (text, start, end)
if (matches == 0)
{
dflags = 0;
if (in_command_position)
if (in_command_position > 0)
dflags |= DEFCOMP_CMDPOS;
matches = bash_default_completion (text, start, end, qc, dflags);
}
+1 -1
View File
@@ -290,7 +290,7 @@ bind_builtin (list)
if (nlen < olen) /* fewer bind -x bindings */
for (d = olen - nlen, i = 0; i < olen && d > 0; i++)
if (nlen == 0 || strvec_search (nbindings, obindings[i]) >= 0)
if (nlen == 0 || strvec_search (nbindings, obindings[i]) < 0)
{
unbind_unix_command (obindings[i]);
d--;
+3 -2
View File
@@ -1072,8 +1072,9 @@ It returns the number of visible characters on the last line of the
Applications may indicate that the prompt contains characters that take
up no physical screen space when displayed by bracketing a sequence of
such characters with the special markers @code{RL_PROMPT_START_IGNORE}
and @code{RL_PROMPT_END_IGNORE} (declared in @file{readline.h}). This may
be used to embed terminal-specific escape sequences in prompts.
and @code{RL_PROMPT_END_IGNORE} (declared in @file{readline.h} as
@samp{\001} and @samp{\002}, respectively).
This may be used to embed terminal-specific escape sequences in prompts.
@end deftypefun
@deftypefun int rl_set_prompt (const char *prompt)
+3 -3
View File
@@ -4,7 +4,7 @@ Copyright (C) 1988-2021 Free Software Foundation, Inc.
@set EDITION 8.1
@set VERSION 8.1
@set UPDATED 31 March 2021
@set UPDATED-MONTH March 2021
@set UPDATED 16 April 2021
@set UPDATED-MONTH April 2021
@set LASTCHANGE Wed Mar 31 11:45:32 EDT 2021
@set LASTCHANGE Fri Apr 16 14:51:06 EDT 2021