ls: enable locale-aware decimal separator for -h/--human-readable - #14326
Open
arbelonson-source wants to merge 1 commit into
Open
ls: enable locale-aware decimal separator for -h/--human-readable#14326arbelonson-source wants to merge 1 commit into
arbelonson-source wants to merge 1 commit into
Conversation
`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 uutils#14232 AI-assisted-by: Claude Opus 5, via Claude Code
|
GNU testsuite comparison: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ls -lh's human-readable size column ignoresLC_NUMERIC's decimal separator — it always shows e.g.4.0K, even under a locale likefr_FR.UTF-8where GNUls -lhshows4,0K.du -handnumfmt --to=iecalready handle this correctly in this implementation.Root cause:
uucore::format::human::human_readable()has had locale-aware decimal-separator logic all along, gated behind thei18n-decimaluucore feature flag (localize_decimal, seesrc/uucore/src/lib/features/format/human.rs).du's andnumfmt'sCargo.tomlalready enable that feature;ls's did not, so it silently compiled against the feature's no-op fallback and always used.regardless of locale.Fix is a one-line addition of
"i18n-decimal"tols's uucore feature list insrc/uu/ls/Cargo.toml, matchingduandnumfmt.Fixes #14232
Test plan
test_human_readable_uses_locale_decimal_separatorintests/by-util/test_ls.rs, assertingls -lhunderLC_ALL=fr_FR.UTF-8shows4,0Kfor a 4000-byte file4.0Kinstead of4,0K)cargo test --features feat_os_unix --test tests -- test_ls— 187 passed, 1 ignored (WASI-only)cargo clippy -p uu_ls --all-targets -- -D warnings— cleanls -lhunderfr_FR.UTF-8,de_DE.UTF-8, andLC_NUMERIC=C(unaffected) — matches in all three casesAI-assisted-by: Claude Opus 5, via Claude Code