Repository navigation
sed: continue with the next command after n instead of starting a new cycle - #592
Merged
Merged
Conversation
|
GNU sed testsuite comparison: |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #592 +/- ##
=======================================
Coverage 94.82% 94.82%
=======================================
Files 14 14
Lines 7203 7212 +9
Branches 424 428 +4
=======================================
+ Hits 6830 6839 +9
Misses 372 372
Partials 1 1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
DePasqualeOrg
marked this pull request as ready for review
October 2, 2026 18:42
|
GNU sed testsuite comparison: |
sylvestre
reviewed
Oct 3, 2026
| .succeeds() | ||
| .stdout_is("a\nXline one\nline two\n"); | ||
| new_ucmd!() | ||
| .args(&["-s", "n;s/^/X/", "-", "input/two-lines.txt"]) |
Contributor
There was a problem hiding this comment.
please add an n case to in_place_edit_separate too, the description mentions -i but nothing tests it
sylvestre
reviewed
Oct 3, 2026
| pub prepend: Vec<u8>, | ||
| /// Data to prepend to the read contents (`N`), or `None` to replace | ||
| /// the pattern space with them (`n`) | ||
| pub prepend: Option<Vec<u8>>, |
Contributor
There was a problem hiding this comment.
None meaning "replace" is a bit implicit, maybe a small enum would read better? not blocking
|
GNU sed testsuite comparison: |
Contributor
|
Thanks for your PR |
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.
Claude Code and Codex flagged this gap during my work with this project. The changes here have gone through extensive automated review. I'm happy to make changes as needed or close this PR and maintain it as a private patch if it doesn't meet your standards.
Fixes #568.
GNU sed's
nprints the pattern space unless-nis given, writes any text queued bya,rorR, replaces the pattern space with the next line of input, and continues with the command aftern. In uutils sed,nends the cycle instead, so the next line starts the script from the top. For example,printf '1\n2\n3\n4\n' | sed 'n;d'prints all four lines, while GNU sed prints1and3.This PR handles
nthe wayNalready works: it records the command to continue from, and when the next line has been read, processing resumes there with that line as the pattern space. If there is no next line, sed stops without running the remaining commands, as GNU sed does. Without-s,nreads the first line of the next file; with-sor-i, each file starts at the top of the script.