Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Non-greedy matching (S-flag) behaving weird
- X-seq: zsh-users 23452
- From: Peter Stephenson <p.stephenson@xxxxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: Non-greedy matching (S-flag) behaving weird
- Date: Fri, 8 Jun 2018 14:54:32 +0100
- Cms-type: 201P
- Dkim-filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20180608135442euoutp01209bd9434a5f2bedfd44836ddbd647f9~2M83bb5rP2072120721euoutp018
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1528466082; bh=W087BhQ1SCIyfLJbLStQk2y3iwSJ/6qbFAENCgAOcLQ=; h=Date:From:To:Subject:In-Reply-To:References:From; b=SRnJXDAzKk7g5EYqwS9fv8u3+qChp8PoAjCh7LA/R00ITJ3exzu0lbA/L/F2Fs7e3 /2oQxuxC+yonx3Sy7iUdNa1FhK5TRFDk+0chVLqNiXnqiLL4jGwdpGx3jQh555CAp+ 6jDXKpRuQ09J1cWRe6L5EWA0q2ly/Cp7G1XPJtvQ=
- In-reply-to: <20180608143012.394398bf@camnpupstephen.cam.scsc.local>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- Organization: SCSC
- References: <CGME20180608064952epcas4p4e8890504ddaf097f8d0df1cb1e89d619@epcas4p4.samsung.com> <CAKc7PVDQcSL2fkot2i6H3YVwcp=q=bQ2DohTdfPGn2p5idH2Sw@mail.gmail.com> <20180608143012.394398bf@camnpupstephen.cam.scsc.local>
On Fri, 8 Jun 2018 14:30:12 +0100
Peter Stephenson <p.stephenson@xxxxxxxxxxx> wrote:
> On Fri, 8 Jun 2018 08:48:05 +0200
> Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx> wrote:
> >
> > ~ __wrd2="echo abc | awk '{ print \$1 } END { print 'Finished' }'"
> >
> > ~
> > __wrd2="${(S)__wrd2/(#b)(#s)(*)(BEGIN|END|print)(*)(#e)/${match[3]}}";
>
> You are onto a loser with multiple *'s with the greedy match rule
> relaxed; it's poorly defined. so the fact it's not doing what you
> expect isn't saying anything. (That's why the greedy match rule
> is there in the first place.) But you'll be better off consulting
> a more authoritative source than me if you want more, so I'll
> sign off now.
I should probably point out, though, that the (S) flag in any
case only guarantees to make the match for the *whole* left part of
the /.../... expression as short as possible. Given you're forcing it
to match the entire string in any case, it has no effect.
It is not documented to match *individual parts* of the match
expression in any particular way. So actually my remarks on non-greedy
matching aren't relevant. Sorry I didn't check the doc earlier
instead of spreading unnecessary confusion.
pws
Messages sorted by:
Reverse Date,
Date,
Thread,
Author