readline and completion fixes

This commit is contained in:
Chet Ramey
2023-04-20 11:27:36 -04:00
parent a46164736e
commit d052bd6fd9
19 changed files with 8015 additions and 7681 deletions
+43
View File
@@ -6044,3 +6044,46 @@ builtins/complete.def
doc/bash.1,lib/readline/doc/rluser.texi
- compgen: document new -V option
4/18
----
lib/readline/vi_mode.c
- rl_domove_read_callback: call _rl_arg_init before reading digit
argument so prompt gets saved, both callback and non-callback modes
From a report by Grisha Levit <grishalevit@gmail.com>
- rl_vi_arg_dispatch: if we return 0 to end the digit argument and
turn off NUMERICARG, call rl_restore_prompt
lib/readline/histexpand.c
- history_expand_internal: make sure subst_lhs is not null before we
call postproc_subst_rhs.
From a report by Grisha Levit <grishalevit@gmail.com>
lib/readline/display.c
- rl_redisplay: remove redundant code that ends up incrementing lpos
too much for meta characters displayed as octal escape sequences.
From a report by Grisha Levit <grishalevit@gmail.com>
4/19
----
bashline.c
- attempt_shell_completion: handle case where s > e after calls to
find_cmd_start and find_cmd_end, respectively.
From a report by Grisha Levit <grishalevit@gmail.com>
lib/readline/display.c
- update_line: fix setting of `wsatend' when computing ols and nls in
the multibyte case; this caused redisplay to print more characters
than it needed
- update_line: fix calculation of visible_wrap_offset when moving up
to line 0, trying to figure whether or not the visible prompt has
any invisible characters. Fixes C locale issue reported by
Grisha Levit <grishalevit@gmail.com>
4/20
----
lib/readline/text.c
- _rl_rubout_char: update erase-at-end-of-line hack to deal with the
unlikely event that a character in a non-multibyte locale is
displayed using an octal representation.
From a report by Grisha Levit <grishalevit@gmail.com>
+7
View File
@@ -313,6 +313,13 @@ The following list is what's changed when 'POSIX mode' is in effect:
that a backslash preceding a double quote character will escape it
and the backslash will be removed.
66. Command substitutions don't set the '?' special parameter. The
exit status of a simple command without a command word is still the
exit status of the last command substitution that occurred while
evaluating the variable assignments and redirections in that
command, but that does not happen until after all of the
assignments and redirections.
There is other POSIX behavior that Bash does not implement by default
even when in POSIX mode. Specifically:
+4
View File
@@ -1672,6 +1672,10 @@ attempt_shell_completion (const char *text, int start, int end)
s1 = s = e1;
break;
}
else if (s > e)
{
s = s1 = start; e = e1 = end; /* reset */
}
/* Skip over assignment statements preceding a command name. If we
don't find a command name at all, we can perform command name
completion. If we find a partial command name, we should perform
+15 -3
View File
@@ -10550,7 +10550,19 @@ case, any completion not matching <I>filterpat</I> is removed.
<P>
The return value is true unless an invalid option is supplied, an option
other than <B>-p</B> or <B>-r</B> is supplied without a <I>name</I>
other than
<B>-p</B>,
<B>-r</B>,
<B>-D</B>,
<B>-E</B>,
or
<B>-I</B>
is supplied without a <I>name</I>
argument, an attempt is made to remove a completion specification for
a <I>name</I> for which no specification exists, or
an error occurs adding a completion specification.
@@ -15038,7 +15050,7 @@ There may be only one active coprocess at a time.
<DT><A HREF="#lbDI">BUGS</A><DD>
</DL>
<HR>
This document was created by man2html from /usr/local/src/bash/bash-20230416/doc/bash.1.<BR>
Time: 17 April 2023 14:27:09 EDT
This document was created by man2html from bash.1.<BR>
Time: 18 April 2023 10:26:09 EDT
</BODY>
</HTML>
BIN
View File
Binary file not shown.
+8 -1
View File
@@ -12706,7 +12706,14 @@ case, any completion not matching <var>filterpat</var> is removed.
</dl>
<p>The return value is true unless an invalid option is supplied, an option
other than <samp>-p</samp> or <samp>-r</samp> is supplied without a <var>name</var>
other than
<samp>-p</samp>,
<samp>-r</samp>,
<samp>-D</samp>,
<samp>-E</samp>,
or
<samp>-I</samp>
is supplied without a <var>name</var>
argument, an attempt is made to remove a completion specification for
a <var>name</var> for which no specification exists, or
an error occurs adding a completion specification.
+21 -47
View File
@@ -1,11 +1,11 @@
This is pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2021/MacPorts 2021.58693_0) (preloaded format=pdfetex 2021.8.30) 17 APR 2023 15:24
This is pdfTeX, Version 3.141592653-2.6-1.40.24 (TeX Live 2022/MacPorts 2022.62882_0) (preloaded format=etex 2022.5.4) 18 APR 2023 10:26
entering extended mode
restricted \write18 enabled.
file:line:error style messages enabled.
%&-line parsing enabled.
**\input /usr/local/src/bash/bash-20230416/doc/bashref.texi
(/usr/local/src/bash/bash-20230416/doc/bashref.texi
(/usr/local/src/bash/bash-20230416/doc/texinfo.tex
**\nonstopmode \input /usr/local/src/chet/src/bash/src/doc/bashref.texi
(/usr/local/src/chet/src/bash/src/doc/bashref.texi
(/usr/local/src/chet/src/bash/src/doc/texinfo.tex
Loading texinfo [version 2015-11-22.14]:
\outerhsize=\dimen16
\outervsize=\dimen17
@@ -161,23 +161,20 @@ This is `epsf.tex' v2.7.4 <14 February 2011>
texinfo.tex: doing @include of version.texi
(/usr/local/src/bash/bash-20230416/doc/version.texi) [1{/opt/local/var/db/texmf
/fonts/map/pdftex/updmap/pdftex.map}] [2]
(/usr/local/build/bash/bash-20230416/doc/bashref.toc [-1] [-2] [-3]) [-4]
(/usr/local/build/bash/bash-20230416/doc/bashref.toc)
(/usr/local/build/bash/bash-20230416/doc/bashref.toc) Chapter 1
(/usr/local/src/chet/src/bash/src/doc/version.texi) [1] [2]
(/usr/local/src/chet/src/bash/src/doc/bashref.toc [-1] [-2] [-3]) [-4]
Chapter 1
\openout0 = `bashref.toc'.
(/usr/local/build/bash/bash-20230416/doc/bashref.aux)
(/usr/local/src/chet/src/bash/src/doc/bashref.aux)
\openout1 = `bashref.aux'.
Chapter 2 [1] [2]
Chapter 2 [1]
[2]
@cpindfile=@write2
\openout2 = `bashref.cp'.
[3] Chapter 3 [4] [5] [6] [7]
[3] Chapter 3 [4] [5] [6] [7]
@vrindfile=@write3
\openout3 = `bashref.vr'.
@@ -260,9 +257,8 @@ Overfull \hbox (38.26585pt too wide) in paragraph at lines 5280--5280
[118]
texinfo.tex: doing @include of rluser.texi
(/usr/local/src/bash/bash-20230416/lib/readline/doc/rluser.texi
Chapter 8 [119] [120] [121] [122] [123] [124] [125] [126] [127] [128] [129]
[130]
(/usr/local/src/chet/src/bash/src/lib/readline/doc/rluser.texi Chapter 8
[119] [120] [121] [122] [123] [124] [125] [126] [127] [128] [129] [130]
Underfull \hbox (badness 7540) in paragraph at lines 874--880
[]@textrm In the ex-am-ple above, @textttsl C-u[] @textrm is bound to the func
-tion
@@ -310,7 +306,7 @@ gnored[]
texinfo.tex: doing @include of hsuser.texi
(/usr/local/src/bash/bash-20230416/lib/readline/doc/hsuser.texi Chapter 9
(/usr/local/src/chet/src/bash/src/lib/readline/doc/hsuser.texi Chapter 9
[154] [155] [156] [157] [158] [159]) Chapter 10 [160] [161] [162] [163]
[164]
Underfull \hbox (badness 10000) in paragraph at lines 9566--9575
@@ -342,38 +338,16 @@ extrm '[], `@texttt strict-posix-default[]@textrm '[], and
[174] [175] Appendix C [176]
texinfo.tex: doing @include of fdl.texi
(/usr/local/src/bash/bash-20230416/doc/fdl.texi
(/usr/local/src/chet/src/bash/src/doc/fdl.texi
[177] [178] [179] [180] [181] [182] [183]) Appendix D [184] [185] [186]
[187] [188] [189] [190] [191] [192] [193] )
Here is how much of TeX's memory you used:
4100 strings out of 497086
47602 string characters out of 6206517
142025 words of memory out of 5000000
4869 multiletter control sequences out of 15000+600000
3530 strings out of 497084
40207 string characters out of 6206695
87715 words of memory out of 5000000
4703 multiletter control sequences out of 15000+600000
34315 words of font info for 116 fonts, out of 8000000 for 9000
51 hyphenation exceptions out of 8191
16i,6n,16p,331b,983s stack positions out of 5000i,500n,10000p,200000b,80000s
{/opt/local/share/texmf-texlive/font
s/enc/dvips/cm-super/cm-super-t1.enc}</opt/local/share/texmf-texlive/fonts/type
1/public/amsfonts/cm/cmbx12.pfb></opt/local/share/texmf-texlive/fonts/type1/pub
lic/amsfonts/cm/cmcsc10.pfb></opt/local/share/texmf-texlive/fonts/type1/public/
amsfonts/cm/cmmi10.pfb></opt/local/share/texmf-texlive/fonts/type1/public/amsfo
nts/cm/cmmi12.pfb></opt/local/share/texmf-texlive/fonts/type1/public/amsfonts/c
m/cmmi9.pfb></opt/local/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmr1
0.pfb></opt/local/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmr9.pfb><
/opt/local/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmsl10.pfb></opt/
local/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmsltt10.pfb></opt/loc
al/share/texmf-texlive/fonts/type1/public/amsfonts/cm/cmsy10.pfb></opt/local/sh
are/texmf-texlive/fonts/type1/public/amsfonts/cm/cmti10.pfb></opt/local/share/t
exmf-texlive/fonts/type1/public/amsfonts/cm/cmtt10.pfb></opt/local/share/texmf-
texlive/fonts/type1/public/amsfonts/cm/cmtt12.pfb></opt/local/share/texmf-texli
ve/fonts/type1/public/amsfonts/cm/cmtt9.pfb></opt/local/share/texmf-texlive/fon
ts/type1/public/cm-super/sfrm1095.pfb></opt/local/share/texmf-texlive/fonts/typ
e1/public/cm-super/sfrm1440.pfb>
Output written on bashref.pdf (199 pages, 805186 bytes).
PDF statistics:
2794 PDF objects out of 2984 (max. 8388607)
2548 compressed objects within 26 object streams
327 named destinations out of 1000 (max. 500000)
1157 words of extra memory for PDF output out of 10000 (max. 10000000)
16i,6n,16p,343b,942s stack positions out of 10000i,1000n,20000p,200000b,200000s
Output written on bashref.dvi (199 pages, 836976 bytes).
+5641 -5401
View File
File diff suppressed because it is too large Load Diff
+2238 -2201
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -1,6 +1,6 @@
%!PS-Adobe-3.0
%%Creator: groff version 1.22.4
%%CreationDate: Fri Dec 2 17:01:16 2022
%%CreationDate: Tue Apr 18 10:26:00 2023
%%DocumentNeededResources: font Times-Roman
%%+ font Times-Bold
%%DocumentSuppliedResources: procset grops 1.22 4
+2
View File
@@ -239,6 +239,8 @@ int executing_builtin = 0;
/* Non-zero if we are executing a command list (a;b;c, etc.) */
int executing_list = 0;
int executing_loop = 0;
/* Non-zero if we should defer closing process substitution FDs. */
int retain_fifos = 0;
+20 -15
View File
@@ -1126,19 +1126,6 @@ rl_redisplay (void)
olen = sprintf (obuf, "\\%o", c);
if (lpos + olen >= _rl_screenwidth)
{
temp = _rl_screenwidth - lpos;
CHECK_INV_LBREAKS ();
inv_lbreaks[++newlines] = out + temp;
#if defined (HANDLE_MULTIBYTE)
line_state_invisible->wrapped_line[newlines] = _rl_wrapped_multicolumn;
#endif
lpos = olen - temp;
}
else
lpos += olen;
for (temp = 0; temp < olen; temp++)
{
invis_addc (&out, obuf[temp], cur_face);
@@ -2043,6 +2030,8 @@ update_line (char *old, char *old_face, char *new, char *new_face, int current_l
#if defined (HANDLE_MULTIBYTE)
/* Find the last character that is the same between the two lines. This
bounds the region that needs to change. */
/* In this case, `last character' means the one farthest from the end of
the line. */
if (mb_cur_max > 1 && rl_byte_oriented == 0)
{
ols = old + _rl_find_prev_mbchar (old, oe - old, MB_FIND_ANY);
@@ -2059,7 +2048,7 @@ update_line (char *old, char *old_face, char *new, char *new_face, int current_l
*olsf != *nlsf)
break;
if (*ols == ' ')
if (*ols != ' ')
wsatend = 0;
ols = old + _rl_find_prev_mbchar (old, ols - old, MB_FIND_ANY);
@@ -2128,7 +2117,23 @@ update_line (char *old, char *old_face, char *new, char *new_face, int current_l
/* We have moved up to a new screen line. This line may or may not have
invisible characters on it, but we do our best to recalculate
visible_wrap_offset based on what we know. */
if (current_line == 0)
/* This first clause handles the case where the prompt has been
recalculated (e.g., by rl_message) but the old prompt is still on
the visible line because we haven't overwritten it yet. We want
to somehow use the old prompt information, but we only want to do
this once. */
if (current_line == 0 && saved_local_prompt && old[0] == saved_local_prompt[0] && memcmp (old, saved_local_prompt, saved_local_length) == 0)
visible_wrap_offset = saved_invis_chars_first_line;
/* This clause handles the opposite: the prompt has been restored (e.g.,
by rl_clear_message) but the old saved_local_prompt (now NULL, so we
can't directly check it) is still on the visible line because we
haven't overwritten it yet. We guess that there aren't any invisible
characters in any of the prompts we put in with rl_message */
else if (current_line == 0 && local_prompt && new[0] == local_prompt[0] &&
(memcmp (new, local_prompt, local_prompt_len) == 0) &&
(memcmp (old, local_prompt, local_prompt_len) != 0))
visible_wrap_offset = 0;
else if (current_line == 0)
visible_wrap_offset = prompt_invis_chars_first_line; /* XXX */
#if 0 /* XXX - not yet */
else if (current_line == prompt_last_screen_line && wrap_offset > prompt_invis_chars_first_line)
+3 -3
View File
@@ -2643,7 +2643,7 @@ com_list (char *arg)
if (!arg)
arg = "";
sprintf (syscom, "ls -FClg %s", arg);
snprintf (syscom, sizeof (syscom), "ls -FClg %s", arg);
return (system (syscom));
@}
@@ -2655,9 +2655,9 @@ com_view (char *arg)
#if defined (__MSDOS__)
/* more.com doesn't grok slashes in pathnames */
sprintf (syscom, "less %s", arg);
snprintf (syscom, sizeof (syscom), "less %s", arg);
#else
sprintf (syscom, "more %s", arg);
snprintf (syscom, sizeof (syscom), "more %s", arg);
#endif
return (system (syscom));
@}
+3 -3
View File
@@ -292,7 +292,7 @@ com_list (arg)
if (!arg)
arg = "";
sprintf (syscom, "ls -FClg %s", arg);
snprintf (syscom, sizeof (syscom), "ls -FClg %s", arg);
return (system (syscom));
}
@@ -305,9 +305,9 @@ com_view (arg)
#if defined (__MSDOS__)
/* more.com doesn't grok slashes in pathnames */
sprintf (syscom, "less %s", arg);
snprintf (syscom, sizeof (syscom), "less %s", arg);
#else
sprintf (syscom, "more %s", arg);
snprintf (syscom, sizeof (syscom), "more %s", arg);
#endif
return (system (syscom));
}
+1 -1
View File
@@ -730,7 +730,7 @@ history_expand_internal (const char *string, int start, int qc, int *end_index_p
/* If `&' appears in the rhs, it's supposed to be replaced
with the lhs. */
if (member ('&', subst_rhs))
if (subst_lhs && member ('&', subst_rhs))
postproc_subst_rhs ();
}
else
+1
View File
@@ -526,6 +526,7 @@ extern int _rl_menu_complete_prefix_first;
/* display.c */
extern int _rl_vis_botlin;
extern int _rl_last_c_pos;
extern int _rl_last_v_pos;
extern int _rl_suppress_redisplay;
extern int _rl_want_redisplay;
+3 -2
View File
@@ -1229,11 +1229,12 @@ _rl_rubout_char (int count, int key)
c = rl_line_buffer[--rl_point];
rl_delete_text (rl_point, orig_point);
/* The erase-at-end-of-line hack is of questionable merit now. */
if (rl_point == rl_end && ISPRINT ((unsigned char)c) && _rl_last_c_pos)
if (rl_point == rl_end && ISPRINT ((unsigned char)c) && _rl_last_c_pos && _rl_last_v_pos == 0)
{
int l;
l = rl_character_len (c, rl_point);
_rl_erase_at_end_of_line (l);
if (_rl_last_c_pos >= l)
_rl_erase_at_end_of_line (l);
}
}
else
+3 -2
View File
@@ -1090,6 +1090,7 @@ _rl_vi_arg_dispatch (int c)
}
else
{
rl_restore_prompt ();
rl_clear_message ();
rl_stuff_char (key);
return 0; /* done */
@@ -1320,7 +1321,7 @@ rl_domove_read_callback (_rl_vimotion_cxt *m)
/* Readine vi motion char starting numeric argument */
else if (_rl_digit_p (c) && RL_ISSTATE (RL_STATE_CALLBACK) && RL_ISSTATE (RL_STATE_VIMOTION) && (RL_ISSTATE (RL_STATE_NUMERICARG) == 0))
{
RL_SETSTATE (RL_STATE_NUMERICARG);
_rl_arg_init ();
return (_rl_vi_arg_dispatch (c));
}
#endif
@@ -1330,7 +1331,7 @@ rl_domove_read_callback (_rl_vimotion_cxt *m)
save = rl_numeric_arg;
rl_numeric_arg = _rl_digit_value (c);
rl_explicit_arg = 1;
RL_SETSTATE (RL_STATE_NUMERICARG);
_rl_arg_init ();
rl_digit_loop1 ();
rl_numeric_arg *= save;
c = rl_vi_domove_getchar (m);
+1 -1
View File
@@ -23,7 +23,7 @@
#include <bashansi.h>
size_t
strlcpy(const char *dest, const const char *src, size_t size)
strlcpy(char *dest, const const char *src, size_t size)
{
size_t ret;