From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: #% anchoring doesn't work with (S)
Date: Mon, 6 Feb 2023 09:17:56 -0800 [thread overview]
Message-ID: <CAH+w=7Z1BVw9s1PbNzonc5knGcSMRWYr7f2teuhEZOazOHKuNg@mail.gmail.com> (raw)
In-Reply-To: <CAKc7PVCqLLrq24Haa7JuUpvEdZz-VSujhsS=fdbhe37HqETBYw@mail.gmail.com>
On Thu, Feb 2, 2023 at 4:49 AM Sebastian Gniazdowski
<sgniazdowski@gmail.com> wrote:
> On Thu, 2 Feb 2023 at 10:32, Mikael Magnusson <mikachu@gmail.com> wrote:
>>
>> Why would you use (S) (shortest possible match) with #% (match the
>> entire string)? It will obviously never have a useful effect other
>> than doing nothing.
>
> It does have sense to match shortest and anchor to #%, it simply moves the "weight" on the right side of the pattern, i.e. "ABC" == (?)* vs ABC == *(?) (not very correct, but shows the thought).
Arguably then this is wrong:
% sample=match
% : ${(S)sample/(#b)(#s)(m*)(*)(#e)}; printf "<%s>" $match ; echo
<match>
I expected <m><atch>. Compare without the end anchor:
% : ${(S)sample/(#b)(#s)(m*)(*)}; printf "<%s>" $match ; echo
<m>
In any case the behavior of PWS's patch appears to be the same.
Also
% : ${(S)sample/(#b)(#s)(m*)(*h)}; printf "<%s>" $match ; echo
<matc><h>
I guess it's ambiguous, but in other patterns like (this|that) we
prefer the left before the right.
next prev parent reply other threads:[~2023-02-06 17:18 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-30 12:32 Sebastian Gniazdowski
2023-02-02 8:31 ` Sebastian Gniazdowski
2023-02-02 10:32 ` Mikael Magnusson
2023-02-02 10:44 ` Mikael Magnusson
2023-02-02 12:47 ` Sebastian Gniazdowski
2023-02-06 17:17 ` Bart Schaefer [this message]
2023-02-06 17:31 ` Peter Stephenson
2023-02-02 10:49 ` Peter Stephenson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAH+w=7Z1BVw9s1PbNzonc5knGcSMRWYr7f2teuhEZOazOHKuNg@mail.gmail.com' \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).