Skip to content

bug: rtk grep exit-code parity differs from rg (always 0 for key failure modes) #162

@pavelbe

Description

@pavelbe

Summary

rtk grep currently returns exit 0 for failure modes where rg returns non-zero.

This breaks CLI parity and forces downstream users to route rg|grep through raw proxy for safety.

Environment

  • RTK: rtk 0.20.0
  • OS: Linux (WSL2 Ubuntu)
  • rg: ripgrep 14.1.1

Reproduction

TMP=/tmp/rtk-parity-grep.txt
printf "alpha\nbeta\n" > "$TMP"

rtk grep "zzz" "$TMP"; echo "rtk no-match: $?"
rg "zzz" "$TMP"; echo "rg no-match: $?"

rtk grep "[" "$TMP"; echo "rtk invalid-regex: $?"
rg "[" "$TMP"; echo "rg invalid-regex: $?"

rtk grep "alpha" /tmp/does-not-exist-rtk-xyz.txt; echo "rtk missing-file: $?"
rg "alpha" /tmp/does-not-exist-rtk-xyz.txt; echo "rg missing-file: $?"

Actual

  • rtk no-match: 0 (output: 🔍 0 for 'zzz')
  • rtk invalid-regex: 0 (output: 🔍 0 for '[')
  • rtk missing-file: 0 (output: 🔍 0 for 'alpha')

Expected (parity with rg)

  • no-match -> exit 1
  • invalid regex -> exit 2
  • missing file -> exit 2

Why this matters

Shell workflows and hooks rely on exit code semantics for control flow. Returning 0 for these cases causes false-success behavior.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions