Fix script output dropping last line without trailing newline#4995
Fix script output dropping last line without trailing newline#4995
Conversation
bufio.Reader.ReadString returns both data and io.EOF when the stream ends without a delimiter. The old loop condition `for err == nil` caused the last line of output to be silently dropped when it lacked a trailing newline. This affected any bundle script (experimental.scripts hooks) whose output didn't end with `\n`. Restructure the loop to always process data before checking for errors, which is the idiomatic Go pattern for ReadString. Task: 001.md Co-authored-by: Isaac
Co-authored-by: Isaac
This test demonstrates the bug where the last line of script output was dropped when it didn't end with a trailing newline. Running this test with -useversion 0.296.0 shows the bug: "line without newline" is missing from the output. Task: 002.md Co-authored-by: Isaac
Approval status: pending
|
Changes
Fix
experimental.scriptshooks silently dropping the last line of output when it doesn't end with a trailing newline (e.g.printf "done").Tests
Added acceptance test at
acceptance/bundle/scripts/no-trailing-newline/and unit tests for the script executor.Running the acceptance test against the previous release demonstrates the bug:
v0.296.0 drops "line without newline" because the last line has no trailing
\n. The fix correctly includes it.