From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 1d1b895d for ; Mon, 30 Dec 2019 22:34:53 +0000 (UTC) Received: (qmail 3418 invoked by alias); 30 Dec 2019 22:34:47 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 45168 Received: (qmail 12857 invoked by uid 1010); 30 Dec 2019 22:34:47 -0000 X-Qmail-Scanner-Diagnostics: from know-smtprelay-omc-8.server.virginmedia.net by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.1/25677. spamassassin: 3.4.2. Clear:RC:0(80.0.253.72):SA:0(-2.0/5.0):. Processed in 2.356002 secs); 30 Dec 2019 22:34:47 -0000 X-Envelope-From: p.w.stephenson@ntlworld.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _smtprelay.virginmedia.com designates 80.0.253.72 as permitted sender) X-Originating-IP: [86.16.88.158] X-Authenticated-User: p.w.stephenson@ntlworld.com X-Spam: 0 X-Authority: v=2.3 cv=X6h81lbe c=1 sm=1 tr=0 a=MiHCjVqLJ44lE3bxSlffFQ==:117 a=MiHCjVqLJ44lE3bxSlffFQ==:17 a=jpOVt7BSZ2e4Z31A5e1TngXxSK0=:19 a=IkcTkHD0fZMA:10 a=hA7Hu1xAfz992XnQRoIA:9 a=QEXdDO2ut3YA:10 Message-ID: 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)) From: Peter Stephenson To: zsh-workers@zsh.org Date: Mon, 30 Dec 2019 22:34:07 +0000 In-Reply-To: <20191230212420.gk2jkimlk3epfdha@tarpaulin.shahaf.local2> References: <20191228210017.2cdgwgpqrssrfhgp@tarpaulin.shahaf.local2> <20191229020534.oqh5ri3nqealx4hj@tarpaulin.shahaf.local2> <20191230180036.u33ixxe5pjjk7lal@tarpaulin.shahaf.local2> <20191230212420.gk2jkimlk3epfdha@tarpaulin.shahaf.local2> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.28.5-0ubuntu0.18.04.1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit X-CMAE-Envelope: MS4wfMvTzfr5mmryC276mWV/w0crg+PiAWICdj3Tp7OYtfcOSLsNKxgYA+ZZNvbQ5T8zOzTaTyxo7I1PmXWg2LNKh5Q9YuFSNb7FKnk0np16dvtQ92LsXlgD pRCPgQJ7GIF1gd4QOXqBb9C40aoSKsUmofFy9Rye7+Js8VoR26HA/Lpu 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