+
Skip to content

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
@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

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载