Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion shell/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ var shellTesting bool

var Default = "modd"

const maxLineLen = 64 * 1024

type Executor struct {
Shell string
Command string
Expand Down Expand Up @@ -162,7 +164,7 @@ func (e *Executor) Stop() error {

func logOutput(wg *sync.WaitGroup, fp io.ReadCloser, out func(string, ...interface{})) {
defer wg.Done()
r := bufio.NewReader(fp)
r := bufio.NewReaderSize(fp, maxLineLen)
for {
line, _, err := r.ReadLine()
if err != nil {
Expand Down
15 changes: 15 additions & 0 deletions shell/shell_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ func testCmd(t *testing.T, shell string, ct cmdTest) {
}
}

var longLine = func() string {
// 6K is longer than the default buffer size, but still well under the
// powershell command line length limit of 8191
var runes [6 * 1024]rune
for i := range runes {
runes[i] = rune('0' + i%10)
}
return string(runes[:])
}()

var shellTests = []cmdTest{
{
name: "echosuccess",
Expand Down Expand Up @@ -129,6 +139,11 @@ var shellTests = []cmdTest{
kill: true,
procerr: true,
},
{
name: "longline",
cmd: "echo " + longLine + "; true",
logHas: longLine,
},
}

func TestShells(t *testing.T) {
Expand Down