Fix a bugs in assignment parsing.
This commit is contained in:
parent
b7df226f0d
commit
bd5c30c30a
2 changed files with 16 additions and 5 deletions
|
|
@ -85,9 +85,6 @@ func expandDoubleQuoted(input string, vars map[string][]string, expandBackticks
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
_, w := utf8.DecodeRuneInString(input[j:])
|
|
||||||
j += w
|
|
||||||
|
|
||||||
c, w := utf8.DecodeRuneInString(input[j:])
|
c, w := utf8.DecodeRuneInString(input[j:])
|
||||||
j += w
|
j += w
|
||||||
|
|
||||||
|
|
|
||||||
18
rules.go
18
rules.go
|
|
@ -189,10 +189,24 @@ func (rs *ruleSet) executeAssignment(ts []token) *assignmentError {
|
||||||
ts[0]}
|
ts[0]}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// interpret tokens in assignment context
|
||||||
|
input := make([]string, 0)
|
||||||
|
for i := 1; i < len(ts); i++ {
|
||||||
|
if ts[i].typ != tokenWord || (i > 1 && ts[i-1].typ != tokenWord) {
|
||||||
|
if len(input) == 0 {
|
||||||
|
input = append(input, ts[i].val)
|
||||||
|
} else {
|
||||||
|
input[len(input)-1] += ts[i].val
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
input = append(input, ts[i].val)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// expanded variables
|
// expanded variables
|
||||||
vals := make([]string, 0)
|
vals := make([]string, 0)
|
||||||
for i := 1; i < len(ts); i++ {
|
for i := 0; i < len(input); i++ {
|
||||||
vals = append(vals, expand(ts[i].val, rs.vars, true)...)
|
vals = append(vals, expand(input[i], rs.vars, true)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
rs.vars[assignee] = vals
|
rs.vars[assignee] = vals
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue