Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: [PATCH] zshexpn: Expand documentation of (S) (was: Re: [Bug] S-flag imposes non-greedy match where it shouldn't)
- X-seq: zsh-workers 45163
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- Subject: Re: [PATCH] zshexpn: Expand documentation of (S) (was: Re: [Bug] S-flag imposes non-greedy match where it shouldn't)
- Date: Mon, 30 Dec 2019 21:20:34 +0100
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx>
- In-reply-to: <CAN=4vMqyNngcWKH7TfN14Rh+5vyDJ-v8ciNiF7OHrNQG=OLvDA@mail.gmail.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- List-unsubscribe: <mailto:zsh-workers-unsubscribe@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVCUBKfsOSakwNwrcx1Xkf09b5CFJJDxjKFYU42oAUFZ-g@mail.gmail.com> <CAKc7PVCPPeE36W4aSKu5rid2Vem+Q+h5XZTX+k7=E9qLU0nPhw@mail.gmail.com> <1a130b2e-5824-4b7a-8510-2b1d0b3fdac5@www.fastmail.com> <CAKc7PVDOMz1wvMGWYOki7ca5dHodMJx30eq8UEzgj=D+W7E4aQ@mail.gmail.com> <20191227052923.yal2nnmxdxfgvfkr@tarpaulin.shahaf.local2> <CAKc7PVDx6WEFcZFS3TQ6+rF1YpA3jkD5sWwr0LCNE_c5MYkxVg@mail.gmail.com> <20191228210017.2cdgwgpqrssrfhgp@tarpaulin.shahaf.local2> <CAKc7PVD7UCc5yqDays=xCVFa=-Ns6phhqLd2se_+3iKNzOr5tA@mail.gmail.com> <20191229020534.oqh5ri3nqealx4hj@tarpaulin.shahaf.local2> <CAKc7PVDhkOm9gQ-mxRnyh=MT_onqvsQAzymcpV+AguanHa7nig@mail.gmail.com> <20191230180036.u33ixxe5pjjk7lal@tarpaulin.shahaf.local2> <CAN=4vMor_OBci8FRDkQjM8GfpGuM2A58D=nN+WoDgpQrpRKBzg@mail.gmail.com> <CAKc7PVAXLpKqZvmbazZK=mvcz8T-AHJXKusut6aEjkkSLzgdbw@mail.gmail.com> <CAN=4vMqyNngcWKH7TfN14Rh+5vyDJ-v8ciNiF7OHrNQG=OLvDA@mail.gmail.com>
On Mon, 30 Dec 2019 at 21:01, Roman Perepelitsa
<roman.perepelitsa@xxxxxxxxx> wrote:
> They do with the latest patch for (S) from Daniel:
>
> > With tt(%) or tt(%%), search for the match that starts closest to the end of
> > the string
>
> This means that ${(S)str%%X##} is going to find a match that starts
> closest to the end of the string and remove it. X## matches one or
> move X characters. We go backwards one character at a time until X##
> matches. The first match starts at str[-2] and the match is X, so X
> gets removed. This seems clear from the docs.
Ok, this does seem to capture the issue.
> I think it would be beneficial to specify that with ${(S)str##pattern}
> the first attempted match starts at str[-1] and that no attempt is
> made to check if the empty string (the ultimate shortest suffix)
> matches. I think you or someone else has recently raised this point as
> this seems inconsistent. It's surprising to me that both ${str#*} and
> ${(S)str%*} expand to $str while ${(S)str%%*} doesn't.
Also, ${str%*} doesn't expand to $str, which seems to be a bug? Is it
a different uncover of the one from users/22600?
--
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org
Messages sorted by:
Reverse Date,
Date,
Thread,
Author