zsh-workers
 help / color / mirror / code / Atom feed
From: Stephane Chazelas <stephane@chazelas.org>
To: "Mark J. Reed" <markjreed@gmail.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Subject: Re: \M-^C vs \203 vs \x83 as visual representations of bytes
Date: Sun, 25 Feb 2024 18:50:40 +0000	[thread overview]
Message-ID: <20240225185040.556pkrig7prtibck@chazelas.org> (raw)
In-Reply-To: <CAA=-s3yLhwkd7zy-2Fwky4DEOfoUD8UE9D14LqyY+yr3DPSyDA@mail.gmail.com>

2024-02-25 12:26:35 -0500, Mark J. Reed:
> 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?
[...]

Note that I'm not suggesting zsh stop accepting it on input, but
to change the output format.

On input, zsh supports \203 and \x83 more widely than \M-\C-C

Supported by print and $'...'

$ print '\x83\203\M-\C-C' | sed -n l
\203\203\203$
$ print -r $'\x83\203\M-\C-C' | sed -n l
\203\203\203$

But not:

$ echo '\x83\203\M-\C-C' | sed -n l
\203\\203\\M-\\C-C$
$ echo '\x83\0203\M-\C-C' | sed -n l
\203\203\\M-\\C-C$
$ printf '\x83\0203\M-\C-C\n' | sed -n l
\203\0203\\M-\\C-C$

So I wouldn't think the switch would break backward
compatibility. Switching to \203 or \x83 would actually improve
compatibility with other shells.

Ksh has \CC instead of \C-C (inside $'...') and it's \M-C seems to expand to
^[C (and \M-c doesn't seem to be recognised).

In ksh however, \xfff is the same as \ufff (while \xff is not
the same as \uff) and you need \x[ff]f or \x{ff}f to have a 0xff
byte followed by f. So the output would not be compatible with
ksh if switching to \xHH.

$ ksh -c 'printf "%q\n" "$@"' ksh $'\xff' $'\xfff'
$'\xff'
$'\x[ff]f'

See also
https://github.com/ksh93/ksh/commit/ac8991e5257978a6359c001b7fa227c334fd9e18

-- 
Stephane


  reply	other threads:[~2024-02-25 18:51 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-25  9:07 Stephane Chazelas
2024-02-25 17:26 ` Mark J. Reed
2024-02-25 18:50   ` Stephane Chazelas [this message]
2024-02-25 20:54   ` Bart Schaefer
2024-02-25 18:25 ` Stephane Chazelas

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=20240225185040.556pkrig7prtibck@chazelas.org \
    --to=stephane@chazelas.org \
    --cc=markjreed@gmail.com \
    --cc=zsh-workers@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).