diff options
| author | Mikael Magnusson <mikachu@gmail.com> | 2026-06-07 01:48:20 +0200 |
|---|---|---|
| committer | Mikael Magnusson <mikachu@gmail.com> | 2026-06-14 01:56:15 +0200 |
| commit | e5f58a80ba5124735d6434845ea382a5db1f1875 (patch) | |
| tree | 0554fe54d4dcd9003b7d96fb5bd083e000c52d5a /Src/Modules | |
| parent | 54677: tests: improve readability (diff) | |
| download | zsh-e5f58a80ba5124735d6434845ea382a5db1f1875.tar zsh-e5f58a80ba5124735d6434845ea382a5db1f1875.tar.gz zsh-e5f58a80ba5124735d6434845ea382a5db1f1875.tar.bz2 zsh-e5f58a80ba5124735d6434845ea382a5db1f1875.tar.lz zsh-e5f58a80ba5124735d6434845ea382a5db1f1875.tar.xz zsh-e5f58a80ba5124735d6434845ea382a5db1f1875.tar.zst zsh-e5f58a80ba5124735d6434845ea382a5db1f1875.zip | |
54710: handle multibyte arguments in error messages
A lot of places check option strings char by char, then send that char
to zwarn/zerr, instead of reading out the full multibyte character.
Doing so is quite easy with unmeta_one in most cases, so just go ahead
and do that. The print functions in fact expect a wchar_t for %c anyway.
Also renames "unknown option" to "bad option" because that's what every
other place calls it (also one place was missing the colon, added that).
To reproduce the math errors, since it's slightly less obvious (you need
a multibyte character that is also an invalid parameter name, otherwise
it actually works fine)
% zsh -c '(( ¯ ))'
zsh:1: bad math expression: illegal character: ^
% zsh -c 'zmodload zsh/mathfunc; (( sin(1¯) ))'
zsh:1: bad math expression: illegal character: ^
% zsh -c 'の=5; echo $(( の ))' # unchanged because it is working
5
Also adds some tests because B12 was looking very empty, not sure if
this is the correct way to handle the intersection of possibly not
compiled module with possibly not available UTF-8 locale, but X02 and
some others do a similar thing with ZSH_TEST_LANG, though in those cases
that's handled specially by comptest, not the test itself.
Diffstat (limited to 'Src/Modules')
| -rw-r--r-- | Src/Modules/stat.c | 3 | ||||
| -rw-r--r-- | Src/Modules/system.c | 3 | ||||
| -rw-r--r-- | Src/Modules/zftp.c | 5 |
3 files changed, 8 insertions, 3 deletions
diff --git a/Src/Modules/stat.c b/Src/Modules/stat.c index f7ec06e9e..cb216f33a 100644 --- a/Src/Modules/stat.c +++ b/Src/Modules/stat.c @@ -450,7 +450,8 @@ bin_stat(char *name, char **args, Options ops, UNUSED(int func)) ops->ind['s'] = 1; break; } else { - zwarnnam(name, "bad option: -%c", *arg); + convchar_t warg = unmeta_one(arg, NULL); + zwarnnam(name, "bad option: -%c", warg); return 1; } } diff --git a/Src/Modules/system.c b/Src/Modules/system.c index 3c0b8421a..4d2f8c42a 100644 --- a/Src/Modules/system.c +++ b/Src/Modules/system.c @@ -653,7 +653,8 @@ bin_zsystem_flock(char *nam, char **args, UNUSED(Options ops), UNUSED(int func)) break; default: - zwarnnam(nam, "flock: unknown option: %c", *optptr); + convchar_t opt = unmeta_one(optptr, NULL); + zwarnnam(nam, "flock: bad option: %c", opt); return 1; } optptr++; diff --git a/Src/Modules/zftp.c b/Src/Modules/zftp.c index 8a8fb9dd5..f863676c1 100644 --- a/Src/Modules/zftp.c +++ b/Src/Modules/zftp.c @@ -3093,7 +3093,10 @@ bin_zftp(char *name, char **args, UNUSED(Options ops), UNUSED(int func)) break; default: - zwarnnam(name, "preference %c not recognized", *ptr); + int sz; + convchar_t p = unmeta_one(ptr, &sz); + ptr += sz - 1; + zwarnnam(name, "preference %c not recognized", p); break; } } |
