Re: Memory Leak - Bash 4.3.x30

2024-03-28 Thread Jordi Ferrer
   El 27/03/24 a les 18:51, Chet Ramey ha escrit:

 On 3/26/24 1:33 PM, Jordi Ferrer wrote:

 Just in case for people running old servers:
 This simple code cause a memory leak in bash:
 #!/bin/bash
 #
 Array=("S" "E")
 while [ 1 ]; do
 A=${Array[0]}
 done

 This was fixed by patch 40 to bash-4.3; if you're running a
 fully-patched
 version you won't encounter it.

   Ok. Thnks
--
Jordi Ferrer
INSTAL·LACIONS, TELECOMUNICACIONS I INFORMÀTICA
[1]jfer...@wattia.cat
(+34) 634 631 625

Wattia Innova S.L.  |  C/ Bòsnia, 6-8  |  17800 - Olot, Girona
Tel. (+34) 972 26 80 02  |  [2]http://wattia.cat

Avis Legal. La informació que conté aquest missatge de correu electrònic és CONF
IDENCIAL i pot incloure dades de caràcter reservat.
El seu accés o ús per part d'una tercera persona no autoritzada pot ser il·legal
. Si vostè no n'és el destinatari, si us plau elimini'l
i ens ho faci saber immediatament per aquesta mateixa via o pel telèfon (+34 972
 26 80 02). El correu electrònic no permet assegurar la
confidencialitat dels missatges, ni la seva recepció íntegra i correcta. No assu
mim cap responsabilitat per aquestes circumstàncies.
Si el destinatari no autoritza l'ús del correu electrònic o l'arxivament dels mi
ssatges, li preguem que ens ho comuniqui.

Abans d'imprimir aquest missatge pensi bé si és realment necessari fer-ho: El me
di ambient és cosa de tots!

References

   1. mailto:jfer...@wattia.cat
   2. http://wattia.cat/


Re: funsub in PS2

2024-03-28 Thread Chet Ramey

On 3/26/24 9:49 AM, Grisha Levit wrote:

Having funsubs in PS2 seems to cause input tokens that are split across
lines to be partially replaced with the last token of the last funsub
to be parsed while expanding the prompt string.

 $ PS2='${ : ; }> '
 $ printf '[%s]\n' ab\
 > cd
 [XXcd]


Thanks for the report. This was a surprisingly involved fix, just to save
and restore the parser state.

Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/



OpenPGP_signature.asc
Description: OpenPGP digital signature


Re: [PATCH] fix cmd and hist nums in ${var@P} inside $PS[012]

2024-03-28 Thread Chet Ramey

On 3/26/24 9:02 AM, Grisha Levit wrote:

When \# or \! is decoded in a ${var@P} expansion embedded in a prompt
string, the value can be off by one from that of the same sequence
embedded directly in the prompt string.


Thanks for the report and patch.

Chet

--
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRUc...@case.eduhttp://tiswww.cwru.edu/~chet/



OpenPGP_signature.asc
Description: OpenPGP digital signature


[PATCH 02/13] doc/bash.1: Fix groff man(7) style warnings.

2024-03-28 Thread G. Branden Robinson
Diff of rendering (ignoring differences in character set, default line
length, and a font selection affecting only a period):

(groff Git, 1.23.0, 1.22.4; mandoc; Heirloom Doctools nroff; DWB nroff)

- expansion, word splitting, pathname expansion, and quote removal .
+ expansion, word splitting, pathname expansion, and quote removal.

Fixes style warnings from groff 1.23.0 "nroff -rCHECKSTYLE=3 -man":
an.tmac:./doc/bash.1:3033: style: .IR expects at least 2 arguments, got 1
an.tmac:./doc/bash.1:6302: style: .BR expects at least 2 arguments, got 1
an.tmac:./doc/bash.1:6454: style: .BR expects at least 2 arguments, got 1
---
 doc/bash.1 | 9 ++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/doc/bash.1 b/doc/bash.1
index 65bd81ce..c3253b09 100644
--- a/doc/bash.1
+++ b/doc/bash.1
@@ -3030,7 +3030,7 @@ .SH EXPANSION
 .IR "word splitting" ,
 .IR "pathname expansion" ,
 and
-.IR "quote removal .
+.IR "quote removal" .
 .PP
 The order of expansions is:
 brace expansion;
@@ -6299,7 +6299,7 @@ .SS "Readline Variables"
 .\" finesse.  We require `\c`, and while the single-font macros don't
 .\" honor input trap continuation, the font alternation macros do.
 .TP
-.BR comment\-begin\ (\c
+.BR comment\-begin\ ( \c
 .Q \fB#\fP \fB)\fP
 The string that is inserted when the readline
 .B insert\-comment
@@ -6450,8 +6450,11 @@ .SS "Readline Variables"
 locale contains eight-bit characters.
 This variable is dependent on the \fBLC_CTYPE\fP locale category, and
 may change if the locale is changed.
+.\" Tucking multiple macro calls into a paragraph tag requires some
+.\" finesse.  We require `\c`, and while the single-font macros don't
+.\" honor input trap continuation, the font alternation macros do.
 .TP
-.BR isearch\-terminators\ (\c
+.BR isearch\-terminators\ ( \c
 .Q \fBC\-[C\-J\fP \fB)\fP
 The string of characters that should terminate an incremental
 search without subsequently executing the character as a command.
-- 
2.30.2



signature.asc
Description: PGP signature


[PATCH 03/13] lib/readline/doc/history.3: Drop spacing around (sub)section headings.

2024-03-28 Thread G. Branden Robinson
When formatting for typesetters, a blank input line produces 1 vee (one
line height, basically) of vertical space, but the default
inter-paragraph distance in man(7) is 0.4v.  Second, the package always
puts inter-paragraph spacing before a (sub)section heading anyway.
Third, forcing vertical space after a (sub)section heading is
nonidiomatic.

Fixes numerous style warnings from "nroff -rCHECKSTYLE=3 -man" in groff
1.23.0 of the following form.

an.tmac:lib/readline/doc/history.3:xxx: style: blank line in input
---
 lib/readline/doc/history.3 | 13 -
 1 file changed, 13 deletions(-)

diff --git a/lib/readline/doc/history.3 b/lib/readline/doc/history.3
index 4f1af5fe..266d91f6 100644
--- a/lib/readline/doc/history.3
+++ b/lib/readline/doc/history.3
@@ -67,7 +67,6 @@ .SH DESCRIPTION
 History library is able to keep track of those lines, associate arbitrary
 data with each line, and utilize information from previous lines in
 composing new ones.
-.PP
 .SH "HISTORY EXPANSION"
 The history library supports a history expansion feature that
 is identical to the history expansion in
@@ -404,7 +403,6 @@ .SS Initializing History and State Management
 
 .F1 void history_set_history_state "HISTORY_STATE *state"
 Set the state of the history list according to \fIstate\fP.
-
 .SS History List Management
 These functions manage individual entries on the history list, or set
 parameters managing the list itself.
@@ -451,9 +449,7 @@ .SS History List Management
 
 .F1 int history_is_stifled "void"
 Returns non-zero if the history is stifled, zero if it is not.
-
 .SS Information About the History List
-
 These functions return information about the entire history list or
 individual list entries.
 
@@ -484,9 +480,7 @@ .SS Information About the History List
 Return the number of bytes that the primary history entries are using.
 This function returns the sum of the lengths of all the lines in the
 history.
-
 .SS Moving Around the History List
-
 These functions allow the current index into the history list to be
 set or changed.
 
@@ -507,9 +501,7 @@ .SS Moving Around the History List
 If the possibly-incremented history offset refers to a valid history
 entry, return a pointer to that entry;
 otherwise, return a \fBNULL\fP pointer.
-
 .SS Searching the History List
-
 These functions allow searching of the history list for entries containing
 a specific string.  Searching may be performed both forward and backward
 from the current history position.  The search may be \fIanchored\fP,
@@ -539,7 +531,6 @@ .SS Searching the History List
 absolute index into the list.  If \fIdirection\fP is negative, the search
 proceeds backward from \fIpos\fP, otherwise forward.  Returns the absolute
 index of the history element where \fIstring\fP was found, or -1 otherwise.
-
 .SS Managing the History File
 The History library can read the history from and write it to a file.
 This section documents the functions for managing a history file.
@@ -574,9 +565,7 @@ .SS Managing the History File
 \fInlines\fP lines.
 If \fIfilename\fP is \fBNULL\fP, then \fI\*~/.history\fP is truncated.
 Returns 0 on success, or \fBerrno\fP on failure.
-
 .SS History Expansion
-
 These functions implement history expansion.
 
 .F2 int history_expand "const char *string" "char **output"
@@ -623,9 +612,7 @@ .SS History Expansion
 Extract a string segment consisting of the \fIfirst\fP through \fIlast\fP
 arguments present in \fIstring\fP.  Arguments are split using
 \fBhistory_tokenize()\fP.
-
 .SS History Variables
-
 This section describes the externally-visible variables exported by
 the GNU History Library.
 
-- 
2.30.2



signature.asc
Description: PGP signature


[PATCH 01/13] lib/readline/doc/history.3: Fix failure to render on DWB and Solaris 10 troff.

2024-03-28 Thread G. Branden Robinson
The following syntax is killing the page on AT&T troff.  You get the
header and footer and nothing else--just an ocean of blank space.

.de Fn1

With traditional roff eyeballs, this is interpreted the same as this:

.deFn1

or:

.de Fn 1

...which may at last make the problem clear.  Identifiers are only two
characters maximum in AT&T roff.  Because a macro named `1` was never
subsequently called, the entire remainder of the page got scooped into a
never-ending macro definition and would not render.
---
 lib/readline/doc/history.3 | 74 +++---
 1 file changed, 37 insertions(+), 37 deletions(-)

diff --git a/lib/readline/doc/history.3 b/lib/readline/doc/history.3
index 7a760019..4f1af5fe 100644
--- a/lib/readline/doc/history.3
+++ b/lib/readline/doc/history.3
@@ -38,17 +38,17 @@
 ..
 .ds lp \fR\|(\fP
 .ds rp \fR\|)\fP
-.\" FnN return-value fun-name N arguments
-.de Fn1
+.\" Fn return-value fun-name n arguments
+.de F1
 \fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3\fP\\*(rp
 .br
 ..
-.de Fn2
+.de F2
 .if t \fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3,\|\\$4\fP\\*(rp
 .if n \fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3, \\$4\fP\\*(rp
 .br
 ..
-.de Fn3
+.de F3
 .if t \fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3,\|\\$4,\|\\$5\fP\|\\*(rp
 .if n \fI\\$1\fP \fB\\$2\fP \\*(lp\fI\\$3, \\$4, \\$5\fP\\*(rp
 .br
@@ -395,61 +395,61 @@ .SS Initializing History and State Management
 the state of the History library when you want to use the history
 functions in your program.
 
-.Fn1 void using_history void
+.F1 void using_history void
 Begin a session in which the history functions might be used.  This
 initializes the interactive variables.
 
-.Fn1 "HISTORY_STATE *" history_get_history_state void
+.F1 "HISTORY_STATE *" history_get_history_state void
 Return a structure describing the current state of the input history.
 
-.Fn1 void history_set_history_state "HISTORY_STATE *state"
+.F1 void history_set_history_state "HISTORY_STATE *state"
 Set the state of the history list according to \fIstate\fP.
 
 .SS History List Management
 These functions manage individual entries on the history list, or set
 parameters managing the list itself.
 
-.Fn1 void add_history "const char *string"
+.F1 void add_history "const char *string"
 Place \fIstring\fP at the end of the history list.  The associated data
 field (if any) is set to \fBNULL\fP.
 If the maximum number of history entries has been set using
 \fBstifle_history()\fP, and the new number of history entries would exceed
 that maximum, the oldest history entry is removed.
 
-.Fn1 void add_history_time "const char *string"
+.F1 void add_history_time "const char *string"
 Change the time stamp associated with the most recent history entry to
 \fIstring\fP.
 
-.Fn1 "HIST_ENTRY *" remove_history "int which"
+.F1 "HIST_ENTRY *" remove_history "int which"
 Remove history entry at offset \fIwhich\fP from the history.  The
 removed element is returned so you can free the line, data,
 and containing structure.
 
-.Fn1 "histdata_t" free_history_entry "HIST_ENTRY *histent"
+.F1 "histdata_t" free_history_entry "HIST_ENTRY *histent"
 Free the history entry \fIhistent\fP and any history library private
 data associated with it.  Returns the application-specific data
 so the caller can dispose of it.
 
-.Fn3 "HIST_ENTRY *" replace_history_entry "int which" "const char *line" 
"histdata_t data"
+.F3 "HIST_ENTRY *" replace_history_entry "int which" "const char *line" 
"histdata_t data"
 Make the history entry at offset \fIwhich\fP have \fIline\fP and \fIdata\fP.
 This returns the old entry so the caller can dispose of any
 application-specific data.  In the case
 of an invalid \fIwhich\fP, a \fBNULL\fP pointer is returned.
 
-.Fn1 void clear_history "void"
+.F1 void clear_history "void"
 Clear the history list by deleting all the entries.
 
-.Fn1 void stifle_history "int max"
+.F1 void stifle_history "int max"
 Stifle the history list, remembering only the last \fImax\fP entries.
 The history list will contain only \fImax\fP entries at a time.
 
-.Fn1 int unstifle_history "void"
+.F1 int unstifle_history "void"
 Stop stifling the history.  This returns the previously-set
 maximum number of history entries (as set by \fBstifle_history()\fP).
 history was stifled.  The value is positive if the history was
 stifled, negative if it wasn't.
 
-.Fn1 int history_is_stifled "void"
+.F1 int history_is_stifled "void"
 Returns non-zero if the history is stifled, zero if it is not.
 
 .SS Information About the History List
@@ -457,30 +457,30 @@ .SS Information About the History List
 These functions return information about the entire history list or
 individual list entries.
 
-.Fn1 "HIST_ENTRY **" history_list "void"
+.F1 "HIST_ENTRY **" history_list "void"
 Return a \fBNULL\fP terminated array of \fIHIST_ENTRY *\fP which is the
 current input history.  Element 0 of this list is the beginning of time.
 If there is no history, return \fBNULL\fP.
 
-.Fn1 int where_history "void"
+.F1 int where_history "void"
 Re

[PATCH 06/13] lib/readline/doc/history.3: Drop microtypography.

2024-03-28 Thread G. Branden Robinson
Now that we're using a correct caret/circumflex/hat glyph on
modern typesetters (and terminals with a Unicode repertoire), drop the
thicket of partial-line motion and type size-altering escape sequences,
certain to frighten and confuse any unfrozen caveman page authors.

I expect this to slightly regress the quality of output on AT&T nroff
and troff (DWB and Solaris 10) when sending output to a line printer or
other device capable of half-line motions, and to typesetters.

The dropped escape sequences have never had effect on character-cell
video terminals.
---
 lib/readline/doc/history.3 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/readline/doc/history.3 b/lib/readline/doc/history.3
index 56d910cd..30b4d7be 100644
--- a/lib/readline/doc/history.3
+++ b/lib/readline/doc/history.3
@@ -150,13 +150,13 @@ .SS Event Designators
 If \fIstring\fP is missing, the string from the most recent search is used;
 it is an error if there is no previous search string.
 .TP
-.B \d\s+2\*^\s-2\u\fIstring1\fP\d\s+2\*^\s-2\u\fIstring2\fP\d\s+2\*^\s-2\u
+.B \*^\fIstring1\fP\*^\fIstring2\fP\*^
 Quick substitution.  Repeat the last command, replacing
 .I string1
 with
 .IR string2 .
 Equivalent to
-.Q !!:s\d\s+2\*^\s-2\u\fIstring1\fP\d\s+2\*^\s-2\u\fIstring2\fP\d\s+2\*^\s-2\u
+.Q !!:s\*^\fIstring1\fP\*^\fIstring2\fP\*^
 (see \fBModifiers\fP below).
 .TP
 .B !#
-- 
2.30.2



signature.asc
Description: PGP signature


[PATCH 05/13] lib/readline/doc/history.3: Fix style minutia.

2024-03-28 Thread G. Branden Robinson
Set a period in the intended face (roman, not bold).

Stop breaking a line in the middle of a sentence without motivation.

Diff of rendering:

(groff Git, 1.23.0, 1.22.4; mandoc; Heirloom Doctools nroff)
- G  Apply the following “s”
- or “&” modifier once to each word in the event line.
+ G  Apply the following “s” or “&” modifier once to each word in the
+event line.

Fixes (from "nroff -rCHECKSTYLE=3 -man" using groff 1.23.0):
an.tmac:lib/readline/doc/history.3:73: style: .BR expects at least 2 arguments, 
got 1
an.tmac:lib/readline/doc/history.3:320: style: 1 leading space(s) on input line
---
 lib/readline/doc/history.3 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/readline/doc/history.3 b/lib/readline/doc/history.3
index 76703833..56d910cd 100644
--- a/lib/readline/doc/history.3
+++ b/lib/readline/doc/history.3
@@ -70,7 +70,7 @@ .SH DESCRIPTION
 .SH "HISTORY EXPANSION"
 The history library supports a history expansion feature that
 is identical to the history expansion in
-.BR bash.
+.BR bash .
 This section describes what syntax features are available.
 .PP
 History expansions introduce words from the history list into
@@ -317,7 +317,7 @@ .SS Modifiers
 .B G
 Apply the following
 .Q \fBs\fP
- or
+or
 .Q \fB&\fP
 modifier once to each word in the event line.
 .PD
-- 
2.30.2



signature.asc
Description: PGP signature


[PATCH 08/13] lib/readline/doc/history.3: Fix font thinko.

2024-03-28 Thread G. Branden Robinson
Replace no-op font selection escape sequence with what appears to have
been intended.
---
 lib/readline/doc/history.3 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/readline/doc/history.3 b/lib/readline/doc/history.3
index 40b85b20..7b6ab73b 100644
--- a/lib/readline/doc/history.3
+++ b/lib/readline/doc/history.3
@@ -728,7 +728,7 @@ .SH BUG REPORTS
 bug report to \fIbug\-readline\fP@\fIgnu.org\fP.
 If you have a fix, you are welcome to mail that
 as well!  Suggestions and `philosophical' bug reports may be mailed
-to \fPbug\-readline\fP@\fIgnu.org\fP or posted to the Usenet
+to \fIbug\-readline\fP@\fIgnu.org\fP or posted to the Usenet
 newsgroup
 .BR gnu.bash.bug .
 .PP
-- 
2.30.2



signature.asc
Description: PGP signature


[PATCH 04/13] lib/readline/doc/history.3: Replace blank lines with macro calls.

2024-03-28 Thread G. Branden Robinson
When formatting for typesetters, a blank input line produces 1 vee (one
line height, basically) of vertical space, but the default
inter-paragraph distance in man(7) is 0.4v.

Fixes numerous style warnings from "nroff -rCHECKSTYLE=3 -man" in groff
1.23.0 of the following form.

an.tmac:lib/readline/doc/history.3:xxx: style: blank line in input
---
 lib/readline/doc/history.3 | 93 +++---
 1 file changed, 46 insertions(+), 47 deletions(-)

diff --git a/lib/readline/doc/history.3 b/lib/readline/doc/history.3
index 266d91f6..76703833 100644
--- a/lib/readline/doc/history.3
+++ b/lib/readline/doc/history.3
@@ -393,89 +393,89 @@ .SS Initializing History and State Management
 This section describes functions used to initialize and manage
 the state of the History library when you want to use the history
 functions in your program.
-
+.PP
 .F1 void using_history void
 Begin a session in which the history functions might be used.  This
 initializes the interactive variables.
-
+.PP
 .F1 "HISTORY_STATE *" history_get_history_state void
 Return a structure describing the current state of the input history.
-
+.PP
 .F1 void history_set_history_state "HISTORY_STATE *state"
 Set the state of the history list according to \fIstate\fP.
 .SS History List Management
 These functions manage individual entries on the history list, or set
 parameters managing the list itself.
-
+.PP
 .F1 void add_history "const char *string"
 Place \fIstring\fP at the end of the history list.  The associated data
 field (if any) is set to \fBNULL\fP.
 If the maximum number of history entries has been set using
 \fBstifle_history()\fP, and the new number of history entries would exceed
 that maximum, the oldest history entry is removed.
-
+.PP
 .F1 void add_history_time "const char *string"
 Change the time stamp associated with the most recent history entry to
 \fIstring\fP.
-
+.PP
 .F1 "HIST_ENTRY *" remove_history "int which"
 Remove history entry at offset \fIwhich\fP from the history.  The
 removed element is returned so you can free the line, data,
 and containing structure.
-
+.PP
 .F1 "histdata_t" free_history_entry "HIST_ENTRY *histent"
 Free the history entry \fIhistent\fP and any history library private
 data associated with it.  Returns the application-specific data
 so the caller can dispose of it.
-
+.PP
 .F3 "HIST_ENTRY *" replace_history_entry "int which" "const char *line" 
"histdata_t data"
 Make the history entry at offset \fIwhich\fP have \fIline\fP and \fIdata\fP.
 This returns the old entry so the caller can dispose of any
 application-specific data.  In the case
 of an invalid \fIwhich\fP, a \fBNULL\fP pointer is returned.
-
+.PP
 .F1 void clear_history "void"
 Clear the history list by deleting all the entries.
-
+.PP
 .F1 void stifle_history "int max"
 Stifle the history list, remembering only the last \fImax\fP entries.
 The history list will contain only \fImax\fP entries at a time.
-
+.PP
 .F1 int unstifle_history "void"
 Stop stifling the history.  This returns the previously-set
 maximum number of history entries (as set by \fBstifle_history()\fP).
 history was stifled.  The value is positive if the history was
 stifled, negative if it wasn't.
-
+.PP
 .F1 int history_is_stifled "void"
 Returns non-zero if the history is stifled, zero if it is not.
 .SS Information About the History List
 These functions return information about the entire history list or
 individual list entries.
-
+.PP
 .F1 "HIST_ENTRY **" history_list "void"
 Return a \fBNULL\fP terminated array of \fIHIST_ENTRY *\fP which is the
 current input history.  Element 0 of this list is the beginning of time.
 If there is no history, return \fBNULL\fP.
-
+.PP
 .F1 int where_history "void"
 Returns the offset of the current history element.
-
+.PP
 .F1 "HIST_ENTRY *" current_history "void"
 Return the history entry at the current position, as determined by
 \fBwhere_history()\fP.  If there is no entry there, return a \fBNULL\fP
 pointer.
-
+.PP
 .F1 "HIST_ENTRY *" history_get "int offset"
 Return the history entry at position \fIoffset\fP.
 The range of valid values of \fIoffset\fP starts at \fBhistory_base\fP
 and ends at \fBhistory_length\fP \- 1.
 If there is no entry there, or if \fIoffset\fP is outside the valid
 range, return a \fBNULL\fP pointer.
-
+.PP
 .F1 "time_t" history_get_time "HIST_ENTRY *"
 Return the time stamp associated with the history entry passed as the argument.
-
+.PP
 .F1 int history_total_bytes "void"
 Return the number of bytes that the primary history entries are using.
 This function returns the sum of the lengths of all the lines in the
@@ -483,18 +483,18 @@ .SS Information About the History List
 .SS Moving Around the History List
 These functions allow the current index into the history list to be
 set or changed.
-
+.PP
 .F1 int history_set_pos "int pos"
 Set the current history offset to \fIpos\fP, an absolute index
 into the list.
 Returns 1 on success, 0 if \fIpos\fP is less than zero or

[PATCH 09/13] lib/readline/doc/history.3: Revise inline struct.

2024-03-28 Thread G. Branden Robinson
This unfilled block of text was oversetting the line on DWB nroff, which
uses a line length of 65n (just like Seventh Edition Unix nroff).

Recast comments to occupy less space.

Also bracket this inline code display with `EX`/`EE` macros; this sets
the code in a monospace/constant-width font on platforms supporting this
Ninth Edition Unix/groff man(7) extension, and does nothing elsewhere.
---
 lib/readline/doc/history.3 | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/lib/readline/doc/history.3 b/lib/readline/doc/history.3
index 7b6ab73b..d36c454d 100644
--- a/lib/readline/doc/history.3
+++ b/lib/readline/doc/history.3
@@ -372,16 +372,18 @@ .SS History Storage
 The state of the History library is encapsulated into a single structure:
 .PP
 .nf
+.EX
 /*
- * A structure used to pass around the current state of the history.
+ * structure for passing around the state of history
  */
 typedef struct _hist_state {
-  HIST_ENTRY **entries; /* Pointer to the entries themselves. */
-  int offset;   /* The location pointer within this array. */
-  int length;   /* Number of elements within this array. */
-  int size; /* Number of slots allocated to this array. */
+  HIST_ENTRY **entries; /* pointer to entry records */
+  int offset;   /* current record */
+  int length;   /* number of records in list */
+  int size; /* capacity of list in records */
   int flags;
 } HISTORY_STATE;
+.EE
 .fi
 .PP
 If the flags member includes \fBHS_STIFLED\fP, the history has been
-- 
2.30.2



signature.asc
Description: PGP signature


[PATCH 07/13] lib/readline/doc/history.3: Fix hyphen-minus signs.

2024-03-28 Thread G. Branden Robinson
Use a *roff minus sign for minus signs and the `-` character in email
addresses.
---
 lib/readline/doc/history.3 | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/readline/doc/history.3 b/lib/readline/doc/history.3
index 30b4d7be..40b85b20 100644
--- a/lib/readline/doc/history.3
+++ b/lib/readline/doc/history.3
@@ -514,7 +514,7 @@ .SS Searching the History List
 If \fIstring\fP is found, then
 the current history index is set to that history entry, and the value
 returned is the offset in the line of the entry where
-\fIstring\fP was found.  Otherwise, nothing is changed, and a -1 is
+\fIstring\fP was found.  Otherwise, nothing is changed, and a \-1 is
 returned.
 .PP
 .F2 int history_search_prefix "const char *string" "int direction"
@@ -524,13 +524,13 @@ .SS Searching the History List
 through previous entries, otherwise through subsequent entries.
 If \fIstring\fP is found, then the
 current history index is set to that entry, and the return value is 0.
-Otherwise, nothing is changed, and a -1 is returned.
+Otherwise, nothing is changed, and a \-1 is returned.
 .PP
 .F3 int history_search_pos "const char *string" "int direction" "int pos"
 Search for \fIstring\fP in the history list, starting at \fIpos\fP, an
 absolute index into the list.  If \fIdirection\fP is negative, the search
 proceeds backward from \fIpos\fP, otherwise forward.  Returns the absolute
-index of the history element where \fIstring\fP was found, or -1 otherwise.
+index of the history element where \fIstring\fP was found, or \-1 otherwise.
 .SS Managing the History File
 The History library can read the history from and write it to a file.
 This section documents the functions for managing a history file.
@@ -728,7 +728,7 @@ .SH BUG REPORTS
 bug report to \fIbug\-readline\fP@\fIgnu.org\fP.
 If you have a fix, you are welcome to mail that
 as well!  Suggestions and `philosophical' bug reports may be mailed
-to \fPbug-readline\fP@\fIgnu.org\fP or posted to the Usenet
+to \fPbug\-readline\fP@\fIgnu.org\fP or posted to the Usenet
 newsgroup
 .BR gnu.bash.bug .
 .PP
-- 
2.30.2



signature.asc
Description: PGP signature


[PATCH 10/13] lib/readline/doc/history.3: Make `EX` and `EE` man(7) macros usable on DWB troff.

2024-03-28 Thread G. Branden Robinson
This prevents lines in the displayed struct definition from oversetting
on DWB troff.

Diff of rendering (DWB only):

@@ -10150,11 +10150,11 @@
The state of the History library is encapsulated into a sin-
gle structure:

-/*
- * structure for passing around the state of history
- */
-typedef struct _hist_state {
-  HIST_ENTRY **entries; /* pointer to entry records */
+   /*
+* structure for passing around the state of history
+*/
+   typedef struct _hist_state {
+ HIST_ENTRY **entries; /* pointer to entry records */

@@ -10169,11 +10169,11 @@

-  int offset;   /* current record */
-  int length;   /* number of records in list */
-  int size; /* capacity of list in records */
-  int flags;
-} HISTORY_STATE;
+ int offset;   /* current record */
+ int length;   /* number of records in list */
+ int size; /* capacity of list in records */
+ int flags;
+   } HISTORY_STATE;

If the flags member includes HS_STIFLED, the history has
@@ -10774,9 +10774,9 @@
When using the form keyname:function-name or macro, keyname
is the name of a key spelled out in English.  For example:

- Control-u: universal-argument
- Meta-Rubout: backward-kill-word
- Control-o: "> output"
+Control-u: universal-argument
+Meta-Rubout: backward-kill-word
+Control-o: "> output"

In the above example, C-u is bound to the function
@@ -10792,9 +10792,9 @@
be used, as in the following example, but the symbolic char-
acter names are not recognized.

- "\C-u": universal-argument
- "\C-x\C-r": re-read-init-file
- "\e[11~": "Function Key 1"
+"\C-u": universal-argument
+"\C-x\C-r": re-read-init-file
+"\e[11~": "Function Key 1"

In this example, C-u is again bound to the function
@@ -11327,10 +11327,10 @@
  key sequence that quotes the current or previous
  word in bash:

-  $if Bash
-  # Quote the current or previous word
-  "\C-xq": "\eb\"\ef\""
-  $endif
+ $if Bash
+ # Quote the current or previous word
+ "\C-xq": "\eb\"\ef\""
+ $endif

 variable
---
 lib/readline/doc/history.3 | 12 
 1 file changed, 12 insertions(+)

diff --git a/lib/readline/doc/history.3 b/lib/readline/doc/history.3
index d36c454d..111cdbf6 100644
--- a/lib/readline/doc/history.3
+++ b/lib/readline/doc/history.3
@@ -23,6 +23,18 @@
 .ds ~ ~
 .\}
 .
+.\" Fix broken EX/EE macros on DWB troff.
+.\" Detect it: only DWB sets up a `)Y` register.
+.if \n()Y \{\
+.\" Revert the undesired changes to indentation.
+.am EX
+.in -5n
+..
+.am EE
+.in +5n
+..
+.\}
+.
 .\" File Name macro.  This used to be `.PN', for Path Name,
 .\" but Sun doesn't seem to like that very much.
 .\"
-- 
2.30.2



signature.asc
Description: PGP signature


[PATCH 12/13] doc/bash.1: Fix *roff style nit.

2024-03-28 Thread G. Branden Robinson
While font mounting position 3 is usually assigned a bold typeface, it
seems a bit fragile to not explicitly ask for bold.  The concept of
mounting positions is also not something man page authors typically need
to think about.
---
 doc/bash.1 | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/doc/bash.1 b/doc/bash.1
index a32fb88c..323356c7 100644
--- a/doc/bash.1
+++ b/doc/bash.1
@@ -3918,8 +3918,8 @@ .SS Word Splitting
 of
 .BR  .
 .PP
-Explicit null arguments (\^\f3\*"\^\*"\fP or
-\^\f3\*'\^\*'\fP\^) are retained
+Explicit null arguments (\^\fB\*"\^\*"\fP or
+\^\fB\*'\^\*'\fP\^) are retained
 and passed to commands as empty strings.
 Unquoted implicit null arguments, resulting from the expansion of
 parameters that have no values, are removed.
@@ -4244,7 +4244,7 @@ .SS Quote Removal
 characters
 .BR \e ,
 .BR \*' ,
-and \^\f3\*"\fP\^ that did not result from one of the above
+and \^\fB\*"\fP\^ that did not result from one of the above
 expansions are removed.
 .SH REDIRECTION
 Before a command is executed, its input and output
-- 
2.30.2



signature.asc
Description: PGP signature


[PATCH 11/13] [man pages]: Make comment more informative.

2024-03-28 Thread G. Branden Robinson
Double quotes aren't any easier to use with AT&T troff just because you
tuck them inside a string definition.  (The _name_ of the string doesn't
matter; that gets interpolated before "quote removal", if you will.)

https://www.gnu.org/software/groff/manual/groff.html.node/Calling-Macros.html
---
 doc/bash.1  | 2 +-
 lib/readline/doc/history.3  | 2 +-
 lib/readline/doc/readline.3 | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/doc/bash.1 b/doc/bash.1
index c3253b09..a32fb88c 100644
--- a/doc/bash.1
+++ b/doc/bash.1
@@ -47,7 +47,7 @@
 .\}
 .el \{\
 .ds ' '
-.ds " ""\" two adjacent quotes and no space before this comment
+.ds " ""\" not usable in macro arguments on AT&T troff (DWB, Solaris 10)
 .ds ^ ^
 .ds ~ ~
 .\}
diff --git a/lib/readline/doc/history.3 b/lib/readline/doc/history.3
index 111cdbf6..ff21029f 100644
--- a/lib/readline/doc/history.3
+++ b/lib/readline/doc/history.3
@@ -18,7 +18,7 @@
 .\}
 .el \{\
 .ds ' '
-.ds " ""\" two adjacent quotes and no space before this comment
+.ds " ""\" not usable in macro arguments on AT&T troff (DWB, Solaris 10)
 .ds ^ ^
 .ds ~ ~
 .\}
diff --git a/lib/readline/doc/readline.3 b/lib/readline/doc/readline.3
index 438da117..bdd0243b 100644
--- a/lib/readline/doc/readline.3
+++ b/lib/readline/doc/readline.3
@@ -18,7 +18,7 @@
 .\}
 .el \{\
 .ds ' '
-.ds " ""\" two adjacent quotes and no space before this comment
+.ds " ""\" not usable in macro arguments on AT&T troff (DWB, Solaris 10)
 .ds ^ ^
 .ds ~ ~
 .\}
-- 
2.30.2



signature.asc
Description: PGP signature


[PATCH 13/13] doc/bash.1: Trivially refactor *roff markup.

2024-03-28 Thread G. Branden Robinson
Use `\fP` to restore previous font in places where it adequately
returns to roman face rather than the explicit `\fR` (which can clobber
the "previous font selection" datum in the formatter).
---
 doc/bash.1 | 30 +++---
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/doc/bash.1 b/doc/bash.1
index 323356c7..eeff6b63 100644
--- a/doc/bash.1
+++ b/doc/bash.1
@@ -89,7 +89,7 @@ .SH COPYRIGHT
 .if t Bash is Copyright \(co 1989-2023 by the Free Software Foundation, Inc.
 .SH DESCRIPTION
 .B Bash
-is an \fBsh\fR-compatible command language interpreter that
+is an \fBsh\fP-compatible command language interpreter that
 executes commands read from the standard input or from a file.
 .B Bash
 also incorporates useful features from the \fIKorn\fP and \fIC\fP
@@ -103,9 +103,9 @@ .SH DESCRIPTION
 can be configured to be POSIX-conformant by default.
 .SH OPTIONS
 All of the single-character shell options documented in the
-description of the \fBset\fR builtin command, including \fB\-o\fP,
+description of the \fBset\fP builtin command, including \fB\-o\fP,
 can be used as options when the shell is invoked.
-In addition, \fBbash\fR
+In addition, \fBbash\fP
 interprets the following options when it is invoked:
 .PP
 .PD 0
@@ -5958,10 +5958,10 @@ .SH READLINE
 builtin.
 .SS "Readline Notation"
 In this section, the Emacs-style notation is used to denote
-keystrokes.  Control keys are denoted by C\-\fIkey\fR, e.g., C\-n
+keystrokes.  Control keys are denoted by C\-\fIkey\fP, e.g., C\-n
 means Control\-N.  Similarly,
 .I meta
-keys are denoted by M\-\fIkey\fR, so M\-x means Meta\-X.  (On keyboards
+keys are denoted by M\-\fIkey\fP, so M\-x means Meta\-X.  (On keyboards
 without a
 .I meta
 key, M\-\fIx\fP means ESC \fIx\fP, i.e., press the Escape key
@@ -7841,11 +7841,11 @@ .SS Event Designators
 or ( (when the \fBextglob\fP shell option is enabled using
 the \fBshopt\fP builtin).
 .TP
-.B !\fIn\fR
+.B !\fIn\fP
 Refer to command line
 .IR n .
 .TP
-.B !\-\fIn\fR
+.B !\-\fIn\fP
 Refer to the current command minus
 .IR n .
 .TP
@@ -7853,12 +7853,12 @@ .SS Event Designators
 Refer to the previous command.  This is a synonym for
 .Q !\-1 .
 .TP
-.B !\fIstring\fR
+.B !\fIstring\fP
 Refer to the most recent command preceding the current position in the
 history list starting with
 .IR string .
 .TP
-.B !?\fIstring\fR\fB[?]\fR
+.B !?\fIstring\fP[?]
 Refer to the most recent command preceding the current position in the
 history list containing
 .IR string .
@@ -7903,7 +7903,7 @@ .SS Word Designators
 word.
 .TP
 .I n
-The \fIn\fRth word.
+The \fIn\fPth word.
 .TP
 .B \*^
 The first argument.  That is, word 1.
@@ -7914,15 +7914,15 @@ .SS Word Designators
 .TP
 .B %
 The first word matched by the most recent
-.Q ?\fIstring\fR?'
+.Q ?\fIstring\fP?'
 search,
 if the search string begins with a character that is part of a word.
 .TP
 .I x\fB\-\fPy
 A range of words;
-.Q \-\fIy\fR
+.Q \-\fIy\fP
 abbreviates
-.Q 0\-\fIy\fR .
+.Q 0\-\fIy\fP .
 .TP
 .B *
 All of the words but the zeroth.
@@ -8005,7 +8005,7 @@ .SS Modifiers
 the last
 .I string
 in a
-.B !?\fIstring\fR\fB[?]\fR
+.B !?\fIstring\fP[?]
 search.
 If
 .I new
@@ -12287,7 +12287,7 @@ .SH BUG REPORTS
 .PP
 .PD 0
 .TP 20
-The version number of \fBbash\fR
+The version number of \fBbash\fP
 .TP
 The hardware and operating system
 .TP
-- 
2.30.2


signature.asc
Description: PGP signature


install-headers stdckdint.h error

2024-03-28 Thread Grisha Levit
The addition of stdckdint.h to CREATED_HEADERS in Makefile.in leads to
an error when installing loadable builtins on platforms that provide
the header:

install: cannot stat '/tmp/bash/stdckdint.h': No such file or directory
make[2]: *** [Makefile:903: install-headers] Error 1
make[2]: Leaving directory '/tmp/bash'
make[1]: *** [Makefile:291: install-dev] Error 2

On platforms where the generated header is used, there is no error when
installing, but the installed generated header is not usable since it
#include's intprops-internal.h, which does not get installed.

Paul's patch[1] used CREATED_CONFIGURE instead, which seems appropriate
for avoiding these problems.

[1]: https://lists.gnu.org/archive/html/bug-bash/2024-03/msg00085.html