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,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 30241 invoked from network); 2 Feb 2023 10:44:51 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 2 Feb 2023 10:44:51 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1675334691; b=Xuf6G2BZirp0qw1fELT7n8ai9wSaMJsb4Xlt2RlYVyniCFHYLBTKmyjrIMwoVctbSHEVi5fs3f 2dUvfELUINQi+go53tuqfUfWEXxwog33j3lX2FcjRu548mS9HyhantppU4CTDjzaW7WbWbWdUJ pB55oCEWFXW7cyoIFTQLWAS8mz/rYjPRok9CH19I7ONDpGnR502LLFl+xvmc4M9mpxAcZOXgFe i+TJttM9MMwOXw6p3VQj081J9PYTVMpAjigKCD4ymHL7homiMf8CXyONJpSnI4a1mfsIbfUA5T ooRrvNpmOShinKGCr9UKxjrbR20HG0TdjWd7yed5PsICBw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f43.google.com) smtp.remote-ip=209.85.218.43; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1675334691; bh=ci0q2iJGQINmrCLdKb8v4BWbAG9g4yLj/usv25rCBzs=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Transfer-Encoding:Content-Type:Cc:To:Subject: Message-ID:Date:From:References:In-Reply-To:MIME-Version:DKIM-Signature: DKIM-Signature; b=XaXtFA4L4yYRAwBR0EZOOPumXPhHoJodeSurvt50fSyqMah8R3QJLwseCF2j9V+KEqP0TJEPYy SM26DF0//yQkvPAXJl0VsfC48Df4cVpP/Ml3St+EkYIWfm3YZkNjH9dvWyEjfDPUI0iKmYKJii bkbW4CIOmGVS3BjGsu60qzH5jP+jZEB9D0tipmvMAr+jQNc08dOZ7DARW8bcOUm+B/CF0SLhGZ Qm/vYMIA3WvQVyRbBjIREladU1T6RbpTvulHmgBK1JWagaId4UEupN76EhVvVk7/47Jfz4EnNf /rEXp4sG7O5zuQm9Rll2YjME/dcYVDJQ/prJtXWt7HTegQ==; 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:Cc:To:Subject:Message-ID:Date:From:References:In-Reply-To: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=Xan0uB1fx6FZTmq0E4uZ67pP5jzzFMxTot9xitMqen4=; b=IHJL3SWEwq14VsXzz79vdNsx4T 5yU+SKDWczjKXlfYrjQumkSQmPAq8/pzSqyPq/+JW/nq3ilEaZ/MZUcXBzlpvg+8sTU8GlL2FMqH6 6x8IMUqWWjz3XaSg5eljRbQjXIQe8eEXXhS9IQ7qEcMy8OvsTxxepf9yFug8uNT3NvTYJ+7OFj4qI W4dNlYO+bmvncevU3dyC6Cl2BPW79G93AlsSeXsrVb2RNNuImOylYVziVg9Bk86JwOtjxDiR1gbhy LdLXyHU++leIt120yipQpc/pLPTXGblPE3f9oZThiwW/asjteTIpQMyXvW4ms9Fwd2GjIRrVHejS7 6am95TYA==; Received: by zero.zsh.org with local id 1pNX5H-000IOW-2C; Thu, 02 Feb 2023 10:44:51 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f43.google.com) smtp.remote-ip=209.85.218.43; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-ej1-f43.google.com ([209.85.218.43]:37414) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1pNX4T-000I2y-Am; Thu, 02 Feb 2023 10:44:02 +0000 Received: by mail-ej1-f43.google.com with SMTP id ud5so4732846ejc.4 for ; Thu, 02 Feb 2023 02:44:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Xan0uB1fx6FZTmq0E4uZ67pP5jzzFMxTot9xitMqen4=; b=RG3NXbS9UebWDmT6hYYfG+wFbMH4R9lPPtA4V8tFwKbdSQzfp8llkrx+rynF6TTW/s aK3pWvnSITzre7quzrr1lFS5yGaOlZWzOnon3dU/pK0ZSTzt/cZ/Q8jROsXHmNVaPLyO 3GfjHTKtUPsGYtoae6cpXvqr2qhDz6bGOow0f5VrxcKboJbQ4UD8aTXi4ySl+l+KnmgN wMXiRxSESx1vJgrefU8sSshC4hCoT0LhQe90YoKnDs47cAosmvH4rSD0dqTRTUsGY0jx /FTdDwqgmtsq8IcQ9or+rxW1zXpLZamcGcC9HQRme5oLcCVq/LC6XvyYVU/ysglplCfu C/ZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Xan0uB1fx6FZTmq0E4uZ67pP5jzzFMxTot9xitMqen4=; b=CaqsOq4+k65d8MOynEBKShYVNrS1MFmPfvbZaR5BQhidtPZmAsjqUQTFtKYLae+rrz rL48xMGo8IHxVjKGsmOkfutaKPxB3eZN/KFQF6XrZkyYh9MNjApQ0/hGnDjEQoo7k23B vYL1Xu4+oqf3R0ZS93h2iBd4gNcIcryNdy5EgItfpIIyGi9w+IR4mQH8M0mKrmXzpbox VmEiLYjXTaTPL/qrrERuAH54Z4uLwH/DsUfAPWQPrGCewLoLF7//uluNrLQdHxVasTzO GY9AruTg/lVtm99hi5CRJX3ww8jXdgZDVu5UGeHR8/Oetau5cMzAFmQEplfbgKx5/rPC 6mpA== X-Gm-Message-State: AO0yUKW7jCZ2DXJ9XzzovRklGG/Nku1tuRflgQifSsmH/j/wHHOC07W5 9uMJlPGvn1RnF2fC6pdxq77nKwUykDGElJq9lK5COH9T X-Google-Smtp-Source: AK7set+Ctz+l3OPEUMdkcm3OjLa0GuILbs+Er2rudUw2phYsI7s0+lp/MDCcqq1X6Ovsvwx5B5a8K+EpC8nYZM9mYSs= X-Received: by 2002:a17:906:f07:b0:888:787d:2061 with SMTP id z7-20020a1709060f0700b00888787d2061mr1619640eji.11.1675334640827; Thu, 02 Feb 2023 02:44:00 -0800 (PST) MIME-Version: 1.0 Received: by 2002:a17:907:c606:b0:7cd:3b2e:124 with HTTP; Thu, 2 Feb 2023 02:44:00 -0800 (PST) In-Reply-To: References: From: Mikael Magnusson Date: Thu, 2 Feb 2023 11:44:00 +0100 Message-ID: Subject: Re: #% anchoring doesn't work with (S) To: Sebastian Gniazdowski Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Seq: 51349 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 2/2/23, Mikael Magnusson wrote: > On 2/2/23, Sebastian Gniazdowski wrote: >> Could the bug be fixed? It already makes #% pretty much unusable for a >> backward compatible software, yet in say 4 years this would be changed, >> if >> the bug would be fixed today > > 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. > > That said, compgetmatch() does this, which is probably your problem > (it gives no real motivation for why it does this) > /* > * Search is anchored to the end of the string if we want to match > * it all, or if we are matching at the end of the string and not > * using substrings. > */ > if ((*flp & SUB_ALL) || ((*flp & SUB_END) && !(*flp & SUB_SUBSTR))) > patflags &=3D ~PAT_NOANCH; Actually this is probably not it, it works if you don't use just a * as the pattern: % INPUT=3DABCABCABC; INPUT=3D${(S)INPUT//#%((#b)(A*C))/=C2=B0match=C2=B0}; = print $INPUT $match =C2=B0match=C2=B0 ABCABCABC % INPUT=3DABCABCABC; INPUT=3D${INPUT//#%((#b)(A*C))/=C2=B0match=C2=B0}; pri= nt $INPUT $match =C2=B0match=C2=B0 ABCABCABC % INPUT=3DABCABCABC; INPUT=3D${(S)INPUT//((#b)(A*C))/=C2=B0match=C2=B0}; pr= int $INPUT $match =C2=B0match=C2=B0=C2=B0match=C2=B0=C2=B0match=C2=B0 ABC so it feels more like the * itself remembers the S flag but not the #% flags. (But still, specifying the (S) flag in this case is useless in the first place, so just don't specify it and your code will be compatible with every version). --=20 Mikael Magnusson