Skip to content

fix(rewrite): handle newline-separated commands - #2197

Closed
jsiu93 wants to merge 1 commit into
rtk-ai:developfrom
jsiu93:fix/rewrite-newline-separators
Closed

jsiu93 wants to merge 1 commit into
rtk-ai:developfrom
jsiu93:fix/rewrite-newline-separators

Conversation

@jsiu93

@jsiu93 jsiu93 commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Closes #2191.

Summary

  • Treat top-level newline and CRLF separators like other shell command separators during rtk rewrite.
  • Rewrite every newline-delimited segment independently while preserving quoted newlines, heredoc passthrough, line-continuation collapse, and pipe group behavior.
  • Cover hook permission checks so newline-separated commands are evaluated segment-by-segment before allow/deny/ask decisions.

Test plan

  • cargo fmt --all -- --check
  • cargo clippy --all-targets -- -D warnings
  • cargo test --all --quiet
  • Manual repro: target/debug/rtk rewrite "$(printf 'cd /tmp\ngrep -c x /tmp/f.txt\ngrep -c x /tmp/f.txt')"

Treat top-level newlines as command separators during rewrite so every newline-delimited segment is considered independently.

Preserve quoted newlines and heredoc passthrough behavior, and cover hook permissions so newline-separated commands are checked segment-by-segment.

Closes rtk-ai#2191.
@rtk-release-bot

Copy link
Copy Markdown
Contributor

This pull request has been automatically marked as stale due to 90 days of inactivity. If this pull request is still relevant, please leave any comment (for example, "bump"), and we'll keep it open. Your contribution is very much appreciated — we're sorry we haven't been able to review it yet.

@rtk-release-bot rtk-release-bot Bot added the stale label Sep 3, 2026
@jsiu93

jsiu93 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Closing this: the multiline rewrite landed upstream in #3319 (line-by-line rewrite via the quote-aware lexer, with &&/||/| continuation joining, CRLF preservation, and conservative passthrough for heredocs/control flow), and #2191 was closed after 952245d. That covers what this PR set out to do, and the branch has since drifted into conflicts with develop. Thanks for the review bandwidth.

@jsiu93 jsiu93 closed this Sep 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rtk rewrite mishandles newline-separated (multi-line) commands → only first line rewritten / empty output

1 participant