Skip to content

Commit

Permalink
Fix an issue with shell expansions.
Browse files Browse the repository at this point in the history
  • Loading branch information
dcjones committed Aug 13, 2013
1 parent c44de7f commit a005edc
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 16 deletions.
6 changes: 3 additions & 3 deletions parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 8 additions & 4 deletions recipe.go
Original file line number Diff line number Diff line change
Expand Up @@ -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]...)
Expand Down Expand Up @@ -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)
}
Expand Down
18 changes: 9 additions & 9 deletions rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ func (p *pattern) match(target string) []string {

// A single rule.
type rule struct {
targets []pattern // non-empty array of targets
attributes attribSet // rule attributes
prereqs []string // possibly empty prerequesites
shell []string // command used to execute the recipe
recipe string // recipe source
command []string // command attribute
ismeta bool // is this a meta rule
file string // file where the rule is defined
line int // line number on which the rule is defined
targets []pattern // non-empty array of targets
attributes attribSet // rule attributes
prereqs []string // possibly empty prerequesites
shell []string // command used to execute the recipe
recipe string // recipe source
command []string // command attribute
ismeta bool // is this a meta rule
file string // file where the rule is defined
line int // line number on which the rule is defined
}

// Equivalent recipes.
Expand Down

0 comments on commit a005edc

Please sign in to comment.