1
0
mirror of https://github.com/go-task/task.git synced 2025-04-21 12:17:07 +02:00

go mod vendor

This commit is contained in:
Andrey Nering 2019-03-16 10:42:54 -03:00
parent de11323d28
commit c5b9773922
7 changed files with 50 additions and 14 deletions

2
vendor/modules.txt vendored
View File

@ -38,7 +38,7 @@ golang.org/x/sys/unix
golang.org/x/sys/windows golang.org/x/sys/windows
# gopkg.in/yaml.v2 v2.2.1 # gopkg.in/yaml.v2 v2.2.1
gopkg.in/yaml.v2 gopkg.in/yaml.v2
# mvdan.cc/sh v2.6.4-0.20190222161105-3c71c7be1070+incompatible # mvdan.cc/sh v2.6.4+incompatible
mvdan.cc/sh/expand mvdan.cc/sh/expand
mvdan.cc/sh/interp mvdan.cc/sh/interp
mvdan.cc/sh/shell mvdan.cc/sh/shell

View File

@ -70,6 +70,7 @@ func (r *Runner) builtinCode(ctx context.Context, pos syntax.Pos, name string, a
r.errf("set: %v\n", err) r.errf("set: %v\n", err)
return 2 return 2
} }
r.updateExpandOpts()
case "shift": case "shift":
n := 1 n := 1
switch len(args) { switch len(args) {

View File

@ -260,7 +260,6 @@ func Params(args ...string) func(*Runner) error {
args = args[1:] args = args[1:]
} }
r.Params = args r.Params = args
r.updateExpandOpts()
return nil return nil
} }
} }
@ -479,6 +478,7 @@ func (r *Runner) Reset() {
Exec: r.Exec, Exec: r.Exec,
Open: r.Open, Open: r.Open,
KillTimeout: r.KillTimeout, KillTimeout: r.KillTimeout,
opts: r.opts,
// emptied below, to reuse the space // emptied below, to reuse the space
Vars: r.Vars, Vars: r.Vars,
@ -791,7 +791,11 @@ func (r *Runner) cmd(ctx context.Context, cm syntax.Command) {
switch y := x.Loop.(type) { switch y := x.Loop.(type) {
case *syntax.WordIter: case *syntax.WordIter:
name := y.Name.Value name := y.Name.Value
for _, field := range r.fields(y.Items...) { items := r.Params // for i; do ...
if y.InPos.IsValid() {
items = r.fields(y.Items...) // for i in ...; do ...
}
for _, field := range items {
r.setVarString(name, field) r.setVarString(name, field)
if r.loopStmtsBroken(ctx, x.Do) { if r.loopStmtsBroken(ctx, x.Do) {
break break

View File

@ -376,14 +376,21 @@ func (*WordIter) loopNode() {}
func (*CStyleLoop) loopNode() {} func (*CStyleLoop) loopNode() {}
// WordIter represents the iteration of a variable over a series of words in a // WordIter represents the iteration of a variable over a series of words in a
// for clause. // for clause. If InPos is an invalid position, the "in" token was missing, so
// the iteration is over the shell's positional parameters.
type WordIter struct { type WordIter struct {
Name *Lit Name *Lit
InPos Pos // position of "in"
Items []*Word Items []*Word
} }
func (w *WordIter) Pos() Pos { return w.Name.Pos() } func (w *WordIter) Pos() Pos { return w.Name.Pos() }
func (w *WordIter) End() Pos { return posMax(w.Name.End(), wordLastEnd(w.Items)) } func (w *WordIter) End() Pos {
if len(w.Items) > 0 {
return wordLastEnd(w.Items)
}
return posMax(w.Name.End(), posAddCol(w.InPos, 2))
}
// CStyleLoop represents the behaviour of a for clause similar to the C // CStyleLoop represents the behaviour of a for clause similar to the C
// language. // language.
@ -781,8 +788,12 @@ func (a *ArrayExpr) Pos() Pos { return a.Lparen }
func (a *ArrayExpr) End() Pos { return posAddCol(a.Rparen, 1) } func (a *ArrayExpr) End() Pos { return posAddCol(a.Rparen, 1) }
// ArrayElem represents a Bash array element. // ArrayElem represents a Bash array element.
//
// Index can be nil; for example, declare -a x=(value).
// Value can be nil; for example, declare -A x=([index]=).
// Finally, neither can be nil; for example, declare -A x=([index]=value)
type ArrayElem struct { type ArrayElem struct {
Index ArithmExpr // [i]=, ["k"]= Index ArithmExpr
Value *Word Value *Word
Comments []Comment Comments []Comment
} }
@ -793,7 +804,12 @@ func (a *ArrayElem) Pos() Pos {
} }
return a.Value.Pos() return a.Value.Pos()
} }
func (a *ArrayElem) End() Pos { return a.Value.End() } func (a *ArrayElem) End() Pos {
if a.Value != nil {
return a.Value.End()
}
return posAddCol(a.Index.Pos(), 1)
}
// ExtGlob represents a Bash extended globbing expression. Note that these are // ExtGlob represents a Bash extended globbing expression. Note that these are
// parsed independently of whether shopt has been called or not. // parsed independently of whether shopt has been called or not.

View File

@ -1003,6 +1003,11 @@ func (p *Parser) wordPart() WordPart {
p.next() p.next()
cs.StmtList = p.stmtList() cs.StmtList = p.stmtList()
if p.tok == bckQuote && p.lastBquoteEsc < p.openBquotes-1 {
// e.g. found ` before the nested backquote \` was closed.
p.tok = _EOF
p.quoteErr(cs.Pos(), bckQuote)
}
p.postNested(old) p.postNested(old)
p.openBquotes-- p.openBquotes--
cs.Right = p.pos cs.Right = p.pos
@ -1587,12 +1592,17 @@ func (p *Parser) getAssign(needEqual bool) *Assign {
p.follow(left, `"[x]"`, assgn) p.follow(left, `"[x]"`, assgn)
} }
if ae.Value = p.getWord(); ae.Value == nil { if ae.Value = p.getWord(); ae.Value == nil {
if p.tok == leftParen { switch p.tok {
case leftParen:
p.curErr("arrays cannot be nested") p.curErr("arrays cannot be nested")
} return nil
case _Newl, rightParen, leftBrack:
// TODO: support [index]=[
default:
p.curErr("array element values must be words") p.curErr("array element values must be words")
break break
} }
}
if len(p.accComs) > 0 { if len(p.accComs) > 0 {
c := p.accComs[0] c := p.accComs[0]
if c.Pos().Line() == ae.End().Line() { if c.Pos().Line() == ae.End().Line() {
@ -2012,7 +2022,8 @@ func (p *Parser) wordIter(ftok string, fpos Pos) *WordIter {
return wi return wi
} }
p.got(_Newl) p.got(_Newl)
if _, ok := p.gotRsrv("in"); ok { if pos, ok := p.gotRsrv("in"); ok {
wi.InPos = pos
for !stopToken(p.tok) { for !stopToken(p.tok) {
if w := p.getWord(); w == nil { if w := p.getWord(); w == nil {
p.curErr("word list can only contain words") p.curErr("word list can only contain words")

View File

@ -620,7 +620,7 @@ func (p *Printer) loop(loop Loop) {
switch x := loop.(type) { switch x := loop.(type) {
case *WordIter: case *WordIter:
p.WriteString(x.Name.Value) p.WriteString(x.Name.Value)
if len(x.Items) > 0 { if x.InPos.IsValid() {
p.spacedString(" in", Pos{}) p.spacedString(" in", Pos{})
p.wordJoin(x.Items) p.wordJoin(x.Items)
} }
@ -788,7 +788,9 @@ func (p *Printer) elemJoin(elems []*ArrayElem, last []Comment) {
if p.wroteIndex(el.Index) { if p.wroteIndex(el.Index) {
p.WriteByte('=') p.WriteByte('=')
} }
if el.Value != nil {
p.word(el.Value) p.word(el.Value)
}
p.comments(left...) p.comments(left...)
} }
if len(last) > 0 { if len(last) > 0 {

View File

@ -199,7 +199,9 @@ func Walk(node Node, f func(Node) bool) {
if x.Index != nil { if x.Index != nil {
Walk(x.Index, f) Walk(x.Index, f)
} }
if x.Value != nil {
Walk(x.Value, f) Walk(x.Value, f)
}
case *ExtGlob: case *ExtGlob:
Walk(x.Pattern, f) Walk(x.Pattern, f)
case *ProcSubst: case *ProcSubst: