feat(find): fall back to native find for unsupported predicates#2474
Open
hgunduzoglu wants to merge 2 commits into
Open
feat(find): fall back to native find for unsupported predicates#2474hgunduzoglu wants to merge 2 commits into
hgunduzoglu wants to merge 2 commits into
Conversation
rtk find refused compound predicates and actions (-not, -exec, -o, -size, -mtime, …) with an error and produced no results, breaking the user's command. Per the Never-Block principle, fall back to native find (unfiltered passthrough) for those queries instead, propagating its exit code. The common -name/-type/-maxdepth path keeps full rtk compaction. Fixes rtk-ai#2469
The two passthrough tests execute the resolved `find` and assert GNU/BSD semantics (a valid -not/-exec query exits 0). On Windows, `find.exe` is an unrelated text-search tool that rejects these args (exit 2), failing the assertions. Gate them behind cfg(unix); the routing decision stays covered cross-platform by has_unsupported_find_flags_detects_and_ignores.
Contributor
Author
|
Fixed the Windows CI failure in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #2469.
rtk findrefused compound predicates and actions —-not,!,-or/-o,-and/-a,-exec,-size,-mtime,-regex, etc. — by printingrtk find does not support compound predicates or actions … Use \find` directly.` and producing no results. That silently breaks the user's command, which violates RTK's Never-Block principle ("if a filter fails, fall back to raw output; RTK should never prevent a command from executing").Change
When
rtk findsees a predicate it can't compact, it now falls back to nativefind(unfiltered passthrough) instead of refusing, and propagates native find's exit code. The common-name/-type/-maxdepthpath is untouched and keeps full rtk compaction.This also makes
-exec,-o,-size,-mtime, … work for the first time, since they all reach native find now.Notes
rtk proxy) — a correct full result beats a broken/refused command. The compactable majority (-name/-type/-maxdepth) still gets rtk's tree formatting. Full compaction of compound-predicate output could be a later enhancement; this PR is the Never-Block fix.parse_find_argskeeps its bail as a defensive contract (its unit tests still pass);run_from_argsnow intercepts unsupported flags before parsing and routes to passthrough.run_from_argsnow returnsResult<i32>to propagate the child exit code; themain.rsFind arm returns it.Testing
-notpassthrough returns Ok(0),-execpassthrough returns Ok(0),has_unsupported_find_flagsdetects unsupported / ignores supported predicates.parse_find_argsbail tests andrun_from_argscompaction tests still pass.cargo fmt --all --check && cargo clippy --all-targets && cargo test— clean, 2202 passed.findfor-not,-o,-exec, and exit-code propagation on an invalid query (rtk exit 1 == native exit 1).