mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-03 18:30:49 +02:00
fixes to read/wait; revert change that processes $'...' quoting in here-documents unconditionally
This commit is contained in:
+48
-28
@@ -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.2, 26 December 2021).
|
||||
the Bash shell (version 5.2, 17 January 2022).
|
||||
|
||||
This is Edition 5.2, last updated 26 December 2021,
|
||||
This is Edition 5.2, last updated 17 January 2022,
|
||||
of The GNU Bash Reference Manual,
|
||||
for Bash, Version 5.2.
|
||||
|
||||
@@ -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, 17 January 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 17 January 2022,
|
||||
of <cite>The GNU Bash Reference Manual</cite>,
|
||||
for <code>Bash</code>, Version 5.2.
|
||||
</p>
|
||||
@@ -2845,45 +2845,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
|
||||
|
||||
Reference in New Issue
Block a user