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 6f7a7fb0 for ; Mon, 30 Dec 2019 21:25:11 +0000 (UTC) Received: (qmail 787 invoked by alias); 30 Dec 2019 21:25:03 -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: 45164 Received: (qmail 22033 invoked by uid 1010); 30 Dec 2019 21:25:03 -0000 X-Qmail-Scanner-Diagnostics: from wout4-smtp.messagingengine.com 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(64.147.123.20):SA:0(-2.6/5.0):. Processed in 4.867486 secs); 30 Dec 2019 21:25:03 -0000 X-Envelope-From: d.s@daniel.shahaf.name X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: none (ns1.primenet.com.au: domain at daniel.shahaf.name does not designate permitted sender hosts) X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedufedrvdefhedgudegkecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhepfffhvffukfhfgggtuggjfgesth dttddttdervdenucfhrhhomhepffgrnhhivghlucfuhhgrhhgrfhcuoegurdhssegurghn ihgvlhdrshhhrghhrghfrdhnrghmvgeqnecukfhppeejledrudektddrheejrdduudelne curfgrrhgrmhepmhgrihhlfhhrohhmpegurdhssegurghnihgvlhdrshhhrghhrghfrdhn rghmvgenucevlhhushhtvghrufhiiigvpedt X-ME-Proxy: Date: Mon, 30 Dec 2019 21:24:20 +0000 From: Daniel Shahaf To: zsh-workers@zsh.org Subject: ${(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)) Message-ID: <20191230212420.gk2jkimlk3epfdha@tarpaulin.shahaf.local2> References: <20191228210017.2cdgwgpqrssrfhgp@tarpaulin.shahaf.local2> <20191229020534.oqh5ri3nqealx4hj@tarpaulin.shahaf.local2> <20191230180036.u33ixxe5pjjk7lal@tarpaulin.shahaf.local2> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: NeoMutt/20170113 (1.7.2) Sebastian Gniazdowski wrote on Mon, Dec 30, 2019 at 21:20:34 +0100: > On Mon, 30 Dec 2019 at 21:01, Roman Perepelitsa > wrote: > > I think it would be beneficial to specify that with ${(S)str##pattern} > > the first attempted match starts at str[-1] and that no attempt is > > made to check if the empty string (the ultimate shortest suffix) > > matches. I think you or someone else has recently raised this point as > > this seems inconsistent. It's surprising to me that both ${str#*} and > > ${(S)str%*} expand to $str while ${(S)str%%*} doesn't. > Let's see: 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? It certainly would be if the docs patch I posted is accepted. The existing documentation doesn't promise this behaviour either. > Also, ${str%*} doesn't expand to $str, It does for me; see above. > which seems to be a bug? Is it a different uncover of the one from > users/22600?