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,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 19538 invoked from network); 25 Jan 2023 16:32:56 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 25 Jan 2023 16:32:56 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1674664377; b=iErZ5u9SDwe3IHiE8GPQzYecLG9dJTyTaD0zkhRXVVx6jO0fVBCsTHTMkxAhvvDj4Uc8Vu7RAS n5iMEb0IkF4DYS57ir2+SFcT9c2yhe47ciV8YWSwsq9JHlTcZswNcvxedD8sr4HthZG6yCAMYY G+Am6V8fohs05OmeMd7DI4OTFu9W9cXgv7y2vYsCSgsukF+rtVg+0cqTQUjVnKNbpczk2rSogA C8Kk5t8POio6f9effpgfoqDfRGvW0GKJo75qSIa4BaHL/OsWY8ghY+unbpbkNA84Ao+exqJ8wN LJ+ELBzgSX3FRKDl3pZ+wEHgzr4/NZ88VcW3j9j6+znPHg==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f171.google.com) smtp.remote-ip=209.85.208.171; 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=1674664377; bh=g/dWNUmnAZEnjod66gZAOhk9j/mcQzuhnesRnjO7QFQ=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=cF/0mWKj6pA0JCZRYgBjbaRpJBTn+X0H6BI/cczizf7Ri93S3EyqOIUGJ6wj0YFW4vFQhebQ6/ IzZBGCWVAVx1o2gWuostGSfi9+S3cFUPDf7o9hAchH/VsV8XMpNKUQArej3RgeCXFEcAyJ+468 RJejTMow1ubpw5yYynRog+wMcf5OsIbDLVoovDuWrO1NF3pCy4EOqW5BcykZFe26tmH3rAOcpO V1gQAJ2/x/brVSLquG9dDz5OV7Rx/jXp2PdAHznQvVFb8iBoRfojEHyiqi+SVR417+OynXqfIS LOQi12v9vdXLiJMZpJQqh9TaIlFsxVGUcZkLqQ1/fx3N1Q==; 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-Type:To:Subject:Message-ID: Date:From:In-Reply-To:References:MIME-Version:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=g/dWNUmnAZEnjod66gZAOhk9j/mcQzuhnesRnjO7QFQ=; b=skcaODT4CSq9fS7FQoLwFe4/3Y IZPyX3Gy3mjaBgU5om5STRRH3+/tvkNJU1t/CkHezWEjJF+0Nd2X9s/bl8JdTwqgMRRhHjfef3KZh k1KBy4HRTOe6QmDvllDdzZFaDFQv/JKwnkFCUc7155xaSrglpdrHwedFYTNZ0yXEzxRdfKlAkAEOW OgxSbbnSyjOZdW946RgEprazIjcGnCPGKX3NwF7Cl70nRy6ayjDyvZDy1sRPLlVCa8AK3n3nnOcQE hl5EUoPL4HLPxtB696YSBfVIKIMhZIUCD7pHpyEg7HzkOik6/KVeWd++euYkXbfMNNEkKJoyOrmWw vIqSfaLw==; Received: by zero.zsh.org with local id 1pKihk-0002No-E9; Wed, 25 Jan 2023 16:32:56 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f171.google.com) smtp.remote-ip=209.85.208.171; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lj1-f171.google.com ([209.85.208.171]:47079) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1pKigx-0001gg-RZ; Wed, 25 Jan 2023 16:32:08 +0000 Received: by mail-lj1-f171.google.com with SMTP id t12so13358723lji.13 for ; Wed, 25 Jan 2023 08:32:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=g/dWNUmnAZEnjod66gZAOhk9j/mcQzuhnesRnjO7QFQ=; b=JkpBwjBdbwjSJGUTrsApmkrSt0IjMVIkstx3y51ZLjawUOr4ZLadH4pupGrShc8ees ncnnoIGioRLa6L85h9yh3/x0XpR0tFSkUHg7Z6qnHjsiiQJLKQC5wdg6uKyh9+t+y3Hn xiKs4cJSVXGVIpAl8y0/5PJ6r5RpEjjL43CtETeFNnAK5DYaKNNxX2NDADcC/lYrB81X /eJajfRZH6pG923XOWXlMPWNEn7EtFP6pXy7TH7ZYEWcHWUHTPMtDwiYlS+c/6TQkSdb KcJRV0RHMze/g6fhSf/w+CZHyS9p8iWNOGG1GfDA4gzBDgpLddDK5jMe/js20RPrBAwO HjoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=g/dWNUmnAZEnjod66gZAOhk9j/mcQzuhnesRnjO7QFQ=; b=EF4jfJWU08W5aRlO41PlLZBV9AwYGhmdPTl4PpIwaWzK5EvVFdqFeY0fazmB/CI2i1 5M+jE5TfjPi8JKRz6VOCmxCFboCf2XMA+OwzW23Y14qrEFGcrVvUVjroTrEKuji1c7Pg d937SfNgCT1fdGr6Pi8NZh9MtqwzNNkOq4TkQnQmS3upH0hZsRLQff1ZsOBMbvyU4WYb vaawlpId1BQbCpXRAm3AhLgp1Kw44kGhPHEvHGstE4pGJ5Z6qpDOEdmOUtxTrEmfWBN3 ghRi+Wn38RMMdKNxej4aq06aoiv1Y3xIMPrpRC98erBrv8p3sgstTNYn5Kb0M8Crjjoq xgFA== X-Gm-Message-State: AFqh2krl1DAQ99uPvkhsVUW6g/hr6Ac6RYlB1cNJTRzI/JZEOnwiyRzf J0i/W0qgPSsXixAVt0xKha5iYqfuNlo6XUjz37rtKPMX X-Google-Smtp-Source: AMrXdXtUx95DoLmX637+CUPlV5rfWP0tr0nAwlehdxPzO8O+RqEOLhvHrlyQWvFqwCyvHi2qkQXwzxSmCZrv7tS2XUA= X-Received: by 2002:a2e:994e:0:b0:289:da59:6cd0 with SMTP id r14-20020a2e994e000000b00289da596cd0mr2195652ljj.298.1674664327040; Wed, 25 Jan 2023 08:32:07 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Sebastian Gniazdowski Date: Wed, 25 Jan 2023 16:31:40 +0000 Message-ID: Subject: Re: Why no $match for parens inside a ~^ ? To: Zsh Users Content-Type: multipart/alternative; boundary="00000000000054d30505f3192c0e" X-Seq: 28788 Archived-At: X-Loop: zsh-users@zsh.org Errors-To: zsh-users-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-users-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: --00000000000054d30505f3192c0e Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable I've found a workaround for testing of -F has been given in one go =E2=80= =93 via the super cool negation `~`: QE=3D'zparseopts qqq -F afwe' print ${QE//(#b)zparseopts(*~*-F*~*-)(-F|)*/=C2=B0match=C2=B0} printf =C2=B0%s\\n "$match[@]" $? Output: =C2=B0match=C2=B0 =C2=B0 qqq =C2=B0-F =C2=B00 So the -F exists there in $match[3] for testing if it has been given to zparseopts. The main point is the ~ rejection of -F on part of the input string: =E2=80=A6(*~*-F*~*-)=E2=80=A6 It translates: everything (*) but not -F (~*-F*) and in that subset, also not dash =3D (~*-). Without the ~*- it would match "not -F", so "-" from within it is still allowed: QE=3D'zparseopts qqq -F afwe' print ${QE//(#b)zparseopts(*~*-F*)(-F|)*/=C2=B0match=C2=B0} printf =C2=B0%s\\n "$match[@]" $? Output: =C2=B0match=C2=B0 =C2=B0 qqq - =C2=B0 =C2=B00 With it and with ~*-F* it correctly accepts other options: QE=3D'zparseopts qqq -q -F afwe' print ${QE//(#b)zparseopts(*~*-F*~*-)(-F|)*/=C2=B0match=C2=B0} printf =C2=B0%s\\n "$match[@]" $? Output: =C2=B0match=C2=B0 =C2=B0 qqq -q =C2=B0-F =C2=B00 I think that this demonstrates the uniqueness of Zsh pattern negations. That really should be available in regexps. On Wed, 25 Jan 2023 at 14:52, Sebastian Gniazdowski wrote: > PS. (#b) is missing in the pattern, correct code is: > [[ "zparseopts -F" =3D=3D (#b)*(zparseopts)*~^*(-F)* ]] > printf =E2=86=92%s\\n $? "$match[@]" > > output is the same. > > > On Wed, 25 Jan 2023 at 14:50, Sebastian Gniazdowski < > sgniazdowski@gmail.com> wrote: > >> Hi, >> I'm matching a pattern: >> [[ "zparseopts -F" =3D=3D *(zparseopts)*~^*(-F)* ]] >> printf =E2=86=92%s\\n $? "$match[@]" >> >> with output: >> =E2=86=920 >> =E2=86=92zparseopts >> =E2=86=92 >> >> I would want \3 to contain -F=E2=80=A6 because, I would once want to use= (-F|) >> there, and be able to test if the option is given=E2=80=A6 Is it possibl= e? >> >> ~^ is a double negation that makes the pattern work like "if-contains >> zparseopts AND -F" >> >> >> -- >> Best regards, >> Sebastian Gniazdowski >> >> > > -- > Best regards, > Sebastian Gniazdowski > > --=20 Best regards, Sebastian Gniazdowski --00000000000054d30505f3192c0e Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I've found a workaround for testing of -F has been given= in one go =E2=80=93 via the super cool negation `~`:

QE=3D'= zparseopts qqq -F afwe'=C2=A0
print ${QE//(#b)zparseopts(*~*-F*~= *-)(-F|)*/=C2=B0match=C2=B0}
printf =C2=B0%s\\n "$match[@]" $?=

Output:
=C2=B0match=C2=B0
=C2=B0 qqq
=C2=B0-F
= =C2=B00

So the -F exists there in $match[3] for testing if i= t has been given to zparseopts. The main point is the ~ rejection of -F on = part of the input string:

=E2=80=A6(*~*-F*~*-)=E2=80=A6

It translates: everything (*) but not -F (~*-F*) and in that subse= t, also not dash =3D (~*-). Without the ~*- it would match "not -F&quo= t;, so "-" from within it is still allowed:

QE=3D'= zparseopts qqq -F afwe'=C2=A0
print ${QE//(#b)zparseopts(*~*-F*)= (-F|)*/=C2=B0match=C2=B0}
printf =C2=B0%s\\n "$match[@]" $?
Output:

=C2=B0match=C2=B0
=C2=B0 qqq -
=C2=B0
= =C2=B00

With it and with ~*-F* it correctly accepts other op= tions:

QE=3D'zparseopts qqq -q -F afwe'
print ${Q= E//(#b)zparseopts(*~*-F*~*-)(-F|)*/=C2=B0match=C2=B0}
printf =C2=B0%s\\n= "$match[@]" $?

Output:

=C2=B0match=C2=B0
= =C2=B0 qqq -q
=C2=B0-F
=C2=B00

I think that this demo= nstrates the uniqueness of Zsh pattern negations. That really should be ava= ilable in regexps.
=C2=A0


On Wed, 25 Jan 2023 at 14:52, Seb= astian Gniazdowski <sgniazdowski@gmail.com> wrote:
=
PS. (#b) is missing in the pattern, correct co= de is:
[[ "zparseopts -F" =3D= =3D (#b)*(zparseopts)*~^*(-F)* ]]
printf = =E2=86=92%s\\n $? "$match[@]"

output is the same.


On Wed, 25 Jan 2023 at 14:50,= Sebastian Gniazdowski <sgniazdowski@gmail.com> wrote:
Hi,
I'm matching a pattern:
[[ "zparseopts -F&q= uot; =3D=3D *(zparseopts)*~^*(-F)* ]]
printf =E2=86=92%s\\n $? "$match[@]"=

=
with out= put:
=E2= =86=920
=E2=86=92zparseopts
=E2=86=92

I would want \3 = to contain -F=E2=80=A6 because, I would once want to use (-F|) there, and b= e able to test if the option is given=E2=80=A6 Is it possible?=C2=A0
<= br>
= ~^ is a double negation that makes the pattern work like "if-contains = zparseopts AND -F"


--
Best regards,
Sebastian Gniazdowski



--
Best regards,
Sebastian Gniazdowski


--
Best regards,
Sebastian Gniazdowski
--00000000000054d30505f3192c0e--