Skip to content

fix(shell): decode multiline sed append continuations (OPE-98) - #241

Merged
aakarim merged 1 commit into
mainfrom
fix/ope-98-sed-append-continuations
Nov 6, 2026
Merged

aakarim merged 1 commit into
mainfrom
fix/ope-98-sed-append-continuations

Conversation

@aakarim

@aakarim aakarim commented Nov 6, 2026

Copy link
Copy Markdown
Owner

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 -i persisted 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

  • Before the fix, all four new regression cases failed with exit 0 and incorrect stdout (including the exact reported two-line payload).
  • 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).
  • gofmt and git diff --check — clean.

Implementation thread

https://ampcode.com/threads/T-ed5ce2ce-0dc6-4112-9153-576179f83d14

This PR is intentionally left unmerged.

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>
@linear-code

linear-code Bot commented Nov 6, 2026

Copy link
Copy Markdown

OPE-98

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.

🟢 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

@aakarim
aakarim merged commit 610fe84 into main Nov 6, 2026
8 checks passed
@aakarim
aakarim deleted the fix/ope-98-sed-append-continuations branch November 6, 2026 11:01
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