From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: zsh-workers@zsh.org
Subject: Re: ${(S)%%*} doesn't match the empty string (was: 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 22:34:07 +0000 [thread overview]
Message-ID: <eb413c6954ed86bfd727df7a813e86db357127c0.camel@ntlworld.com> (raw)
In-Reply-To: <20191230212420.gk2jkimlk3epfdha@tarpaulin.shahaf.local2>
On Mon, 2019-12-30 at 21:24 +0000, Daniel Shahaf wrote:
> 1 % set -- foo
> 2 % p ${1#*}
> 3 foo
> 4 % p ${1%*}
> 5 foo
> 6 % p ${(S)1#*}
> 7 foo
> 8 % p ${(S)1%*}
> 9 foo
> 10 % p ${1##*}
> 11
> 12 % p ${1%%*}
> 13
> 14 % p ${(S)1##*}
> 15
> 16 % p ${(S)1%%*}
> 17 fo
> 18 %
>
> Isn't this an implementation bug?
The last one certainly doesn't look right.
The top-and-tail operators are already complicated without the substring
matching, which was bolted on later wihtout a particularly good set of
ground rules about how the loops looking for the longest or shortest
match and for a given substring interacted in the case of pattern
matches where the match itself can have a variable length. Furthermore,
as you'll see, a lot of the various cases start / end, longest /
shortest, full / substring are implemented separately (though in return
that makes it a bit easier to fix a problem case without disturbing
others). So it's actually quite easy for something like this to lie
around for a long time.
pws
next prev parent reply other threads:[~2019-12-30 22:34 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-18 20:41 [Bug] S-flag imposes non-greedy match where it shouldn't Sebastian Gniazdowski
2019-12-18 20:44 ` Sebastian Gniazdowski
2019-12-19 15:29 ` Daniel Shahaf
2019-12-26 18:35 ` Sebastian Gniazdowski
2019-12-27 4:54 ` Sebastian Gniazdowski
2019-12-27 5:09 ` Sebastian Gniazdowski
2019-12-27 5:29 ` Daniel Shahaf
2019-12-28 19:04 ` Sebastian Gniazdowski
2019-12-28 20:34 ` Bart Schaefer
2019-12-28 21:00 ` Daniel Shahaf
2019-12-29 0:56 ` Sebastian Gniazdowski
2019-12-29 2:05 ` Daniel Shahaf
2019-12-29 3:14 ` Sebastian Gniazdowski
2019-12-30 18:00 ` [PATCH] zshexpn: Expand documentation of (S) (was: Re: [Bug] S-flag imposes non-greedy match where it shouldn't) Daniel Shahaf
2019-12-30 18:11 ` Roman Perepelitsa
[not found] ` <CAKc7PVAXLpKqZvmbazZK=mvcz8T-AHJXKusut6aEjkkSLzgdbw@mail.gmail.com>
2019-12-30 20:01 ` Roman Perepelitsa
2019-12-30 20:20 ` Sebastian Gniazdowski
2019-12-30 21:24 ` ${(S)%%*} doesn't match the empty string (was: Re: [PATCH] zshexpn: Expand documentation of (S) (was: Re: [Bug] S-flag imposes non-greedy match where it shouldn't)) Daniel Shahaf
2019-12-30 21:44 ` Roman Perepelitsa
2019-12-30 22:11 ` Sebastian Gniazdowski
2019-12-30 22:34 ` Peter Stephenson [this message]
2019-12-30 21:40 ` [PATCH] zshexpn: Expand documentation of (S) (was: Re: [Bug] S-flag imposes non-greedy match where it shouldn't) Roman Perepelitsa
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=eb413c6954ed86bfd727df7a813e86db357127c0.camel@ntlworld.com \
--to=p.w.stephenson@ntlworld.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).