provisioner/shell: comment on why we return right away if advance == 0
/cc @mwhooker
This commit is contained in:
parent
f673ca52ba
commit
528ae09c37
|
@ -55,7 +55,11 @@ func (r *UnixReader) Read(p []byte) (n int, err error) {
|
||||||
func scanUnixLine(data []byte, atEOF bool) (advance int, token []byte, err error) {
|
func scanUnixLine(data []byte, atEOF bool) (advance int, token []byte, err error) {
|
||||||
advance, token, err = bufio.ScanLines(data, atEOF)
|
advance, token, err = bufio.ScanLines(data, atEOF)
|
||||||
if advance == 0 {
|
if advance == 0 {
|
||||||
|
// If we reached the end of a line without a newline, then
|
||||||
|
// just return as it is. Otherwise the Scanner will keep trying
|
||||||
|
// to scan, blocking forever.
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
return advance, append(token, '\n'), err
|
return advance, append(token, '\n'), err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue