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 25271 invoked from network); 25 Jan 2023 13:01:49 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 25 Jan 2023 13:01:49 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1674651709; b=EMhjUek3kOsx3vq3XdwZ5pW4XFziSzTZ02iqVAtDkUT2yrGS35ZGq+moAHoiejHZHeqybvJCPv +dqp+k9L4yv6fpbUjn/mosWMYL6RW57+2zc043kQTTjs0Dzfe+m8PXu65ONt/+IZ0wqGU9p5Zr 0v+nus8ZUsgRWn2Vgoch7yy4VLsS5a3868+mA1fHULInynv0DHDUCaJgzXB9060F6dbrn3IQtR Pw+CdEglHEUugSLzcVfkxM8lYVa3GNGcgVLAuz4of0CvsKJHOyLLdF7e8ohvJrPjbfd9+lmd7q aNyuSyl9c37o5V8AZaHJx7k3RHcPXw8p/VmbyHiEn8jg3g==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lf1-f41.google.com) smtp.remote-ip=209.85.167.41; 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=1674651709; bh=wqvlvvtEFrK+ceHV+IDfQYsqiqrdmXTL5DSdeUqPCUQ=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=iMmBmCoaDCSlAafxrT4lvNI2fM06aBb+b2pm7SYvpCn4cqOpwR7WfFe2aFJvJdurXNX5WLGheE FiYIiZNMtmH9zXPZaFZS6uQqDFMnSj4LS6DUo90chn5K8+EWDlUiyhkGgQpOOKW6j+fmmsSi/x 0RnzlWc37/7oZPriYmCGPyqfRRJN1+c8D5u/M+jNWSdc+nEk6cbJhI6zLz9SwS3UU5KpHhz+LN 8TyUneTpIlE9B6WULyRl78QNEkX12t1DYWQ5RTdUUk3oTIdH0FzCDCWRAxMezPIZxHVw2mgHR0 WP5nW7SUS3rNxCg9UgzQK+jI6o/UFrkDWsDNxVFOFsgagw==; 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:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=s8QV6vfRYq6p46/4bWk8dycaZnYknsGRQriDlrXRMCI=; b=MKSUspFfHG9TqNSzkh6gEGxISG agZyr52+990sUdZMxGhKby0p+oUytinatGLE6MLYUc1SY0L4Z4EbX0SobfMiab16cm94tdJGHmkg2 aO2Usqt/MQ3KGz2XCp8o2CjNG8ofKew6kMa9phyp4rChWR/vB4/mNFk6JjqZVviHq/kMJTY0u+24Z ly8wj4Egf487UiXN27cURVuTIqluTDj/fTMhQ8CuMeUesUGOfUAT+tUlDX8zqnK/P4FbnsdPZgBm4 Sg7Jq9wIF8mo4uD+04Xnj/qolWmgGnuevNL5lCcyLOPHE1at5AWqHCYFc4v0Mr0syZIbRWinj+v7C FTKvbbxw==; Received: by zero.zsh.org with local id 1pKfPR-000EoM-7m; Wed, 25 Jan 2023 13:01:49 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lf1-f41.google.com) smtp.remote-ip=209.85.167.41; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lf1-f41.google.com ([209.85.167.41]:35561) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1pKfNu-000E7F-SJ; Wed, 25 Jan 2023 13:00:15 +0000 Received: by mail-lf1-f41.google.com with SMTP id b3so28839035lfv.2 for ; Wed, 25 Jan 2023 05:00:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=s8QV6vfRYq6p46/4bWk8dycaZnYknsGRQriDlrXRMCI=; b=OkiwO0NLpW6sQsygfRRJSxGp8e2+41qp0Io+Vq2rVclokxQmUKN5fWJoOCJ5nkSjTX +mI3VMb4zQvnCjOtNEogmv4SVY4BYaqO6jZD4AAl1a1TSxawofottp2TZFE3ckIh0Suh IdrKrTCfeuzjaRDBw8NL3vFzbW/p/dzqHrH14dcW9x2CWhxgv11KItZhotRCk/OlBgez Ufdn7y/juZJbVQ7ld63bnCqiqPX8e+5vNQfrjpTlupDYarkeFP3Z6N2wH7APBagoF8y3 yXl3ONX7AXZwkQgeWFp1PUnDtXd7WI24sxLcjV1cQu0dJqKRus4KjC7dWIFu56UDdNvG XzbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc: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=s8QV6vfRYq6p46/4bWk8dycaZnYknsGRQriDlrXRMCI=; b=bFxlGr4Rk7rHheKTnmQKfza0o0dh1qrXVVakC091zWRWNaN34EUqd1BAB43/VdJq+B CjBtuHIz2krA6F+sPqIpOUJRLy+MUzJ7s5lXKY5yNMFceNiqOhkrd/QZ1SL7rlSGj7fg AEP2S4BVgfB/WGJIk59gAYPoIOKQnlTVJF/maTw9LSLhRKqE2+N8vGWtalzaER3JO1C5 jXPb1exsvGGsoQd30AduvgDPndefSX2m5efWd2ORRNGeb+GELAIfRyGOfRqd8Hh183iB 43EdWHfBHecLw1PLNqK/d4Nqm81RNUITLauXtMj8JPoXbNxPOdplM2jJL1ZSRENzcG7g U2oQ== X-Gm-Message-State: AFqh2krRdM/6tFGY5hlwaTIuxdk3JtnWPoZkDVba5Rlp2IUuIb6lEjRi g9+AFG3x45qFe/HZ+aNz3YxiZ7Hy63i1P19SFvw= X-Google-Smtp-Source: AMrXdXv6qolbN2sA6LzpXay+L4gL690WEi7R9m314SrO08iTc+lZQSXHHCXP1oMQwAxXgHJaeq/dj/EGauOT+A5tQD0= X-Received: by 2002:a19:ee03:0:b0:4cc:83a5:e64d with SMTP id g3-20020a19ee03000000b004cc83a5e64dmr3262088lfb.455.1674651614182; Wed, 25 Jan 2023 05:00:14 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Sebastian Gniazdowski Date: Wed, 25 Jan 2023 12:59:47 +0000 Message-ID: Subject: Re: Why a '-quoted string isn't respected by // subst, while \-quoted is? To: Roman Perepelitsa Cc: Zsh Users Content-Type: multipart/alternative; boundary="00000000000096015b05f3163616" X-Seq: 28781 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: --00000000000096015b05f3163616 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Ok, I'll take a closer look, however I'm now struggling with similar problem: QE=3D'0=3D${${(M)${0::=3D${(%):-%x}}:#/*}:-$PWD/$0}' print ${QE//'0=3D${${(M)${0::=3D${(%):-%x}}:#/*}:-$PWD/$0}'/=C2=B0match=C2= =B0} the strings in QE and in =E2=80=A6//'=E2=80=A6'/=E2=80=A6 are identical. Wh= y no match? A simpler example works as expected: QE=3Dqeqe print ${(S)QE//'qeqe'/=C2=B0match=C2=B0} Output: =C2=B0match=C2=B0 On Wed, 25 Jan 2023 at 12:36, Roman Perepelitsa wrote: > On Wed, Jan 25, 2023 at 12:05 PM Sebastian Gniazdowski > wrote: > > > > Hi, > > I'm storing a pattern in a var: > > > > E=3D"0=3D'\${\${\\(M\\)\${0::=3D\${\\(%\\):-%x}}:\\#/\\*}:-\$PWD/\$0}'" > > > > to then match it against: > > > > Q=3D'0=3D${${(M)${0::=3D${(%):-%x}}:#/*}:-$PWD/$0}' > > > > with // substitution: > > > > printf %s\\n $E $Q ${Q//$~E/q} > > > > The result is no match. However, if I instead quote the string with \: > > > > E=3D'0=3D${${\(M\)${0::=3D${\(%\):-%x}}:\#/*}:-$PWD/$0}' > > You can print them to see the difference: > > % E=3D"0=3D'\${\${\\(M\\)\${0::=3D\${\\(%\\):-%x}}:\\#/\\*}:-\$PWD/\$= 0}'" > % print -r -- $E > 0=3D'${${\(M\)${0::=3D${\(%\):-%x}}:\#/\*}:-$PWD/$0}' > > % E=3D'0=3D${${\(M\)${0::=3D${\(%\):-%x}}:\#/*}:-$PWD/$0}' > % print -r -- $E > 0=3D${${\(M\)${0::=3D${\(%\):-%x}}:\#/*}:-$PWD/$0} > > As you can see, the first `E` has three extra characters: two quotes > and a backslash. > > Roman. > --=20 Best regards, Sebastian Gniazdowski --00000000000096015b05f3163616 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Ok, I'll take a closer look, however I'm now struggl= ing with similar problem:

QE=3D'0=3D${${(M)${0::=3D${(%):-= %x}}:#/*}:-$PWD/$0}'
print ${QE//'0=3D${${(M)${0::=3D${(%):-= %x}}:#/*}:-$PWD/$0}'/=C2=B0match=C2=B0}

the strings in Q= E and in =E2=80=A6//'=E2=80=A6'/=E2=80=A6 are identical. Why no mat= ch? A simpler example works as expected:

QE=3Dqeqe
print = ${(S)QE//'qeqe'/=C2=B0match=C2=B0}

Output:

On Wed, 25 Jan 2023 at 12:36, Roman Perepelit= sa <rom= an.perepelitsa@gmail.com> wrote:
On Wed, Jan 25, 2023 at 12:05 PM Sebastian Gniazdow= ski
<sgniazdowsk= i@gmail.com> wrote:
>
> Hi,
> I'm storing a pattern in a var:
>
> E=3D"0=3D'\${\${\\(M\\)\${0::=3D\${\\(%\\):-%x}}:\\#/\\*}:-\$= PWD/\$0}'"
>
> to then match it against:
>
> Q=3D'0=3D${${(M)${0::=3D${(%):-%x}}:#/*}:-$PWD/$0}'
>
> with // substitution:
>
> printf %s\\n $E $Q ${Q//$~E/q}
>
> The result is no match. However, if I instead quote the string with \:=
>
> E=3D'0=3D${${\(M\)${0::=3D${\(%\):-%x}}:\#/*}:-$PWD/$0}'

You can print them to see the difference:

=C2=A0 =C2=A0 % E=3D"0=3D'\${\${\\(M\\)\${0::=3D\${\\(%\\):-%x}}:\= \#/\\*}:-\$PWD/\$0}'"
=C2=A0 =C2=A0 % print -r -- $E
=C2=A0 =C2=A0 0=3D'${${\(M\)${0::=3D${\(%\):-%x}}:\#/\*}:-$PWD/$0}'=

=C2=A0 =C2=A0 % E=3D'0=3D${${\(M\)${0::=3D${\(%\):-%x}}:\#/*}:-$PWD/$0}= '
=C2=A0 =C2=A0 % print -r -- $E
=C2=A0 =C2=A0 0=3D${${\(M\)${0::=3D${\(%\):-%x}}:\#/*}:-$PWD/$0}

As you can see, the first `E` has three extra characters: two quotes
and a backslash.

Roman.


--
Best regards,
Sebastian Gniazdowski
--00000000000096015b05f3163616--