mirror of
https://https.git.savannah.gnu.org/git/bash.git
synced 2026-07-12 22:50:49 +02:00
enable support for using `&' in the pattern substitution replacement string
This commit is contained in:
+36
-10
@@ -5,12 +5,12 @@
|
||||
.\" Case Western Reserve University
|
||||
.\" chet.ramey@case.edu
|
||||
.\"
|
||||
.\" Last Change: Mon Aug 23 10:08:28 EDT 2021
|
||||
.\" Last Change: Fri Oct 1 14:20:30 EDT 2021
|
||||
.\"
|
||||
.\" bash_builtins, strip all but Built-Ins section
|
||||
.if \n(zZ=1 .ig zZ
|
||||
.if \n(zY=1 .ig zY
|
||||
.TH BASH 1 "2021 August 23" "GNU Bash 5.1"
|
||||
.TH BASH 1 "2021 October 1" "GNU Bash 5.1"
|
||||
.\"
|
||||
.\" There's some problem with having a `@'
|
||||
.\" in a tagged paragraph with the BSD man macros.
|
||||
@@ -3336,22 +3336,48 @@ the pattern removal operation is applied to each member of the
|
||||
array in turn, and the expansion is the resultant list.
|
||||
.TP
|
||||
${\fIparameter\fP\fB/\fP\fIpattern\fP\fB/\fP\fIstring\fP}
|
||||
.PD 0
|
||||
.TP
|
||||
${\fIparameter\fP\fB//\fP\fIpattern\fP\fB/\fP\fIstring\fP}
|
||||
.TP
|
||||
${\fIparameter\fP\fB/#\fP\fIpattern\fP\fB/\fP\fIstring\fP}
|
||||
.TP
|
||||
${\fIparameter\fP\fB/%\fP\fIpattern\fP\fB/\fP\fIstring\fP}
|
||||
.PD
|
||||
\fBPattern substitution\fP.
|
||||
The \fIpattern\fP is expanded to produce a pattern just as in
|
||||
pathname expansion,
|
||||
pathname expansion.
|
||||
\fIParameter\fP is expanded and the longest match of \fIpattern\fP
|
||||
against its value is replaced with \fIstring\fP.
|
||||
\fIstring\fP undergoes tilde expansion, parameter and variable expansion,
|
||||
arithmetic expansion, command and process substitution, and quote removal.
|
||||
The match is performed using the rules described under
|
||||
.B Pattern Matching
|
||||
below.
|
||||
If \fIpattern\fP begins with \fB/\fP, all matches of \fIpattern\fP are
|
||||
replaced with \fIstring\fP. Normally only the first match is replaced.
|
||||
If \fIpattern\fP begins with \fB#\fP, it must match at the beginning
|
||||
of the expanded value of \fIparameter\fP.
|
||||
If \fIpattern\fP begins with \fB%\fP, it must match at the end
|
||||
of the expanded value of \fIparameter\fP.
|
||||
If \fIstring\fP is null, matches of \fIpattern\fP are deleted
|
||||
In the first form above, only the first match is replaced.
|
||||
If there are two slashes separating \fIparameter\fP and \fIpattern\fP
|
||||
(the second form above), all matches of \fIpattern\fP are
|
||||
replaced with \fIstring\fP.
|
||||
If \fIpattern\fP is preceded by \fB#\fP (the third form above),
|
||||
it must match at the beginning of the expanded value of \fIparameter\fP.
|
||||
If \fIpattern\fP is preceded by \fB%\fP (the fourth form above),
|
||||
it must match at the end of the expanded value of \fIparameter\fP.
|
||||
If the expansion of \fIstring\fP is null,
|
||||
matches of \fIpattern\fP are deleted.
|
||||
If \fIstring\fP is null,
|
||||
matches of \fIpattern\fP are deleted
|
||||
and the \fB/\fP following \fIpattern\fP may be omitted.
|
||||
Any unquoted instances of \fB&\fP in \fIstring\fP are replaced with the
|
||||
matching portion of \fIpattern\fP.
|
||||
Backslash is used to quote \fB&\fP in \fIstring\fP; the backslash is removed
|
||||
in order to permit a literal \fB&\fP in the replacement string.
|
||||
Users should take care
|
||||
if \fIstring\fP is double-quoted to avoid unwanted interactions between
|
||||
the backslash and double-quoting.
|
||||
Pattern substitution performs the check for \fB&\fP after expanding
|
||||
\fIstring\fP; shell programmers should quote backslashes intended to escape
|
||||
the \fB&\fP and inhibit replacement so they survive any quote removal
|
||||
performed by the expansion of \fIstring\fP.
|
||||
If the
|
||||
.B nocasematch
|
||||
shell option is enabled, the match is performed without regard to the case
|
||||
|
||||
Reference in New Issue
Block a user