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=DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,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 0f0f9532 for ; Mon, 30 Dec 2019 20:21:26 +0000 (UTC) Received: (qmail 21152 invoked by alias); 30 Dec 2019 20:21:20 -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: 45163 Received: (qmail 9285 invoked by uid 1010); 30 Dec 2019 20:21:20 -0000 X-Qmail-Scanner-Diagnostics: from mail-ua1-f65.google.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(209.85.222.65):SA:0(-2.0/5.0):. Processed in 3.010642 secs); 30 Dec 2019 20:21:20 -0000 X-Envelope-From: sgniazdowski@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.222.65 as permitted sender) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=K4QAjUSJvSHFx3wO7KuhqqGrmCuXEdbUHf6PGoWIQ74=; b=iBPHbcIEmWaJe0Fan+yp0uq76rvT5hdJb7K/Yl86a5mGlMwYDsbUrvCL6rR9RdGSo9 L/+i73oTuV3jFtNxlXkm0u2ra9CzeUtqOp6nqFypt6GW76GZqVkRmKi6s09pZu04nFek DSdP0vcLoRDUwLXYCxYNJKw/GZfzdmNJ4XJ2XZ1xqK7ASi/0yP5txHIPvfCzdfwI1czJ WVWCPpf+DbhdK+f907wJv3ozAtKg8x903y/EACekVuOxOyGcHo3B2TD3oGzaS2+zNlLc BA0uBSTFHbQaAFcPmOmdf9xFyPyUa5L8kXxL+AScDRykTFhde8yQKsrzV+neyjqJQ2ul KqmQ== X-Gm-Message-State: APjAAAWXmU6v/FONVmCNVOIou6Zn5lc0P9/Ylv4DfwSBnyJ4HX1gEliA ZjqELYiX8xY3urUj8DX4rj1ySeq3D1Ia3mO7Y7Y= X-Google-Smtp-Source: APXvYqyMEa0e/o2q2ChhyF+sMDOdgIzbw59f2u8Nabc/kg56c5G9mNTfRK9PCvdIWpOxmcra3TWPJc13ogRXWiMDOgU= X-Received: by 2002:ab0:7852:: with SMTP id y18mr31113755uaq.28.1577737243986; Mon, 30 Dec 2019 12:20:43 -0800 (PST) MIME-Version: 1.0 References: <1a130b2e-5824-4b7a-8510-2b1d0b3fdac5@www.fastmail.com> <20191227052923.yal2nnmxdxfgvfkr@tarpaulin.shahaf.local2> <20191228210017.2cdgwgpqrssrfhgp@tarpaulin.shahaf.local2> <20191229020534.oqh5ri3nqealx4hj@tarpaulin.shahaf.local2> <20191230180036.u33ixxe5pjjk7lal@tarpaulin.shahaf.local2> In-Reply-To: From: Sebastian Gniazdowski Date: Mon, 30 Dec 2019 21:20:34 +0100 Message-ID: Subject: Re: [PATCH] zshexpn: Expand documentation of (S) (was: Re: [Bug] S-flag imposes non-greedy match where it shouldn't) To: Roman Perepelitsa Cc: Zsh hackers list , Daniel Shahaf Content-Type: text/plain; charset="UTF-8" On Mon, 30 Dec 2019 at 21:01, Roman Perepelitsa wrote: > They do with the latest patch for (S) from Daniel: > > > With tt(%) or tt(%%), search for the match that starts closest to the end of > > the string > > This means that ${(S)str%%X##} is going to find a match that starts > closest to the end of the string and remove it. X## matches one or > move X characters. We go backwards one character at a time until X## > matches. The first match starts at str[-2] and the match is X, so X > gets removed. This seems clear from the docs. Ok, this does seem to capture the issue. > 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. Also, ${str%*} doesn't expand to $str, which seems to be a bug? Is it a different uncover of the one from users/22600? -- Sebastian Gniazdowski News: https://twitter.com/ZdharmaI IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin Blog: http://zdharma.org