quilt-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Quilt-dev] [PATCH] patch_format: escape all occurences of %


From: Jean Delvare
Subject: Re: [Quilt-dev] [PATCH] patch_format: escape all occurences of %
Date: Fri, 7 Jun 2024 15:49:28 +0200

Hallo Andreas,

On Thu, 6 Jun 2024 16:30:01 +0200, Andreas Grünbacher wrote:
> Am Do., 6. Juni 2024 um 09:26 Uhr schrieb Jean Delvare <jdelvare@suse.de>:
> > $ prefix='a%b\c'; echo ${prefix//[%\\]/&&}
> > a&&b&&c
> > $ echo $BASH_VERSION
> > 4.4.23(1)-release
> >
> > So it clearly doesn't work for me.
> >
> > From the CHANGES file, it is a new feature of bash version 5.2:
> >
> > x. 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 `&'.
> >
> > Quilt currently works with bash versions 3.0 and later, so I'm afraid
> > you'll have to come up with a more portable solution.  
> 
> Uh, I didn't notice this was a rather new bash feature. Thanks for
> pointing this out; I've fixed it now.

Thanks. Unfortunately the test suite no longer passes for bash 3.0:

bash-3.00$ prefix=patches/
bash-3.00$ echo "${prefix//%/%%}%s"
patches/%%%s

This makes no sense whatsoever and is clearly a bug in this old version
of bash. Even odder is that this issue is listed as being fixed since
bash 2.03:

i.  Fixed pattern substitution so that a bare `#'as a pattern causes the
    replacement string to be prefixed to the search string, and a bare
    `%' causes the replacement string to be appended to the search string.

but my testing clearly shows that bash 3.0.22 and 3.1.23 are still
affected. 3.2.57 is good.

A workaround exists, which is to escape the % in the pattern with a \.
Note that this was the case before you fixed the bug reported by
Andreas Schwab. When I looked at the diff, I wonder why this \ was
there in the first place as it did not seem to be needed. Now I
understand... Alternatively, we can use [%] as the pattern, this also
works around the bug.

So I think that we have 2 options, either we use a workaround again,
or we have to increase the minimum bash version from 3.0 to 3.2. If we
go for a workaround, we should add a comment to avoid reintroducing the
same regression in the future.

-- 
Jean Delvare
SUSE L3 Support



reply via email to

[Prev in Thread] Current Thread [Next in Thread]