Skip to content

find: reject a signed -maxdepth/-mindepth value to match GNU - #835

Merged
sylvestre merged 1 commit into
uutils:mainfrom
AlejandroCoronadoN:fix-maxdepth-signed
Aug 19, 2026
Merged

find: reject a signed -maxdepth/-mindepth value to match GNU#835
sylvestre merged 1 commit into
uutils:mainfrom
AlejandroCoronadoN:fix-maxdepth-signed

Conversation

@AlejandroCoronadoN

Copy link
Copy Markdown
Contributor

Problem

-maxdepth/-mindepth accepted a +-signed value that GNU rejects:

$ find dir -maxdepth +1     # uutils: runs normally (parsed as 1)
$ gfind dir -maxdepth +1
find: Expected a positive decimal integer argument to -maxdepth, but got '+1'

Rust's usize::from_str accepts a leading +, so convert_arg_to_number let
it through, which is inconsistent with the function's own "positive decimal
integer" error message.

Fix

Only accept plain decimal digits.

Verification

Compared against GNU findutils (gfind) for -maxdepth and -mindepth over
1, +1, -1, +2, 0, 2; exit codes match in every case. Added a unit
test; cargo test --lib passes and cargo fmt / cargo clippy are clean.

@codspeed-hq

codspeed-hq Bot commented Aug 13, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 20 untouched benchmarks


Comparing AlejandroCoronadoN:fix-maxdepth-signed (0f7a2da) with main (1acf40a)

Open in CodSpeed

@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.27%. Comparing base (1acf40a) to head (0f7a2da).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #835      +/-   ##
==========================================
+ Coverage   92.22%   92.27%   +0.05%     
==========================================
  Files          35       35              
  Lines        7435     7435              
  Branches      386      386              
==========================================
+ Hits         6857     6861       +4     
+ Misses        437      433       -4     
  Partials      141      141              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@github-actions

Copy link
Copy Markdown

Commit 2c18ead has test result changes:

GNU findutils testsuite:

Test results comparison:
  Current:   TOTAL: 495 / PASSED: 421 / FAILED: 73 / SKIPPED: 1
  Reference: TOTAL: 495 / PASSED: 417 / FAILED: 77 / SKIPPED: 1

Changes from main branch:
  TOTAL: +0
  PASSED: +4
  FAILED: -4

Test improvements (4):
  + mindepth-badarg.new-O0
  + mindepth-badarg.new-O1
  + mindepth-badarg.new-O2
  + mindepth-badarg.new-O3

bfs testsuite:

Test results comparison:
  Current:   TOTAL: 313 / PASSED: 266 / FAILED: 41 / SKIPPED: 6
  Reference: TOTAL: 313 / PASSED: 267 / FAILED: 40 / SKIPPED: 6

Changes from main branch:
  TOTAL: +0
  PASSED: -1
  FAILED: +1

New test failures (1):
  - gnu/files0_from_ok

@sylvestre

Copy link
Copy Markdown
Contributor

please add a test_find.rs

@AlejandroCoronadoN

Copy link
Copy Markdown
Contributor Author

Done, added an integration test in test_find.rs for the signed -maxdepth/-mindepth case.

@github-actions

Copy link
Copy Markdown

Commit e056014 has test result changes:

GNU findutils testsuite:

Test results comparison:
  Current:   TOTAL: 495 / PASSED: 424 / FAILED: 70 / SKIPPED: 1
  Reference: TOTAL: 495 / PASSED: 420 / FAILED: 74 / SKIPPED: 1

Changes from main branch:
  TOTAL: +0
  PASSED: +4
  FAILED: -4

Test improvements (4):
  + mindepth-badarg.new-O0
  + mindepth-badarg.new-O1
  + mindepth-badarg.new-O2
  + mindepth-badarg.new-O3

bfs testsuite:

Test results comparison:
  Current:   TOTAL: 315 / PASSED: 267 / FAILED: 42 / SKIPPED: 6
  Reference: TOTAL: 314 / PASSED: 266 / FAILED: 42 / SKIPPED: 6

Changes from main branch:
  TOTAL: +1
  PASSED: +1
  FAILED: +0

New test failures (1):
  - gnu/okdir_path_relative

Test improvements (1):
  + gnu/okdir_path_empty

@github-actions

Copy link
Copy Markdown

Commit f9fbd6e has test result changes:

GNU findutils testsuite:

Test results comparison:
  Current:   TOTAL: 495 / PASSED: 425 / FAILED: 69 / SKIPPED: 1
  Reference: TOTAL: 495 / PASSED: 421 / FAILED: 73 / SKIPPED: 1

Changes from main branch:
  TOTAL: +0
  PASSED: +4
  FAILED: -4

Test improvements (4):
  + mindepth-badarg.new-O0
  + mindepth-badarg.new-O1
  + mindepth-badarg.new-O2
  + mindepth-badarg.new-O3

bfs testsuite:

Test results comparison:
  Current:   TOTAL: 314 / PASSED: 267 / FAILED: 41 / SKIPPED: 6
  Reference: TOTAL: 313 / PASSED: 267 / FAILED: 40 / SKIPPED: 6

Changes from main branch:
  TOTAL: +1
  PASSED: +0
  FAILED: +1

New test failures (1):
  - gnu/okdir_path_relative

@sylvestre

Copy link
Copy Markdown
Contributor

a bunch of jobs have been failing

convert_arg_to_number parsed the depth with Rust's usize parser, which accepts a
leading '+', so "-maxdepth +1" was silently accepted. GNU find rejects a signed
value there. Only accept plain decimal digits. Adds a test_find.rs test.
@AlejandroCoronadoN

Copy link
Copy Markdown
Contributor Author

The failing jobs were from a stale base; rebased the branch on the latest main. fmt, clippy and the tests pass locally now.

@github-actions

Copy link
Copy Markdown

Commit 0f7a2da has test result changes:

GNU findutils testsuite:

Test results comparison:
  Current:   TOTAL: 495 / PASSED: 425 / FAILED: 69 / SKIPPED: 1
  Reference: TOTAL: 495 / PASSED: 421 / FAILED: 73 / SKIPPED: 1

Changes from main branch:
  TOTAL: +0
  PASSED: +4
  FAILED: -4

Test improvements (4):
  + mindepth-badarg.new-O0
  + mindepth-badarg.new-O1
  + mindepth-badarg.new-O2
  + mindepth-badarg.new-O3

@sylvestre
sylvestre merged commit f5f0f64 into uutils:main Aug 19, 2026
23 checks passed
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