Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

The q parameter expansion flag does not support Unicode



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 <vincent@xxxxxxxxxx> - 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)




Messages sorted by: Reverse Date, Date, Thread, Author