du `-b` behavior doesn't match GNU du
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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