From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from zero.zsh.org (zero.zsh.org [IPv6:2a02:898:31:0:48:4558:7a:7368]) by inbox.vuxu.org (Postfix) with ESMTP id C1B01269F3 for ; Sun, 25 Feb 2024 18:27:11 +0100 (CET) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1708882031; b=kLYZynAUSJGtKufRrotrRkKagoNPqDqw9gt8aYDv8TYWu8k7uyPPeEkBPAWR06PUzQh33DMP3Y qQ+C+gx7Jecym6YrQH9+L5+M8QRuNn1HcZ63fXTGJFrLhKpQ4u9AH2FgXDCNRA8LFpvDzcp3T9 Eh0vH98lt8al0WjIASw3hGpEC6pwGUWgUmsZO59HLQJTYuOG60g9hNvV4zKX5bNrLXFc7w0j+4 VHXjptc9OZ2MUZaC63/AJMr/Ty+p0YKbaURqP3yG1sELm08aAXmIqjYMPRj1sMU/zbtcihisXs HQXyRmdvK/2pf791SCQYjqqLGL6jaoMLWxdJRYubyjDKCQ==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-lj1-f178.google.com) smtp.remote-ip=209.85.208.178; dkim=pass header.d=gmail.com header.s=20230601 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=1708882031; bh=V1c/UvO6Ams1u8TkjcWnyW71HdxDFLdj+Bjv7U1cnfM=; 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=Dt2uPxofQNUWWeZtUXaSiIMcBig9ZcantEVo1fs5TBZR/CpiKcnj8p7mKW5/4rGV73zXBVSJm6 XJihW6E+jUhTAJVTPpn28isWI21fg6xpxKbbt8gfyIWiK/OmvbexcaUWN5/LML1AzocIic5b3l P7TpjC2UKuYf9G17obnCtW/x4fanIZ6Sm5lo/t2zM9jndXfcJavHr3k5d23wHXKM1rfD1i3mOH ShyjdWnExXjdnR8hWNMwtSiqg99nc9UKxVs7i8nI1kJPmAsmqJJZqZvzekYzA5io8DKah4je3w K+OX/o9pk/iNHFWGmNjPTdG1nig8ZQu/sot6AJe0pMkWxA==; 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=V1c/UvO6Ams1u8TkjcWnyW71HdxDFLdj+Bjv7U1cnfM=; b=EvX44DftOYGwRRqMeBN8QSoEXV ierJ3tT47RrP2CeaHhLjAmlaXbCYJGcvvl7P6jd8IAw7Z3uYv2ApQMw5GmKaX+AtDArQZC3udeJTP +6e//rrEroeT4dYr93+o8BBT+zmTBiiZfpPDM3qph7BZkZ9Fv2nEbW0Ml2ELcWP4MG3P2R79m+O4W IbICiWMe5sTTkq5kymbiBoOkw72bw946CzK3Azx7QppoNJG460wQcTkCa6FSLFb26cE9btmbQaAlq +SlotpFtnialhcD6giC2QQXR1yvr9a3UZjbyJVIS46psHEaHOWZH04TtSKRs4rK9g4WaLhBTyYIaz 21SFG2bQ==; Received: by zero.zsh.org with local id 1reIHM-0001Tw-F4; Sun, 25 Feb 2024 17:27:08 +0000 Authentication-Results: zsh.org; iprev=pass (mail-lj1-f178.google.com) smtp.remote-ip=209.85.208.178; dkim=pass header.d=gmail.com header.s=20230601 header.a=rsa-sha256; dmarc=pass header.from=gmail.com; arc=none Received: from mail-lj1-f178.google.com ([209.85.208.178]:47452) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1reIH3-0001BQ-Lq; Sun, 25 Feb 2024 17:26:50 +0000 Received: by mail-lj1-f178.google.com with SMTP id 38308e7fff4ca-2d2505352e6so32835901fa.3 for ; Sun, 25 Feb 2024 09:26:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708882008; x=1709486808; darn=zsh.org; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=V1c/UvO6Ams1u8TkjcWnyW71HdxDFLdj+Bjv7U1cnfM=; b=CVEUd3DQO/cep4kJyK+zYumUZStJUkeTKliCezw3TxvZAiwLt1F1LxjRQnCEDgTOBL 4GK7isYeTfm17piJIq+fIf2rI0IFxCPYdlk7vJis0Bw9F8UNBJYRRKpYjfN8cacXYpOC ptWJkx3IeW3wqV0PoZxwt2o3mwTF1sjNeTqA+7kKRjblj942AxLVNY+jisLPm9kL4BX1 rZl5HClq4+24tA5cidy8VYgf08nY8vhSrtcQ1VYdN3lBL0XAnBFkLTXsxMaeNRpAt2st YijOXIJvleNvpWF52IveuZMpHXSFra8YRLasTTFdMPMn6Ebh5wwLF+/zTJQ78yt0Q8dm Zapg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708882008; x=1709486808; 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=V1c/UvO6Ams1u8TkjcWnyW71HdxDFLdj+Bjv7U1cnfM=; b=b0fBFCzX9I35CSTWQGoZJBDyzcvUAGIxU5n/Rs08aWeLkPeKaYACxeG6LN6wtoHUMP 1othFWpJqthqCFOn7+qFhQLrmj909zatqxKeGokP4zea0AAs6IoFdWBffh5rOAnCk9FQ ShJSN0Pbxm+eRkoh3I+0uZJ0IZu7AeBcVyyIeFdykwLaddvsLdjxFsSQEgBQFXDh1QBD H2VTc8EBRUExHqXm20Gm6PTpxknbnxPvdGb8CgpRXAXVnzkgTidWwxciB/gHdRgCEqWg ZmcuTlLZyaJI7gPgRp9CpayWNVMV5QqOfEGi2gjvp+pwhBCLpJt2e0iXEkaIgoMz14PP OahA== X-Gm-Message-State: AOJu0Yxn5ODXltahABV2XoNcZ9554A7S8W4mWbQT8GGoOY8ZE3mO8txv llacuZXkNP84fWkTFoIG7vx+UoXbV+pNmDInMBPCab8WTYoH5ThLjllgyqksy84Fzl/TSXiyqrU aWK/Um4M0ttQdSZ1tCd8r7l5AfP31ptrM X-Google-Smtp-Source: AGHT+IEo6LtuenKOHrOLcFpN8+byDt6qT/Xob32n9HgTQtareXorNB7qRu/NNBC9soo/S+Bql36xOLWuV/liLPRON0E= X-Received: by 2002:a2e:2c18:0:b0:2d2:5f8b:1386 with SMTP id s24-20020a2e2c18000000b002d25f8b1386mr2650898ljs.10.1708882007845; Sun, 25 Feb 2024 09:26:47 -0800 (PST) MIME-Version: 1.0 References: <20240225090751.yqb23ewm4pgocg7e@chazelas.org> In-Reply-To: <20240225090751.yqb23ewm4pgocg7e@chazelas.org> From: "Mark J. Reed" Date: Sun, 25 Feb 2024 12:26:35 -0500 Message-ID: Subject: Re: \M-^C vs \203 vs \x83 as visual representations of bytes To: Zsh hackers list Content-Type: multipart/alternative; boundary="0000000000000a7014061238190f" X-Seq: 52607 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: --0000000000000a7014061238190f Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Wow; I had no idea Zsh printed out nonprintable characters that way. I concur that it would make sense to change, modulo backward compatibility considerations. Maybe a settable option? The M- "meta" syntax is something I associate with Emacs key-binding, and have rarely seen in other contexts. On Sun, Feb 25, 2024 at 4:08=E2=80=AFAM Stephane Chazelas wrote: > I guess \M-^C (or \M-\C-C) as the representation of 0x83 made > sense to people in the 80s/90s when they could actually type > Meta-Ctrl-C on their keyboard to input them. > > Noaways, you can still enter ^C with Ctrl+C but bytes >=3D 0x80 > are used for non-ASCII characters, and Alt-C usually sends ^[c > (0x1b 0x63) and Alt-Ctrl-C ^[^C (0x1b 0x3) > > I find the \x83 representation more useful when giving visual > representations of bytes not forming part of a printable > characters (and \uffff / \U0010ffff for valid but non-printable > multi-byte characters). Octal used to be more popular than hex, > but I think nowadays it's the reverse, though I still find \203 > more useful than \M-^C if not \x83. > > What do people think? > > Would it make sense to change some of the output intended for > user consumption such as: > > $ a=3D$'\x83' > $ typeset a > a=3D$'\M-\C-C' > $ print -r ${(q+)a} > $'\M-\C-C' > $ (set -x; : $a) > +/bin/zsh:29> : $'\M-\C-C' > > > $ let $a > zsh: bad math expression: illegal character: \M-C > $ let 1+$a > zsh: bad math expression: operand expected at `\M-^C' > > (another M-C vs M-^C bug above by the way). > > Comparison with some other tools/shells: > > $ echo $a | cat -v > M-^C > $ echo $a | sed -n l > \203$ > $ bash -xc 'printf "%q\n" "$a"' > + printf '%q\n' $'\203' > $'\203' > $ ksh -xc 'printf "%q\n" "$a"' > + printf '%q\n' $'\x83' > $'\x83' > > -- > Stephane > > --=20 Mark J. Reed --0000000000000a7014061238190f Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Wow; I had no idea Zsh printed out nonprintable characters= that way. I concur that it would make sense to change, modulo backward com= patibility considerations. Maybe a settable option?

=C2= =A0The M- "meta" syntax is something=C2=A0I associate with Emacs = key-binding, and have rarely seen in other contexts.

On Sun, Feb 25, 2= 024 at 4:08=E2=80=AFAM Stephane Chazelas <stephane@chazelas.org> wrote:
I guess \M-^C (or \M-\C-C) as the represen= tation of 0x83 made
sense to people in the 80s/90s when they could actually type
Meta-Ctrl-C on their keyboard to input them.

Noaways, you can still enter ^C with Ctrl+C but bytes >=3D 0x80
are used for non-ASCII characters, and Alt-C usually sends ^[c
(0x1b 0x63) and Alt-Ctrl-C ^[^C (0x1b 0x3)

I find the \x83 representation more useful when giving visual
representations of bytes not forming part of a printable
characters (and \uffff / \U0010ffff for valid but non-printable
multi-byte characters). Octal used to be more popular than hex,
but I think nowadays it's the reverse, though I still find \203
more useful than \M-^C if not \x83.

What do people think?

Would it make sense to change some of the output intended for
user consumption such as:

$ a=3D$'\x83'
$ typeset a
a=3D$'\M-\C-C'
$ print -r ${(q+)a}
$'\M-\C-C'
$ (set -x; : $a)
+/bin/zsh:29> : $'\M-\C-C'


$ let $a
zsh: bad math expression: illegal character: \M-C
$ let 1+$a
zsh: bad math expression: operand expected at `\M-^C'

(another M-C vs M-^C bug above by the way).

Comparison with some other tools/shells:

$ echo $a | cat -v
M-^C
$ echo $a | sed -n l
\203$
$ bash -xc 'printf "%q\n" "$a"'
+ printf '%q\n' $'\203'
$'\203'
$ ksh -xc 'printf "%q\n" "$a"'
+ printf '%q\n' $'\x83'
$'\x83'

--
Stephane



--
Ma= rk J. Reed <mar= kjreed@gmail.com>
--0000000000000a7014061238190f--