]> git.ipfire.org Git - thirdparty/bash.git/blobdiff - doc/bashref.texi
changes for quoting special and multibyte characters in glob patterns; changes to...
[thirdparty/bash.git] / doc / bashref.texi
index f831ff049ab86b37c16644c35832ec25c270ca27..4aa9ed88c7ded9ab330ece4d325593ed62dfe32c 100644 (file)
@@ -14,7 +14,7 @@ This is Edition @value{EDITION}, last updated @value{UPDATED},
 of @cite{The GNU Bash Reference Manual},
 for @code{Bash}, Version @value{VERSION}.
 
-Copyright @copyright{} 1988--2021 Free Software Foundation, Inc.
+Copyright @copyright{} 1988--2023 Free Software Foundation, Inc.
 
 @quotation
 Permission is granted to copy, distribute and/or modify this document
@@ -475,8 +475,8 @@ when in double quotes (@pxref{Shell Parameter Expansion}).
 @subsubsection ANSI-C Quoting
 @cindex quoting, ANSI
 
-Character sequences of the form $'@var{string}' are treated as a special
-kind of single quotes.
+Character sequences of the form @code{$'@var{string}'} are treated as
+a special kind of single quotes.
 The sequence expands to @var{string}, with backslash-escaped characters
 in @var{string} replaced as specified by the ANSI C standard.
 Backslash escape sequences, if present, are decoded as follows:
@@ -795,13 +795,14 @@ shell builtins, shell functions, and pipelines.  An external
 When the shell is in @sc{posix} mode (@pxref{Bash POSIX Mode}), @code{time}
 may be followed by a newline.  In this case, the shell displays the
 total user and system time consumed by the shell and its children.
-The @env{TIMEFORMAT} variable may be used to specify the format of
-the time information.
+The @env{TIMEFORMAT} variable specifies the format of the time information.
 
 If the pipeline is not executed asynchronously (@pxref{Lists}), the
 shell waits for all commands in the pipeline to complete.
 
-Each command in a pipeline is executed in its own @dfn{subshell}, which is a
+Each command in a multi-command pipeline,
+where pipes are created,
+is executed in its own @dfn{subshell}, which is a
 separate process (@pxref{Command Execution Environment}).
 If the @code{lastpipe} option is enabled using the @code{shopt} builtin
 (@pxref{The Shopt Builtin}),
@@ -1094,16 +1095,16 @@ select @var{name} [in @var{words} @dots{}]; do @var{commands}; done
 @end example
 
 The list of words following @code{in} is expanded, generating a list
-of items.  The set of expanded words is printed on the standard
+of items, and the set of expanded words is printed on the standard
 error output stream, each preceded by a number.  If the
 @samp{in @var{words}} is omitted, the positional parameters are printed,
 as if @samp{in "$@@"} had been specified.
-The @env{PS3} prompt is then displayed and a line is read from the
-standard input.
+@code{select} then displays the @env{PS3}
+prompt and reads a line from the standard input.
 If the line consists of a number corresponding to one of the displayed
 words, then the value of @var{name} is set to that word.
 If the line is empty, the words and prompt are displayed again.
-If @code{EOF} is read, the @code{select} command completes.
+If @code{EOF} is read, the @code{select} command completes and returns 1.
 Any other value read causes @var{name} to be set to null.
 The line read is saved in the variable @env{REPLY}.
 
@@ -1333,6 +1334,11 @@ expression are saved in the remaining @code{BASH_REMATCH} indices.
 The element of @code{BASH_REMATCH} with index @var{n} is the portion of the
 string matching the @var{n}th parenthesized subexpression.
 
+Bash sets
+@code{BASH_REMATCH}
+in the global scope; declaring it as a local variable will lead to
+unexpected results.
+
 Expressions may be combined using the following operators, listed
 in decreasing order of precedence:
 
@@ -1600,10 +1606,22 @@ return status is the exit status of the last command executed
 before the @code{return}.
 
 Variables local to the function may be declared with the
-@code{local} builtin.  These variables are visible only to
+@code{local} builtin (@dfn{local variables}).
+Ordinarily, variables and their values
+are shared between a function and its caller.
+These variables are visible only to
 the function and the commands it invokes.  This is particularly
 important when a shell function calls other functions.
 
+In the following description, the @dfn{current scope} is a currently-
+executing function.
+Previous scopes consist of that function's caller and so on,
+back to the "global" scope, where the shell is not executing
+any shell function.
+Consequently, a local variable at the current local scope is a variable
+declared using the @code{local} or @code{declare} builtins in the
+function that is currently executing.
+
 Local variables "shadow" variables with the same name declared at
 previous scopes.  For instance, a local variable declared in a function
 hides a global variable of the same name: references and assignments
@@ -1656,11 +1674,13 @@ variable is local to the current scope, @code{unset} will unset it;
 otherwise the unset will refer to the variable found in any calling scope 
 as described above.
 If a variable at the current local scope is unset, it will remain so
+(appearing as unset)
 until it is reset in that scope or until the function returns.
 Once the function returns, any instance of the variable at a previous
 scope will become visible.
 If the unset acts on a variable at a previous scope, any instance of a   
-variable with that name that had been shadowed will become visible.
+variable with that name that had been shadowed will become visible
+(see below how @code{localvar_unset}shell option changes this behavior).
 
 Function names and definitions may be listed with the
 @option{-f} option to the @code{declare} (@code{typeset})
@@ -1933,7 +1953,7 @@ command substitution.
 
 After these expansions are performed, quote characters present in the
 original word are removed unless they have been quoted themselves
-(@dfn{quote removal}).
+(@dfn{quote removal}). @xref{Quote Removal} for more details.
 
 Only brace expansion, word splitting, and filename expansion
 can increase the number of words of the expansion; other expansions
@@ -1943,9 +1963,6 @@ The only exceptions to this are the expansions of
 @code{"$@{@var{name}[@@]@}"} and @code{$@{@var{name}[*]@}}
 (@pxref{Arrays}).
 
-After all expansions, @code{quote removal} (@pxref{Quote Removal})
-is performed.
-
 @node Brace Expansion
 @subsection Brace Expansion
 @cindex brace expansion
@@ -2142,7 +2159,7 @@ introduce indirection.
 In each of the cases below, @var{word} is subject to tilde expansion,
 parameter expansion, command substitution, and arithmetic expansion.
 
-When not performing substring expansion, using the form described
+When not performing substring expansion, using the forms described
 below (e.g., @samp{:-}), Bash tests for a parameter that is unset or null.
 Omitting the colon results in a test only for a parameter that is unset.
 Put another way, if the colon is included,
@@ -2160,6 +2177,14 @@ If @var{parameter} is unset or null, the expansion of
 $ v=123
 $ echo $@{v-unset@}
 123
+$ echo $@{v:-unset-or-null@}
+123
+$ unset v
+$ echo $@{v-unset@}
+unset
+$ v=
+$ echo $@{v:-unset-or-null@}
+unset-or-null
 @end example
 
 @item $@{@var{parameter}:=@var{word}@}
@@ -2207,7 +2232,7 @@ var is set and not null
 This is referred to as Substring Expansion.
 It expands to up to @var{length} characters of the value of @var{parameter}
 starting at the character specified by @var{offset}.
-If @var{parameter} is @samp{@@}, an indexed array subscripted by
+If @var{parameter} is @samp{@@} or @samp{*}, an indexed array subscripted by
 @samp{@@} or @samp{*}, or an associative array name, the results differ as
 described below.
 If @var{length} is omitted, it expands to the substring of the value of
@@ -2284,11 +2309,11 @@ $ echo ${array[0]: -7:-2}
 bcdef
 @end verbatim
 
-If @var{parameter} is @samp{@@}, the result is @var{length} positional
-parameters beginning at @var{offset}.
+If @var{parameter} is @samp{@@} or @samp{*}, the result is @var{length}
+positional parameters beginning at @var{offset}.
 A negative @var{offset} is taken relative to one greater than the greatest
 positional parameter, so an offset of -1 evaluates to the last positional
-parameter.
+parameter (or 0 if there are no positional parameters).
 It is an expansion error if @var{length} evaluates to a number less than zero.
 
 The following examples illustrate substring expansion using positional
@@ -2444,46 +2469,67 @@ If the @code{patsub_replacement} shell option is enabled using @code{shopt},
 any unquoted instances of @samp{&} in @var{string} are replaced with the
 matching portion of @var{pattern}.
 This is intended to duplicate a common @code{sed} idiom.
-Backslash is used to quote @samp{&} in @var{string}; the backslash is removed
+
+Quoting any part of @var{string} inhibits replacement in the
+expansion of the quoted portion, including replacement strings stored
+in shell variables.
+Backslash will escape @samp{&} in @var{string}; the backslash is removed
 in order to permit a literal @samp{&} in the replacement string.
-Pattern substitution performs the check for @samp{&} after expanding
-@var{string},
-so users should take care to quote backslashes intended to escape
-the @samp{&} and inhibit replacement so they survive any quote removal
-performed by the expansion of @var{string}.
+Users should take care if @var{string} is double-quoted to avoid
+unwanted interactions between the backslash and double-quoting, since
+backslash has special meaning within double quotes.
+Pattern substitution performs the check for unquoted @samp{&} after
+expanding @var{string},
+so users should ensure to properly quote any occurrences of @samp{&}
+they want to be taken literally in the replacement
+and ensure any instances of @samp{&} they want to be replaced are unquoted.
+
 For instance,
 
 @example
 var=abcdef
+rep='& '
 echo $@{var/abc/& @}
 echo "$@{var/abc/& @}"
-echo $@{var/abc/"& "@}
+echo $@{var/abc/$rep@}
+echo "$@{var/abc/$rep@}"
 @end example
 
 @noindent
-will display three lines of "abc def", while
+will display four lines of "abc def", while
 
 @example
 var=abcdef
+rep='& '
 echo $@{var/abc/\& @}
 echo "$@{var/abc/\& @}"
-echo $@{var/abc/"\& "@}
+echo $@{var/abc/"& "@}
+echo $@{var/abc/"$rep"@}
+@end example
+
+@noindent
+will display four lines of "& def".
+Like the pattern removal operators, double quotes surrounding the
+replacement string quote the expanded characters, while double quotes
+enclosing the entire parameter substitution do not, since
+the expansion is performed in a
+context that doesn't take any enclosing double quotes into account.
+
+Since backslash can escape @samp{&}, it can also escape a backslash in
+the replacement string.
+This means that @samp{\\} will insert a literal
+backslash into the replacement, so these two @code{echo} commands
+
+@example
+var=abcdef
+rep='\\&xyz'
+echo $@{var/abc/\\&xyz@}
+echo $@{var/abc/$rep@}
 @end example
 
 @noindent
-will display two lines of "abc def" and a third line of "& def".
-The first two are replaced because the backslash is removed by quote
-removal performed during the expansion of @var{string}
-(the expansion is performed in a
-context that doesn't take any enclosing double quotes into account, as
-with other word expansions).
-In the third case, the double quotes affect the expansion
-of @samp{\&}, and, because @samp{&} is not one of the characters for
-which backslash is special in double quotes,
-the backslash survives the expansion, inhibits the replacement,
-but is removed because it is treated specially.
-One could use @samp{\\&}, unquoted, as the replacement string to achive
-the same effect.
+will both output @samp{\abcxyzdef}.
+
 It should rarely be necessary to enclose only @var{string} in double
 quotes.
 
@@ -2586,26 +2632,27 @@ expansion as described below.
 
 Command substitution allows the output of a command to replace
 the command itself.
-Command substitution occurs when a command is enclosed as follows:
+The standard form of command substitution occurs when a command is
+enclosed as follows:
 @example
 $(@var{command})
 @end example
 @noindent
-or
+or (deprecated)
 @example
-`@var{command}`
+`@var{command}`.
 @end example
 
 @noindent
-Bash performs the expansion by executing @var{command} in a subshell environment
-and replacing the command substitution with the standard output of the
-command, with any trailing newlines deleted.
+Bash performs command substitution by executing @var{command} in a subshell
+environment and replacing the command substitution with the standard
+output of the command, with any trailing newlines deleted.
 Embedded newlines are not deleted, but they may be removed during
 word splitting.
 The command substitution @code{$(cat @var{file})} can be
 replaced by the equivalent but faster @code{$(< @var{file})}.
 
-When the old-style backquote form of substitution is used,
+With the old-style backquote form of substitution,
 backslash retains its literal meaning except when followed by
 @samp{$}, @samp{`}, or @samp{\}. 
 The first backquote not preceded by a backslash terminates the
@@ -2613,11 +2660,73 @@ command substitution.
 When using the @code{$(@var{command})} form, all characters between
 the parentheses make up the command; none are treated specially.
 
+There is an alternate form of command substitution:
+
+@example
+$@{@var{c} @var{command}; @}
+@end example
+
+@noindent
+which executes @var{command} in the current execution environment
+and captures its output, again with trailing newlines removed.
+
+The character @var{c} following the open brace must be a space, tab,
+newline, or @samp{|}, and the close brace must be in a position
+where a reserved word may appear (i.e., preceded by a command terminator
+such as semicolon).
+Bash allows the close brace to be joined to the remaining characters in
+the word without being followed by a shell metacharacter as a reserved
+word would usually require.
+
+Any side effects of @var{command} take effect immediately
+in the current execution environment and persist in the current 
+environment after the command completes (e.g., the @code{exit} builtin
+will exit the shell).
+
+This type of command substitution superficially resembles executing an
+unnamed shell function: local variables are created as when a shell
+function is executing, and the @code{return} builtin forces
+@var{command} to complete;
+however, the rest of the execution environment,
+including the positional parameters, is shared with the caller.
+
+If the first character following the open brace
+is a @samp{|}, the construct expands to the
+value of the @code{REPLY} shell variable after @var{command} executes,
+without removing any trailing newlines,
+and the standard output of @var{command} remains the same as in the
+calling shell.
+Bash creates @code{REPLY} as an initially-unset local variable when
+@var{command} executes, and restores @code{REPLY} to the value it had
+before the command substitution after @var{command} completes,
+as with any local variable.
+
+For example, this construct expands to @samp{12345}, and leaves the
+shell variable @code{X} unchanged in the current execution environment:
+
+@example
+
+$@{ local X=12345 ; echo $X; @}
+@end example
+
+@noindent
+(not declaring @code{X} as local would modify its value in the current
+environment, as with normal shell function execution),
+while this construct does not require any output to expand to
+@samp{12345}:
+
+@example
+$@{| REPLY=12345; @}
+@end example
+
+@noindent
+and restores @code{REPLY} to the value it had before the command substitution.
+
 Command substitutions may be nested.  To nest when using the backquoted
 form, escape the inner backquotes with backslashes.
 
-If the substitution appears within double quotes, word splitting and
-filename expansion are not performed on the results.
+If the substitution appears within double quotes, Bash does not perform
+word splitting and filename expansion on the results.
 
 @node Arithmetic Expansion
 @subsection Arithmetic Expansion
@@ -2691,9 +2800,10 @@ word splitting.
 The shell treats each character of @env{$IFS} as a delimiter, and splits
 the results of the other expansions into words using these characters
 as field terminators.
+
 If @env{IFS} is unset, or its value is exactly @code{<space><tab><newline>},
 the default, then sequences of
-@code{ <space>}, @code{<tab>}, and @code{<newline>}
+@code{space}, @code{tab}, and @code{newline}
 at the beginning and end of the results of the previous
 expansions are ignored, and any sequence of @env{IFS}
 characters not at the beginning or end serves to delimit words.
@@ -2706,7 +2816,10 @@ Any character in @env{IFS} that is not @env{IFS}
 whitespace, along with any adjacent @env{IFS}
 whitespace characters, delimits a field.  A sequence of @env{IFS}
 whitespace characters is also treated as a delimiter.
+
 If the value of @env{IFS} is null, no word splitting occurs.
+If @env{IFS} is unset, word splitting behaves as if it contained
+the default value @code{<space><tab><newline>}.
 
 Explicit null arguments (@code{""} or @code{''}) are retained
 and passed to commands as empty strings.
@@ -2757,6 +2870,9 @@ must be matched explicitly, unless the shell option @code{dotglob} is set.
 In order to match the filenames @samp{.} and @samp{..},
 the pattern must begin with @samp{.} (for example, @samp{.?}),
 even if @code{dotglob} is set.
+If the @code{globskipdots} shell option is enabled, the filenames
+@samp{.} and @samp{..} are never matched, even if the pattern begins
+with a @samp{.}.
 When not matching filenames, the @samp{.} character is not treated specially.
 
 When matching a filename, the slash character must always be
@@ -2766,6 +2882,7 @@ below (@pxref{Pattern Matching}).
 
 See the description of @code{shopt} in @ref{The Shopt Builtin},
 for a description of the @code{nocaseglob}, @code{nullglob},
+@code{globskipdots},
 @code{failglob}, and @code{dotglob} options.
 
 The @env{GLOBIGNORE}
@@ -2788,6 +2905,10 @@ To get the old behavior of ignoring filenames beginning with a
 The @code{dotglob} option is disabled when @env{GLOBIGNORE}
 is unset.
 
+After the pattern is expanded and matched against filenames, the value of the
+@env{GLOBSORT} variable controls how the results are sorted, as described
+below (@pxref{Bash Variables}).
+
 @node Pattern Matching
 @subsubsection Pattern Matching
 @cindex pattern matching
@@ -2824,14 +2945,16 @@ then any character not enclosed is matched.  A @samp{@minus{}}
 may be matched by including it as the first or last character
 in the set.  A @samp{]} may be matched by including it as the first
 character in the set.
-The sorting order of characters in range expressions is determined by
+The sorting order of characters in range expressions,
+and the characters included in the range,
+are determined by
 the current locale and the values of the
 @env{LC_COLLATE} and @env{LC_ALL} shell variables, if set.
 
 For example, in the default C locale, @samp{[a-dx-z]} is equivalent to
 @samp{[abcdxyz]}.  Many locales sort characters in dictionary order, and in
 these locales @samp{[a-dx-z]} is typically not equivalent to @samp{[abcdxyz]};
-it might be equivalent to @samp{[aBbCcDdxXyYz]}, for example.  To obtain
+it might be equivalent to @samp{[aBbCcDdxYyZz]}, for example.  To obtain
 the traditional interpretation of ranges in bracket expressions, you can
 force the use of the C locale by setting the @env{LC_COLLATE} or
 @env{LC_ALL} environment variable to the value @samp{C}, or enable the
@@ -2885,6 +3008,12 @@ Matches one of the given patterns.
 Matches anything except one of the given patterns.
 @end table
 
+The @code{extglob} option changes the behavior of the parser, since the
+parentheses are normally treated as operators with syntactic meaning.
+To ensure that extended matching patterns are parsed correctly, make sure
+that @code{extglob} is enabled before parsing constructs containing the
+patterns, including shell functions and command substitutions.
+
 When matching filenames, the @code{dotglob} shell option determines
 the set of filenames that are tested:
 when @code{dotglob} is enabled, the set of filenames includes all files
@@ -2972,7 +3101,7 @@ before the standard output was redirected to @var{dirlist}.
 Bash handles several filenames specially when they are used in
 redirections, as described in the following table.
 If the operating system on which Bash is running provides these
-special files, bash will use them; otherwise it will emulate them
+special files, Bash will use them; otherwise it will emulate them
 internally with the behavior described below.
 
 @table @code
@@ -3098,9 +3227,9 @@ This is semantically equivalent to
 
 @subsection Here Documents
 This type of redirection instructs the shell to read input from the
-current source until a line containing only @var{word}
-(with no trailing blanks) is seen.  All of
-the lines read up to that point are then used as the standard
+current source until a line containing only @var{delimiter}
+(with no trailing blanks) is seen.
+All of the lines read up to that point are then used as the standard
 input (or file descriptor @var{n} if @var{n} is specified) for a command.
 
 The format of here-documents is:
@@ -3112,10 +3241,13 @@ The format of here-documents is:
 
 No parameter and variable expansion, command substitution,
 arithmetic expansion, or filename expansion is performed on
-@var{word}.  If any part of @var{word} is quoted, the
+@var{word}.
+
+If any part of @var{word} is quoted, the
 @var{delimiter} is the result of quote removal on @var{word},
 and the lines in the here-document are not expanded.
 If @var{word} is unquoted,
+@var{delimiter} is @var{word} itself,
 all lines of the here-document are subjected to
 parameter expansion, command substitution, and arithmetic expansion,
 the character sequence @code{\newline} is ignored, and @samp{\}
@@ -3276,8 +3408,8 @@ were no command substitutions, the command exits with a status of zero.
 @cindex command search
 
 After a command has been split into words, if it results in a
-simple command and an optional list of arguments, the following
-actions are taken.
+simple command and an optional list of arguments, the shell performs
+the following actions.
 
 @enumerate
 @item
@@ -3725,7 +3857,7 @@ Read and execute commands from the @var{filename} argument in the
 current shell context.  If @var{filename} does not contain a slash,
 the @env{PATH} variable is used to find @var{filename},
 but @var{filename} does not need to be executable.
-When Bash is not in @sc{posix} mode, the current directory is searched
+When Bash is not in @sc{posix} mode, it searches the current directory
 if @var{filename} is not found in @env{$PATH}.
 If any @var{arguments} are supplied, they become the positional
 parameters when @var{filename} is executed.  Otherwise the positional
@@ -3755,7 +3887,7 @@ The return status is zero unless @var{n} is not greater than or equal to 1.
 @item cd
 @btindex cd
 @example
-cd [-L|[-P [-e]] [-@@] [@var{directory}]
+cd [-L|[-P [-e]]] [-@@] [@var{directory}]
 @end example
 
 Change the current working directory to @var{directory}.
@@ -3884,6 +4016,14 @@ The return status is zero unless an invalid option is supplied, one of
 the names is not a valid shell variable name, or @option{-f} is supplied
 with a name that is not a shell function.
 
+@item false
+@btindex false
+@example
+false
+@end example
+
+Does nothing, returns a non-zero status.
+
 @item getopts
 @btindex getopts
 @example
@@ -3945,15 +4085,16 @@ If @code{getopts} is silent, then a colon (@samp{:}) is placed in
 hash [-r] [-p @var{filename}] [-dt] [@var{name}]
 @end example
 
-Each time @code{hash} is invoked, it remembers the full pathnames of the
+Each time @code{hash} is invoked, it remembers the full filenames of the
 commands specified as @var{name} arguments,
 so they need not be searched for on subsequent invocations.
 The commands are found by searching through the directories listed in
 @env{$PATH}.
-Any previously-remembered pathname is discarded.
+Any previously-remembered filename is discarded.
 The @option{-p} option inhibits the path search, and @var{filename} is
 used as the location of @var{name}.
 The @option{-r} option causes the shell to forget all remembered locations.
+Assigning to the @env{PATH} variable also clears all hashed filenames.
 The @option{-d} option causes the shell to forget the remembered location
 of each @var{name}.
 If the @option{-t} option is supplied, the full pathname to which each
@@ -4155,8 +4296,30 @@ The expression is parsed and evaluated according to precedence
 using the rules listed above.
 @end table
 
-When used with @code{test} or @samp{[}, the @samp{<} and @samp{>}
+If the shell is not in @sc{posix} mode,
+when used with @code{test} or @samp{[}, the @samp{<} and @samp{>}
 operators sort lexicographically using ASCII ordering.
+If the shell is in @sc{posix} mode, these operators use the current locale.
+
+The historical operator-precedence parsing with 4 or more arguments can
+lead to ambiguities when it encounters strings that look like primaries.
+The @sc{posix} standard has deprecated the @option{-a} and @option{-o}
+primaries and enclosing expressions within parentheses.
+Scripts should no longer use them.
+It's much more reliable to restrict test invocations to a single primary,
+and to replace uses of @option{-a} and @option{-o} with the shell's
+@code{&&} and @code{||} list operators. For example, use
+
+@example
+test -n string1 && test -n string2
+@end example
+
+@noindent
+instead of
+
+@example
+test -n string1 -a -n string2
+@end example
 
 @item times
 @btindex times
@@ -4170,41 +4333,54 @@ The return status is zero.
 @item trap
 @btindex trap
 @example
-trap [-lp] [@var{arg}] [@var{sigspec} @dots{}]
+trap [-Plp] [@var{action}] [@var{sigspec} @dots{}]
 @end example
 
-The commands in @var{arg} are to be read and executed when the
-shell receives signal @var{sigspec}.  If @var{arg} is absent (and
+The @var{action} is a command that is read and executed when the
+shell receives signal @var{sigspec}. If @var{action} is absent (and
 there is a single @var{sigspec}) or
 equal to @samp{-}, each specified signal's disposition is reset
 to the value it had when the shell was started.
-If @var{arg} is the null string, then the signal specified by
+If @var{action} is the null string, then the signal specified by
 each @var{sigspec} is ignored by the shell and commands it invokes.
-If @var{arg} is not present and @option{-p} has been supplied,
-the shell displays the trap commands associated with each @var{sigspec}.
-If no arguments are supplied, or
-only @option{-p} is given, @code{trap} prints the list of commands
-associated with each signal number in a form that may be reused as
-shell input.
-The @option{-l} option causes the shell to print a list of signal names
+
+If no arguments are supplied, @code{trap} prints the actions
+associated with each trapped signal
+as a set of @code{trap} commands that can be reused as shell input to
+restore the current signal dispositions.
+If @var{action} is not present and @option{-p} has been supplied,
+@code{trap} displays the trap commands associated with each @var{sigspec},
+or, if no @var{sigspec}s are supplied, for all trapped signals,
+as a set of @code{trap} commands that can be reused as shell input to
+restore the current signal dispositions.
+The @option{-P} option behaves similarly, but displays only the actions
+associated with each @var{sigspec} argument.
+@option{-P} requires at least one @var{sigspec} argument.
+The @option{-P} or @option{-p} options to @code{trap} may be
+used in a subshell environment (e.g., command substitution) and,
+as long as they are used before @code{trap} is used to change a
+signal's handling, will display the state of its parent's traps.
+
+The @option{-l} option causes @code{trap} to print a list of signal names
 and their corresponding numbers.
 Each @var{sigspec} is either a signal name or a signal number.
 Signal names are case insensitive and the @code{SIG} prefix is optional.
 
 If a @var{sigspec}
-is @code{0} or @code{EXIT}, @var{arg} is executed when the shell exits.
-If a @var{sigspec} is @code{DEBUG}, the command @var{arg} is executed
+is @code{0} or @code{EXIT}, @var{action} is executed when the shell exits.
+If a @var{sigspec} is @code{DEBUG}, @var{action} is executed
 before every simple command, @code{for} command, @code{case} command,
-@code{select} command, every arithmetic @code{for} command, and before
-the first command executes in a shell function.
+@code{select} command, (( arithmetic command, [[ conditional command,
+arithmetic @code{for} command,
+and before the first command executes in a shell function.
 Refer to the description of the @code{extdebug} option to the
 @code{shopt} builtin (@pxref{The Shopt Builtin}) for details of its
 effect on the @code{DEBUG} trap.
-If a @var{sigspec} is @code{RETURN}, the command @var{arg} is executed
+If a @var{sigspec} is @code{RETURN}, @var{action} is executed
 each time a shell function or a script executed with the @code{.} or
 @code{source} builtins finishes executing.
 
-If a @var{sigspec} is @code{ERR}, the command @var{arg
+If a @var{sigspec} is @code{ERR}, @var{action
 is executed whenever
 a pipeline (which may consist of a single simple
 command), a list, or a compound command returns a
@@ -4221,13 +4397,23 @@ status is being inverted using @code{!}.
 These are the same conditions obeyed by the @code{errexit} (@option{-e})
 option.
 
-Signals ignored upon entry to the shell cannot be trapped or reset.
+Signals ignored upon entry to a non-interactive shell cannot be trapped or
+reset.
+Interactive shells permit trapping signals ignored on entry.
 Trapped signals that are not being ignored are reset to their original
 values in a subshell or subshell environment when one is created.
 
 The return status is zero unless a @var{sigspec} does not specify a
 valid signal.
 
+@item true
+@btindex true
+@example
+true
+@end example
+
+Does nothing, returns a 0 status.
+
 @item umask
 @btindex umask
 @example
@@ -4718,7 +4904,9 @@ The @var{option} can be any of the options accepted by @code{declare}.
 children.
 If @var{name} is @samp{-}, the set of shell options is made local to the
 function in which @code{local} is invoked: shell options changed using
-the @code{set} builtin inside the function are restored to their original
+the @code{set} builtin inside the function
+after the call to @code{local}
+are restored to their original
 values when the function returns.
 The restore is effected as if a series of @code{set} commands were executed
 to restore the values that were in place before the function.
@@ -4804,8 +4992,9 @@ plain characters, which are simply copied to standard output, character
 escape sequences, which are converted and copied to the standard output, and
 format specifications, each of which causes printing of the next successive
 @var{argument}.
-In addition to the standard @code{printf(1)} formats, @code{printf}
-interprets the following extensions:
+In addition to the standard @code{printf(3)} format characters
+@code{csndiouxXeEfFgGaA},
+@code{printf} interprets the following additional format specifiers:
 
 @table @code
 @item %b
@@ -4815,6 +5004,12 @@ corresponding @var{argument} in the same way as @code{echo -e}
 @item %q
 Causes @code{printf} to output the
 corresponding @var{argument} in a format that can be reused as shell input.
+@code{%q} and @code{%Q}P use the ANSI-C quoting style (@pxref{ANSI-C Quoting})
+if any characters
+in the argument string require it, and backslash quoting otherwise.
+If the format string uses the @code{printf} @var{alternate form}, these two
+formats quote the argument string using single quotes.
+
 @item %Q
 like @code{%q}, but applies any supplied precision to the @var{argument}
 before quoting it.
@@ -4830,11 +5025,18 @@ This is an exception to the usual @code{printf} behavior.
 @end table
 
 @noindent
-The %b, %q, and %T directives all use the field width and precision
+The %b, %q, and %T format specifiers all use the field width and precision
 arguments from the format specification and write that many bytes from    
 (or use that wide a field for) the expanded argument, which usually
 contains more characters than the original.
 
+The %n format specifier accepts a corresponding argument that is treated
+as a shell variable name.
+
+The %s and %c format specifiers accept an l (long) modifier, which forces
+them to convert the argument string to a wide-character string and apply
+any supplied field width and precision in terms of characters, not bytes.
+
 Arguments to non-string format specifiers are treated as C language constants,
 except that a leading plus or minus sign is allowed, and if the leading
 character is a single or double quote, the value is the ASCII value of
@@ -4843,8 +5045,10 @@ the following character.
 The @var{format} is reused as necessary to consume all of the @var{arguments}.
 If the @var{format} requires more @var{arguments} than are supplied, the
 extra format specifications behave as if a zero value or null string, as
-appropriate, had been supplied.  The return value is zero on success,
-non-zero on failure.
+appropriate, had been supplied.
+The return value is zero on success,
+non-zero if an invalid option is supplied or a write or assignment error
+occurs.
 
 @item read
 @btindex read
@@ -4987,27 +5191,32 @@ For each @var{name}, indicate how it would be interpreted if used as a
 command name.
 
 If the @option{-t} option is used, @code{type} prints a single word
-which is one of @samp{alias}, @samp{function}, @samp{builtin},
-@samp{file} or @samp{keyword},
-if @var{name} is an alias, shell function, shell builtin,
-disk file, or shell reserved word, respectively.
+which is one of @samp{alias}, @samp{keyword}, @samp{function},
+@samp{builtin}, or @samp{file},
+if @var{name} is an alias, shell reserved word, shell function,
+shell builtin, or executable disk file, respectively.
 If the @var{name} is not found, then nothing is printed, and
 @code{type} returns a failure status.
 
 If the @option{-p} option is used, @code{type} either returns the name
-of the disk file that would be executed, or nothing if @option{-t}
-would not return @samp{file}.
+of the executable file that would be found by searching @code{$PATH},
+or nothing if @option{-t} would not return @samp{file}.
 
 The @option{-P} option forces a path search for each @var{name}, even if
 @option{-t} would not return @samp{file}.
 
-If a command is hashed, @option{-p} and @option{-P} print the hashed value,
-which is not necessarily the file that appears first in @code{$PATH}.
+If a @var{name} is present in the table of hashed commands,
+options @option{-p} and @option{-P} print the hashed value, which is not
+necessarily the file that appears first in @code{$PATH}.
 
 If the @option{-a} option is used, @code{type} returns all of the places
-that contain an executable named @var{file}.
-This includes aliases and functions, if and only if the @option{-p} option
-is not also used.
+that contain a command named @var{name}.
+This includes aliases, reserved words, functions, and builtins,
+but the path search options (@option{-p} and @option{-P}) can be supplied
+to restrict the output to executable files.
+If @option{-a} is supplied with @option{-p}, @code{type} does not look
+in the table of hashed commands, and only performs a @code{PATH}
+search for @var{name}.
 
 If the @option{-f} option is used, @code{type} does not attempt to find
 shell functions, as with the @code{command} builtin.
@@ -5175,6 +5384,8 @@ parameters, or to display the names and values of shell variables.
 @example
 set [-abefhkmnptuvxBCEHPT] [-o @var{option-name}] [--] [-] [@var{argument} @dots{}]
 set [+abefhkmnptuvxBCEHPT] [+o @var{option-name}] [--] [-] [@var{argument} @dots{}]
+set -o
+set +o
 @end example
 
 If no options or arguments are supplied, @code{set} displays the names
@@ -5255,7 +5466,15 @@ This option is ignored by interactive shells.
 
 @item -o @var{option-name}
 
-Set the option corresponding to @var{option-name}:
+Set the option corresponding to @var{option-name}.
+If @option{-o} is supplied with no @var{option-name},
+@code{set} prints the current shell options settings.
+If @option{+o} is supplied with no @var{option-name},
+@code{set} prints a series of
+@code{set}
+commands to recreate the current option settings
+on the standard output.
+Valid option names are:
 
 @table @code
 @item allexport
@@ -5370,7 +5589,9 @@ Exit after reading and executing one command.
 
 @item -u
 Treat unset variables and parameters other than the special parameters
-@samp{@@} or @samp{*} as an error when performing parameter expansion.
+@samp{@@} or @samp{*},
+or array variables subscripted with @samp{@@} or @samp{*},
+as an error when performing parameter expansion.
 An error message will be written to the standard error, and a non-interactive
 shell will exit.
 
@@ -5380,9 +5601,9 @@ Print shell input lines as they are read.
 @item -x
 Print a trace of simple commands, @code{for} commands, @code{case}
 commands, @code{select} commands, and arithmetic @code{for} commands
-and their arguments or associated word lists after they are
-expanded and before they are executed.  The value of the @env{PS4}
-variable is expanded and the resultant value is printed before
+and their arguments or associated word lists to standard error
+after they are expanded and before they are executed.
+The shell prints the expanded value of the @env{PS4} variable before
 the command and its expanded arguments.
 
 @item -B
@@ -5516,12 +5737,16 @@ option.
 The list of @code{shopt} options is:
 @table @code
 
-@item assoc_expand_once
-If set, the shell suppresses multiple evaluation of associative array
-subscripts during arithmetic expression evaluation, while executing
+@item array_expand_once
+If set, the shell suppresses multiple evaluation of
+associative and indexed array subscripts
+during arithmetic expression evaluation, while executing
 builtins that can perform variable assignments,
 and while executing builtins that perform array dereferencing.
 
+@item assoc_expand_once
+Deprecated; a synonym for @code{array_expand_once}. 
+
 @item autocd
 If set, a command name that is the name of a directory is executed as if
 it were the argument to the @code{cd} command.
@@ -5589,7 +5814,7 @@ completed.
 This means that dollar signs in variable names that expand to directories
 will not be quoted;
 however, any dollar signs appearing in filenames will not be quoted, either.
-This is active only when bash is using backslashes to quote completed
+This is active only when Bash is using backslashes to quote completed
 filenames.
 This variable is set by default, which is the default Bash behavior in
 versions through 4.2.
@@ -5597,7 +5822,7 @@ versions through 4.2.
 @item direxpand
 If set, Bash
 replaces directory names with the results of word expansion when performing
-filename completion.  This changes the contents of the readline editing
+filename completion.  This changes the contents of the Readline editing
 buffer.
 If not set, Bash attempts to preserve what the user typed.
 
@@ -5690,6 +5915,12 @@ is not taken into account, so
 @samp{b} will not collate between @samp{A} and @samp{B},
 and upper-case and lower-case ASCII characters will collate together.   
 
+@item globskipdots
+If set, filename expansion will never match the filenames
+@samp{.} and @samp{..},
+even if the pattern begins with a @samp{.}.
+This option is enabled by default.
+
 @item globstar
 If set, the pattern @samp{**} used in a filename expansion context will
 match all files and zero or more directories and subdirectories.
@@ -6012,7 +6243,7 @@ subsequently reset.
 
 @item BASH_ARGC
 An array variable whose values are the number of parameters in each
-frame of the current bash execution call stack.  The number of
+frame of the current Bash execution call stack.  The number of
 parameters to the current subroutine (shell function or script executed
 with @code{.} or @code{source}) is at the top of the stack.  When a
 subroutine is executed, the number of parameters passed is pushed onto
@@ -6024,9 +6255,10 @@ builtin).
 Setting @code{extdebug} after the shell has started to execute a script,
 or referencing this variable when @code{extdebug} is not set,
 may result in inconsistent values.
+Assignments to @env{BASH_ARGC} have no effect, and it may not be unset.
 
 @item BASH_ARGV
-An array variable containing all of the parameters in the current bash
+An array variable containing all of the parameters in the current Bash
 execution call stack.  The final parameter of the last subroutine call
 is at the top of the stack; the first parameter of the initial call is
 at the bottom.  When a subroutine is executed, the parameters supplied
@@ -6038,6 +6270,7 @@ builtin).
 Setting @code{extdebug} after the shell has started to execute a script,
 or referencing this variable when @code{extdebug} is not set,
 may result in inconsistent values.
+Assignments to @env{BASH_ARGV} have no effect, and it may not be unset.
 
 @item BASH_ARGV0
 When referenced, this variable expands to the name of the shell or shell
@@ -6102,12 +6335,21 @@ where each corresponding member of @env{FUNCNAME} was invoked.
 @code{$@{FUNCNAME[$i]@}} was called (or @code{$@{BASH_LINENO[$i-1]@}} if
 referenced within another shell function). 
 Use @code{LINENO} to obtain the current line number.
+Assignments to @env{BASH_LINENO} have no effect, and it may not be unset.
 
 @item BASH_LOADABLES_PATH
 A colon-separated list of directories in which the shell looks for
 dynamically loadable builtins specified by the
 @code{enable} command.
 
+@item BASH_MONOSECONDS
+Each time this variable is referenced, it expands to the value returned
+by the system's monotonic clock, if one is available.
+If there is no monotonic clock, this is equivalent to @env{EPOCHSECONDS}.
+If @env{BASH_MONOSECONDS}
+is unset, it loses its special properties, even if it is
+subsequently reset.
+
 @item BASH_REMATCH
 An array variable whose members are assigned by the @samp{=~} binary
 operator to the @code{[[} conditional command
@@ -6123,6 +6365,7 @@ corresponding shell function names in the @code{FUNCNAME} array
 variable are defined.
 The shell function @code{$@{FUNCNAME[$i]@}} is defined in the file
 @code{$@{BASH_SOURCE[$i]@}} and called from @code{$@{BASH_SOURCE[$i+1]@}}
+Assignments to @env{BASH_SOURCE} have no effect, and it may not be unset.
 
 @item BASH_SUBSHELL
 Incremented by one within each subshell or subshell environment when
@@ -6132,6 +6375,13 @@ If @env{BASH_SUBSHELL}
 is unset, it loses its special properties, even if it is
 subsequently reset.
 
+@item BASH_TRAPSIG
+Set to the signal number corresponding to the trap action being executed
+during its execution.
+See the description of @code{trap}
+(@pxref{Bourne Shell Builtins})
+for information about signal numbers and trap execution.
+
 @item BASH_VERSINFO
 A readonly array variable (@pxref{Arrays})
 whose members hold version information for this instance of Bash.
@@ -6270,7 +6520,7 @@ starts with value @samp{t}, it assumes that the shell is running in an
 Emacs shell buffer and disables line editing.
 
 @item ENV
-Expanded and executed similarlty to @code{BASH_ENV}
+Expanded and executed similarly to @code{BASH_ENV}
 (@pxref{Bash Startup Files})
 when an interactive shell is invoked in
 @sc{posix} Mode (@pxref{Bash POSIX Mode}).
@@ -6360,6 +6610,38 @@ of matches.
 The pattern matching honors the setting of the @code{extglob} shell
 option.
 
+@item GLOBSORT
+Control how the results of filename expansion are sorted.
+The value of this variable specifies the sort criteria and sort order for
+the results of filename expansion.
+If this variable is unset or set to the null string, filename expansion
+uses the historial behavior of sorting by name.
+If set, a valid value begins with an optional @samp{+}, which is ignored,
+or @samp{-}, which reverses the sort order from ascending to descending,
+followed by a sort specifier.
+The valid sort specifiers are
+@samp{name},
+@samp{size},
+@samp{mtime},
+@samp{atime},
+@samp{ctime},
+and
+@samp{blocks},
+which sort the files on name, file size, modification time, access time,
+inode change time, and number of blocks, respectively.
+
+For example, a value of @code{-mtime} sorts the results in descending
+order by modification time (newest first).
+
+A sort specifier of @samp{nosort} disables sorting completely; the results
+are returned in the order they are read from the file system,.
+
+If the sort specifier is missing, it defaults to @var{name},
+so a value of @samp{+} is equivalent to the null string,
+and a value of @samp{-} sorts by name in descending order.
+
+Any invalid value restores the historical sorting behavior.
+
 @item GROUPS
 An array variable containing the list of groups of which the current    
 user is a member.
@@ -6733,8 +7015,8 @@ The CPU percentage, computed as (%U + %S) / %R.
 The optional @var{p} is a digit specifying the precision, the number of
 fractional digits after a decimal point.
 A value of 0 causes no decimal point or fraction to be output.
-At most three places after the decimal point may be specified; values
-of @var{p} greater than 3 are changed to 3.
+At most six places after the decimal point may be specified;
+values of @var{p} greater than 6 are changed to 6.
 If @var{p} is not specified, the value 3 is used. 
 
 The optional @code{l} specifies a longer format, including minutes, of
@@ -7054,10 +7336,12 @@ No other startup files are read.
 @subsubheading Invoked by remote shell daemon
 
 Bash attempts to determine when it is being run with its standard input
-connected to a network connection, as when executed by the remote shell
-daemon, usually @code{rshd}, or the secure shell daemon @code{sshd}.
-If Bash determines it is being run in
-this fashion, it reads and executes commands from @file{~/.bashrc}, if that
+connected to a network connection, as when executed by
+the historical remote shell daemon, usually @code{rshd},
+or the secure shell daemon @code{sshd}.
+If Bash
+determines it is being run non-interactively in this fashion,
+it reads and executes commands from @file{~/.bashrc}, if that
 file exists and is readable.
 It will not do this if invoked as @code{sh}.
 The @option{--norc} option may be used to inhibit this behavior, and the
@@ -7084,7 +7368,7 @@ the same, but the effective user id is not reset.
 @menu
 * What is an Interactive Shell?::      What determines whether a shell is Interactive.
 * Is this Shell Interactive?:: How to tell if a shell is interactive.
-* Interactive Shell Behavior:: What changes in a interactive shell?
+* Interactive Shell Behavior:: What changes in an interactive shell?
 @end menu
 
 @node What is an Interactive Shell?
@@ -7419,6 +7703,11 @@ equal-precedence operators.
 The levels are listed in order of decreasing precedence. 
 
 @table @code
+@cindex arithmetic operators
+@cindex unary arithmetic operators
+@cindex binary arithmetic operators
+@cindex conditional arithmetic operator
+@cindex bitwise arithmetic operators
 
 @item @var{id}++ @var{id}--
 variable post-increment and post-decrement 
@@ -7465,7 +7754,7 @@ logical AND
 @item ||
 logical OR
 
-@item expr ? expr : expr
+@item expr ? if-true-expr : if-false-expr
 conditional operator
 
 @item = *= /= %= += -= <<= >>= &= ^= |=
@@ -7512,14 +7801,19 @@ rules above.
 @section Aliases
 @cindex alias expansion
 
-@dfn{Aliases} allow a string to be substituted for a word when it is used
-as the first word of a simple command.
-The shell maintains a list of aliases that may be set and unset with
-the @code{alias} and @code{unalias} builtin commands.
+@dfn{Aliases} allow a string to be substituted for a word that is in
+a position in the input where it can be the first word of a simple
+command. Aliases have names and corresponding values that are set
+and unset using the @code{alias} and @code{unalias} builtin commands
+(@pxref{Shell Builtin Commands}).
+
+If the shell reads an unquoted word in the right position, it checks
+the word to see if it matches an alias name. If it matches, the shell
+replaces the word with the alias value, and reads that value as if it
+had been read instead of the word.
+The shell doesn't look at any characters following the word before
+attempting alias substitution. 
 
-The first word of each simple command, if unquoted, is checked to see
-if it has an alias.
-If so, that word is replaced by the text of the alias.
 The characters @samp{/}, @samp{$}, @samp{`}, @samp{=} and any of the
 shell metacharacters or quoting characters listed above may not appear
 in an alias name.
@@ -7531,6 +7825,7 @@ is not expanded a second time.
 This means that one may alias @code{ls} to @code{"ls -F"},
 for instance, and Bash does not try to recursively expand the
 replacement text.
+
 If the last character of the alias value is a
 @code{blank}, then the next command word following the
 alias is also checked for alias expansion.
@@ -7541,7 +7836,7 @@ command, and removed with the @code{unalias} command.
 There is no mechanism for using arguments in the replacement text,
 as in @code{csh}.
 If arguments are needed, use a shell function
-(@pxref{Shell Functions}).
+(@pxref{Shell Functions}) instead.
 
 Aliases are not expanded when the shell is not interactive,
 unless the @code{expand_aliases} shell option is set using
@@ -7629,8 +7924,12 @@ the optional subscript is supplied, that index is assigned to;
 otherwise the index of the element assigned is the last index assigned
 to by the statement plus one.  Indexing starts at zero.
 
-Each @var{value} in the list undergoes all the shell expansions
-described above (@pxref{Shell Expansions}).
+Each @var{value} in the list undergoes the shell expansions
+described above (@pxref{Shell Expansions}),
+but @var{value}s that are valid variable assignments
+including the brackets and subscript do not undergo
+brace expansion and word splitting, as with individual
+variable assignments.
 
 When assigning to an associative array, the words in a compound assignment
 may be either assignment statements, for which the subscript is required,
@@ -7654,6 +7953,9 @@ interpreted as relative to one greater than the maximum index of
 @var{name}, so negative indices count back from the end of the
 array, and an index of -1 references the last element.
 
+The @samp{+=} operator will append to an array variable when assigning
+using the compound assignment syntax; see @ref{Shell Parameters} above.
+
 Any element of an array may be referenced using
 @code{$@{@var{name}[@var{subscript}]@}}.
 The braces are required to avoid
@@ -8039,9 +8341,62 @@ such as @code{jails}, @code{zones}, or @code{containers}.
 
 
 @node Bash POSIX Mode
-@section Bash POSIX Mode
+@section Bash and POSIX
+
+@subsection What is POSIX?
+@cindex POSIX description
+
+@sc{posix} is the name for a family of standards based on Unix.
+A number of Unix services, tools, and functions are part of the standard,
+ranging from the basic system calls and C library functions to common
+applications and tools to system administration and management.
+
+The @sc{posix} Shell and Utilities standard was originally developed by
+IEEE Working Group 1003.2 (POSIX.2).
+The first edition of the 1003.2 standard was published in 1992.
+It was merged with the original IEEE 1003.1 Working Group and is
+currently maintained by the Austin Group (a joint working group of the
+IEEE, The Open Group and ISO/IEC SC22/WG15).
+Today the Shell and Utilities are a volume within the set of documents that
+make up IEEE Std 1003.1-2017, and thus the former POSIX.2 (from 1992)
+is now part of the current unified @sc{posix} standard.
+
+The Shell and Utilities volume concentrates on the command
+interpreter interface and utility programs commonly executed from
+the command line or by other programs.
+The standard is freely available on the web at
+@url{https://pubs.opengroup.org/onlinepubs/9699919799/utilities/contents.html}.
+
+Bash is concerned with the aspects of the shell's behavior defined
+by the @sc{posix} Shell and Utilities volume.  The shell command
+language has of course been standardized, including the basic flow
+control and program execution constructs, I/O redirection and
+pipelines, argument handling, variable expansion, and quoting.
+
+The @i{special} builtins, which must be implemented as part of the
+shell to provide the desired functionality, are specified as
+being part of the shell; examples of these are @code{eval} and
+@code{export}.
+Other utilities appear in the sections of POSIX not
+devoted to the shell which are commonly (and in some cases must
+be) implemented as builtin commands, such as
+@code{read} and @code{test}.
+POSIX also specifies aspects of the shell's interactive
+behavior, including job control and command
+line editing.
+Only vi-style line editing commands have been
+standardized; emacs editing commands were left out due to
+objections.
+
+@subsection Bash POSIX Mode
 @cindex POSIX Mode
 
+Although Bash is an implementation of the @sc{posix} shell
+specification, there are areas where the Bash default behavior
+differs from the specification.
+The Bash @dfn{posix mode} changes the Bash
+behavior in these areas so that it conforms to the standard more closely. 
+
 Starting Bash with the @option{--posix} command-line option or executing
 @samp{set -o posix} while Bash is running will cause Bash to conform more
 closely to the @sc{posix} standard by changing the behavior to
@@ -8082,6 +8437,13 @@ Alias expansion is always enabled, even in non-interactive shells.
 Reserved words appearing in a context where reserved words are recognized
 do not undergo alias expansion.
 
+@item
+Alias expansion is performed when initially parsing a command substitution.
+The default mode generally defers it, when enabled, until the command
+substitution is executed. This means that command substitution will not
+expand aliases that are defined after the command substitution is initially
+parsed (e.g., as part of a function definition).
+
 @item
 The @sc{posix} @env{PS1} and @env{PS2} expansions of @samp{!} to
 the history number and @samp{!!} to @samp{!} are enabled,
@@ -8118,6 +8480,11 @@ causes a fatal syntax error in non-interactive shells.
 Function names may not be the same as one of the @sc{posix} special
 builtins.
 
+@item
+Even if a shell function whose name contains a slash was defined before
+entering @sc{posix} mode, the shell will not execute a function whose name
+contains one or more slashes.
+
 @item
 @sc{posix} special builtins are found before shell functions
 during command lookup.
@@ -8166,6 +8533,12 @@ the @sc{posix} standard, and include things like passing incorrect options,
 redirection errors, variable assignment errors for assignments preceding
 the command name, and so on.
 
+@item
+The @code{unset} builtin with the @option{-v} option specified returns a
+fatal error if it attempts to unset a @code{readonly} or @code{non-unsettable}
+variable, or encounters a variable name argument that is an invalid identifier,
+which causes a non-interactive shell to exit.
+
 @item
 A non-interactive shell exits with an error status if a variable
 assignment error occurs when no command name follows the assignment
@@ -8207,7 +8580,7 @@ While variable indirection is available, it may not be applied to the
 @samp{#} and @samp{?} special parameters.
 
 @item
-When expanding the @samp{*} special parameter in a pattern context where the
+Expanding the @samp{*} special parameter in a pattern context where the
 expansion is double-quoted does not treat the @code{$*} as if it were
 double-quoted.
 
@@ -8251,8 +8624,9 @@ signal to the original disposition, they should use @samp{-} as the
 first argument.
 
 @item
-@code{trap -p} displays signals whose dispositions are set to SIG_DFL and
-those that were ignored when the shell started.
+@code{trap -p} without arguments displays signals whose dispositions are
+set to SIG_DFL and those that were ignored when the shell started, not
+just trapped signals.
 
 @item
 The @code{.} and @code{source} builtins do not search the current directory
@@ -8311,6 +8685,10 @@ indication of whether or not a history entry has been modified.
 @item
 The default editor used by @code{fc} is @code{ed}.
 
+@item
+If there are too many arguments supplied to @code{fc -s}, @code{fc} prints
+an error message and returns failure.
+
 @item
 The @code{type} and @code{command} builtins will not report a non-executable
 file as having been found, though the shell will attempt to execute such a
@@ -8341,10 +8719,39 @@ has been set.
 If Bash receives a trapped signal while executing @code{read}, the trap
 handler executes and @code{read} returns an exit status greater than 128.
 
+@item
+The @code{printf} builtin uses @code{double} (via @code{strtod}) to convert
+arguments corresponding to floating point conversion specifiers, instead of
+@code{long double} if it's available. The @samp{L} length modifier forces
+@code{printf} to use @code{long double} if it's available.
+
 @item
 Bash removes an exited background process's status from the list of such
 statuses after the @code{wait} builtin is used to obtain it.
 
+@item
+A double quote character (@samp{"}) is treated specially when it appears
+in a backquoted command substitution in the body of a here-document that
+undergoes expansion.
+That means, for example, that a backslash preceding a double quote
+character will escape it and the backslash will be removed.
+
+@item
+The @code{test} builtin compares strings using the current locale when
+processing the @samp{<} and @samp{>} binary operators.
+
+@item
+The @code{test} builtin's @option{-t} unary primary requires an argument.
+Historical versions of @code{test} made the argument optional in certain
+cases, and bash attempts to accommodate those for backwards compatibility.
+
+@item
+Command substitutions don't set the @samp{?} 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.
+
 @end enumerate
 
 There is other @sc{posix} behavior that Bash does not implement by
@@ -8358,6 +8765,10 @@ The @code{fc} builtin checks @code{$EDITOR} as a program to edit history
 entries if @code{FCEDIT} is unset, rather than defaulting directly to
 @code{ed}.  @code{fc} uses @code{ed} if @code{EDITOR} is unset.
 
+@item
+A non-interactive shell does not exit if a variable assignment preceding
+the @code{command} builtin or another non-special builtin fails.
+
 @item
 As noted above, Bash requires the @code{xpg_echo} option to be enabled for
 the @code{echo} builtin to be fully conformant.
@@ -8373,8 +8784,8 @@ the @option{--enable-strict-posix-default} to @code{configure} when building
 @cindex Compatibility Level
 @cindex Compatibility Mode
 
-Bash-4.0 introduced the concept of a `shell compatibility level', specified
-as a set of options to the shopt builtin
+Bash-4.0 introduced the concept of a @dfn{shell compatibility level},
+specified as a set of options to the shopt builtin
 (@code{compat31},
 @code{compat32},
 @code{compat40},
@@ -8390,7 +8801,7 @@ behavior. It's intended to be a temporary solution.
 This section does not mention behavior that is standard for a particular
 version (e.g., setting @code{compat32} means that quoting the rhs of the regexp
 matching operator quotes special regexp characters in the word, which is
-default behavior in bash-3.2 and above). 
+default behavior in bash-3.2 and subsequent versions). 
 
 If a user enables, say, @code{compat32}, it may affect the behavior of other
 compatibility levels up to and including the current compatibility level.
@@ -8437,16 +8848,6 @@ quoting the rhs of the @code{[[} command's regexp matching operator (=~)
 has no special effect
 @end itemize
 
-@item compat32
-@itemize @bullet
-@item
-interrupting a command list such as "a ; b ; c" causes the execution
-of the next command in the list (in bash-4.0 and later versions,
-the shell acts as if it received the interrupt, so
-interrupting one command in a list aborts the execution of the
-entire list)
-@end itemize
-
 @item compat40
 @itemize @bullet
 @item
@@ -8490,7 +8891,7 @@ are not special within double-quoted word expansions
 @item
 the shell does not print a warning message if an attempt is made to
 use a quoted compound assignment as an argument to declare
-(declare -a foo='(1 2)'). Later versions warn that this usage is
+(e.g., declare -a foo='(1 2)'). Later versions warn that this usage is
 deprecated
 @item
 word expansion errors are considered non-fatal errors that cause the
@@ -8568,6 +8969,15 @@ the $@{@var{parameter}[:]=@var{value}@} word expansion will return
 @var{value}, before any variable-specific transformations have been
 performed (e.g., converting to lowercase).
 Bash-5.2 will return the final value assigned to the variable.
+@item
+Parsing command substitutions will behave as if extended glob
+(@pxref{The Shopt Builtin})
+is enabled, so that parsing a command substitution containing an extglob
+pattern (say, as part of a shell function) will not fail.
+This assumes the intent is to enable extglob before the command is executed
+and word expansions are performed.
+It will fail at word expansion time if extglob hasn't been
+enabled by the time the command is executed.
 @end itemize
 @end table
 
@@ -8818,10 +9228,14 @@ The variable will be unset initially, before any assignment.
 This is useful only when the @option{-n} option is supplied.
 Supplying the @option{-f} option, when job control is enabled,
 forces @code{wait} to wait for each @var{pid} or @var{jobspec} to
-terminate before returning its status, intead of returning when it changes
+terminate before returning its status, instead of returning when it changes
 status.
 If neither @var{jobspec} nor @var{pid} specifies an active child process
 of the shell, the return status is 127.
+If @code{wait} is interrupted by a signal, the return status will be greater
+than 128, as described above (@pxref{Signals}).
+Otherwise, the return status is the exit  status
+of the last process or job waited for.
 
 @item disown
 @btindex disown
@@ -8848,8 +9262,16 @@ suspend [-f]
 
 Suspend the execution of this shell until it receives a
 @code{SIGCONT} signal.
-A login shell cannot be suspended; the @option{-f}
+A login shell,
+or a shell without job control enabled,
+cannot be suspended; the @option{-f}
 option can be used to override this and force the suspension.
+The return status is 0 unless the shell is a login shell
+or job control is not enabled
+and
+@option{-f}
+is not supplied.
+
 @end table
 
 When job control is not active, the @code{kill} and @code{wait}
@@ -8988,7 +9410,7 @@ at the Bash prompt in your Bash source directory.
 If you want to build Bash in a directory separate from the source
 directory -- to build for multiple architectures, for example --
 just use the full path to the configure script. The following commands
-will build bash in a directory under @file{/usr/local/build} from
+will build Bash in a directory under @file{/usr/local/build} from
 the source code in @file{/usr/local/src/bash-4.4}:
 
 @example
@@ -9057,7 +9479,7 @@ supply the @option{--srcdir=PATH} argument to tell @code{configure} where the
 source files are.  @code{configure} automatically checks for the
 source code in the directory that @code{configure} is in and in `..'.
 
-If you have to use a @code{make} that does not supports the @code{VPATH}
+If you have to use a @code{make} that does not support the @code{VPATH}
 variable, you can compile Bash for one architecture at a
 time in the source code directory.  After you have installed
 Bash for one architecture, use @samp{make distclean} before
@@ -9090,7 +9512,7 @@ or by specifying a value for the @env{prefix} @samp{make}
 variable when running @samp{make install}
 (e.g., @samp{make install prefix=@var{PATH}}).
 The @env{prefix} variable provides a default for @env{exec_prefix} and
-other variables used when installing bash.
+other variables used when installing Bash.
 
 You can specify separate installation prefixes for
 architecture-specific files and architecture-independent files. 
@@ -9104,7 +9526,7 @@ you can specify these variables as arguments to @code{make}:
 @samp{make install exec_prefix=/} will install @code{bash} and
 @code{bashbug} into @file{/bin} instead of the default @file{/usr/local/bin}.
 
-If you want to see the files bash will install and where it will install
+If you want to see the files Bash will install and where it will install
 them without changing anything on your system, specify the variable
 @env{DESTDIR} as an argument to @code{make}. Its value should be the
 absolute directory path you'd like to use as the root of your sample
@@ -9130,7 +9552,7 @@ variables and their effects.
 @section Specifying the System Type
 
 There may be some features @code{configure} can not figure out
-automatically, but need to determine by the type of host Bash
+automatically, but needs to determine by the type of host Bash
 will run on.  Usually @code{configure} can figure that
 out, but if it prints a message saying it can not guess the host
 type, give it the @option{--host=TYPE} option.  @samp{TYPE} can
@@ -9243,7 +9665,7 @@ the installed version of Readline in subdirectories of that directory
 
 @item --with-libintl-prefix[=@var{PREFIX}]
 Define this to make Bash link with a locally-installed version of the
-libintl library instead ofthe version in @file{lib/intl}.
+libintl library instead of the version in @file{lib/intl}.
 
 @item --with-libiconv-prefix[=@var{PREFIX}]
 Define this to make Bash look for libiconv in @var{PREFIX} instead of the
@@ -9259,7 +9681,7 @@ compiled, linked, and installed, rather than changing run-time features.
 
 @table @code
 @item --enable-largefile
-Enable support for @uref{http://www.unix.org/version2/whatsnew/lfs20mar.html,
+Enable support for @url{http://www.unix.org/version2/whatsnew/lfs20mar.html,
 large files} if the operating system requires special compiler options
 to build programs which can access large files.  This is enabled by
 default, if the operating system provides large file support.
@@ -9298,7 +9720,7 @@ Allow alias expansion and include the @code{alias} and @code{unalias}
 builtins (@pxref{Aliases}).
 
 @item --enable-alt-array-implementation
-This builds bash using an alternate implementation of arrays
+This builds Bash using an alternate implementation of arrays
 (@pxref{Arrays}) that provides faster access at the expense of using
 more memory (sometimes many times more, depending on how sparse an array is).
 
@@ -9348,7 +9770,7 @@ Include support for coprocesses and the @code{coproc} reserved word
 (@pxref{Pipelines}).
 
 @item --enable-debugger
-Include support for the bash debugger (distributed separately).
+Include support for the Bash debugger (distributed separately).
 
 @item --enable-dev-fd-stat-broken
 If calling @code{stat} on /dev/fd/@var{N} returns different results than
@@ -9491,11 +9913,11 @@ The latest version of Bash is always available for FTP from
 @uref{http://git.savannah.gnu.org/cgit/bash.git/snapshot/bash-master.tar.gz}.
 
 Once you have determined that a bug actually exists, use the
-@code{bashbug} command to submit a bug report.
-If you have a fix, you are encouraged to mail that as well!
+@code{bashbug} command to submit a bug report or use the form at the
+@uref{https://savannah.gnu.org/projects/bash/,Bash project page}.
+If you have a fix, you are encouraged to submit that as well!
 Suggestions and `philosophical' bug reports may be mailed
-to @email{bug-bash@@gnu.org} or posted to the Usenet
-newsgroup @code{gnu.bash.bug}.
+to @email{bug-bash@@gnu.org} or @email{help-bash@@gnu.org}.
 
 All bug reports should include:
 @itemize @bullet
@@ -9868,7 +10290,7 @@ The @code{ERR} trap is not inherited by shell functions unless the
 The @code{trap} builtin (@pxref{Bourne Shell Builtins}) allows a
 @code{RETURN} pseudo-signal specification, similar to
 @code{EXIT} and @code{DEBUG}.
-Commands specified with an @code{RETURN} trap are executed before
+Commands specified with a @code{RETURN} trap are executed before
 execution resumes after a shell function or a shell script executed with
 @code{.} or @code{source} returns.
 The @code{RETURN} trap is not inherited by shell functions unless the