Repository navigation
fix(shell): decode multiline sed append continuations (OPE-98) - #241
Merged
Merged
Conversation
Remove continuation markers from sed append text while decoding escaped backslashes in a single pass. Cover streaming and in-place edits with two- and three-line payloads. Amp-Thread-ID: https://ampcode.com/threads/T-ed5ce2ce-0dc6-4112-9153-576179f83d14 Co-authored-by: Amp <amp@ampcode.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the multiline sed append parsing fix.
No open issues 🎉
What changed in this PR
Fixes multiline sed append parsing in the shell so continuation backslashes no longer appear in output or persist in files edited with sed -i.
Changes:
- Decode backslash-newline continuations and escaped backslashes in one pass.
- Add regression coverage for two- and three-line appends, literal backslashes, piped output, and in-place edits.
| File | Description |
|---|---|
pkg/shell/cmds/sed.go |
Decode continuations and escaped backslashes in backslash-form append text. |
pkg/shell/cmds/sed_test.go |
Verify multiline append output and in-place file contents. |
Review effort: Balanced
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.
Issue
Fixes OPE-98.
Diagnosis
The sed append parser removed the opening
a\marker but copied the remaining text verbatim. A continued two-line append therefore emitted a trailing backslash with exit 0;sed -ipersisted the same corruption.Fix
Decode backslash-newline continuations and escaped backslashes in a single pass for the backslash append form. Preserve whitespace, semicolons, and the existing unescaped multiline append support. Add shell-level regression coverage for two and three lines, literal backslashes, piped output, and in-place file contents.
Verification
nix develop --command go test -race ./pkg/shell/...— passed.nix develop --command go test -race -short ./...— passed across the repository.nix develop --command go vet ./pkg/shell/...— passed.nix develop --command go build ./...— passed (Go compilation/type checking).gofmtandgit diff --check— clean.Implementation thread
https://ampcode.com/threads/T-ed5ce2ce-0dc6-4112-9153-576179f83d14
This PR is intentionally left unmerged.