Skip to content

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

Open
AlejandroCoronadoN wants to merge 2 commits into
uutils:mainfrom
AlejandroCoronadoN:fix-maxdepth-signed
Open

find: reject a signed -maxdepth/-mindepth value to match GNU#835
AlejandroCoronadoN wants to merge 2 commits 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 (f9fbd6e) with main (6e4a7fb)

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.07%. Comparing base (9e778f1) to head (e056014).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #835      +/-   ##
==========================================
+ Coverage   92.01%   92.07%   +0.05%     
==========================================
  Files          35       35              
  Lines        7316     7316              
  Branches      378      378              
==========================================
+ Hits         6732     6736       +4     
+ Misses        442      438       -4     
  Partials      142      142              

☔ 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

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

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

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