On Thu, Jun 19, 2025, at 6:10 PM, Lawrence Velázquez wrote:
> This changed in bash 5.2:
>
>       There is a new shell option, `patsub_replacement'.  When
>       enabled, a `&' in the replacement string of the pattern
>       substitution expansion is replaced by the portion of the
>       string that matched the pattern.  Backslash will escape the
>       `&' and insert a literal `&'.  This option is enabled by
>       default.
>
> (Since '\' is now an escape character, the fact that it escapes
> itself is implied.)

To be clear, I meant that it is implied in that announcement excerpt.
The current man page states it rather explicitly:

        Quoting any part of _string_ inhibits replacement in the
        expansion of the quoted portion, including replacement
        strings stored in shell variables.  Backslash will escape
        `&' in _string_; the backslash is removed in order to permit
        a literal `&' in the replacement string.  Backslash can
        also be used to escape a backslash; `\\' results in a literal
        backslash in the replacement.

-- 
vq

Reply via email to