Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ZFS command output uses wrong comma separator #16987

Open
cbinner opened this issue Jan 23, 2025 · 3 comments · May be fixed by #17075
Open

ZFS command output uses wrong comma separator #16987

cbinner opened this issue Jan 23, 2025 · 3 comments · May be fixed by #17075
Assignees
Labels
good first issue Indicates a good issue for first-time contributors Type: Defect Incorrect behavior (e.g. crash, hang)

Comments

@cbinner
Copy link

cbinner commented Jan 23, 2025

Distribution Name | Ubuntu/Arch Linux
Distribution Version | 22.04.5/Current
Kernel Version | 5.15.0/6.6.72
Architecture | amd64
OpenZFS Version | 2.1.5/2.3.0

openzfs’ supposedly human readable output uses a full stop rather than a comma as the decimal separator even in locales that require the latter.

Besides being an aesthetic problem this makes sort useless:
`$ zfs list -o used | sort -h
USED
12K
536K
897K
239M
239M
5.38M
7.43M
10.3G
10.3G
3.07G
3.07G
42.2G
42.2G
62.8G
6.81G
6.82G

$ export LANG=C
$ zfs list -o used | sort -h
USED
12K
536K
897K
5.38M
7.43M
239M
239M
3.07G
3.07G
6.81G
6.82G
10.3G
10.3G
42.2G
42.2G
62.8G`

Problem doesn’t exist in illumos’ zfs.

@cbinner cbinner added the Type: Defect Incorrect behavior (e.g. crash, hang) label Jan 23, 2025
@tonyhutter tonyhutter added the good first issue Indicates a good issue for first-time contributors label Jan 23, 2025
@Egor-OSSRevival
Copy link

Hi, I’m Egor from OSS Revival. We specialize in revitalizing and maintaining open-source projects for long-term stability. I’ll work on this issue, ensuring it stays aligned with the project’s original vision.

@cbinner
Copy link
Author

cbinner commented Feb 18, 2025

I tested older Ubuntu releases: 18.04 (zfs 0.7.5) is fine, 20.04 (zfs 0.8.3) has the described issue.
lib/libzutil/zutil_nicenum.c seems to do the formatting, but I guess the decimal separator is handled by the OS’s locale tools?

@cbinner
Copy link
Author

cbinner commented Feb 19, 2025

Issue isn’t limited to Linux, FreeBSD 14.2 (zfs 2.2.6) has it, too.

Egor-OSSRevival added a commit to Project-OSS-Revival/zfs that referenced this issue Feb 20, 2025
ZFS incorrectly uses a full stop (.) as the decimal separator in
human-readable output, even in locales that require a comma (,).
This inconsistency causes issues with tools like `sort -h`, making
sorting unreliable.

This fix ensures that ZFS respects the system locale when formatting
numerical output by setting `LC_NUMERIC` via `setlocale()`.

Signed-off-by: Egor Kovalcuk <[email protected]>
@amotin amotin linked a pull request Feb 20, 2025 that will close this issue
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Indicates a good issue for first-time contributors Type: Defect Incorrect behavior (e.g. crash, hang)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants