Fix an issue with shell expansions.

This commit is contained in:
Daniel Jones 2013-08-13 13:03:21 -07:00
parent c44de7fb69
commit a005edc4a7
3 changed files with 20 additions and 16 deletions

View file

@ -107,9 +107,9 @@ func parsePipeInclude(p *parser, t token) parserStateFun {
p.basicErrorAtToken("empty pipe include", t) p.basicErrorAtToken("empty pipe include", t)
} }
args := make([]string, len(p.tokenbuf)-1) args := make([]string, len(p.tokenbuf))
for i := 1; i < len(p.tokenbuf); i++ { for i := 0; i < len(p.tokenbuf); i++ {
args[i-1] = p.tokenbuf[i].val args[i] = p.tokenbuf[i].val
} }
output, success := subprocess("sh", args, "", true) output, success := subprocess("sh", args, "", true)

View file

@ -160,12 +160,11 @@ func subprocess(program string,
buf := make([]byte, 1024) buf := make([]byte, 1024)
for { for {
n, err := stdout_pipe_read.Read(buf) n, err := stdout_pipe_read.Read(buf)
if err != nil {
log.Fatal(err)
}
if n == 0 { if err == io.EOF && n == 0 {
break break
} else if err != nil {
log.Fatal(err)
} }
output = append(output, buf[:n]...) output = append(output, buf[:n]...)
@ -193,6 +192,11 @@ func subprocess(program string,
}() }()
state, err := proc.Wait() state, err := proc.Wait()
if attr.Files[1] != os.Stdout {
attr.Files[1].Close()
}
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }

View file

@ -50,15 +50,15 @@ func (p *pattern) match(target string) []string {
// A single rule. // A single rule.
type rule struct { type rule struct {
targets []pattern // non-empty array of targets targets []pattern // non-empty array of targets
attributes attribSet // rule attributes attributes attribSet // rule attributes
prereqs []string // possibly empty prerequesites prereqs []string // possibly empty prerequesites
shell []string // command used to execute the recipe shell []string // command used to execute the recipe
recipe string // recipe source recipe string // recipe source
command []string // command attribute command []string // command attribute
ismeta bool // is this a meta rule ismeta bool // is this a meta rule
file string // file where the rule is defined file string // file where the rule is defined
line int // line number on which the rule is defined line int // line number on which the rule is defined
} }
// Equivalent recipes. // Equivalent recipes.