Description
In tools/find/find.go, when -not is passed, cfg.Invert = true is set globally. Inside evaluateConditions, every condition check independently applies if cfg.Invert { matched = !matched }. This means -not inverts all predicates simultaneously.
GNU find applies -not only to the immediately following predicate.
Steps to Reproduce
# Intended: find non-.go regular files
aict find . -not -name "*.go" -type f
# Actual: also inverts -type f, so returns directories named *.go (nonsensical)
Expected Behavior
-not -name "*.go" -type f should return regular files whose name does not match *.go.
Proposed Fix
Change Invert from a global bool to a per-condition flag. Parse predicates in order and associate the invert flag with the immediately following condition only.
Related
tools/find/find.go parseFlags and evaluateConditions
Description
In
tools/find/find.go, when-notis passed,cfg.Invert = trueis set globally. InsideevaluateConditions, every condition check independently appliesif cfg.Invert { matched = !matched }. This means-notinverts all predicates simultaneously.GNU
findapplies-notonly to the immediately following predicate.Steps to Reproduce
Expected Behavior
-not -name "*.go" -type fshould return regular files whose name does not match*.go.Proposed Fix
Change
Invertfrom a global bool to a per-condition flag. Parse predicates in order and associate the invert flag with the immediately following condition only.Related
tools/find/find.goparseFlagsandevaluateConditions