From 8f42f35dd84b0f1c796628e3e84f2a04ba51279d Mon Sep 17 00:00:00 2001 From: arbelonson-source <269032023+arbelonson-source@users.noreply.github.com> Date: Mon, 31 Aug 2026 10:16:34 +0300 Subject: [PATCH] ls: enable locale-aware decimal separator for -h/--human-readable `ls -lh`'s size column ignored LC_NUMERIC's decimal separator (e.g. always showing "4.0K" instead of "4,0K" under fr_FR/de_DE locales), while `du -h` and `numfmt --to=iec` already handled this correctly. uucore's human_readable() formatter has had locale-aware decimal separator logic all along, gated behind the "i18n-decimal" uucore feature flag. du's and numfmt's Cargo.toml already enabled it; ls's did not, so ls always compiled against the feature's no-op fallback and silently used '.' regardless of locale. Fixes #14232 AI-assisted-by: Claude Opus 5, via Claude Code --- src/uu/ls/Cargo.toml | 1 + tests/by-util/test_ls.rs | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/src/uu/ls/Cargo.toml b/src/uu/ls/Cargo.toml index 388639fbbf0..362d46c922c 100644 --- a/src/uu/ls/Cargo.toml +++ b/src/uu/ls/Cargo.toml @@ -33,6 +33,7 @@ uucore = { workspace = true, features = [ "fsext", "fsxattr", "i18n-collator", + "i18n-decimal", "parser-size", "parser-glob", "quoting-style", diff --git a/tests/by-util/test_ls.rs b/tests/by-util/test_ls.rs index 08233e3ebe3..7956be93702 100644 --- a/tests/by-util/test_ls.rs +++ b/tests/by-util/test_ls.rs @@ -1765,6 +1765,25 @@ fn test_ls_long_total_size() { } } +#[test] +#[cfg(unix)] +#[cfg_attr(wasi_runner, ignore = "WASI: locale env vars not propagated")] +fn test_human_readable_uses_locale_decimal_separator() { + // GNU's -h/--human-readable fraction follows LC_NUMERIC (e.g. "4,0K" + // under fr_FR, not "4.0K"); this implementation's own human-readable + // formatter has the same locale-aware logic, but ls's own Cargo.toml + // was missing the uucore feature flag that turns it on, so this + // silently always used '.' regardless of locale. + let (at, mut ucmd) = at_and_ucmd!(); + at.write("f", &"a".repeat(4000)); + ucmd.env("LC_ALL", "fr_FR.UTF-8") + .arg("-l") + .arg("-h") + .arg("f") + .succeeds() + .stdout_contains("4,0K"); +} + #[test] #[cfg(not(feature = "selinux"))] // Disabled on the SELinux runner for now