Repository navigation
sed: don't write a missing final newline on Q, as GNU sed does - #597
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #597 +/- ##
=======================================
Coverage 94.85% 94.85%
=======================================
Files 14 14
Lines 7226 7230 +4
Branches 431 432 +1
=======================================
+ Hits 6854 6858 +4
Misses 371 371
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:
|
|
|
||
| if context.stop_processing { | ||
| output.flush_pending_newline()?; | ||
| if !context.quit_silently { |
There was a problem hiding this comment.
do we need a new flag? Q already sets quiet.
what does GNU give for printf a | sed -n 'p;q'? if it's a without newline, !context.quiet would be enough here
There was a problem hiding this comment.
GNU sed’s -n 'p;q' outputs "a\n", so quiet cannot distinguish q from Q. The separate flag is needed.
| .pipe_in("a") | ||
| .succeeds() | ||
| .stdout_is("a"); | ||
| } |
There was a problem hiding this comment.
could you please also check p;q gives a\na here, so we cover the difference between q and Q?
|
Thanks for your PR |
When the last line of input has no final newline, GNU sed's
Qquits without writing it, whileqwrites it. uutils sed writes it for both:printf a | sed 'p;Q'printsaand a newline, while GNU sed prints onlya. This PR adds aquit_silentlyflag thatQsets, so that onlyqwrites the newline.