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,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 28547 invoked from network); 19 Oct 2021 19:18:38 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 19 Oct 2021 19:18:38 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1634671118; b=n77lR/cndtJiA54fYE01Gsq8GRroV95gw8RN445RSua+rwHAghTErDY27OSnOqUYUwvgMTfaE9 j/Y0AAlOCTE0BDrwxFZZH6HEHZoZw1G/NC00kH0xQJbtRxWPQVMMb2c5d3WQouKLBeNAX+M+G6 lHkH4JQW7bTFKv0fnjr0TTF3y3E8epmdpmyj9uSb0sOV7rWim9LuWR5RDMpO7arZoxblAi+z1t e/PfxPWAEbzs2jsVrySqjfya0agEQTsquW+P5Vy21d0HNgUA6pTFeQ0jYsRWza53E4HN3tCr9s jgB5E7bBJwxbYv47iwn3nYqwPxc+2Q4Pd62+szqF7lL2QQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-wm1-f51.google.com) smtp.remote-ip=209.85.128.51; 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=1634671118; bh=5O+G8ND2b30R+azHquDPszJzqOzdvjJKwuNL/EUfCw4=; 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=fnXPcfu5X/Z5F9nr7/qnFwk7sQshkdOU2F/E0AucUxtR1k+6/R5LxpT7e33mQ2x/acmg+e1WAI mP41sEGykZcVhQ56yLvJxQa88qfowxTe7+MnK4nS3hACMSEQKgBABqUYfwRsvQLP1O2z9aMq77 XqO8V36AjUgeWapN8Af2hNP0dnrxjSSpKxOQ1U7BNHCnZ4vEmACTCw0gRvLuP1XgoFKzKWtvY4 I/5Xem9yg9niR6OKnKiDnRQ9y25XzrDGGOIHOYCDE1VqVsd0RqkpHirhLED32BpLlp0Pr/Zk1a 1LqSnpTO4EqixuR3QkJSBUrnw2Z0jGgyOOJY0b/Nkkfgaw==; 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=TRSswGTUmRGoEW6upXLbWjOqviCQ9iEdvIXOisqu4eA=; b=DNy+ANECsghCyBoNKKToin6wGG 2aOD/yxqJLnMr46ecY2JbX4omwTWtWb6AfU4iZ8AxnKH/ypb9izt3slv5DzGTKfKYKC0alFPW+zPR dh4LkXEeDDkn7TnfuCjxAvwA253PYLmnCNyvFuI1CtqYYAiD+HqdHrqKbXngEqQ8eLWVYuva74dKC +efVUzkbRmJFKH+vsyqwe0PsP1nv5pq/sI0nGPF+kxJresVbsrAEAAqCgjD1k1/H4SqEVpkCbHHw+ 5J1DHVeFFZE+KHLddbI1Cik6lDMtuovn4rSJo4Z1gYl3hffXRZNsIEIpW8X5u97prN9wjRsm/uFdr IRjofqGw==; Received: from authenticated user by zero.zsh.org with local id 1mcudB-0000ES-Gr; Tue, 19 Oct 2021 19:18:37 +0000 Authentication-Results: zsh.org; iprev=pass (mail-wm1-f51.google.com) smtp.remote-ip=209.85.128.51; dkim=pass header.d=gmail.com header.s=20210112 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-wm1-f51.google.com ([209.85.128.51]:45903) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1mcuca-000PW2-2H; Tue, 19 Oct 2021 19:18:01 +0000 Received: by mail-wm1-f51.google.com with SMTP id o24-20020a05600c511800b0030d9da600aeso5044230wms.4; Tue, 19 Oct 2021 12:17:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TRSswGTUmRGoEW6upXLbWjOqviCQ9iEdvIXOisqu4eA=; b=T6jpKygi8vI2H+LxwNMA4P4BAt4GlXlZYR5btpRNP4KzMg/BAMTbvUbptP1WvZmw9Q BI125Fa2y9+o2bcSkaIDAvfK6WkcDmpHD1Z3D24eUtHjQnKUTCLPxERJxcGqlYvzhfhW 16ufwgEX/6vNhe30mStHaXyg6NNArQnzqxhe1ajO0Vz8aJfZ7RO+Tqwe45rvZVQMkBuN +UvuJ3z8/IYnKs0OkQ/AFGDRxXqxgQIS8990e6nVJSHBROufbPt6aQM1GmxxDzci0pIK 8kEO7xWwJulFusYQgfPJU0SbRPcotU55bSR+W+VmQGCNjw69R/8KpowKFRskOXPNLhuD 1h7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TRSswGTUmRGoEW6upXLbWjOqviCQ9iEdvIXOisqu4eA=; b=DcfG+LR24ldQIhr5XhRvufQ+FeRimUbcpZ4tLit1RN5VvRyT25R2cV27a9r8ysyqq0 1NdnDQXrjr0/6dVtbDE6CtDKoSSHArLAm8dT55PfVN+8c+Xw1mb5t74R1VEZZVzhyfQL s09xTmHNJBZbtdViBpXRppfA6VA+lEqIiLkXj7wipTOwxjcUBXpO7iBYDzvPKR3g+Ces Zz16oSwtYsQMQ2nTCqz1aXf9Bxu1cJcom5VGMRj+iShnuhqwqYbdmN0WWnPgp1Rl/M8Y lol0yMzungCC1MjkrDUb6QdrRCWvlrBCiIFaH4v6ayOcV77hIFBaYnPzoVOvVPeJP7B6 QfaQ== X-Gm-Message-State: AOAM532wVJhA62Npp9iuwfL84tge+Srb52Iv8Q160aL8kR4FcOBhs714 fmJlPIE1F3e/antGvHFL1Rjv6BOlJqwMYhZ+Uz60tao8OUk= X-Google-Smtp-Source: ABdhPJytFwzw6qejtjtlAnWCvPnVmOxcb8Dai9K7QKQ/2R+DmhXOlTnkwtlZ3/LW5j5jGQdKPhBDT+Y25/PtqbHfihI= X-Received: by 2002:a05:600c:1d19:: with SMTP id l25mr8332884wms.119.1634671079413; Tue, 19 Oct 2021 12:17:59 -0700 (PDT) MIME-Version: 1.0 References: <27bc215c-3916-4afe-b8b3-7946dd0cb4bc@www.fastmail.com> <20210814155252.GG11391@tarpaulin.shahaf.local2> In-Reply-To: <20210814155252.GG11391@tarpaulin.shahaf.local2> From: Zach Riggle Date: Tue, 19 Oct 2021 14:17:48 -0500 Message-ID: Subject: Re: Odd behavior with various (q) array modifiers and non-printable characters (backspace, newline) To: Daniel Shahaf , Bart Schaefer Cc: =?UTF-8?Q?Lawrence_Vel=C3=A1zquez?= , Zsh Users Content-Type: multipart/alternative; boundary="000000000000035af005ceb98507" X-Seq: 27250 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: --000000000000035af005ceb98507 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Apologies for resurrecting this thread, but I wanted to revisit and thank everybody for the help. I ran into some issues where my print-a-$-and-then-the-minally-quoted-version-of-this-array-of-scalars when dealing with regex, due to "builtin echo" treating '\bfoo bar\b' incorrectly. I attempted a variety of things to fix the problem, but going back through this thread really helped a bunch. I had written additional code that relied in builtin echo. "command echo" and the issue is resolved. On Sat, Aug 14, 2021 at 10:52 AM Daniel Shahaf wrote: > Lawrence Vel=C3=A1zquez wrote on Wed, Aug 11, 2021 at 17:42:09 -0400: > > On Wed, Aug 11, 2021, at 5:16 PM, Bart Schaefer wrote: > > > You need to stop testing things with "echo". The "echo" builtin > > > interprets some backslash escapes itself, which will confuse you abou= t > > > what the quoting options have done. > > > > > > Repeat all your tests instead with > > > printf "%s\n" ${(q)...} > > > and so on, and come back if you still have questions. > > > > Additionally, \b and \n are not interpreted in double quotes, so > > your initial data does not actually contain BS or NL characters. > =E2=8B=AE > > As per the QUOTING section of zshmisc(1): > > > > Inside double quotes (""), parameter and command substitution > > occur, and `\' quotes the characters `\', ``', `"', `$', > > and the first character of $histchars (default `!'). > > There are third-party plugins that implement syntax highlighting at the > prompt (I happen to co-maintain one such plugin). Those plugins are > aware of the quoted docs section, so on input such as > . > % foo "bar \n \\ \x" > . > they will correctly highlight only the =C2=AB\\=C2=BB as an escape sequen= ce, and > everything else as literals. > --000000000000035af005ceb98507 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Apologies for resurrecting this thread, but I wanted to re= visit and thank everybody for the help.

I ran into some = issues where my print-a-$-and-then-the-minally-quoted-version-of-this-array= -of-scalars when dealing with regex, due to "builtin echo" treati= ng '\bfoo bar\b' incorrectly.

I attempted = a variety of things to fix the problem, but going back through this thread = really helped a bunch.=C2=A0 I had written additional code that relied in b= uiltin echo.=C2=A0 "command echo" and the issue is resolved.
<= br>

On Sat, Aug 14, 2021 at 10:52 AM Daniel Shahaf <d.s@daniel.shahaf.name> wrote:
<= blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-l= eft:1px solid rgb(204,204,204);padding-left:1ex">Lawrence Vel=C3=A1zquez wr= ote on Wed, Aug 11, 2021 at 17:42:09 -0400:
> On Wed, Aug 11, 2021, at 5:16 PM, Bart Schaefer wrote:
> > You need to stop testing things with "echo".=C2=A0 The = "echo" builtin
> > interprets some backslash escapes itself, which will confuse you = about
> > what the quoting options have done.
> >
> > Repeat all your tests instead with
> >=C2=A0 =C2=A0printf "%s\n" ${(q)...}
> > and so on, and come back if you still have questions.
>
> Additionally, \b and \n are not interpreted in double quotes, so
> your initial data does not actually contain BS or NL characters.
=E2=8B=AE
> As per the QUOTING section of zshmisc(1):
>
>=C2=A0 =C2=A0 =C2=A0 =C2=A0Inside double quotes (""), paramet= er and command substitution
>=C2=A0 =C2=A0 =C2=A0 =C2=A0occur, and `\' quotes the characters `\&= #39;, ``', `"', `$',
>=C2=A0 =C2=A0 =C2=A0 =C2=A0and the first character of $histchars (defau= lt `!').

There are third-party plugins that implement syntax highlighting at the
prompt (I happen to co-maintain one such plugin).=C2=A0 Those plugins are aware of the quoted docs section, so on input such as
.
=C2=A0 =C2=A0 % foo "bar \n \\ \x"
.
they will correctly highlight only the =C2=AB\\=C2=BB as an escape sequence= , and
everything else as literals.
--000000000000035af005ceb98507--