Repository navigation
feat(find): fall back to native find for unsupported predicates - #2474
hgunduzoglu wants to merge 3 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.
|
Fixed the Windows CI failure in |
|
Thanks for reporting this and for the never-block reasoning, which is the right call. This is fixed on develop by #3603, merged 2026-08-26 (commit 203948b): rtk find now parses find's own grammar, sends predicates it does not model to real find and still compresses the results, and runs actions like -exec or -delete through passthrough with the exit code preserved. I re-ran the examples from your description against a current develop build and -not, parenthesised -o and -exec all work and match native find. Closing as already covered, and please comment or reopen if you find a predicate that still gets refused. |
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).