Skip to content

df: let the last of -B, -h, -H, -k and -m win, like GNU - #15848

Open
TanbirRamim wants to merge 1 commit into
uutils:mainfrom
TanbirRamim:df-last-size-option-wins
Open

TanbirRamim wants to merge 1 commit into
uutils:mainfrom
TanbirRamim:df-last-size-option-wins

Conversation

@TanbirRamim

Copy link
Copy Markdown
Contributor

In GNU df, -B, -h, -H, -k and -m override each other and the last one on the command line wins. uutils always let -h/-H win, so df -h -B 1K still printed human sizes.

This came up while looking at a Copilot note on #14522 (--total -h --block-size=...).

Checked against GNU df 9.11 (--output=size):

args GNU 9.11 before after
-h -B 1K 1K-blocks Size 1K-blocks
-B 1K -h Size Size Size
-h -k 1K-blocks Size 1K-blocks
-H -k 1K-blocks Size 1K-blocks
-k -H Size Size Size
-h -m 1M-blocks Size 1M-blocks
-m -h Size Size Size

The fix just puts all five options in one overrides_with_all list, so clap keeps the last one. BLOCK_SIZE / DF_BLOCK_SIZE still lose to -h like before (same as GNU).

Added two tests: one for the header in each order, and one that checks -h -B 1 really prints a plain number, not just the right header. Both fail on main.

Copilot AI balanced review requested due to automatic review settings October 25, 2026 23:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.

This branch has not been deployed

No deployments
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.

2 participants