fix: replace {} placeholder in -exec utility name#647
fix: replace {} placeholder in -exec utility name#647mvanhorn wants to merge 2 commits intouutils:mainfrom
Conversation
The {} placeholder was only replaced in arguments to -exec, not in the
utility_name position itself. Running `find -exec {} \;` passed the
literal string "{}" to Command::new, causing "No such file or directory".
Extracted arg parsing into a shared `parse_arg` helper and changed the
`executable` field from String to the existing Arg enum so it undergoes
the same {} replacement as other arguments.
Fixes uutils#614
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #647 +/- ##
==========================================
- Coverage 91.76% 91.70% -0.06%
==========================================
Files 31 31
Lines 6203 6207 +4
Branches 328 328
==========================================
Hits 5692 5692
- Misses 390 394 +4
Partials 121 121 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
What do you do with Also, probably a good idea to add some tests. Claude didn't do that automatically? |
|
Indeed, it needs tests |
Verify that SingleExecMatcher resolves {} in arguments
when the executable is a known path. Covers the case
where -exec receives {} in argument positions.
|
Added a test in da847c6. On the |
Summary
Fixed -exec to replace {} in the utility_name position, not just in arguments. Previously
find -exec {} \;passed the literal string "{}" to Command::new.Why this matters
Per POSIX (
find -exec utility_name [argument ...] ;), a utility_name containing only "{}" should be replaced with the current pathname. GNU find and BSD find both handle this correctly. uutils find failed with "No such file or directory" because {} was never substituted in the executable field.Repro from #614:
Changes
src/find/matchers/exec.rs: Extractedparse_arghelper from the duplicated split logic. ChangedSingleExecMatcher.executablefromStringtoArgso it undergoes the same {} replacement as arguments. Updated error formatting to use the resolved executable path.Testing
All 25 existing tests pass. Verified compilation with
cargo checkandcargo clippy(no warnings). Tested manually withcargo run --bin find -- /usr/bin -name pwd -exec {} -P \;.Fixes #614
This contribution was developed with AI assistance (Claude Code).