1
0
mirror of https://github.com/go-task/task.git synced 2025-04-15 11:56:34 +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
# gopkg.in/yaml.v2 v2.2.1
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/interp
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)
return 2
}
r.updateExpandOpts()
case "shift":
n := 1
switch len(args) {

View File

@ -260,7 +260,6 @@ func Params(args ...string) func(*Runner) error {
args = args[1:]
}
r.Params = args
r.updateExpandOpts()
return nil
}
}
@ -479,6 +478,7 @@ func (r *Runner) Reset() {
Exec: r.Exec,
Open: r.Open,
KillTimeout: r.KillTimeout,
opts: r.opts,
// emptied below, to reuse the space
Vars: r.Vars,
@ -791,7 +791,11 @@ func (r *Runner) cmd(ctx context.Context, cm syntax.Command) {
switch y := x.Loop.(type) {
case *syntax.WordIter:
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)
if r.loopStmtsBroken(ctx, x.Do) {
break

View File

@ -376,14 +376,21 @@ func (*WordIter) loopNode() {}
func (*CStyleLoop) loopNode() {}
// 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 {
Name *Lit
InPos Pos // position of "in"
Items []*Word
}
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
// language.
@ -781,8 +788,12 @@ func (a *ArrayExpr) Pos() Pos { return a.Lparen }
func (a *ArrayExpr) End() Pos { return posAddCol(a.Rparen, 1) }
// 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 {
Index ArithmExpr // [i]=, ["k"]=
Index ArithmExpr
Value *Word
Comments []Comment
}
@ -793,7 +804,12 @@ func (a *ArrayElem) Pos() 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
// parsed independently of whether shopt has been called or not.

View File

@ -1003,6 +1003,11 @@ func (p *Parser) wordPart() WordPart {
p.next()
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.openBquotes--
cs.Right = p.pos
@ -1587,11 +1592,16 @@ func (p *Parser) getAssign(needEqual bool) *Assign {
p.follow(left, `"[x]"`, assgn)
}
if ae.Value = p.getWord(); ae.Value == nil {
if p.tok == leftParen {
switch p.tok {
case leftParen:
p.curErr("arrays cannot be nested")
return nil
case _Newl, rightParen, leftBrack:
// TODO: support [index]=[
default:
p.curErr("array element values must be words")
break
}
p.curErr("array element values must be words")
break
}
if len(p.accComs) > 0 {
c := p.accComs[0]
@ -2012,7 +2022,8 @@ func (p *Parser) wordIter(ftok string, fpos Pos) *WordIter {
return wi
}
p.got(_Newl)
if _, ok := p.gotRsrv("in"); ok {
if pos, ok := p.gotRsrv("in"); ok {
wi.InPos = pos
for !stopToken(p.tok) {
if w := p.getWord(); w == nil {
p.curErr("word list can only contain words")

View File

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

View File

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