Skip to content

Rg invalid args error#5

Closed
jediahkatz wants to merge 1 commit intoanyspherefrom
cursor/rg-invalid-args-error-9006
Closed

Rg invalid args error#5
jediahkatz wants to merge 1 commit intoanyspherefrom
cursor/rg-invalid-args-error-9006

Conversation

@jediahkatz
Copy link

Change exit codes to differentiate between invalid arguments (2) and non-fatal runtime errors (3), classifying the \n literal regex error as an invalid argument.

Previously, ripgrep used exit code 2 for all errors, making it impossible to distinguish between invalid arguments and runtime errors. This PR introduces exit code 3 for non-fatal runtime errors (e.g., file not found) while keeping exit code 2 for fatal errors (e.g., invalid regex, unrecognized flags). The \n literal regex error is a fatal error (invalid argument) and now correctly returns exit code 2.


Slack Thread

Open in Cursor Open in Web

Previously, ripgrep used exit code 2 for all errors - both invalid
arguments (bad patterns, unrecognized flags) and runtime errors (file
not found, permission denied). This made it impossible for callers to
distinguish between the two.

Now:
  - Exit code 2: invalid arguments (e.g., literal \n in regex without
    --multiline, invalid regex syntax, unrecognized flags)
  - Exit code 3: non-fatal runtime errors (e.g., file not found)

The \n-not-allowed-in-regex error (which goes through the fatal Err
path from matcher()) correctly gets exit code 2, classifying it as an
invalid args error rather than a generic 'other error'.

Updated tests to expect exit code 3 for file-not-found scenarios.

Co-authored-by: Jediah Katz <jediahkatz@gmail.com>
@cursor
Copy link

cursor bot commented Feb 17, 2026

Cursor Agent can help with this pull request. Just @cursor in comments and I'll start working on changes in this branch.
Learn more about Cursor Agents

@jediahkatz jediahkatz closed this Feb 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants