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

du: give -h output the same precision as GNU coreutils #6226

Merged
merged 4 commits into from
Apr 24, 2024

Conversation

mvo5
Copy link
Contributor

@mvo5 mvo5 commented Apr 13, 2024

When printing the du -h output GNU coreutils does autoscale
the size, e.g.

$ truncate -s12M a
$ truncate -s8500 b
$ truncate -s133456345 c
$ truncate -s56990456345 d
$ du -h --apparent-size a b c d
12M     a
8,4K    b
128M    c
54G     d

Align our version to do the same by sharing the code with ls.

Closes: #6159


ls,uucore: extract display human_readable() helper from ls

This commit extract the display_size() helper from ls into
uucore as human_readable to be similar to the gnulib helper
so that the human readable display of sizes can be shared between
ls, du, df.

Copy link

GNU testsuite comparison:

GNU test failed: tests/cp/same-file. tests/cp/same-file is passing on 'main'. Maybe you have to rebase?
GNU test failed: tests/cp/cross-dev-symlink. tests/cp/cross-dev-symlink is passing on 'main'. Maybe you have to rebase?

mvo5 and others added 3 commits April 24, 2024 16:53
This commit extract the `display_size()` helper from `ls` into
`uucore` as `human_readable` to be similar to the gnulib helper
so that the human readable display of sizes can be shared between
ls, du, df.
When printing the `du -h` output GNU coreutils does autoscale
the size, e.g.
```
$ truncate -s12M a
$ truncate -s8500 b
$ truncate -s133456345 c
$ truncate -s56990456345 d
$ du -h --apparent-size a b c d
12M	a
8,4K	b
128M	c
54G	d
```
Align our version to do the same by sharing the code with `ls`.

Closes: uutils#6159
@cakebaker cakebaker merged commit 7cee2c5 into uutils:main Apr 24, 2024
67 checks passed
@cakebaker
Copy link
Contributor

Good work, thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

du -h --apparent-size adds an extra zero on stdout .
2 participants