Skip to content

evo grep never uses ripgrep — availability check is inverted, always falls back to grep #94

Description

@Srinivasan8888

Summary

evo grep is documented/intended to prefer ripgrep and fall back to grep, but the availability check is inverted, so rg is never selected — every evo grep runs grep -rn.

Location

plugins/evo/src/evo/cli.py:2432 (cmd_ws_grep):

which = executor.run(["which", "rg"], cwd=str(base))
if (which.exit_code or 1) == 0 and which.stdout.strip():
    cmd = ["rg", "--no-heading", "--line-number", args.pattern, str(base)]
else:
    cmd = ["grep", "-rn", args.pattern, str(base)]

Root cause

which rg exits 0 when rg is present. But (which.exit_code or 1) collapses the success value: 0 is falsy, so 0 or 11, and the test becomes 1 == 0False. When rg is absent the exit code is 1, so 1 or 11, again 1 == 0False.

The condition is False in every case → the rg branch is dead code. The or 1 idiom (meant to coerce a None exit code into a failure sentinel) also clobbers the only value that should pass the check.

>>> (0 or 1) == 0   # rg present
False
>>> (1 or 1) == 0   # rg absent
False

Impact

On any machine with rg installed, evo grep <pattern> silently runs grep -rn instead. Because rg and grep differ in:

  • regex dialect — a pattern written for rg (\d, \b, lookarounds) matches differently or errors under BRE grep;
  • ignore semanticsrg respects .gitignore (skips node_modules/, build dirs); grep -rn searches them.

…the tool returns different/wrong results than intended, and the "prefer rg" contract is entirely non-functional.

Proposed fix

if which.exit_code == 0 and which.stdout.strip():

(or, preserving the None-guard intent: if (which.exit_code if which.exit_code is not None else 1) == 0 and which.stdout.strip():).

Verify

Stub executor.run(["which","rg"])exit_code=0, stdout="/usr/bin/rg\n" and assert cmd[0] == "rg"; it fails on current code. Or add a trace print of cmd and run evo grep foo in a workspace with rg on PATH — it picks grep.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions