zsh-users
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Roman Perepelitsa <roman.perepelitsa@gmail.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: Why a '-quoted string isn't respected by // subst, while \-quoted is?
Date: Wed, 25 Jan 2023 13:09:55 +0000	[thread overview]
Message-ID: <CAKc7PVBCwhcg7sSE9348bQLrKfZkt6iCzED4Xvs+mO5f1SYjGw@mail.gmail.com> (raw)
In-Reply-To: <CAKc7PVC8DMPJJFY64sErMhdgS3mwRFe0fz5hPKJ-vuBh8bX=rg@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2018 bytes --]

It seems that it's / within the '-quoted string that causes the problem:

print ${QE//'0=${${(M)${0::=${(%):-%x}}:#\/*}:-$PWD\/$0}'/°match°}

outputs °match°, while:

print ${QE//'0=${${(M)${0::=${(%):-%x}}:#/*}:-$PWD/$0}'/°match°}

doesn't. Isn't it a bug of ignoring '-quoting of /?


On Wed, 25 Jan 2023 at 12:59, Sebastian Gniazdowski <sgniazdowski@gmail.com>
wrote:

> Ok, I'll take a closer look, however I'm now struggling with similar
> problem:
>
> QE='0=${${(M)${0::=${(%):-%x}}:#/*}:-$PWD/$0}'
> print ${QE//'0=${${(M)${0::=${(%):-%x}}:#/*}:-$PWD/$0}'/°match°}
>
> the strings in QE and in …//'…'/… are identical. Why no match? A simpler
> example works as expected:
>
> QE=qeqe
> print ${(S)QE//'qeqe'/°match°}
>
> Output:
>
> °match°
>
> On Wed, 25 Jan 2023 at 12:36, Roman Perepelitsa <
> roman.perepelitsa@gmail.com> wrote:
>
>> On Wed, Jan 25, 2023 at 12:05 PM Sebastian Gniazdowski
>> <sgniazdowski@gmail.com> wrote:
>> >
>> > Hi,
>> > I'm storing a pattern in a var:
>> >
>> > E="0='\${\${\\(M\\)\${0::=\${\\(%\\):-%x}}:\\#/\\*}:-\$PWD/\$0}'"
>> >
>> > to then match it against:
>> >
>> > Q='0=${${(M)${0::=${(%):-%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='0=${${\(M\)${0::=${\(%\):-%x}}:\#/*}:-$PWD/$0}'
>>
>> You can print them to see the difference:
>>
>>     % E="0='\${\${\\(M\\)\${0::=\${\\(%\\):-%x}}:\\#/\\*}:-\$PWD/\$0}'"
>>     % print -r -- $E
>>     0='${${\(M\)${0::=${\(%\):-%x}}:\#/\*}:-$PWD/$0}'
>>
>>     % E='0=${${\(M\)${0::=${\(%\):-%x}}:\#/*}:-$PWD/$0}'
>>     % print -r -- $E
>>     0=${${\(M\)${0::=${\(%\):-%x}}:\#/*}:-$PWD/$0}
>>
>> As you can see, the first `E` has three extra characters: two quotes
>> and a backslash.
>>
>> Roman.
>>
>
>
> --
> Best regards,
> Sebastian Gniazdowski
>
>

-- 
Best regards,
Sebastian Gniazdowski

[-- Attachment #2: Type: text/html, Size: 4857 bytes --]

  reply	other threads:[~2023-01-25 13:11 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-25 11:04 Sebastian Gniazdowski
2023-01-25 12:36 ` Roman Perepelitsa
2023-01-25 12:59   ` Sebastian Gniazdowski
2023-01-25 13:09     ` Sebastian Gniazdowski [this message]
2023-01-25 13:10     ` Roman Perepelitsa
2023-01-27 18:43       ` Daniel Shahaf
2023-01-27 19:38         ` Bart Schaefer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAKc7PVBCwhcg7sSE9348bQLrKfZkt6iCzED4Xvs+mO5f1SYjGw@mail.gmail.com \
    --to=sgniazdowski@gmail.com \
    --cc=roman.perepelitsa@gmail.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).