From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 15437 invoked from network); 6 Feb 2023 17:31:59 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 6 Feb 2023 17:31:59 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1675704719; b=Rm2Hla/SrzLcqgWrPF85qRaKonLs8HU1C71kfUsT5wzpOksCoEjTy/MwAhrW6gHO4poZZ0dSbM afN+My5smz8bb0W56bblIN8WIMugfmdJb0ySbHWrxwjruOiIDbO02I75Xwtja9OrjfVD+1hieU s77oGTTXAHldWXKTZwOE3vjApt/s04uhrRUGlKWRY3MEwo7MZM1sI3GmXas+cME1WPuEOfL15s pNabJoprHtyEJeFHtfDwngS/FptvYVJYLCPsAxu4tleRQ2P/ofOuIt40n5r3s/MQgthsMo80Zg KJSOEWzi4KA2+1Funk263TfUuPVqKRLCMU4H01DSXB+O7A==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (smtpq2.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.97; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1675704719; bh=6sV9UC0o70iE71h2C61KsimjZ0ZmYctM3oL5bNUuLwk=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject: References:In-Reply-To:Message-ID:To:From:Date:DKIM-Signature: DKIM-Signature; b=hapc55wyHvwjM8PCZjTzGkfcCl3o3+xe/VPQgjk9n/l/mfvX8V0MZhkFjRORVba4DAk4u5hnKy J9Hp+6Yt/f1EeDB7Vl6cxspy1A8/8EyuVMT/v11xiTTmbI66+rU8OunB3KqlQSuVlVMQ7KG3pI rcMoVhQo67Z/iVuu98p6QIS1buNsIRe5U7oHZE3fKiu0Y5AlPkxV1TphbkvdwVv4GxLN+nv9Tf JocNiwonoD5TlTICg6zTcAS5vqbXuVxsZrOqbTu8gdew60PuxmOLC/jwcHnQoU3LQx69UomLyt oGC1uYQf+kczy6NmLVYe67+YTOqec1cfn7t7uENe2YOCNQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Subject:References:In-Reply-To:Message-ID:To:From: Date:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=DGIVpObc4zLhZntHFrxpyNJ7L6UaWTHX2UzJ9474T1U=; b=moZalwxQUKebKgrSgJNoN9mTH8 OSBNwmBP4gRQdcg86mW/Ok/BvkrOCvAUIPNLg3L7YDdDYaznOHFWmSIWfO+63F1YG2GN/4X4U2Eri KhZ9b8aoIV5FL7jhIpfmcwk7cWbAbc58JgoPq6HIObXLMeInpZ8XpIeBM90gC+37ncUbXQJqhJjSp mCzbdRTv6bz1rjui1bG3QYohamtQVVzT/BRz8Aqx3pHvdV9ZirnTdKbcaiJNMZrNQsl1lctRphMZD /o8EH6/e2ApdevwC8PT01/LibRw0uIaCxBdfO5t1G4ri0thK0wTcLZSjc58EjXqZx/hncrg0BRmFU 65g6960g==; Received: by zero.zsh.org with local id 1pP5LS-000EGR-Pl; Mon, 06 Feb 2023 17:31:58 +0000 Authentication-Results: zsh.org; iprev=pass (smtpq2.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.97; dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256; dmarc=pass header.from=ntlworld.com; arc=none Received: from smtpq2.tb.ukmail.iss.as9143.net ([212.54.57.97]:33372) by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) id 1pP5Kh-000Dus-Sa; Mon, 06 Feb 2023 17:31:13 +0000 Received: from [212.54.57.80] (helo=smtp1.tb.ukmail.iss.as9143.net) by smtpq2.tb.ukmail.iss.as9143.net with esmtp (Exim 4.90_1) (envelope-from ) id 1pP5Kh-000312-7M for zsh-workers@zsh.org; Mon, 06 Feb 2023 18:31:11 +0100 Received: from oxbe7.tb.ukmail.iss.as9143.net ([172.25.160.138]) by smtp1.tb.ukmail.iss.as9143.net with ESMTP id P5KgpeyTI5gtoP5KhpSdK2; Mon, 06 Feb 2023 18:31:11 +0100 X-Env-Mailfrom: p.w.stephenson@ntlworld.com X-Env-Rcptto: zsh-workers@zsh.org X-SourceIP: 172.25.160.138 X-CNFS-Analysis: v=2.4 cv=cvhd0X0i c=1 sm=1 tr=0 ts=63e1395f cx=a_exe a=fsVlV1GYKS3C/xnq+HX56g==:117 a=1DWFKdCB1IcA:10 a=IkcTkHD0fZMA:10 a=ZjyAdWuDOD4A:10 a=q2GGsy2AAAAA:8 a=pGLkceISAAAA:8 a=qlvxnHO8-rheZ_iolSIA:9 a=QEXdDO2ut3YA:10 a=z9dJwno5l634igLiVhy-:22 X-Authenticated-Sender: p.w.stephenson@ntlworld.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ntlworld.com; s=meg.feb2017; t=1675704671; bh=6sV9UC0o70iE71h2C61KsimjZ0ZmYctM3oL5bNUuLwk=; h=Date:From:To:In-Reply-To:References:Subject; b=M/NS+F2hHYg5EtkxT/15cqhzIMOYQJ+3dk7X6mUOvuf1CcIIIz/G5BzTDnFcuo4fg ulF607YJArtCP7c45N2Gj4Y3O24fhyaALXlho5zP+1iY1Qt7mgbn0i3mV7oQNpy1h8 Q8N5UwVp/U2xr/ws3+0alhxrdo7FxCJF2uIkaq6mJjx/yevMe3hUXQnlLL0Mr+KBfP p9k0zTvrDVQzzAkrn9x2jYgybo4uKtT8/Mi38Vxj1uhYS6KIifrqK3aV03RD/aBB1J 5XFLnqFuKihyO552jZXb17CPxXLaHcQciJMWV4XdRsuIsSqFqdAIiBdGKTv4VwCsbR SSkQMaQZibpdw== Date: Mon, 6 Feb 2023 17:31:10 +0000 (GMT) From: Peter Stephenson To: Zsh hackers list Message-ID: <1402453624.10822810.1675704670930@mail.virginmedia.com> In-Reply-To: References: Subject: Re: #% anchoring doesn't work with (S) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Priority: 3 Importance: Normal X-Mailer: Open-Xchange Mailer X-Originating-IP: 147.161.224.167 X-Originating-Client: open-xchange-appsuite X-CMAE-Envelope: MS4xfEpapjuUpyl0unwd1osANYskeBM4DQvrvtgHeN+VstCwQhDY+4CSaJHWby9/PeaY+jBg/pPzqqe/Xtphba6jPiJV0tpts7nTjHI3VzrJ3GWehO2mDzAv 1kQQdn/Ry6BB4zS9KtdwStScgwGi0mLO/2J3Og4QrQ5acaly6ChUlVYF8RxwKh3YHa9XcAbpdRcuwxEPEyrNzdnjvy4jFhYVJ05TGkHvbf18rojweVqByNQA X-Seq: 51366 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: > On 06/02/2023 17:17 Bart Schaefer wrote: > On Thu, Feb 2, 2023 at 4:49 AM Sebastian Gniazdowski > wrote: > > On Thu, 2 Feb 2023 at 10:32, Mikael Magnusson wrote: > >> > >> 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. > > > > It does have sense to match shortest and anchor to #%, it simply moves the "weight" on the right side of the pattern, i.e. "ABC" == (?)* vs ABC == *(?) (not very correct, but shows the thought). > > Arguably then this is wrong: > > % sample=match > % : ${(S)sample/(#b)(#s)(m*)(*)(#e)}; printf "<%s>" $match ; echo > > > I expected . Compare without the end anchor: > > % : ${(S)sample/(#b)(#s)(m*)(*)}; printf "<%s>" $match ; echo > > > In any case the behavior of PWS's patch appears to be the same. I haven't followed this through in detail, but I believe we just don't have enough state in the matcher to deal with longest vs. shortest substring at the same time as everything else. pws