Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Metafication in error messages (Was: [PATCH] unmetafy Re: $var not expanded in ${x?$var})
- X-seq: zsh-workers 52601
- From: Stephane Chazelas <stephane@xxxxxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: zsh workers <zsh-workers@xxxxxxx>
- Subject: Re: Metafication in error messages (Was: [PATCH] unmetafy Re: $var not expanded in ${x?$var})
- Date: Sun, 25 Feb 2024 07:29:51 +0000
- Archived-at: <https://zsh.org/workers/52601>
- In-reply-to: <CAH+w=7Z9EhH_caA-kioEjvFLXN06s82cAu-Mq9XyU4BwbVsktA@mail.gmail.com>
- List-id: <zsh-workers.zsh.org>
- Mail-followup-to: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>, zsh workers <zsh-workers@xxxxxxx>
- References: <CAH+w=7ah2tG=QOFDVirAm2PdeX4CXqqjjc+0JinOAG_jkgR6sQ@mail.gmail.com> <20240222072313.7woy5vxvt4fbxyhj@chazelas.org> <20240222075528.eruaoosiuhmcrdsy@chazelas.org> <CAH+w=7Z5CELddo2qJtiNWM2AmxkRoqKz3Pj9LdEGb1z_3SyqeQ@mail.gmail.com> <CAH+w=7YcXGPDNFaGA_onRnRmWPhrZ3ems5x_9amEaH8y2miWSA@mail.gmail.com> <20240223192717.tczrbc63fei7d4m2@chazelas.org> <CAH+w=7bTFowrTNu8rorLzSbQyW70oGuppYYvPdF40RTJk4bQ8w@mail.gmail.com> <20240224094722.hnullrzrb6gsswnm@chazelas.org> <CAH+w=7b0GYtGChO=vOUqO8MEkysi7TmxCUhdW=GRxWqYFaBHjw@mail.gmail.com> <CAH+w=7Z9EhH_caA-kioEjvFLXN06s82cAu-Mq9XyU4BwbVsktA@mail.gmail.com>
2024-02-24 22:05:26 -0800, Bart Schaefer:
> On Sat, Feb 24, 2024 at 6:17 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> >
> > The actual tradeoff to make %l do the raw output is:
> > + fix the width calculation in math.c, then use %s *
> > + add one call to metafy() in parse.c, to use %s instead of %l **
> > + add one call to unmetafy() in subst.c, to use %l instead of %s
> > - remove metalen(), zhalloc(), memcpy(), and nicezputs() from utils.c
> > + add one call to fwrite() in place of the above
>
> Stephane, if you really still think it preferable to add %S (thus
> moving the unmetafy() from subst.c to utils.c) then I think we should
> just do away with %l entirely. Either way we're ending up with a
> branch in zerrmsg() that's used for exactly one special case.
I don't have a strong opinion on it. Either way, the internal
documentation should make it clear the metafy and nicezputs
expectations.
Like:
%s expects metafied string, prints it nicezputs'ed
%l expects non-metafied string and byte length, prints it raw.
it's the caller's responsibility to make sure the string is
not truncated in the middle of a character.
Note that there's truncating in between the bytes of a
character and there's truncating between the characters of a
grapheme cluster like decomposed Hangul syllables (or
$'Ste\u301phane'). I don't think we'd want to try and address
that.
Other option could be to have %s, %S and %*s %*S and let
nicezputs do the truncation and ellipsis in %*s case which might
be a cleaner interface if (likely) more cumbersome to implement.
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author