Skip to content

fix(log): preserve line endings from files and stdin - #5381

Open
zhiwuyazhe-fjr wants to merge 1 commit into
rtk-ai:developfrom
zhiwuyazhe-fjr:codex/fix-5380-log-line-endings
Open

zhiwuyazhe-fjr wants to merge 1 commit into
rtk-ai:developfrom
zhiwuyazhe-fjr:codex/fix-5380-log-line-endings

Conversation

@zhiwuyazhe-fjr

Copy link
Copy Markdown
Contributor

Fixes #5380.

A two-line CRLF log produced different bytes depending on how it reached rtk log. The file path appended a blank line, and the stdin path also replaced both CRLF endings with LF. Even empty input produced one byte of output.

Read the stdin text without rebuilding its lines and use the existing emit_guarded printer for both entry points. It preserves existing line endings, supplies one newline to nonempty unterminated text, and returns the exact output for savings tracking.

Verification

  • Added a CLI regression test that compares the exact stdout of file and piped input for CRLF, LF, an empty log, an unterminated line, an intentional trailing blank line, and a compressible 80-line log.
  • On the base revision, the CRLF case returned one\ntwo\n\n through stdin. The patched binary returns one\r\ntwo\r\n through both entry points. An empty log now emits zero bytes.
  • Passed cargo fmt --all --check, cargo clippy --all-targets -- -D warnings and cargo test --all on Linux (6,057 tests passed, 8 ignored).

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.

rtk log changes CRLF on stdin and adds a blank line to short logs

1 participant