fix ZFS command output uses wrong comma separator #17075
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.
Motivation and Context
Currently, OpenZFS incorrectly uses a full stop (.) as the decimal separator in its human-readable output, even in locales that require a comma (,). This issue not only affects aesthetics but also breaks tools like sort -h, which rely on correct numerical formatting.
For example, running:
produces incorrect sorting when using a locale that expects a comma separator.
This issue does not exist in illumos' ZFS, where numeric formatting respects the system locale.
This PR ensures that OpenZFS respects the system’s locale when formatting numerical output.
Description
This change ensures that OpenZFS uses the correct decimal separator based on the system locale.
The fix involves adding:
to lib/libzutil/zutil_nicenum.c, ensuring that numeric output is formatted according to the user's locale settings.
How Has This Been Tested?
The changes were tested on a system with different locales, including en_US.UTF-8 and de_DE.UTF-8, to verify that the decimal separator correctly follows the system locale. The output of zfs list -o used | sort -h was checked before and after applying the fix, ensuring that numeric sorting behaves as expected. Additional testing confirmed that the change does not affect systems where the default decimal separator is a period (.).
Types of changes
Checklist:
Signed-off-by
.