The q parameter expansion flag does not support Unicode
Vincent Lefevre <[email protected]> Sun, 12 Jul 2026 12:04:48 +0200
| Newsgroups | gmane.comp.shells.zsh.devel |
|---|---|
| Message-ID | <[email protected]> |
With zsh 5.9 under Debian: The zshexpn(1) man page says under
"Parameter Expansion Flags":
q Quote characters that are special to the shell in the
resulting words with backslashes; unprintable or
invalid characters are quoted using the $'\NNN' form,
with separate quotes for each octet.
The first part of the sentence is correct *only* for ASCII characters.
With
var=$(printf "A\bB\u2060C")
printf "%s\n" ${(q)var}
printf "%s\n" $var:q
the \b is quoted as $'\b', but the U+2060 WORD JOINER character
is not quoted though it is not printable. I would have expected
it to be quoted as $'\u2060'.
--
Vincent Lefèvre <[email protected]> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Pascaline project (LIP, ENS-Lyon)