mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2026-11-17 18:02:09 +03:00
tests: ls: cover quoting in the C.UTF-8 locale
The quoting characters and the printability of a multibyte character are selected by the locale's codeset, not by its language, but no test covered a locale that has a UTF-8 codeset and no language. * tests/ls/quoting-utf8.sh: Check that in C.UTF-8 the locale/clocale styles use the Unicode quotes and that literal/escape/shell-escape pass a multibyte character through unaltered, whereas the plain C locale octal-escapes it or replaces it with '?'. Link: https://github.com/coreutils/coreutils/pull/323
This commit is contained in:
1 parent
ab6b01f40f
commit
fc426cc142
1 file changed
+33
@@ -75,4 +75,37 @@ LC_ALL=C ls --quoting-style=clocale > out_clocale_c || fail=1
|
||||
grep '^"hello world"$' out_clocale_c > /dev/null 2>&1 \
|
||||
|| { echo "clocale C: expected ASCII double quotes"; fail=1; }
|
||||
|
||||
# C.UTF-8 provides no translations either, but its codeset is UTF-8.
|
||||
# It is the codeset, not the language, that selects the quoting characters
|
||||
# and decides whether a multibyte character is printable.
|
||||
if test "$(LC_ALL=C.UTF-8 locale charmap 2>/dev/null)" = UTF-8; then
|
||||
# U+00EF = \xc3\xaf (LATIN SMALL LETTER I WITH DIAERESIS)
|
||||
mb=$(printf 'na\303\257ve')
|
||||
touch "$mb" || framework_failure_
|
||||
|
||||
for style in locale clocale; do
|
||||
LC_ALL=C.UTF-8 ls --quoting-style=$style "$mb" > out_cutf8 || fail=1
|
||||
printf '%s%s%s\n' "$lq" "$mb" "$rq" > exp_cutf8 || framework_failure_
|
||||
compare exp_cutf8 out_cutf8 || fail=1
|
||||
done
|
||||
|
||||
# The character is printable here, so it is passed through unaltered.
|
||||
printf '%s\n' "$mb" > exp_cutf8 || framework_failure_
|
||||
for style in literal escape shell-escape; do
|
||||
LC_ALL=C.UTF-8 ls --hide-control-chars --quoting-style=$style "$mb" \
|
||||
> out_cutf8 || fail=1
|
||||
compare exp_cutf8 out_cutf8 || fail=1
|
||||
done
|
||||
|
||||
# Whereas in the C locale the same bytes are not printable.
|
||||
LC_ALL=C ls --quoting-style=escape "$mb" > out_c || fail=1
|
||||
printf 'na\\303\\257ve\n' > exp_c || framework_failure_
|
||||
compare exp_c out_c || fail=1
|
||||
|
||||
LC_ALL=C ls --hide-control-chars --quoting-style=literal "$mb" > out_c \
|
||||
|| fail=1
|
||||
printf 'na??ve\n' > exp_c || framework_failure_
|
||||
compare exp_c out_c || fail=1
|
||||
fi
|
||||
|
||||
Exit $fail
|
||||
Reference in new issue
Block a user