fix(shell): reject unsupported grep options - #133
Merged
Merged
Conversation
Amp-Thread-ID: https://ampcode.com/threads/T-01a0dc4c-c732-71c8-a179-937af4910847 Co-authored-by: Amp <amp@ampcode.com>
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Align assets/lore/commands.md with the updated grep options.
Review effort: Lite
Findings: 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.
Amp-Thread-ID: https://ampcode.com/threads/T-01a0dc4c-c732-71c8-a179-937af4910847 Co-authored-by: Amp <amp@ampcode.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Linear
Fixes OPE-32.
Amp work thread: https://ampcode.com/threads/T-01a0dc4c-c732-71c8-a179-937af4910847
Diagnosis
CmdGrepmanually 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-eshifted subsequent patterns into file-path position and produced misleading missing-file errors.Fix
-eto the supported-E 'a|b'form.-e.Verification
go test ./pkg/shell/cmds -run '^TestGrep'go test ./...go vet ./...git diff --checkAll checks pass in the repository's Nix development shell.