next set of documentation updates (word splitting), rearrange a test in readline's tilde expansion to avoid touching uninitialized data

This commit is contained in:
Chet Ramey
2024-10-22 15:40:46 -04:00
parent 261c6e8cc6
commit 474743f2da
21 changed files with 4581 additions and 4506 deletions
+47 -58
View File
@@ -5,14 +5,14 @@
.\" Case Western Reserve University
.\" chet.ramey@case.edu
.\"
.\" Last Change: Tue Oct 15 16:53:49 EDT 2024
.\" Last Change: Sun Oct 20 12:31:15 EDT 2024
.\"
.\" bash_builtins, strip all but Built-Ins section
.\" avoid a warning about an undefined register
.\" .if !rzY .nr zY 0
.if \n(zZ=1 .ig zZ
.if \n(zY=1 .ig zY
.TH BASH 1 "2024 October 15" "GNU Bash 5.3"
.TH BASH 1 "2024 October 20" "GNU Bash 5.3"
.\"
.ie \n(.g \{\
.ds ' \(aq
@@ -483,6 +483,10 @@ document.
.B blank
A space or tab.
.TP
.B whitespace
A character belonging to the \fBspace\fP character class in the
current locale, or for which \fIisspace\fP(3) returns true.
.TP
.B word
A sequence of characters considered as a single unit by the shell.
Also known as a
@@ -4015,92 +4019,77 @@ and
arithmetic expansion
that did not occur within double quotes for
.IR "word splitting" .
Words that were not expanded are not split.
.PP
The shell treats each character of
.SM
.B IFS
as a delimiter, and splits the results of the other
expansions into words using these characters as field terminators.
as a delimiter,
and splits the results of the other expansions into words
using these characters as field terminators.
.PP
An \fIIFS whitespace\fP character is whitespace as defined above
(see \fBDefinitions\fP) that appears in the value of
.SM
.BR IFS .
Space, tab, and newline are always considered IFS whitespace, even
if they don't appear in the locale's \fBspace\fP category.
.PP
If
.SM
.B IFS
is unset, or its
value is exactly
is unset, field splitting acts as if its value were
.BR <space><tab><newline> ,
the default, then
sequences of
.BR space ,
.BR tab ,
and
.B newline
at the beginning and end of the results of the previous
expansions are ignored, and
any sequence of
and treats these characters as IFS whitespace.
If the value of
.SM
.B IFS
characters not at the beginning or end delimits words.
If
.SM
.B IFS
has a value other than the default, then sequences of
the whitespace characters
.BR space ,
.BR tab ,
and
.B newline
present in the value of
.SM
.B IFS
(an
.SM
.B IFS
whitespace character)
are ignored at the beginning and end of the word.
Any character in
.SM
.B IFS
that is not
.SM
.B IFS
whitespace, along with any adjacent
.SM
.B IFS
whitespace characters, delimits a field.
A sequence of
.SM
.B IFS
whitespace characters is also treated as a delimiter.
is null, no word splitting occurs,
but implicit null arguments (see below) are still removed.
.PP
Word splitting begins by removing sequences of IFS whitespace characters
from the beginning and end of the results of the previous expansions,
then splits the remaining words.
.PP
If the value of
.SM
.B IFS
is null, no word splitting occurs.
consists solely of IFS whitespace,
any sequence of IFS whitespace characters delimits a field,
so a field consists of characters that are not unquoted IFS
whitespace, and null fields result only from quoting.
.PP
If
.SM
.B IFS
is unset, word splitting behaves as if it contained the default value
of
.BR <space><tab><newline> .
contains a non-whitespace character, then any character in
the value of
.SM
.B IFS
that is not IFS whitespace,
along with any adjacent IFS whitespace characters, delimits a field.
This means that adjacent non-IFS-whitespace delimiters produce a
null field.
A sequence of IFS whitespace characters also delimits a field.
.PP
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.
If a parameter with no value is expanded within double quotes, a
null argument results and is retained
and passed to a command as an empty string.
Expanding a parameter with no value within double quotes
produces a null field,
which is retained and passed to a command as an empty string.
.PP
When a quoted null argument appears as part of a word whose expansion is
non-null, the null argument is removed.
non-null, word splitting removes the null argument portion,
leaving the non-null expansion.
That is, the word
.Q "\-d\*'\^\*'"
becomes
.Q \-d
after word splitting and null argument removal.
.PP
Note that if no expansion occurs, no splitting is performed.
.SS Pathname Expansion
.SS "Pathname Expansion"
After word splitting,
unless the
.B \-f