fix return EOF failure on lines with trailing empty lines (#5176)

This commit is contained in:
dorman
2025-03-28 02:05:40 -07:00
committed by GitHub
parent 5ce725ba7d
commit ceb07bee89
+7 -3
View File
@@ -22,6 +22,7 @@ import (
"compress/bzip2"
"compress/gzip"
"context"
"errors"
"io"
"os"
"strings"
@@ -142,9 +143,12 @@ func headOut(r io.Reader, nlines int64) *probe.Error {
}
for nlines > 0 {
line, _, e := br.ReadLine()
if e != nil {
return probe.NewError(e)
line, _, err := br.ReadLine()
if err != nil && !errors.Is(err, io.EOF) {
return probe.NewError(err)
}
if errors.Is(err, io.EOF) {
break
}
if _, e := stdout.Write(line); e != nil {
switch e := e.(type) {