mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-02 09:50:50 +02:00
bash-5.2-beta release
This commit is contained in:
+116
-41
@@ -4,13 +4,13 @@
|
||||
<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.2, 26 December 2021).
|
||||
the Bash shell (version 5.2, 24 February 2022).
|
||||
|
||||
This is Edition 5.2, last updated 26 December 2021,
|
||||
This is Edition 5.2, last updated 24 February 2022,
|
||||
of The GNU Bash Reference Manual,
|
||||
for Bash, Version 5.2.
|
||||
|
||||
Copyright (C) 1988-2021 Free Software Foundation, Inc.
|
||||
Copyright (C) 1988-2022 Free Software Foundation, Inc.
|
||||
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3 or
|
||||
@@ -77,10 +77,10 @@ Next: <a href="#Introduction" accesskey="n" rel="next">Introduction</a>, Previou
|
||||
<span id="Bash-Features-1"></span><h1 class="top">Bash Features</h1>
|
||||
|
||||
<p>This text is a brief description of the features that are present in
|
||||
the Bash shell (version 5.2, 26 December 2021).
|
||||
the Bash shell (version 5.2, 24 February 2022).
|
||||
The Bash home page is <a href="http://www.gnu.org/software/bash/">http://www.gnu.org/software/bash/</a>.
|
||||
</p>
|
||||
<p>This is Edition 5.2, last updated 26 December 2021,
|
||||
<p>This is Edition 5.2, last updated 24 February 2022,
|
||||
of <cite>The GNU Bash Reference Manual</cite>,
|
||||
for <code>Bash</code>, Version 5.2.
|
||||
</p>
|
||||
@@ -1947,10 +1947,22 @@ return status is the exit status of the last command executed
|
||||
before the <code>return</code>.
|
||||
</p>
|
||||
<p>Variables local to the function may be declared with the
|
||||
<code>local</code> builtin. These variables are visible only to
|
||||
<code>local</code> builtin (<em>local variables</em>).
|
||||
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.
|
||||
</p>
|
||||
<p>In the following description, the <em>current scope</em> 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</code> or <code>declare</code> builtins in the
|
||||
function that is currently executing.
|
||||
</p>
|
||||
<p>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
|
||||
@@ -2003,11 +2015,13 @@ variable is local to the current scope, <code>unset</code> 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</code>shell option changes this behavior).
|
||||
</p>
|
||||
<p>Function names and definitions may be listed with the
|
||||
<samp>-f</samp> option to the <code>declare</code> (<code>typeset</code>)
|
||||
@@ -2608,7 +2622,7 @@ var is set and not null
|
||||
<dd><p>This is referred to as Substring Expansion.
|
||||
It expands to up to <var>length</var> characters of the value of <var>parameter</var>
|
||||
starting at the character specified by <var>offset</var>.
|
||||
If <var>parameter</var> is ‘<samp>@</samp>’, an indexed array subscripted by
|
||||
If <var>parameter</var> is ‘<samp>@</samp>’ or ‘<samp>*</samp>’, an indexed array subscripted by
|
||||
‘<samp>@</samp>’ or ‘<samp>*</samp>’, or an associative array name, the results differ as
|
||||
described below.
|
||||
If <var>length</var> is omitted, it expands to the substring of the value of
|
||||
@@ -2683,8 +2697,8 @@ bc
|
||||
$ echo ${array[0]: -7:-2}
|
||||
bcdef
|
||||
</pre>
|
||||
<p>If <var>parameter</var> is ‘<samp>@</samp>’, the result is <var>length</var> positional
|
||||
parameters beginning at <var>offset</var>.
|
||||
<p>If <var>parameter</var> is ‘<samp>@</samp>’ or ‘<samp>*</samp>’, the result is <var>length</var>
|
||||
positional parameters beginning at <var>offset</var>.
|
||||
A negative <var>offset</var> is taken relative to one greater than the greatest
|
||||
positional parameter, so an offset of -1 evaluates to the last positional
|
||||
parameter.
|
||||
@@ -2845,45 +2859,65 @@ and the ‘<samp>/</samp>’ following <var>pattern</var> may be omitted
|
||||
any unquoted instances of ‘<samp>&</samp>’ in <var>string</var> are replaced with the
|
||||
matching portion of <var>pattern</var>.
|
||||
This is intended to duplicate a common <code>sed</code> idiom.
|
||||
Backslash is used to quote ‘<samp>&</samp>’ in <var>string</var>; the backslash is removed
|
||||
</p>
|
||||
<p>Quoting any part of <var>string</var> inhibits replacement in the
|
||||
expansion of the quoted portion, including replacement strings stored
|
||||
in shell variables.
|
||||
Backslash will escape ‘<samp>&</samp>’ in <var>string</var>; the backslash is removed
|
||||
in order to permit a literal ‘<samp>&</samp>’ in the replacement string.
|
||||
Pattern substitution performs the check for ‘<samp>&</samp>’ after expanding
|
||||
<var>string</var>,
|
||||
so users should take care to quote backslashes intended to escape
|
||||
the ‘<samp>&</samp>’ and inhibit replacement so they survive any quote removal
|
||||
performed by the expansion of <var>string</var>.
|
||||
For instance,
|
||||
Users should take care if <var>string</var> 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>&</samp>’ after
|
||||
expanding <var>string</var>,
|
||||
so users should ensure to properly quote any occurrences of ‘<samp>&</samp>’
|
||||
they want to be taken literally in the replacement
|
||||
and ensure any instances of ‘<samp>&</samp>’ they want to be replaced are unquoted.
|
||||
</p>
|
||||
<p>For instance,
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">var=abcdef
|
||||
rep='& '
|
||||
echo ${var/abc/& }
|
||||
echo "${var/abc/& }"
|
||||
echo ${var/abc/"& "}
|
||||
echo ${var/abc/$rep}
|
||||
echo "${var/abc/$rep}"
|
||||
</pre></div>
|
||||
|
||||
<p>will display three lines of "abc def", while
|
||||
<p>will display four lines of "abc def", while
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">var=abcdef
|
||||
rep='& '
|
||||
echo ${var/abc/\& }
|
||||
echo "${var/abc/\& }"
|
||||
echo ${var/abc/"\& "}
|
||||
echo ${var/abc/"& "}
|
||||
echo ${var/abc/"$rep"}
|
||||
</pre></div>
|
||||
|
||||
<p>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</var>
|
||||
(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>\&</samp>’, and, because ‘<samp>&</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>\\&</samp>’, unquoted, as the replacement string to achive
|
||||
the same effect.
|
||||
It should rarely be necessary to enclose only <var>string</var> in double
|
||||
<p>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.
|
||||
</p>
|
||||
<p>Since backslash can escape ‘<samp>&</samp>’, it can also escape a backslash in
|
||||
the replacement string.
|
||||
This means that ‘<samp>\\</samp>’ will insert a literal
|
||||
backslash into the replacement, so these two <code>echo</code> commands
|
||||
</p>
|
||||
<div class="example">
|
||||
<pre class="example">var=abcdef
|
||||
rep='\\&xyz'
|
||||
echo ${var/abc/\\&xyz}
|
||||
echo ${var/abc/$rep}
|
||||
</pre></div>
|
||||
|
||||
<p>will both output ‘<samp>\abcxyzdef</samp>’.
|
||||
</p>
|
||||
<p>It should rarely be necessary to enclose only <var>string</var> in double
|
||||
quotes.
|
||||
</p>
|
||||
<p>If the <code>nocasematch</code> shell option
|
||||
@@ -8626,6 +8660,9 @@ interpreted as relative to one greater than the maximum index of
|
||||
<var>name</var>, so negative indices count back from the end of the
|
||||
array, and an index of -1 references the last element.
|
||||
</p>
|
||||
<p>The ‘<samp>+=</samp>’ operator will append to an array variable when assigning
|
||||
using the compound assignment syntax; see <a href="#Shell-Parameters">Shell Parameters</a> above.
|
||||
</p>
|
||||
<p>Any element of an array may be referenced using
|
||||
<code>${<var>name</var>[<var>subscript</var>]}</code>.
|
||||
The braces are required to avoid
|
||||
@@ -9102,6 +9139,12 @@ example, <code>SIGTSTP</code>.
|
||||
</li><li> Reserved words appearing in a context where reserved words are recognized
|
||||
do not undergo alias expansion.
|
||||
|
||||
</li><li> 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).
|
||||
|
||||
</li><li> The <small>POSIX</small> <code>PS1</code> and <code>PS2</code> expansions of ‘<samp>!</samp>’ to
|
||||
the history number and ‘<samp>!!</samp>’ to ‘<samp>!</samp>’ are enabled,
|
||||
and parameter expansion is performed on the values of <code>PS1</code> and
|
||||
@@ -9338,8 +9381,8 @@ Previous: <a href="#Bash-POSIX-Mode" accesskey="p" rel="prev">Bash POSIX Mode</a
|
||||
<span id="index-Compatibility-Level"></span>
|
||||
<span id="index-Compatibility-Mode"></span>
|
||||
|
||||
<p>Bash-4.0 introduced the concept of a ‘shell compatibility level’, specified
|
||||
as a set of options to the shopt builtin
|
||||
<p>Bash-4.0 introduced the concept of a <em>shell compatibility level</em>,
|
||||
specified as a set of options to the shopt builtin
|
||||
(<code>compat31</code>,
|
||||
<code>compat32</code>,
|
||||
<code>compat40</code>,
|
||||
@@ -10293,6 +10336,32 @@ variables.
|
||||
</p>
|
||||
<span id="index-variables_002c-readline"></span>
|
||||
<dl compact="compact">
|
||||
<dt id='index-active_002dregion_002dstart_002dcolor'><span><code>active-region-start-color</code><a href='#index-active_002dregion_002dstart_002dcolor' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>A string variable that controls the text color and background when displaying
|
||||
the text in the active region (see the description of
|
||||
<code>enable-active-region</code> below).
|
||||
This string must not take up any physical character positions on the display,
|
||||
so it should consist only of terminal escape sequences.
|
||||
It is output to the terminal before displaying the text in the active region.
|
||||
This variable is reset to the default value whenever the terminal type changes.
|
||||
The default value is the string that puts the terminal in standout mode,
|
||||
as obtained from the terminal’s terminfo description.
|
||||
A sample value might be ‘<samp>\e[01;33m</samp>’.
|
||||
</p>
|
||||
</dd>
|
||||
<dt id='index-active_002dregion_002dend_002dcolor'><span><code>active-region-end-color</code><a href='#index-active_002dregion_002dend_002dcolor' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>A string variable that "undoes" the effects of <code>active-region-start-color</code>
|
||||
and restores "normal" terminal display appearance after displaying text
|
||||
in the active region.
|
||||
This string must not take up any physical character positions on the display,
|
||||
so it should consist only of terminal escape sequences.
|
||||
It is output to the terminal after displaying the text in the active region.
|
||||
This variable is reset to the default value whenever the terminal type changes.
|
||||
The default value is the string that restores the terminal from standout mode,
|
||||
as obtained from the terminal’s terminfo description.
|
||||
A sample value might be ‘<samp>\e[0m</samp>’.
|
||||
</p>
|
||||
</dd>
|
||||
<dt id='index-bell_002dstyle'><span><code>bell-style</code><a href='#index-bell_002dstyle' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>Controls what happens when Readline wants to ring the terminal bell.
|
||||
If set to ‘<samp>none</samp>’, Readline never rings the bell. If set to
|
||||
@@ -10426,6 +10495,8 @@ The text between the point and mark is referred to as the <em>region</em>.
|
||||
When this variable is set to ‘<samp>On</samp>’, Readline allows certain commands
|
||||
to designate the region as <em>active</em>.
|
||||
When the region is active, Readline highlights the text in the region using
|
||||
the value of the <code>active-region-start-color</code>, which defaults to the
|
||||
string that enables
|
||||
the terminal’s standout mode.
|
||||
The active region shows the text inserted by bracketed-paste and any
|
||||
matching text found by incremental and non-incremental history searches.
|
||||
@@ -10433,11 +10504,13 @@ The default is ‘<samp>On</samp>’.
|
||||
</p>
|
||||
</dd>
|
||||
<dt id='index-enable_002dbracketed_002dpaste'><span><code>enable-bracketed-paste</code><a href='#index-enable_002dbracketed_002dpaste' class='copiable-anchor'> ¶</a></span></dt>
|
||||
<dd><p>When set to ‘<samp>On</samp>’, Readline will configure the terminal in a way
|
||||
that will enable it to insert each paste into the editing buffer as a
|
||||
single string of characters, instead of treating each character as if
|
||||
it had been read from the keyboard. This can prevent pasted characters
|
||||
from being interpreted as editing commands. The default is ‘<samp>On</samp>’.
|
||||
<dd><p>When set to ‘<samp>On</samp>’, Readline configures the terminal to insert each
|
||||
paste into the editing buffer as a single string of characters, instead
|
||||
of treating each character as if it had been read from the keyboard.
|
||||
This is called putting the terminal into <em>bracketed paste mode</em>;
|
||||
it prevents Readline from executing any editing commands bound to key
|
||||
sequences appearing in the pasted text.
|
||||
The default is ‘<samp>On</samp>’.
|
||||
</p>
|
||||
</dd>
|
||||
<dt id='index-enable_002dkeypad'><span><code>enable-keypad</code><a href='#index-enable_002dkeypad' class='copiable-anchor'> ¶</a></span></dt>
|
||||
@@ -15129,6 +15202,8 @@ Next: <a href="#Function-Index" accesskey="n" rel="next">Function Index</a>, Pre
|
||||
<tr><td></td><td valign="top"><a href="#index-_005f"><code>_</code></a>:</td><td> </td><td valign="top"><a href="#Bash-Variables">Bash Variables</a></td></tr>
|
||||
<tr><td colspan="4"> <hr></td></tr>
|
||||
<tr><th id="Variable-Index_vr_letter-A">A</th><td></td><td></td></tr>
|
||||
<tr><td></td><td valign="top"><a href="#index-active_002dregion_002dend_002dcolor"><code>active-region-end-color</code></a>:</td><td> </td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
|
||||
<tr><td></td><td valign="top"><a href="#index-active_002dregion_002dstart_002dcolor"><code>active-region-start-color</code></a>:</td><td> </td><td valign="top"><a href="#Readline-Init-File-Syntax">Readline Init File Syntax</a></td></tr>
|
||||
<tr><td></td><td valign="top"><a href="#index-auto_005fresume"><code>auto_resume</code></a>:</td><td> </td><td valign="top"><a href="#Job-Control-Variables">Job Control Variables</a></td></tr>
|
||||
<tr><td colspan="4"> <hr></td></tr>
|
||||
<tr><th id="Variable-Index_vr_letter-B">B</th><td></td><td></td></tr>
|
||||
|
||||
Reference in New Issue
Block a user