Skip to content

du: accept --exclude, --exclude-from and --files0-from values starting with '-' - #16990

Open
emirmrkaljevic wants to merge 2 commits into
uutils:mainfrom
emirmrkaljevic:du-hyphen-values
Open

emirmrkaljevic wants to merge 2 commits into
uutils:mainfrom
emirmrkaljevic:du-hyphen-values

Conversation

@emirmrkaljevic

Copy link
Copy Markdown
Contributor

Fixes #16989.

--exclude, -X/--exclude-from and --files0-from now accept a value that starts with -, so du -a --exclude -skip dir excludes dir/-skip and du --files0-from -list reads the file -list, like GNU du 9.12. Before, clap treated the value as an option and du exited with 1. --max-depth and --threshold already allow this.

test_du_option_values_starting_with_hyphen covers all three options.

Found with behave.

@xtqqczze

Copy link
Copy Markdown
Collaborator

test_du_option_values_starting_with_hyphen is failing

@emirmrkaljevic

emirmrkaljevic commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor Author

Thanks, it failed only on Windows because du prints dir\keep there and the test looked for dir/keep. The test now checks for keep, which still covers the point (the -skip file is excluded, keep is listed). Amended into the same commit (3691a7a), du tests pass locally.

@codspeed

codspeed Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ 4 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 4 untouched benchmarks
⏩ 486 skipped benchmarks1


Comparing emirmrkaljevic:du-hyphen-values (bd87b95) with main (279cdbf)2

Open in CodSpeed

Footnotes

  1. 486 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

  2. No successful run was found on main (9be3446) during the generation of this report, so 279cdbf was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

Comment thread tests/by-util/test_du.rs Outdated
.stdout_contains("keep")
.stdout_does_not_contain("-skip");

ts.ucmd()

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.

this is the same arg as -X, so this block doesn't add much. Could be removed, no?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right, removed it in bd87b95.

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.

du: --exclude, --exclude-from and --files0-from reject values starting with '-'

3 participants