fix bug parsing a compound assignment inside a (( nested subshell; man page style and formatting updates

This commit is contained in:
Chet Ramey
2024-01-19 12:05:12 -05:00
parent f2fdb5e313
commit a4f44b7a11
13 changed files with 564 additions and 413 deletions
+6 -2
View File
@@ -1355,6 +1355,7 @@ compute_lcd_of_matches (char **match_list, int matches, const char *text)
int low; /* Count of max-matched characters. */
int lx;
char *dtext; /* dequoted TEXT, if needed */
size_t len1, len2;
#if defined (HANDLE_MULTIBYTE)
int v;
size_t v1, v2;
@@ -1381,6 +1382,9 @@ compute_lcd_of_matches (char **match_list, int matches, const char *text)
memset (&ps2, 0, sizeof (mbstate_t));
}
#endif
len1 = strlen (match_list[i]);
len2 = strlen (match_list[i + 1]);
for (si = 0; (c1 = match_list[i][si]) && (c2 = match_list[i + 1][si]); si++)
{
if (_rl_completion_case_fold)
@@ -1391,8 +1395,8 @@ compute_lcd_of_matches (char **match_list, int matches, const char *text)
#if defined (HANDLE_MULTIBYTE)
if (MB_CUR_MAX > 1 && rl_byte_oriented == 0)
{
v1 = MBRTOWC (&wc1, match_list[i]+si, strlen (match_list[i]+si), &ps1);
v2 = MBRTOWC (&wc2, match_list[i+1]+si, strlen (match_list[i+1]+si), &ps2);
v1 = MBRTOWC (&wc1, match_list[i]+si, len1 - si, &ps1);
v2 = MBRTOWC (&wc2, match_list[i+1]+si, len2 - si, &ps2);
if (MB_INVALIDCH (v1) || MB_INVALIDCH (v2))
{
if (c1 != c2) /* do byte comparison */
+13 -6
View File
@@ -6,15 +6,22 @@
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
.\" Last Change: Thu Dec 14 15:42:44 EST 2023
.\" Last Change: Thu Jan 18 11:05:09 EST 2024
.\"
.TH HISTORY 3 "2023 December 14" "GNU History 8.3"
.TH HISTORY 3 "2023 January 18" "GNU History 8.3"
.\"
.\" File Name macro. This used to be `.PN', for Path Name,
.\" but Sun doesn't seem to like that very much.
.\"
.de FN
\fI\|\\$1\|\fP
\%\fI\|\\$1\|\fP
..
.de Q
.ie \n(.g \(lq\\$1\(rq\\$2
.el \{
. if t ``\\$1''\\$2
. if n "\\$1"\\$2
.\}
..
.ds lp \fR\|(\fP
.ds rp \fR\|)\fP
@@ -40,8 +47,8 @@
.SH NAME
history \- GNU History Library
.SH COPYRIGHT
.if t The GNU History Library is Copyright \(co 1989-2023 by the Free Software Foundation, Inc.
.if n The GNU History Library is Copyright (C) 1989-2023 by the Free Software Foundation, Inc.
.if t The GNU History Library is Copyright \(co 1989-2024 by the Free Software Foundation, Inc.
.if n The GNU History Library is Copyright (C) 1989-2024 by the Free Software Foundation, Inc.
.SH DESCRIPTION
Many programs read input from the user a line at a time. The GNU
History library is able to keep track of those lines, associate arbitrary
@@ -136,7 +143,7 @@ Quick substitution. Repeat the last command, replacing
with
.IR string2 .
Equivalent to
``!!:s\d\s+2\(ha\s-2\u\fIstring1\fP\d\s+2\(ha\s-2\u\fIstring2\fP\d\s+2\(ha\s-2\u''
.Q !!:s\d\s+2\(ha\s-2\u\fIstring1\fP\d\s+2\(ha\s-2\u\fIstring2\fP\d\s+2\(ha\s-2\u
(see \fBModifiers\fP below).
.TP
.B !#
+1 -1
View File
@@ -193,7 +193,7 @@ With no options, display the history list with line numbers.
Lines prefixed with a @samp{*} have been modified.
An argument of @var{n} lists only the last @var{n} lines.
If the shell variable @env{HISTTIMEFORMAT} is set and not null,
it is used as a format string for @var{strftime} to display
it is used as a format string for @code{strftime}(3) to display
the time stamp associated with each displayed history entry.
No intervening blank is printed between the formatted time stamp
and the history line.
+47 -31
View File
@@ -6,15 +6,22 @@
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
.\" Last Change: Fri Jan 5 11:02:00 EST 2024
.\" Last Change: Thu Jan 18 11:05:44 EST 2024
.\"
.TH READLINE 3 "2024 January 5" "GNU Readline 8.3"
.TH READLINE 3 "2024 January 18" "GNU Readline 8.3"
.\"
.\" File Name macro. This used to be `.PN', for Path Name,
.\" but Sun doesn't seem to like that very much.
.\"
.de FN
\fI\|\\$1\|\fP
\%\fI\|\\$1\|\fP
..
.de Q
.ie \n(.g \(lq\\$1\(rq\\$2
.el \{
. if t ``\\$1''\\$2
. if n "\\$1"\\$2
.\}
..
.SH NAME
readline \- get a line from a user with editing
@@ -141,7 +148,7 @@ or
.RS
C\-Meta\-u: universal\-argument
.RE
.sp
.LP
into the
.I inputrc
would make M\-C\-u execute the readline command
@@ -179,7 +186,7 @@ whitespace between the name and the colon.
When using the form \fBkeyname\fP:\^\fIfunction-name\fP or \fImacro\fP,
.I keyname
is the name of a key spelled out in English. For example:
.sp
.PP
.RS
Control\-u: universal\-argument
.br
@@ -199,8 +206,7 @@ and
.I C\-o
is bound to run the macro
expressed on the right hand side (that is, to insert the text
.if t \f(CW> output\fP
.if n ``> output''
.Q "> output"
into the line).
.PP
In the second form, \fB"keyseq"\fP:\^\fIfunction\-name\fP or \fImacro\fP,
@@ -212,7 +218,7 @@ an entire key sequence may be specified by placing the sequence
within double quotes. Some GNU Emacs style key escapes can be
used, as in the following example, but the symbolic character names
are not recognized.
.sp
.PP
.RS
"\eC\-u": universal\-argument
.br
@@ -231,8 +237,7 @@ is bound to the function
and
.I "ESC [ 1 1 \(ti"
is bound to insert the text
.if t \f(CWFunction Key 1\fP.
.if n ``Function Key 1''.
.Q "Function Key 1" .
.PP
The full set of GNU Emacs style escape sequences available when specifying
key sequences is
@@ -352,19 +357,24 @@ It is output to the terminal before displaying the text in the active region.
This variable is reset to the default value whenever the terminal type changes.
The default value is the string that puts the terminal in standout mode,
as obtained from the terminal's terminfo description.
A sample value might be \f(CW"\ee[01;33m"\fP.
A sample value might be
.Q "\ee[01;33m" .
.TP
.B active\-region\-end\-color
A string variable that "undoes" the effects of \fBactive\-region\-start\-color\fP
and restores "normal" terminal display appearance after displaying text
in the active region.
A string variable that
.Q undoes
the effects of \fBactive\-region\-start\-color\fP
and restores
.Q normal
terminal display appearance after displaying text in the active region.
This string must not take up any physical character positions on the display,
so it should consist only of terminal escape sequences.
It is output to the terminal after displaying the text in the active region.
This variable is reset to the default value whenever the terminal type changes.
The default value is the string that restores the terminal from standout mode,
as obtained from the terminal's terminfo description.
A sample value might be \f(CW"\ee[0m\fP".
A sample value might be
.Q "\ee[0m" .
.TP
.B bell\-style (audible)
Controls what happens when readline wants to ring the terminal bell.
@@ -378,7 +388,9 @@ characters that are
treated specially by the kernel's terminal driver to their
readline equivalents.
These override the default readline bindings described here.
Type \f(CWstty -a\fP at a bash prompt to see your current terminal settings,
Type
.Q "stty -a"
at a \fBbash\fP prompt to see your current terminal settings,
including the special control characters (usually \fBcchars\fP).
.TP
.B blink\-matching\-paren (Off)
@@ -391,7 +403,8 @@ common prefix of the set of possible completions using a different color.
The color definitions are taken from the value of the \fBLS_COLORS\fP
environment variable.
If there is a color definition in \fB$LS_COLORS\fP for the custom suffix
"readline-colored-completion-prefix", readline uses this color for
.Q readline-colored-completion-prefix ,
readline uses this color for
the common prefix instead of its default.
.TP
.B colored\-stats (Off)
@@ -752,7 +765,7 @@ file can test for a particular value.
This could be used to bind key sequences to functions useful for
a specific program. For instance, the following command adds a
key sequence that quotes the current or previous word in \fBbash\fP:
.sp 1
.PP
.RS
.nf
\fB$if\fP Bash
@@ -781,8 +794,8 @@ the test fails.
This directive takes a single filename as an argument and reads commands
and bindings from that file. For example, the following directive
would read \fI/etc/inputrc\fP:
.sp 1
.RS
.PP
.nf
\fB$include\fP \^ \fI/etc/inputrc\fP
.fi
@@ -977,7 +990,9 @@ insert the \fIn\fPth word from the previous command (the words
in the previous command begin with word 0). A negative argument
inserts the \fIn\fPth word from the end of the previous command.
Once the argument \fIn\fP is computed, the argument is extracted
as if the "!\fIn\fP" history expansion had been specified.
as if the
.Q !\fIn\fP
history expansion had been specified.
.TP
.B
yank\-last\-arg (M\-.\^, M\-_\^)
@@ -991,15 +1006,16 @@ Any numeric argument supplied to these successive calls determines
the direction to move through the history. A negative argument switches
the direction through the history (back or forward).
The history expansion facilities are used to extract the last argument,
as if the "!$" history expansion had been specified.
as if the
.Q !$
history expansion had been specified.
.PD
.SS Commands for Changing Text
.PD 0
.TP
.B \fIend\-of\-file\fP (usually C\-d)
The character indicating end-of-file as set, for example, by
.if t \f(CWstty\fP.
.if n ``stty''.
.IR stty (1).
If this character is read when there are no characters
on the line, and point is at the beginning of the line, readline
interprets it as the end of input and returns
@@ -1280,7 +1296,9 @@ character. A negative argument searches for subsequent occurrences.
Read enough characters to consume a multi-key sequence such as those
defined for keys like Home and End. Such sequences begin with a
Control Sequence Indicator (CSI), usually ESC\-[. If this sequence is
bound to "\e[", keys producing such sequences will have no effect
bound to
.Q \e[ ,
keys producing such sequences will have no effect
unless explicitly bound to a readline command, instead of inserting
stray characters into the editing buffer. This is unbound by default,
but usually bound to ESC\-[.
@@ -1363,7 +1381,7 @@ variable).
.ta 2.5i
.sp
Emacs Standard bindings
.sp
.PP
"C-@" set-mark
"C-A" beginning-of-line
"C-B" backward-char
@@ -1395,7 +1413,7 @@ Emacs Standard bindings
"C-?" backward-delete-char
.PP
Emacs Meta bindings
.sp
.PP
"M-C-G" abort
"M-C-H" backward-kill-word
"M-C-I" tab-insert
@@ -1443,7 +1461,7 @@ Emacs Meta bindings
"M-_" yank-last-arg
.PP
Emacs Control-X bindings
.sp
.PP
"C-XC-G" abort
"C-XC-R" re-read-init-file
"C-XC-U" undo
@@ -1452,16 +1470,14 @@ Emacs Control-X bindings
"C-X)" end-kbd-macro
"C-XE" call-last-kbd-macro
"C-XC-?" backward-kill-line
.sp
.RE
.SS VI Mode bindings
.RS +.6i
.nf
.ta 2.5i
.sp
.PP
VI Insert Mode functions
.sp
.PP
"C-D" vi-eof-maybe
"C-H" backward-delete-char
"C-I" complete
@@ -1482,7 +1498,7 @@ VI Insert Mode functions
"C-?" backward-delete-char
.PP
VI Command Mode functions
.sp
.PP
"C-D" vi-eof-maybe
"C-E" emacs-editing-mode
"C-G" abort
+16 -12
View File
@@ -323,13 +323,14 @@ the line, thereby executing the command from the history list.
A movement command will terminate the search, make the last line found
the current line, and begin editing.
Readline remembers the last incremental search string. If two
@kbd{C-r}s are typed without any intervening characters defining a new
search string, any remembered search string is used.
Readline remembers the last incremental search string.
If two @kbd{C-r}s are typed without any intervening characters defining
a new search string, Readline uses any remembered search string.
Non-incremental searches read the entire search string before starting
to search for matching history lines. The search string may be
typed by the user or be part of the contents of the current line.
to search for matching history lines.
The search string may be typed by the user or be part of the contents of
the current line.
@node Readline Init File
@section Readline Init File
@@ -2502,9 +2503,11 @@ complete -o filenames -o nospace -o bashdefault -F _comp_cd cd
@noindent
Since we'd like Bash and Readline to take care of some
of the other details for us, we use several other options to tell Bash
and Readline what to do. The @option{-o filenames} option tells Readline
and Readline what to do.
The @option{-o filenames} option tells Readline
that the possible completions should be treated as filenames, and quoted
appropriately. That option will also cause Readline to append a slash to
appropriately.
That option will also cause Readline to append a slash to
filenames it can determine are directories (which is why we might want to
extend @code{_comp_cd} to append a slash if we're using directories found
via @var{CDPATH}: Readline can't tell those completions are directories).
@@ -2512,9 +2515,10 @@ The @option{-o nospace} option tells Readline to not append a space
character to the directory name, in case we want to append to it.
The @option{-o bashdefault} option brings in the rest of the "Bash default"
completions -- possible completions that Bash adds to the default Readline
set. These include things like command name completion, variable completion
for words beginning with @samp{$} or @samp{$@{}, completions containing pathname
expansion patterns (@pxref{Filename Expansion}), and so on.
set.
These include things like command name completion, variable completion
for words beginning with @samp{$} or @samp{$@{}, completions containing
pathname expansion patterns (@pxref{Filename Expansion}), and so on.
Once installed using @code{complete}, @code{_comp_cd} will be called every
time we attempt word completion for a @code{cd} command.
@@ -2523,8 +2527,8 @@ Many more examples -- an extensive collection of completions for most of
the common GNU, Unix, and Linux commands -- are available as part of the
bash_completion project. This is installed by default on many GNU/Linux
distributions. Originally written by Ian Macdonald, the project now lives
at @url{https://github.com/scop/bash-completion/}. There are ports for
other systems such as Solaris and Mac OS X.
at @url{https://github.com/scop/bash-completion/}.
There are ports for other systems such as Solaris and Mac OS X.
An older version of the bash_completion package is distributed with bash
in the @file{examples/complete} subdirectory.
+2 -2
View File
@@ -5,7 +5,7 @@ Copyright (C) 1988-2024 Free Software Foundation, Inc.
@set EDITION 8.3
@set VERSION 8.3
@set UPDATED 5 January 2024
@set UPDATED 19 January 2024
@set UPDATED-MONTH January 2024
@set LASTCHANGE Fri Jan 5 11:01:44 EST 2024
@set LASTCHANGE Fri Jan 19 11:01:44 EST 2024