Repository navigation
sed: with --posix, do not join text commands across -e expressions - #701
yunusarda-sudo wants to merge 4 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #701 +/- ##
=======================================
Coverage 95.45% 95.46%
=======================================
Files 14 14
Lines 7762 7777 +15
Branches 469 470 +1
=======================================
+ Hits 7409 7424 +15
Misses 352 352
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:
|
Merging this PR will not alter performance1 warning
Comparing |
|
thanks for this PR! |
|
|
||
| /// Return the next script line from the currently active script source, | ||
| /// without advancing to subsequent script sources if the current one has ended. | ||
| pub fn next_line_within_source(&mut self) -> UResult<Option<Vec<u8>>> { |
There was a problem hiding this comment.
this is almost the same code as in next_line, could be dedup, no?
for example a small helper that reads and trims one line from the reader
There was a problem hiding this comment.
Done: deduplicated into a read_trimmed_line helper method on ScriptLineProvider.
| let msg = err.to_string(); | ||
|
|
||
| assert_eq!(msg, "input.txt:3:1: error: invalid command 'x'"); | ||
| assert!(msg.starts_with("input.txt:3:1: error: invalid command 'x'")); |
There was a problem hiding this comment.
why this change? it seems unrelated to this PR
please drop it or explain
There was a problem hiding this comment.
With modern uucore, compilation errors include the multi-line rendered source snippet (╭─[ input.txt:3:1 ]...), which caused the exact assert_eq! on msg in this unit test to fail. Checking that msg.contains("input.txt:3:1: error: invalid command 'x'") allows the test to pass with the rendered snippet.
| // GNU extension: without --posix the next fragment is the text. | ||
| new_ucmd!() | ||
| .args(&["-e", cmd, "-e", "second fragment"]) | ||
| .pipe_in("") |
There was a problem hiding this comment.
with an empty input, this passes whatever the text is
please pipe a line and check that the second fragment is in stdout
There was a problem hiding this comment.
Done: updated the test to pipe line\n and assert stdout_contains("second fragment").
a3d799d to
168c6cf
Compare
|
Thanks for the review @sylvestre! Addressed all three points in 168c6cf:
|
72d9808 to
1079097
Compare
As a GNU extension, `sed -e 'i\\' -e hello` uses the next `-e` fragment as the text of `a`, `i` or `c`. With `--posix`, GNU sed does not join the fragments across `-e` expressions; an `a\`, `i\\' or `c\\' at the end of an expression without text on a following line in the same source is an incomplete command. Provide `ScriptLineProvider::next_line_within_source` (sharing line reading with `next_line`) so text command compilation in POSIX mode does not advance across script source boundaries, leaving the incomplete command to fail as expected under POSIX. Fixes uutils#688
…ion boundaries - deduplicate read_trimmed_line helper in ScriptLineProvider - revert unrelated test assertion change in compiler.rs - pipe non-empty input in test to verify second fragment appears in stdout
…diagnostic rendering
1079097 to
6168f46
Compare
As a GNU extension,
sed -e 'i\' -e hellouses the next-efragment as the text ofa,iorc. With--posix, GNU sed does not join fragments across-eexpressions; ana\,i\orc\at the end of an expression without text on a following line in the same source is an incomplete command.Add
ScriptLineProvider::next_line_within_sourceso text command compilation in POSIX mode does not advance across script source boundaries, leaving the incomplete command to fail as expected under POSIX.Fixes #688