uutils / uutils/coreutils

du `-b` behavior doesn't match GNU du

Open
#10,661 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

U - du
Dominant language
Rust
Stars
24.1k
Forks
2k
Avg merge
1d 5h
Merged PRs (30d)
365

Description

For GNU coreutils, the order of arguments matters in du:

$ du -m -sb Base
23507402	Base
$ du -sb -m Base
23	Base

-b means both --apparent-size and --block-size=1. If -b is before -m (--block-size=1M), the size is printed in megabytes.

uutils du ignores the order and always prints the size in bytes:

$ ~/repos/uutils-coreutils/target/debug/coreutils du -m -sb Base/
23507402	Base/
$ ~/repos/uutils-coreutils/target/debug/coreutils du -sb -m Base/
23507402	Base/

SerenityOS currently needs a workaround for this (see https://github.com/SerenityOS/serenity/pull/26120 and https://github.com/SerenityOS/serenity/pull/26121).
We can't use --apparent-size everywhere since BusyBox only supports short arguments, so only -b, which is described as:
-b Apparent size (including holes)
For BusyBox this argument doesn't even mean --block-size=1.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No source file or test path is named. Start by locating the du command entry point and its short-option parsing, then compare handling of -b and -m in both argument orders with GNU du. Done means the two orderings produce the documented GNU-compatible results while retaining the stated BusyBox-compatible -b behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.