From 528ae09c3730e7c2cbf35a3f7ee30cdfaffed930 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 15 Oct 2013 09:48:12 -1000 Subject: [PATCH] provisioner/shell: comment on why we return right away if advance == 0 /cc @mwhooker --- provisioner/shell/unix_reader.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/provisioner/shell/unix_reader.go b/provisioner/shell/unix_reader.go index 1e4ea76a1..837ecdeae 100644 --- a/provisioner/shell/unix_reader.go +++ b/provisioner/shell/unix_reader.go @@ -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 }