Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: \M-^C vs \203 vs \x83 as visual representations of bytes
- X-seq: zsh-workers 52609
- From: Stephane Chazelas <stephane@xxxxxxxxxxxx>
- To: "Mark J. Reed" <markjreed@xxxxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: \M-^C vs \203 vs \x83 as visual representations of bytes
- Date: Sun, 25 Feb 2024 18:50:40 +0000
- Archived-at: <https://zsh.org/workers/52609>
- In-reply-to: <CAA=-s3yLhwkd7zy-2Fwky4DEOfoUD8UE9D14LqyY+yr3DPSyDA@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- Mail-followup-to: "Mark J. Reed" <markjreed@xxxxxxxxx>, Zsh hackers list <zsh-workers@xxxxxxx>
- References: <20240225090751.yqb23ewm4pgocg7e@chazelas.org> <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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author