fix return EOF failure on lines with trailing empty lines (#5176)
This commit is contained in:
+7
-3
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user