update fix to save history if fatal signal arrives during $PROMPT_COMMAND execution; fix issue with extglob and empty patterns preceding pattern beginning with a `.'

This commit is contained in:
Chet Ramey
2026-03-24 10:10:30 -04:00
parent 1f292e433e
commit 55f721c51e
22 changed files with 3626 additions and 3540 deletions
+23
View File
@@ -12786,3 +12786,26 @@ sig.c
builtins/psize.c
- sigpipe: work around cygwin SIGPIPE delivery bug
Report and fix from Duncan Roe <bduncan_roe@optusnet.com.au>
3/10
----
sig.c
- termsig_handler: save history even if the shell is non-interactive
when the signal is delivered if parse_and_execute_level or
sourcelevel are non-zero
Update to fix from 3/6
3/11
----
lib/glob/glob.c
- skipname,wskipname: make sure PAT is not the empty string when
checking whether it begins with `.' when deciding whether to skip
a filename that begins with `.'. This `match' defers the matching
until subsequent functions can match the rest of the pattern.
Fixes bug reported by Isaac Z. Schlueter <i@izs.me>
3/16
----
doc/bash.1,doc/bashref.texi
- BASH_REMATCH: update [[ documentation to note that BASH_REMATCH can
be a local variable
+2 -2
View File
@@ -1,6 +1,6 @@
# Makefile for bash-5.3, version 5.11
# Makefile for bash-5.3, version 5.12
#
# Copyright (C) 1996-2025 Free Software Foundation, Inc.
# Copyright (C) 1996-2026 Free Software Foundation, Inc.
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
+1 -1
View File
@@ -1,7 +1,7 @@
/* array.h -- definitions for the interface exported by array.c that allows
the rest of the shell to manipulate array variables. */
/* Copyright (C) 1997-2022 Free Software Foundation, Inc.
/* Copyright (C) 1997-2022,2026 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+1 -1
View File
@@ -7,7 +7,7 @@
* chet@ins.cwru.edu
*/
/* Copyright (C) 2008,2009,2011-2023 Free Software Foundation, Inc.
/* Copyright (C) 2008,2009,2011-2023,2026 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+1 -1
View File
@@ -1,7 +1,7 @@
/* assoc.h -- definitions for the interface exported by assoc.c that allows
the rest of the shell to manipulate associative array variables. */
/* Copyright (C) 2008,2009-2023 Free Software Foundation, Inc.
/* Copyright (C) 2008,2009-2023,2026 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+3177 -3175
View File
File diff suppressed because it is too large Load Diff
+9 -2
View File
@@ -907,6 +907,10 @@ The array variable
.SM
.B BASH_REMATCH
records which parts of the string matched the pattern.
.B Bash
unsets
.B BASH_REMATCH
before attempting the match, so if there is no match, it remains unset.
The element of
.SM
.B BASH_REMATCH
@@ -925,8 +929,11 @@ string matching the \fIn\fPth parenthesized subexpression.
\fBBash\fP sets
.SM
.B BASH_REMATCH
in the global scope; declaring it as a local variable will lead to
unexpected results.
in the global scope if it is not set;
if it is declared as a local variable before running
.BR [[ ,
.B bash
keeps it a local variable.
.IP
Expressions may be combined using the following operators, listed
in decreasing order of precedence:
+34 -28
View File
@@ -1,5 +1,5 @@
<!-- Creator : groff version 1.23.0 -->
<!-- CreationDate: Thu Jan 29 13:25:46 2026 -->
<!-- CreationDate: Mon Mar 16 15:46:12 2026 -->
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
@@ -1028,7 +1028,9 @@ string.</p>
<p style="margin-left:18%; margin-top: 1em">The array
variable <b><small>BASH_REMATCH</small></b> records which
parts of the string matched the pattern. The element of
parts of the string matched the pattern. <b>Bash</b> unsets
<b>BASH_REMATCH</b> before attempting the match, so if there
is no match, it remains unset. The element of
<b><small>BASH_REMATCH</small></b> with index 0 contains the
portion of the string matching the entire regular
expression. Substrings matched by parenthesized
@@ -1037,9 +1039,10 @@ the remaining <b><small>BASH_REMATCH</small></b> indices.
The element of <b><small>BASH_REMATCH</small></b> with index
<i>n</i> is the portion of the string matching the
<i>n</i>th parenthesized subexpression. <b>Bash</b> sets
<b><small>BASH_REMATCH</small></b> in the global scope;
declaring it as a local variable will lead to unexpected
results.</p>
<b><small>BASH_REMATCH</small></b> in the global scope if it
is not set; if it is declared as a local variable before
running <b>[[</b>, <b>bash</b> keeps it a local
variable.</p>
<p style="margin-left:18%; margin-top: 1em">Expressions may
be combined using the following operators, listed in
@@ -4094,47 +4097,50 @@ cases below, <i>word</i> is subject to tilde expansion,
parameter expansion, command substitution, and arithmetic
expansion.</p>
<p style="margin-left:9%; margin-top: 1em">When not
performing substring expansion, using the forms documented
below (e.g., <b>:-</b>), <b>bash</b> tests for a parameter
that is unset or null. Omitting the colon tests only for a
parameter that is unset. <br>
<p style="margin-left:9%; margin-top: 1em">When performing
the first four expansions documented below (<b>:-</b>,
<b>:=</b>, <b>:?</b>, and <b>:+</b>), including the colon,
<b>bash</b> tests for a parameter that is unset or null.
Omitting the colon tests only for a parameter that is unset.
<br>
${<i>parameter</i><b>:&minus;</b><i>word</i>}</p>
<p style="margin-left:18%;"><b>Use Default Values</b>. If
<i>parameter</i> is unset or null, the expansion of
<i>word</i> is substituted. Otherwise, the value of
<i>parameter</i> is substituted.</p>
<i>parameter</i> is unset or null, or unset if the colon is
not present, the expansion of <i>word</i> is substituted.
Otherwise, the value of <i>parameter</i> is substituted.</p>
<p style="margin-left:9%;">${<i>parameter</i><b>:=</b><i>word</i>}</p>
<p style="margin-left:18%;"><b>Assign Default Values</b>.
If <i>parameter</i> is unset or null, the expansion of
<i>word</i> is assigned to <i>parameter</i>, and the
expansion is the final value of <i>parameter</i>. Positional
parameters and special parameters may not be assigned in
this way.</p>
If <i>parameter</i> is unset or null, or unset if the colon
is not present, the expansion of <i>word</i> is assigned to
<i>parameter</i>, and the expansion is the final value of
<i>parameter</i>. Positional parameters and special
parameters may not be assigned in this way.</p>
<p style="margin-left:9%;">${<i>parameter</i><b>:?</b><i>word</i>}</p>
<p style="margin-left:18%;"><b>Display Error if Null or
Unset</b>. If <i>parameter</i> is null or unset, the shell
writes the expansion of <i>word</i> (or a message to that
effect if <i>word</i> is not present) to the standard error
and, if it is not interactive, exits with a non-zero status.
An interactive shell does not exit, but does not execute the
command associated with the expansion. Otherwise, the value
of <i>parameter</i> is substituted.</p>
Unset</b>. If <i>parameter</i> is unset or null, or unset if
the colon is not present, the shell writes the expansion of
<i>word</i> (or a message to that effect if <i>word</i> is
not present) to the standard error and, if it is not
interactive, exits with a non-zero status. An interactive
shell does not exit, but does not execute the command
associated with the expansion. Otherwise, the value of
<i>parameter</i> is substituted.</p>
<p style="margin-left:9%;">${<i>parameter</i><b>:+</b><i>word</i>}</p>
<p style="margin-left:18%;"><b>Use Alternate Value</b>. If
<i>parameter</i> is null or unset, nothing is substituted,
otherwise the expansion of <i>word</i> is substituted. The
value of <i>parameter</i> is not used.</p>
<i>parameter</i> is unset or null, or unset if the colon is
not present, nothing is substituted, otherwise the expansion
of <i>word</i> is substituted. The value of <i>parameter</i>
is not used.</p>
<p style="margin-left:9%;">${<i>parameter</i><b>:</b><i>offset</i>}
+148 -146
View File
@@ -1,9 +1,9 @@
This is bash.info, produced by makeinfo version 7.2 from bashref.texi.
This text is a brief description of the features that are present in the
Bash shell (version 5.3, 3 March 2026).
Bash shell (version 5.3, 16 March 2026).
This is Edition 5.3, last updated 3 March 2026, of The GNU Bash
This is Edition 5.3, last updated 16 March 2026, of The GNU Bash
Reference Manual, for Bash, Version 5.3.
Copyright © 1988-2026 Free Software Foundation, Inc.
@@ -26,10 +26,10 @@ Bash Features
*************
This text is a brief description of the features that are present in the
Bash shell (version 5.3, 3 March 2026). The Bash home page is
Bash shell (version 5.3, 16 March 2026). The Bash home page is
<http://www.gnu.org/software/bash/>.
This is Edition 5.3, last updated 3 March 2026, of The GNU Bash
This is Edition 5.3, last updated 16 March 2026, of The GNU Bash
Reference Manual, for Bash, Version 5.3.
Bash contains features that appear in other popular shells, and some
@@ -1165,16 +1165,18 @@ File: bash.info, Node: Conditional Constructs, Next: Command Grouping, Prev:
quote special pattern characters where that's necessary.
The array variable BASH_REMATCH records which parts of the string
matched the pattern. The element of BASH_REMATCH with index 0
contains the portion of the string matching the entire regular
expression. Substrings matched by parenthesized subexpressions
within the regular expression are saved in the remaining
BASH_REMATCH indices. The element of BASH_REMATCH with index N
is the portion of the string matching the Nth parenthesized
subexpression.
matched the pattern. Bash unsets BASH_REMATCH before attempting
the match, so if there is no match, it remains unset. The element
of BASH_REMATCH with index 0 contains the portion of the string
matching the entire regular expression. Substrings matched by
parenthesized subexpressions within the regular expression are
saved in the remaining BASH_REMATCH indices. The element of
BASH_REMATCH with index N is the portion of the string matching
the Nth parenthesized subexpression.
Bash sets BASH_REMATCH in the global scope; declaring it as a
local variable will lead to unexpected results.
Bash sets BASH_REMATCH in the global scope if it is not set; if
it is declared as a local variable before running [[, Bash keeps
it a local variable.
Expressions may be combined using the following operators, listed
in decreasing order of precedence:
@@ -4529,7 +4531,7 @@ standard.
Bash Builtins::).
%q
Causes printf to output the corresponding ARGUMENT in a
format that can be reused as shell input. %q and %QP use
format that can be reused as shell input. %q and %Q use
the ANSI-C quoting style (*note ANSI-C Quoting::) if any
characters in the argument string require it, and backslash
quoting otherwise. If the format string uses the printf
@@ -13738,138 +13740,138 @@ D.5 Concept Index

Tag Table:
Node: Top893
Node: Introduction2826
Node: What is Bash?3039
Node: What is a shell?4172
Node: Definitions6782
Node: Basic Shell Features10109
Node: Shell Syntax11333
Node: Shell Operation12360
Node: Quoting13651
Node: Escape Character14989
Node: Single Quotes15524
Node: Double Quotes15873
Node: ANSI-C Quoting17218
Node: Locale Translation18612
Node: Creating Internationalized Scripts20015
Node: Comments24213
Node: Shell Commands24980
Node: Reserved Words25919
Node: Simple Commands27062
Node: Pipelines27724
Node: Lists30980
Node: Compound Commands32929
Node: Looping Constructs33938
Node: Conditional Constructs36487
Node: Command Grouping51624
Node: Coprocesses53116
Node: GNU Parallel55802
Node: Shell Functions56720
Node: Shell Parameters65168
Node: Positional Parameters70069
Node: Special Parameters71159
Node: Shell Expansions74620
Node: Brace Expansion76809
Node: Tilde Expansion80145
Node: Shell Parameter Expansion83100
Node: Command Substitution103948
Node: Arithmetic Expansion107799
Node: Process Substitution108975
Node: Word Splitting110083
Node: Filename Expansion112527
Node: Pattern Matching115751
Node: Quote Removal121517
Node: Redirections121821
Node: Executing Commands132077
Node: Simple Command Expansion132744
Node: Command Search and Execution134852
Node: Command Execution Environment137296
Node: Environment140822
Node: Exit Status142725
Node: Signals144784
Node: Shell Scripts149732
Node: Shell Builtin Commands153030
Node: Bourne Shell Builtins155371
Node: Bash Builtins182090
Node: Modifying Shell Behavior219826
Node: The Set Builtin220168
Node: The Shopt Builtin232162
Node: Special Builtins249215
Node: Shell Variables250204
Node: Bourne Shell Variables250638
Node: Bash Variables253146
Node: Bash Features292430
Node: Invoking Bash293444
Node: Bash Startup Files300028
Node: Interactive Shells305270
Node: What is an Interactive Shell?305678
Node: Is this Shell Interactive?306340
Node: Interactive Shell Behavior307164
Node: Bash Conditional Expressions310925
Node: Shell Arithmetic316342
Node: Aliases319669
Node: Arrays322803
Node: The Directory Stack330506
Node: Directory Stack Builtins331303
Node: Controlling the Prompt335748
Node: The Restricted Shell338632
Node: Bash POSIX Mode341725
Node: Shell Compatibility Mode361541
Node: Job Control370548
Node: Job Control Basics371005
Node: Job Control Builtins377373
Node: Job Control Variables384161
Node: Command Line Editing385392
Node: Introduction and Notation387095
Node: Readline Interaction389447
Node: Readline Bare Essentials390635
Node: Readline Movement Commands392443
Node: Readline Killing Commands393439
Node: Readline Arguments395462
Node: Searching396552
Node: Readline Init File398795
Node: Readline Init File Syntax400098
Node: Conditional Init Constructs427049
Node: Sample Init File431434
Node: Bindable Readline Commands434554
Node: Commands For Moving436092
Node: Commands For History438556
Node: Commands For Text443947
Node: Commands For Killing448072
Node: Numeric Arguments450860
Node: Commands For Completion452012
Node: Keyboard Macros457708
Node: Miscellaneous Commands458409
Node: Readline vi Mode465952
Node: Programmable Completion466929
Node: Programmable Completion Builtins476665
Node: A Programmable Completion Example488402
Node: Using History Interactively493747
Node: Bash History Facilities494428
Node: Bash History Builtins498163
Node: History Interaction505758
Node: Event Designators510708
Node: Word Designators512286
Node: Modifiers514678
Node: Installing Bash516615
Node: Basic Installation517731
Node: Compilers and Options521607
Node: Compiling For Multiple Architectures522357
Node: Installation Names524110
Node: Specifying the System Type526344
Node: Sharing Defaults527090
Node: Operation Controls527804
Node: Optional Features528823
Node: Reporting Bugs541546
Node: Major Differences From The Bourne Shell542903
Node: GNU Free Documentation License564330
Node: Indexes589507
Node: Builtin Index589958
Node: Reserved Word Index597056
Node: Variable Index599501
Node: Function Index616914
Node: Concept Index631047
Node: Top895
Node: Introduction2830
Node: What is Bash?3043
Node: What is a shell?4176
Node: Definitions6786
Node: Basic Shell Features10113
Node: Shell Syntax11337
Node: Shell Operation12364
Node: Quoting13655
Node: Escape Character14993
Node: Single Quotes15528
Node: Double Quotes15877
Node: ANSI-C Quoting17222
Node: Locale Translation18616
Node: Creating Internationalized Scripts20019
Node: Comments24217
Node: Shell Commands24984
Node: Reserved Words25923
Node: Simple Commands27066
Node: Pipelines27728
Node: Lists30984
Node: Compound Commands32933
Node: Looping Constructs33942
Node: Conditional Constructs36491
Node: Command Grouping51788
Node: Coprocesses53280
Node: GNU Parallel55966
Node: Shell Functions56884
Node: Shell Parameters65332
Node: Positional Parameters70233
Node: Special Parameters71323
Node: Shell Expansions74784
Node: Brace Expansion76973
Node: Tilde Expansion80309
Node: Shell Parameter Expansion83264
Node: Command Substitution104112
Node: Arithmetic Expansion107963
Node: Process Substitution109139
Node: Word Splitting110247
Node: Filename Expansion112691
Node: Pattern Matching115915
Node: Quote Removal121681
Node: Redirections121985
Node: Executing Commands132241
Node: Simple Command Expansion132908
Node: Command Search and Execution135016
Node: Command Execution Environment137460
Node: Environment140986
Node: Exit Status142889
Node: Signals144948
Node: Shell Scripts149896
Node: Shell Builtin Commands153194
Node: Bourne Shell Builtins155535
Node: Bash Builtins182254
Node: Modifying Shell Behavior219989
Node: The Set Builtin220331
Node: The Shopt Builtin232325
Node: Special Builtins249378
Node: Shell Variables250367
Node: Bourne Shell Variables250801
Node: Bash Variables253309
Node: Bash Features292593
Node: Invoking Bash293607
Node: Bash Startup Files300191
Node: Interactive Shells305433
Node: What is an Interactive Shell?305841
Node: Is this Shell Interactive?306503
Node: Interactive Shell Behavior307327
Node: Bash Conditional Expressions311088
Node: Shell Arithmetic316505
Node: Aliases319832
Node: Arrays322966
Node: The Directory Stack330669
Node: Directory Stack Builtins331466
Node: Controlling the Prompt335911
Node: The Restricted Shell338795
Node: Bash POSIX Mode341888
Node: Shell Compatibility Mode361704
Node: Job Control370711
Node: Job Control Basics371168
Node: Job Control Builtins377536
Node: Job Control Variables384324
Node: Command Line Editing385555
Node: Introduction and Notation387258
Node: Readline Interaction389610
Node: Readline Bare Essentials390798
Node: Readline Movement Commands392606
Node: Readline Killing Commands393602
Node: Readline Arguments395625
Node: Searching396715
Node: Readline Init File398958
Node: Readline Init File Syntax400261
Node: Conditional Init Constructs427212
Node: Sample Init File431597
Node: Bindable Readline Commands434717
Node: Commands For Moving436255
Node: Commands For History438719
Node: Commands For Text444110
Node: Commands For Killing448235
Node: Numeric Arguments451023
Node: Commands For Completion452175
Node: Keyboard Macros457871
Node: Miscellaneous Commands458572
Node: Readline vi Mode466115
Node: Programmable Completion467092
Node: Programmable Completion Builtins476828
Node: A Programmable Completion Example488565
Node: Using History Interactively493910
Node: Bash History Facilities494591
Node: Bash History Builtins498326
Node: History Interaction505921
Node: Event Designators510871
Node: Word Designators512449
Node: Modifiers514841
Node: Installing Bash516778
Node: Basic Installation517894
Node: Compilers and Options521770
Node: Compiling For Multiple Architectures522520
Node: Installation Names524273
Node: Specifying the System Type526507
Node: Sharing Defaults527253
Node: Operation Controls527967
Node: Optional Features528986
Node: Reporting Bugs541709
Node: Major Differences From The Bourne Shell543066
Node: GNU Free Documentation License564493
Node: Indexes589670
Node: Builtin Index590121
Node: Reserved Word Index597219
Node: Variable Index599664
Node: Function Index617077
Node: Concept Index631210

End Tag Table
+39 -15
View File
@@ -4,9 +4,9 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- This text is a brief description of the features that are present in
the Bash shell (version 5.3, 14 January 2026).
the Bash shell (version 5.3, 16 March 2026).
This is Edition 5.3, last updated 14 January 2026,
This is Edition 5.3, last updated 16 March 2026,
of The GNU Bash Reference Manual,
for Bash, Version 5.3.
@@ -77,10 +77,10 @@ Next: <a href="#Introduction" accesskey="n" rel="next">Introduction</a>, Previou
<h1 class="top" id="Bash-Features-1"><span>Bash Features<a class="copiable-link" href="#Bash-Features-1"> &para;</a></span></h1>
<p>This text is a brief description of the features that are present in
the Bash shell (version 5.3, 14 January 2026).
the Bash shell (version 5.3, 16 March 2026).
The Bash home page is <a class="url" href="http://www.gnu.org/software/bash/">http://www.gnu.org/software/bash/</a>.
</p>
<p>This is Edition 5.3, last updated 14 January 2026,
<p>This is Edition 5.3, last updated 16 March 2026,
of <cite class="cite">The GNU Bash Reference Manual</cite>,
for <code class="code">Bash</code>, Version 5.3.
</p>
@@ -1699,6 +1699,8 @@ special pattern characters where that&rsquo;s necessary.
</p>
<p>The array variable <code class="code">BASH_REMATCH</code> records which parts of the string
matched the pattern.
Bash unsets <code class="code">BASH_REMATCH</code>
before attempting the match, so if there is no match, it remains unset.
The element of <code class="code">BASH_REMATCH</code> with index 0 contains the portion of
the string matching the entire regular expression.
Substrings matched by parenthesized subexpressions within the regular
@@ -1708,8 +1710,10 @@ string matching the <var class="var">n</var>th parenthesized subexpression.
</p>
<p>Bash sets
<code class="code">BASH_REMATCH</code>
in the global scope; declaring it as a local variable will lead to
unexpected results.
in the global scope if it is not set;
if it is declared as a local variable before running
<code class="code">[[</code>,
Bash keeps it a local variable.
</p>
<p>Expressions may be combined using the following operators, listed
in decreasing order of precedence:
@@ -2705,8 +2709,10 @@ introduce indirection.
<p>In each of the cases below, <var class="var">word</var> is subject to tilde expansion,
parameter expansion, command substitution, and arithmetic expansion.
</p>
<p>When not performing substring expansion, using the forms described
below (e.g., &lsquo;<samp class="samp">:&minus;</samp>&rsquo;), Bash tests for a parameter that is unset or null.
<p>When performing the first four expansions documented below
(&lsquo;<samp class="samp">:-</samp>&rsquo;, &lsquo;<samp class="samp">:=</samp>&rsquo;, &lsquo;<samp class="samp">:?</samp>&rsquo;, and &lsquo;<samp class="samp">:+</samp>&rsquo;),
including the colon,
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,
the operator tests for both <var class="var">parameter</var>&rsquo;s existence and that its value
@@ -2714,7 +2720,10 @@ is not null; if the colon is omitted, the operator tests only for existence.
</p>
<dl class="table">
<dt><code class="code">${<var class="var">parameter</var>:&minus;<var class="var">word</var>}</code></dt>
<dd><p>If <var class="var">parameter</var> is unset or null, the expansion of
<dd><p>If <var class="var">parameter</var>
is unset or null,
or unset if the colon is not present,
the expansion of
<var class="var">word</var> is substituted.
Otherwise, the value of <var class="var">parameter</var> is substituted.
</p>
@@ -2736,7 +2745,10 @@ unset-or-null
</dd>
<dt><code class="code">${<var class="var">parameter</var>:=<var class="var">word</var>}</code></dt>
<dd><p>If <var class="var">parameter</var> is unset or null, the expansion of <var class="var">word</var>
<dd><p>If <var class="var">parameter</var>
is unset or null,
or unset if the colon is not present,
the expansion of <var class="var">word</var>
is assigned to <var class="var">parameter</var>,
and the result of the expansion
is the final value of <var class="var">parameter</var>.
@@ -2765,7 +2777,9 @@ DEFAULT
</dd>
<dt><code class="code">${<var class="var">parameter</var>:?<var class="var">word</var>}</code></dt>
<dd><p>If <var class="var">parameter</var>
is null or unset, the shell writes
is unset or null,
or unset if the colon is not present,
the shell writes
the expansion of <var class="var">word</var> (or a message
to that effect if <var class="var">word</var>
is not present) to the standard error and, if it
@@ -2793,7 +2807,10 @@ $ echo ${var:?var is unset or null}
</dd>
<dt><code class="code">${<var class="var">parameter</var>:+<var class="var">word</var>}</code></dt>
<dd><p>If <var class="var">parameter</var>
is null or unset, nothing is substituted, otherwise the expansion of
is unset or null,
or unset if the colon is not present,
nothing is substituted,
otherwise the expansion of
<var class="var">word</var> is substituted.
The value of <var class="var">parameter</var> is not used.
</p>
@@ -6106,7 +6123,7 @@ corresponding <var class="var">argument</var> in the same way as <code class="co
<dt><code class="code">%q</code></dt>
<dd><p>Causes <code class="code">printf</code> to output the
corresponding <var class="var">argument</var> in a format that can be reused as shell input.
<code class="code">%q</code> and <code class="code">%Q</code>P use the ANSI-C quoting style (see <a class="pxref" href="#ANSI_002dC-Quoting">ANSI-C Quoting</a>)
<code class="code">%q</code> and <code class="code">%Q</code> use the ANSI-C quoting style (see <a class="pxref" href="#ANSI_002dC-Quoting">ANSI-C Quoting</a>)
if any characters
in the argument string require it, and backslash quoting otherwise.
If the format string uses the <code class="code">printf</code> <em class="emph">alternate form</em>, these two
@@ -9524,7 +9541,7 @@ This means you can use <var class="var">x</var>,
where <var class="var">x</var> is a shell variable name, in an arithmetic expression,
and the shell will evaluate its value as an expression and use the
result.
A shell variable that is null or unset evaluates to 0 when referenced
A shell variable that is unset or null evaluates to 0 when referenced
by name in an expression.
</p>
<p>The value of a variable is evaluated as an arithmetic expression
@@ -10333,7 +10350,8 @@ redirection.
builtins.
</li><li> Tilde expansion is only performed on assignments preceding a command
name, rather than on all assignment statements on the line.
name, rather than on all assignment statements on the line, unless
the command is a declaration command.
</li><li> While variable indirection is available, it may not be applied to the
&lsquo;<samp class="samp">#</samp>&rsquo; and &lsquo;<samp class="samp">?</samp>&rsquo; special parameters.
@@ -10636,6 +10654,12 @@ entries if <code class="code">FCEDIT</code> is unset, rather than defaulting dir
<code class="code">fc</code> uses <code class="code">ed</code> if <code class="code">EDITOR</code> is unset.
</li><li> Bash does not perform redirections before expanding variable assignments
preceding a simple command; it does not allow the redirections access to
the results of the variable assignments, but any side effects of expanding
the redirections take place first.
If compiled in <i class="i">strict posix</i> mode, Bash performs redirections first.
</li><li> As noted above, Bash requires the <code class="code">xpg_echo</code> option to be enabled for
the <code class="code">echo</code> builtin to be fully conformant.
+148 -146
View File
@@ -2,9 +2,9 @@ This is bashref.info, produced by makeinfo version 7.2 from
bashref.texi.
This text is a brief description of the features that are present in the
Bash shell (version 5.3, 3 March 2026).
Bash shell (version 5.3, 16 March 2026).
This is Edition 5.3, last updated 3 March 2026, of The GNU Bash
This is Edition 5.3, last updated 16 March 2026, of The GNU Bash
Reference Manual, for Bash, Version 5.3.
Copyright © 1988-2026 Free Software Foundation, Inc.
@@ -27,10 +27,10 @@ Bash Features
*************
This text is a brief description of the features that are present in the
Bash shell (version 5.3, 3 March 2026). The Bash home page is
Bash shell (version 5.3, 16 March 2026). The Bash home page is
<http://www.gnu.org/software/bash/>.
This is Edition 5.3, last updated 3 March 2026, of The GNU Bash
This is Edition 5.3, last updated 16 March 2026, of The GNU Bash
Reference Manual, for Bash, Version 5.3.
Bash contains features that appear in other popular shells, and some
@@ -1166,16 +1166,18 @@ File: bashref.info, Node: Conditional Constructs, Next: Command Grouping, Pre
quote special pattern characters where that's necessary.
The array variable BASH_REMATCH records which parts of the string
matched the pattern. The element of BASH_REMATCH with index 0
contains the portion of the string matching the entire regular
expression. Substrings matched by parenthesized subexpressions
within the regular expression are saved in the remaining
BASH_REMATCH indices. The element of BASH_REMATCH with index N
is the portion of the string matching the Nth parenthesized
subexpression.
matched the pattern. Bash unsets BASH_REMATCH before attempting
the match, so if there is no match, it remains unset. The element
of BASH_REMATCH with index 0 contains the portion of the string
matching the entire regular expression. Substrings matched by
parenthesized subexpressions within the regular expression are
saved in the remaining BASH_REMATCH indices. The element of
BASH_REMATCH with index N is the portion of the string matching
the Nth parenthesized subexpression.
Bash sets BASH_REMATCH in the global scope; declaring it as a
local variable will lead to unexpected results.
Bash sets BASH_REMATCH in the global scope if it is not set; if
it is declared as a local variable before running [[, Bash keeps
it a local variable.
Expressions may be combined using the following operators, listed
in decreasing order of precedence:
@@ -4530,7 +4532,7 @@ standard.
Bash Builtins::).
%q
Causes printf to output the corresponding ARGUMENT in a
format that can be reused as shell input. %q and %QP use
format that can be reused as shell input. %q and %Q use
the ANSI-C quoting style (*note ANSI-C Quoting::) if any
characters in the argument string require it, and backslash
quoting otherwise. If the format string uses the printf
@@ -13739,138 +13741,138 @@ D.5 Concept Index

Tag Table:
Node: Top896
Node: Introduction2832
Node: What is Bash?3048
Node: What is a shell?4184
Node: Definitions6797
Node: Basic Shell Features10127
Node: Shell Syntax11354
Node: Shell Operation12384
Node: Quoting13678
Node: Escape Character15019
Node: Single Quotes15557
Node: Double Quotes15909
Node: ANSI-C Quoting17257
Node: Locale Translation18654
Node: Creating Internationalized Scripts20060
Node: Comments24261
Node: Shell Commands25031
Node: Reserved Words25973
Node: Simple Commands27119
Node: Pipelines27784
Node: Lists31043
Node: Compound Commands32995
Node: Looping Constructs34007
Node: Conditional Constructs36559
Node: Command Grouping51699
Node: Coprocesses53194
Node: GNU Parallel55883
Node: Shell Functions56804
Node: Shell Parameters65255
Node: Positional Parameters70159
Node: Special Parameters71252
Node: Shell Expansions74716
Node: Brace Expansion76908
Node: Tilde Expansion80247
Node: Shell Parameter Expansion83205
Node: Command Substitution104056
Node: Arithmetic Expansion107910
Node: Process Substitution109089
Node: Word Splitting110200
Node: Filename Expansion112647
Node: Pattern Matching115874
Node: Quote Removal121643
Node: Redirections121950
Node: Executing Commands132209
Node: Simple Command Expansion132879
Node: Command Search and Execution134990
Node: Command Execution Environment137437
Node: Environment140966
Node: Exit Status142872
Node: Signals144934
Node: Shell Scripts149885
Node: Shell Builtin Commands153186
Node: Bourne Shell Builtins155530
Node: Bash Builtins182252
Node: Modifying Shell Behavior219991
Node: The Set Builtin220336
Node: The Shopt Builtin232333
Node: Special Builtins249389
Node: Shell Variables250381
Node: Bourne Shell Variables250818
Node: Bash Variables253329
Node: Bash Features292616
Node: Invoking Bash293633
Node: Bash Startup Files300220
Node: Interactive Shells305465
Node: What is an Interactive Shell?305876
Node: Is this Shell Interactive?306541
Node: Interactive Shell Behavior307368
Node: Bash Conditional Expressions311132
Node: Shell Arithmetic316552
Node: Aliases319882
Node: Arrays323019
Node: The Directory Stack330725
Node: Directory Stack Builtins331525
Node: Controlling the Prompt335973
Node: The Restricted Shell338860
Node: Bash POSIX Mode341956
Node: Shell Compatibility Mode361775
Node: Job Control370785
Node: Job Control Basics371245
Node: Job Control Builtins377616
Node: Job Control Variables384407
Node: Command Line Editing385641
Node: Introduction and Notation387347
Node: Readline Interaction389702
Node: Readline Bare Essentials390893
Node: Readline Movement Commands392704
Node: Readline Killing Commands393703
Node: Readline Arguments395729
Node: Searching396822
Node: Readline Init File399068
Node: Readline Init File Syntax400374
Node: Conditional Init Constructs427328
Node: Sample Init File431716
Node: Bindable Readline Commands434839
Node: Commands For Moving436380
Node: Commands For History438847
Node: Commands For Text444241
Node: Commands For Killing448369
Node: Numeric Arguments451160
Node: Commands For Completion452315
Node: Keyboard Macros458014
Node: Miscellaneous Commands458718
Node: Readline vi Mode466264
Node: Programmable Completion467244
Node: Programmable Completion Builtins476983
Node: A Programmable Completion Example488723
Node: Using History Interactively494071
Node: Bash History Facilities494755
Node: Bash History Builtins498493
Node: History Interaction506091
Node: Event Designators511044
Node: Word Designators512625
Node: Modifiers515020
Node: Installing Bash516960
Node: Basic Installation518079
Node: Compilers and Options521958
Node: Compiling For Multiple Architectures522711
Node: Installation Names524467
Node: Specifying the System Type526704
Node: Sharing Defaults527453
Node: Operation Controls528170
Node: Optional Features529192
Node: Reporting Bugs541918
Node: Major Differences From The Bourne Shell543278
Node: GNU Free Documentation License564708
Node: Indexes589888
Node: Builtin Index590342
Node: Reserved Word Index597443
Node: Variable Index599891
Node: Function Index617307
Node: Concept Index631443
Node: Top898
Node: Introduction2836
Node: What is Bash?3052
Node: What is a shell?4188
Node: Definitions6801
Node: Basic Shell Features10131
Node: Shell Syntax11358
Node: Shell Operation12388
Node: Quoting13682
Node: Escape Character15023
Node: Single Quotes15561
Node: Double Quotes15913
Node: ANSI-C Quoting17261
Node: Locale Translation18658
Node: Creating Internationalized Scripts20064
Node: Comments24265
Node: Shell Commands25035
Node: Reserved Words25977
Node: Simple Commands27123
Node: Pipelines27788
Node: Lists31047
Node: Compound Commands32999
Node: Looping Constructs34011
Node: Conditional Constructs36563
Node: Command Grouping51863
Node: Coprocesses53358
Node: GNU Parallel56047
Node: Shell Functions56968
Node: Shell Parameters65419
Node: Positional Parameters70323
Node: Special Parameters71416
Node: Shell Expansions74880
Node: Brace Expansion77072
Node: Tilde Expansion80411
Node: Shell Parameter Expansion83369
Node: Command Substitution104220
Node: Arithmetic Expansion108074
Node: Process Substitution109253
Node: Word Splitting110364
Node: Filename Expansion112811
Node: Pattern Matching116038
Node: Quote Removal121807
Node: Redirections122114
Node: Executing Commands132373
Node: Simple Command Expansion133043
Node: Command Search and Execution135154
Node: Command Execution Environment137601
Node: Environment141130
Node: Exit Status143036
Node: Signals145098
Node: Shell Scripts150049
Node: Shell Builtin Commands153350
Node: Bourne Shell Builtins155694
Node: Bash Builtins182416
Node: Modifying Shell Behavior220154
Node: The Set Builtin220499
Node: The Shopt Builtin232496
Node: Special Builtins249552
Node: Shell Variables250544
Node: Bourne Shell Variables250981
Node: Bash Variables253492
Node: Bash Features292779
Node: Invoking Bash293796
Node: Bash Startup Files300383
Node: Interactive Shells305628
Node: What is an Interactive Shell?306039
Node: Is this Shell Interactive?306704
Node: Interactive Shell Behavior307531
Node: Bash Conditional Expressions311295
Node: Shell Arithmetic316715
Node: Aliases320045
Node: Arrays323182
Node: The Directory Stack330888
Node: Directory Stack Builtins331688
Node: Controlling the Prompt336136
Node: The Restricted Shell339023
Node: Bash POSIX Mode342119
Node: Shell Compatibility Mode361938
Node: Job Control370948
Node: Job Control Basics371408
Node: Job Control Builtins377779
Node: Job Control Variables384570
Node: Command Line Editing385804
Node: Introduction and Notation387510
Node: Readline Interaction389865
Node: Readline Bare Essentials391056
Node: Readline Movement Commands392867
Node: Readline Killing Commands393866
Node: Readline Arguments395892
Node: Searching396985
Node: Readline Init File399231
Node: Readline Init File Syntax400537
Node: Conditional Init Constructs427491
Node: Sample Init File431879
Node: Bindable Readline Commands435002
Node: Commands For Moving436543
Node: Commands For History439010
Node: Commands For Text444404
Node: Commands For Killing448532
Node: Numeric Arguments451323
Node: Commands For Completion452478
Node: Keyboard Macros458177
Node: Miscellaneous Commands458881
Node: Readline vi Mode466427
Node: Programmable Completion467407
Node: Programmable Completion Builtins477146
Node: A Programmable Completion Example488886
Node: Using History Interactively494234
Node: Bash History Facilities494918
Node: Bash History Builtins498656
Node: History Interaction506254
Node: Event Designators511207
Node: Word Designators512788
Node: Modifiers515183
Node: Installing Bash517123
Node: Basic Installation518242
Node: Compilers and Options522121
Node: Compiling For Multiple Architectures522874
Node: Installation Names524630
Node: Specifying the System Type526867
Node: Sharing Defaults527616
Node: Operation Controls528333
Node: Optional Features529355
Node: Reporting Bugs542081
Node: Major Differences From The Bourne Shell543441
Node: GNU Free Documentation License564871
Node: Indexes590051
Node: Builtin Index590505
Node: Reserved Word Index597606
Node: Variable Index600054
Node: Function Index617470
Node: Concept Index631606

End Tag Table
+7 -3
View File
@@ -1379,6 +1379,8 @@ special pattern characters where that's necessary.
The array variable @code{BASH_REMATCH} records which parts of the string
matched the pattern.
Bash unsets @code{BASH_REMATCH}
before attempting the match, so if there is no match, it remains unset.
The element of @code{BASH_REMATCH} with index 0 contains the portion of
the string matching the entire regular expression.
Substrings matched by parenthesized subexpressions within the regular
@@ -1388,8 +1390,10 @@ 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.
in the global scope if it is not set;
if it is declared as a local variable before running
@code{[[},
Bash keeps it a local variable.
Expressions may be combined using the following operators, listed
in decreasing order of precedence:
@@ -5552,7 +5556,7 @@ 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})
@code{%q} and @code{%Q} 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} @emph{alternate form}, these two
+2 -2
View File
@@ -2,10 +2,10 @@
Copyright (C) 1988-2026 Free Software Foundation, Inc.
@end ignore
@set LASTCHANGE Tue Mar 3 10:46:54 EST 2026
@set LASTCHANGE Mon Mar 16 15:38:02 EDT 2026
@set EDITION 5.3
@set VERSION 5.3
@set UPDATED 3 March 2026
@set UPDATED 16 March 2026
@set UPDATED-MONTH March 2026
+3 -1
View File
@@ -263,6 +263,8 @@ cutfields (SHELL_VAR *v, arrayind_t ind, char *line, struct cutop *ops)
size_t llen, fsize;
int i, b, n, s, e, nf;
llen = strlen(line);
delim[0] = ops->delim;
delim[1] = '\0';
@@ -318,7 +320,7 @@ cutfields (SHELL_VAR *v, arrayind_t ind, char *line, struct cutop *ops)
}
/* build the string and assign or print it all at once */
buf = xmalloc (strlen (line) + 1);
buf = xmalloc (llen + 1);
for (i = 1, n = b = 0; b < nf; b++)
{
+2
View File
@@ -5424,6 +5424,8 @@ execute_function (SHELL_VAR *var, WORD_LIST *words, int flags, struct fd_bitmap
stop_pipeline (async, (COMMAND *)NULL);
#endif
/* We are no longer in a loop. See Posix interp 842 (the function is not
"lexically enclosed" by the loop). */
if (shell_compatibility_level > 43)
loop_level = 0;
+11 -6
View File
@@ -1,6 +1,6 @@
/* glob.c -- file-name wildcard pattern matching for Bash.
Copyright (C) 1985-2023 Free Software Foundation, Inc.
Copyright (C) 1985-2026 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne-Again SHell.
@@ -279,13 +279,16 @@ skipname (char *pat, char *dname, int flags)
literal `.'. This is the negation of the next clause. */
else if ((flags & GX_NEGATE) && noglob_dot_filenames == 0 &&
dname[0] == '.' &&
(pat[0] == '.' || (pat[0] == '\\' && pat[1] == '.')))
(pat[0] && pat[0] == '.' || (pat[0] == '\\' && pat[1] == '.')))
return 0;
#endif
/* If a dot must be explicitly matched, check to see if they do. */
/* If a dot must be explicitly matched, check to see if the
pattern and dirname both have one. */
/* This allows the empty pattern to `match' a `.', deferring the match
until later. */
else if (noglob_dot_filenames && dname[0] == '.' &&
pat[0] != '.' && (pat[0] != '\\' || pat[1] != '.'))
pat[0] && pat[0] != '.' && (pat[0] != '\\' || pat[1] != '.'))
return 1;
return 0;
@@ -312,14 +315,16 @@ wskipname (wchar_t *pat, wchar_t *dname, int flags)
literal `.'. This is the negation of the next clause. */
else if ((flags & GX_NEGATE) && noglob_dot_filenames == 0 &&
dname[0] == L'.' &&
(pat[0] == L'.' || (pat[0] == L'\\' && pat[1] == L'.')))
(pat[0] != L'\0' && pat[0] == L'.' || (pat[0] == L'\\' && pat[1] == L'.')))
return 0;
#endif
/* If a leading dot must be explicitly matched, check to see if the
pattern and dirname both have one. */
/* This allows the empty pattern to `match' a `.', deferring the match
until later. */
else if (noglob_dot_filenames && dname[0] == L'.' &&
pat[0] != L'.' && (pat[0] != L'\\' || pat[1] != L'.'))
pat[0] && pat[0] != L'.' && (pat[0] != L'\\' || pat[1] != L'.'))
return 1;
return 0;
+6 -4
View File
@@ -786,14 +786,15 @@ fprintf(stderr, "extmatch: flags = %d\n", flags);
switch (xc)
{
case L('+'): /* match one or more occurrences */
case L('*'): /* match zero or more occurrences */
/* If we can get away with no matches, don't even bother. Just
call GMATCH on the rest of the pattern and return success if
it succeeds. */
if (xc == L('*') && (GMATCH (s, se, prest, pe, NULL, flags) == 0))
if (GMATCH (s, se, prest, pe, NULL, flags) == 0)
return 0;
/* FALLTHROUGH */
case L('+'): /* match one or more occurrences */
/* OK, we have to do this the hard way. First, we make sure one of
the subpatterns matches, then we try to match the rest of the
string. */
@@ -824,13 +825,14 @@ fprintf(stderr, "extmatch: flags = %d\n", flags);
return (FNM_NOMATCH);
case L('?'): /* match zero or one of the patterns */
case L('@'): /* match one (or more) of the patterns */
/* If we can get away with no matches, don't even bother. Just
call gmatch on the rest of the pattern and return success if
it succeeds. */
if (xc == L('?') && (GMATCH (s, se, prest, pe, NULL, flags) == 0))
if ((GMATCH (s, se, prest, pe, NULL, flags) == 0))
return 0;
/* FALLTHROUGH */
case L('@'): /* match one (or more) of the patterns */
/* OK, we have to do this the hard way. First, we see if one of
the subpatterns matches, then, if it does, we try to match the
rest of the string. */
+2 -2
View File
@@ -1,6 +1,6 @@
/* patchlevel.h -- current bash patch level */
/* Copyright (C) 2001-2025 Free Software Foundation, Inc.
/* Copyright (C) 2001-2026 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
@@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
#define PATCHLEVEL 0
#define PATCHLEVEL 9
#endif /* _PATCHLEVEL_H_ */
+1 -1
View File
@@ -1,6 +1,6 @@
/* print_command -- A way to make readable commands from a command tree. */
/* Copyright (C) 1989-2025 Free Software Foundation, Inc.
/* Copyright (C) 1989-2026 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+1 -1
View File
@@ -1,6 +1,6 @@
/* shell.c -- GNU's idea of the POSIX shell specification. */
/* Copyright (C) 1987-2025 Free Software Foundation, Inc.
/* Copyright (C) 1987-2026 Free Software Foundation, Inc.
This file is part of GNU Bash, the Bourne Again SHell.
+4 -1
View File
@@ -616,7 +616,10 @@ termsig_handler (int sig)
an interactive shell is running in a terminal window that gets closed
with the `close' button. We can't test for RL_STATE_READCMD because
readline no longer handles SIGTERM synchronously. */
if (interactive_shell && interactive && (sig == SIGHUP || sig == SIGTERM) && (remember_on_history || enable_history_list))
if (interactive_shell &&
(interactive || parse_and_execute_level || sourcelevel) &&
(sig == SIGHUP || sig == SIGTERM) &&
(remember_on_history || enable_history_list))
maybe_save_shell_history ();
#endif /* HISTORY */
+4 -2
View File
@@ -7,8 +7,10 @@ trap 'echo CHLD' SIGCHLD
{ echo before ; : ; echo after; } &
wait
sleep 1 &
sleep 1 &
# use sleep 2 to avoid reaping these children while running the SIGCHLD trap
# after the `sleep 1'
sleep 2 &
sleep 2 &
sleep 1
wait