From: Mikael Magnusson <mikachu@gmail.com>
To: Sebastian Gniazdowski <sgniazdowski@gmail.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: #% anchoring doesn't work with (S)
Date: Thu, 2 Feb 2023 11:44:00 +0100 [thread overview]
Message-ID: <CAHYJk3RTbwYaWsVo40kSa6HsrBYRpM46uhbTK_OApUpLFTFjZw@mail.gmail.com> (raw)
In-Reply-To: <CAHYJk3R9UGo=UTo=brTqHQnmrxTHiRxaoN1Q_9QfN4LWrsk7gQ@mail.gmail.com>
On 2/2/23, Mikael Magnusson <mikachu@gmail.com> wrote:
> On 2/2/23, Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
>> Could the bug be fixed? It already makes #% pretty much unusable for a
>> backward compatible software, yet in say 4 years this would be changed,
>> if
>> the bug would be fixed today
>
> 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.
>
> That said, compgetmatch() does this, which is probably your problem
> (it gives no real motivation for why it does this)
> /*
> * Search is anchored to the end of the string if we want to match
> * it all, or if we are matching at the end of the string and not
> * using substrings.
> */
> if ((*flp & SUB_ALL) || ((*flp & SUB_END) && !(*flp & SUB_SUBSTR)))
> patflags &= ~PAT_NOANCH;
Actually this is probably not it, it works if you don't use just a *
as the pattern:
% INPUT=ABCABCABC; INPUT=${(S)INPUT//#%((#b)(A*C))/°match°}; print
$INPUT $match
°match° ABCABCABC
% INPUT=ABCABCABC; INPUT=${INPUT//#%((#b)(A*C))/°match°}; print $INPUT
$match
°match° ABCABCABC
% INPUT=ABCABCABC; INPUT=${(S)INPUT//((#b)(A*C))/°match°}; print
$INPUT $match
°match°°match°°match° ABC
so it feels more like the * itself remembers the S flag but not the #%
flags. (But still, specifying the (S) flag in this case is useless in
the first place, so just don't specify it and your code will be
compatible with every version).
--
Mikael Magnusson
next prev parent reply other threads:[~2023-02-02 10:44 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 [this message]
2023-02-02 12:47 ` Sebastian Gniazdowski
2023-02-06 17:17 ` Bart Schaefer
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=CAHYJk3RTbwYaWsVo40kSa6HsrBYRpM46uhbTK_OApUpLFTFjZw@mail.gmail.com \
--to=mikachu@gmail.com \
--cc=sgniazdowski@gmail.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).