Skip to content

fix(shell): reject unsupported grep options - #133

Merged
aakarim merged 2 commits into
mainfrom
fix/ope-32-grep-options
Oct 1, 2026
Merged

aakarim merged 2 commits into
mainfrom
fix/ope-32-grep-options

Conversation

@aakarim

@aakarim aakarim commented Sep 26, 2026

Copy link
Copy Markdown
Owner

Linear

Fixes OPE-32.

Amp work thread: https://ampcode.com/threads/T-01a0dc4c-c732-71c8-a179-937af4910847

Diagnosis

CmdGrep manually parsed short-option groups but had no default case, so unsupported short flags were silently discarded. Arguments beginning with -- bypassed option parsing and became the search pattern. As a result, repeatable -e shifted subsequent patterns into file-path position and produced misleading missing-file errors.

Fix

  • Reject unsupported short and long options with exit code 2 and an error naming the option.
  • Direct callers using repeatable -e to the supported -E 'a|b' form.
  • Add regression coverage for standalone/grouped short flags, long flags, and repeatable -e.
  • Align interactive help and the command reference with the options actually supported.

Verification

  • go test ./pkg/shell/cmds -run '^TestGrep'
  • go test ./...
  • go vet ./...
  • git diff --check

All checks pass in the repository's Nix development shell.

@linear-code

linear-code Bot commented Sep 26, 2026

Copy link
Copy Markdown

OPE-32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟡 Changes recommended

Align assets/lore/commands.md with the updated grep options.

Review effort: Lite
Findings: 1 Low severity

Open (1)
What changed in this PR

This PR makes grep reject unsupported options with exit code 2 and updates related guidance.

Changes:

  • Adds validation for unsupported short and long options.
  • Adds regression tests for invalid options and repeatable -e.
  • Updates interactive help and command documentation.
File Summary
pkg/​shell/​cmds/​help.go Updates interactive grep help.
pkg/​shell/​cmds/​grep.go Validates grep options.
pkg/​shell/​cmds/​grep_test.go Adds regression coverage.
docs/​commands.md Updates the command reference; the embedded reference still needs alignment.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread docs/commands.md
@aakarim
aakarim merged commit c6a9cb9 into main Oct 1, 2026
2 checks passed
@aakarim
aakarim deleted the fix/ope-32-grep-options branch October 1, 2026 15:35
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