[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Quilt-dev] [PATCH] patch_format: escape all occurences of %
From: |
Andreas Grünbacher |
Subject: |
Re: [Quilt-dev] [PATCH] patch_format: escape all occurences of % |
Date: |
Thu, 6 Jun 2024 16:30:01 +0200 |
Am Do., 6. Juni 2024 um 09:26 Uhr schrieb Jean Delvare <jdelvare@suse.de>:
> On Wed, 5 Jun 2024 23:11:43 +0200, Andreas Grünbacher wrote:
> > Am Mi., 5. Juni 2024 um 22:57 Uhr schrieb Jean Delvare <jdelvare@suse.de>:
> > > On Tue, 14 May 2024 14:50:34 +0200, Andreas Grünbacher wrote:
> > > > Thanks, that's better, but since that's used as a printf format
> > > > string, shouldn't backslashes also be escaped, like
> > > > ${prefix//[%\\]/&&}?
> > >
> > > Have you tested this? I don't think "&" as a reference to the pattern
> > > match works in bash pattern substitution the way it does in sed
> > > substitutions.
> >
> > No, I alway commit code completely untested. Here's a "test script":
> >
> > prefix='a%b\c'; echo ${prefix//[%\\]/&&}
>
> $ 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.
Andreas