Re: [PATCH] Fix leaked internal escapes of patsub_replacement ${var/$pat
From:
Chet Ramey
Subject:
Re: [PATCH] Fix leaked internal escapes of patsub_replacement ${var/$pat/"&"} with pat=# or pat=%
Date:
Mon, 18 Jul 2022 16:46:47 -0400
User-agent:
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:91.0) Gecko/20100101 Thunderbird/91.10.0
On 7/18/22 2:11 AM, Koichi Murase wrote:
Here is another patch that was pending.
Bash Version: 5.2
Commit 87a6e89edc7cb1af057e2c15666df189595d305b (the current devel)
Description:
When `shopt -s patsub_replacement' is turned on and the pattern
string `pat' of ${var/$pat/"&"} is just an anchoring character `#'
or `%', the internal escape of `&' (i.e., `\&') remains in the
result of the parameter expansion. Also, with the same condition,
the unquoted & in ${var/$pat/&} remains a literal & where we expect
it to be expanded to an empty string.
Thanks for the patch. I think this is reasonable; it duplicates what `sed'
does when presented with a BRE like '^' or '$', or when it gets a null
input line. I'll put this in for 5.2-rc2.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/