provisioner/shell: comment on why we return right away if advance == 0

/cc @mwhooker
This commit is contained in:
Mitchell Hashimoto 2013-10-15 09:48:12 -10:00
parent f673ca52ba
commit 528ae09c37
1 changed files with 4 additions and 0 deletions

View File

@ -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) {
advance, token, err = bufio.ScanLines(data, atEOF)
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 advance, append(token, '\n'), err
}