coreutils
coreutils copied to clipboard
echo, printf: UTF-8 sensitivity in arguments
❯ coreutils echo "$(coreutils printf 'A \xFF Z')"
error: invalid UTF-8 was detected in one or more arguments
Usage: coreutils echo [OPTIONS]... [STRING]...
For more information, try '--help'.
❯ /usr/bin/echo "$(coreutils printf 'A \xFF Z')"
A � Z
❯ coreutils printf "$(coreutils printf 'A \xFF Z')\n"
error: invalid UTF-8 was detected in one or more arguments
Usage: coreutils printf FORMATSTRING [ARGUMENT]...
coreutils printf FORMAT [ARGUMENT]...
coreutils printf OPTION
For more information, try '--help'.
❯ /usr/bin/printf "$(coreutils printf 'A \xFF Z')\n"
A � Z
I'm not sure if this is practically relevant. You can't print arbitrary binary data with echo/printf anyway, because the arguments are C strings (null terminated).
Fixed in echo by https://github.com/uutils/coreutils/pull/6803
Not yet fixed in printf