zsh-users
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.stephenson@samsung.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: Non-greedy matching (S-flag) behaving weird
Date: Fri, 8 Jun 2018 14:54:32 +0100	[thread overview]
Message-ID: <20180608135436eucas1p2672a3bf2fe4781a1a588e85aa0c8fda2~2M8xnZsPd1645716457eucas1p2_@eucas1p2.samsung.com> (raw)
In-Reply-To: <20180608143012.394398bf@camnpupstephen.cam.scsc.local>

On Fri, 8 Jun 2018 14:30:12 +0100
Peter Stephenson <p.stephenson@samsung.com> wrote:
> On Fri, 8 Jun 2018 08:48:05 +0200
> Sebastian Gniazdowski <sgniazdowski@gmail.com> 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


      parent reply	other threads:[~2018-06-08 13:54 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20180608064952epcas4p4e8890504ddaf097f8d0df1cb1e89d619@epcas4p4.samsung.com>
2018-06-08  6:48 ` Sebastian Gniazdowski
2018-06-08  8:15   ` Peter Stephenson
2018-06-08 12:42     ` Sebastian Gniazdowski
2018-06-08 12:48       ` Sebastian Gniazdowski
2018-06-08 13:30   ` Peter Stephenson
     [not found]   ` <20180608143012.394398bf@camnpupstephen.cam.scsc.local>
2018-06-08 13:54     ` Peter Stephenson [this message]

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='20180608135436eucas1p2672a3bf2fe4781a1a588e85aa0c8fda2~2M8xnZsPd1645716457eucas1p2_@eucas1p2.samsung.com' \
    --to=p.stephenson@samsung.com \
    --cc=zsh-users@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).