From: Chet Ramey Date: Mon, 19 Apr 2021 13:40:14 +0000 (-0400) Subject: command completion, key binding fixes X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d128c3ddc157f6f9b8bc02f881aff7297c990115;p=thirdparty%2Fbash.git command completion, key binding fixes --- diff --git a/CWRU/CWRU.chlog b/CWRU/CWRU.chlog index d7456f6f4..e0610f629 100644 --- a/CWRU/CWRU.chlog +++ b/CWRU/CWRU.chlog @@ -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 + + 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 + +lib/readline/doc/rltech.texi + - RL_PROMPT_{START,END}_IGNORE: document current values of \001 and + \002. Report from Mingye Wang diff --git a/bashline.c b/bashline.c index 970b297f1..362f0176a 100644 --- a/bashline.c +++ b/bashline.c @@ -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); } diff --git a/builtins/bind.def b/builtins/bind.def index ccfc08dcd..2eaaafda5 100644 --- a/builtins/bind.def +++ b/builtins/bind.def @@ -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--; diff --git a/lib/readline/doc/rltech.texi b/lib/readline/doc/rltech.texi index a44022566..0baf588dd 100644 --- a/lib/readline/doc/rltech.texi +++ b/lib/readline/doc/rltech.texi @@ -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) diff --git a/lib/readline/doc/version.texi b/lib/readline/doc/version.texi index 0b565239b..e90db4c18 100644 --- a/lib/readline/doc/version.texi +++ b/lib/readline/doc/version.texi @@ -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