Fix an issue with shell expansions.
This commit is contained in:
parent
c44de7fb69
commit
a005edc4a7
3 changed files with 20 additions and 16 deletions
6
parse.go
6
parse.go
|
|
@ -107,9 +107,9 @@ func parsePipeInclude(p *parser, t token) parserStateFun {
|
|||
p.basicErrorAtToken("empty pipe include", t)
|
||||
}
|
||||
|
||||
args := make([]string, len(p.tokenbuf)-1)
|
||||
for i := 1; i < len(p.tokenbuf); i++ {
|
||||
args[i-1] = p.tokenbuf[i].val
|
||||
args := make([]string, len(p.tokenbuf))
|
||||
for i := 0; i < len(p.tokenbuf); i++ {
|
||||
args[i] = p.tokenbuf[i].val
|
||||
}
|
||||
|
||||
output, success := subprocess("sh", args, "", true)
|
||||
|
|
|
|||
12
recipe.go
12
recipe.go
|
|
@ -160,12 +160,11 @@ func subprocess(program string,
|
|||
buf := make([]byte, 1024)
|
||||
for {
|
||||
n, err := stdout_pipe_read.Read(buf)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if n == 0 {
|
||||
if err == io.EOF && n == 0 {
|
||||
break
|
||||
} else if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
output = append(output, buf[:n]...)
|
||||
|
|
@ -193,6 +192,11 @@ func subprocess(program string,
|
|||
}()
|
||||
|
||||
state, err := proc.Wait()
|
||||
|
||||
if attr.Files[1] != os.Stdout {
|
||||
attr.Files[1].Close()
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue