Skip to content

Commit fabb858

Browse files
committed
fix panic whan bash process never started
(e.g. because of 'argument list too long')
1 parent 8911ca3 commit fabb858

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

CHANGES.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
0.3.9
2+
=====
3+
+ fix panic whan bash process never started (e.g. because of 'argument list too long')
4+
15
0.3.8
26
=====
37
+ report time in log output

main.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
)
2222

2323
// Version is the current version
24-
const Version = "0.3.8"
24+
const Version = "0.3.9"
2525

2626
// ExitCode is the highest exit code seen in any command
2727
var ExitCode = 0
@@ -214,8 +214,11 @@ func run(args Params) {
214214
if args.Verbose {
215215
fmt.Fprintf(os.Stderr, "%s\n", p)
216216
}
217-
_, err := io.Copy(stdout, p)
218-
check(err)
217+
// reader can be nil if we couldn't even start the bash process
218+
if p.Reader != nil {
219+
_, err := io.Copy(stdout, p)
220+
check(err)
221+
}
219222

220223
p.Cleanup()
221224
if t := time.Now(); t.After(last) {

process/process.go

+11-5
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,18 @@ func (c *Command) String() string {
7171
if len(c.CmdStr) > 100 {
7272
cmd = cmd[:80] + "..."
7373
}
74-
out, _ := c.Peek(20)
75-
prompt := ", stdout[:20]: "
76-
if len(out) < 20 {
77-
prompt = "stdout: "
74+
var prompt string
75+
if c.Reader != nil {
76+
out, _ := c.Peek(20)
77+
prompt = ", stdout[:20]: "
78+
if len(out) < 20 {
79+
prompt = "stdout: "
80+
}
81+
prompt += fmt.Sprintf("'%s'", strings.Replace(string(out), "\n", "\\n", -1))
82+
} else {
83+
prompt = ", [no stdout]"
84+
7885
}
79-
prompt += fmt.Sprintf("'%s'", strings.Replace(string(out), "\n", "\\n", -1))
8086
errString := ""
8187
if e := c.error(); e != "" {
8288
errString = fmt.Sprintf(", error: %s", e)

0 commit comments

Comments
 (0)