Re: Changed behaviour of ${PARAMETER/#PATTERN/STRING} and ${PARAMETER/%P
From:
Chet Ramey
Subject:
Re: Changed behaviour of ${PARAMETER/#PATTERN/STRING} and ${PARAMETER/%PATTERN/STRING}
Date:
Tue, 14 May 2024 11:02:28 -0400
User-agent:
Mozilla Thunderbird
On 5/13/24 12:04 PM, Andreas Schwab wrote:
In 5.3-alpha, it is no longer possible to quote the special % and #
characters in a pattern replacement expansion.
$ a=1/%2/%3
$ echo "${a/\%/##}"
1/%2/%3##
Interesting. This is actually the result of the (seemingly unrelated)
https://lists.gnu.org/archive/html/bug-bash/2023-07/msg00115.html
The fix for this issue is to make sure that backslashes preceding `%' and
`#' are not removed. That should take care of pattern substitution and
pattern removal.
--
``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/