fix(tac): preserve unterminated last line on reversal#1760
Merged
Conversation
Real GNU tac splits input by newline separator and reverses records while keeping their original separators. An unterminated last line stays unterminated when reversed, so it concatenates directly with the previous reversed record. Bashkit's reverse_lines always re-inserted a separator and appended a final newline, producing extra newlines for inputs lacking a trailing separator. Reproduced by coreutils_differential_tests::tac_no_trailing_newline, which the weekly Coreutils Args Drift workflow now flags.
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
bashkit | b0aca29 | Commit Preview URL Branch Preview URL |
May 25 2026, 03:08 PM |
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.
What
Fix
tacto match GNU tac behavior when input lacks a trailing newline.Why
Real GNU tac splits input by newline separator and reverses records while keeping their original separators. An unterminated last line stays unterminated when reversed, so it concatenates directly with the previous reversed record (no inserted newline).
bashkit's
reverse_linesalways re-inserted a separator and appended a final newline, producing extra newlines for inputs lacking a trailing separator. Example:one\ntwo\nthreetac:threetwo\none\nthree\ntwo\none\nThis was caught by
coreutils_differential_tests::tac_no_trailing_newline, which the weekly Coreutils Args Drift workflow now flags as failing.How
Risk
tac. Existing tac differential cases (tac_file_input,tac_pipe_input) still pass — they use newline-terminated input.Testing
BASHKIT_RUN_COREUTILS_DIFF=1 cargo test -p bashkit --test coreutils_differential_tests tac— all 6 tac cases pass, including the previously failingtac_no_trailing_newline.cargo clippy -p bashkit --all-targets -- -D warningsclean.cargo fmt --check.Checklist
Generated by Claude Code