Skip to content

find -not flag incorrectly inverts all conditions instead of only the next predicate #25

@github-actions

Description

@github-actions

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions