Implement GNU R (read one line from file) command - #544
Implement GNU R (read one line from file) command#544Jorge-Polanco-Roque wants to merge 2 commits into
Conversation
The R command queues the next successive line of a file to be output at the end of the current cycle. It is the line-oriented counterpart to r, mirroring how W relates to w. The backing file is opened lazily and read one line at a time via a new NamedReader; an unreadable or exhausted file yields no further lines, matching GNU sed (no error is raised). Reserved to non-POSIX mode and rejected under --sandbox, like r. Fixes uutils#394 Signed-off-by: Jorge Polanco <55784702+Jorge-Polanco-Roque@users.noreply.github.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #544 +/- ##
==========================================
+ Coverage 83.04% 83.09% +0.05%
==========================================
Files 13 14 +1
Lines 7046 7127 +81
Branches 401 405 +4
==========================================
+ Hits 5851 5922 +71
- Misses 1192 1202 +10
Partials 3 3
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:
|
Merging this PR will improve performance by 3.17%
Performance Changes
Tip Curious why performance improved? Comment Comparing |
|
please add tests to improve the coverage. some tests are missing to reach important cases |
Add unit tests for compile_read_line_command (sandbox rejection and that it installs a NamedReader) and integration tests covering R appending under -n (suppressed auto-print) and a file shorter than the input.
|
Thanks — added tests to cover the missing cases: unit tests for |
Closes #394.
Implements the GNU
Rcommand, the line-oriented counterpart tor(mirroring howWrelates tow, added in #531).R filenamequeues the next successive line offilenameto be inserted into the output stream at the end of the current cycle. Each cycle consumes one more line; once the file is exhausted no line is queued.Behavior
NamedReader, analogous toNamedWriter).--sandbox, exactly liker/w/W.Tests
NamedReader(successive lines, final line without newline, missing file).--posixrejection,--sandboxrejection.cargo fmt --all -- --check,cargo test --all, andcargo clippy --all-targets --workspace -psed -- -D warningsall pass locally.