Skip to content

Commit c5b9773

Browse files
committed
go mod vendor
1 parent de11323 commit c5b9773

File tree

7 files changed

+50
-14
lines changed

7 files changed

+50
-14
lines changed

vendor/modules.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ golang.org/x/sys/unix
3838
golang.org/x/sys/windows
3939
# gopkg.in/yaml.v2 v2.2.1
4040
gopkg.in/yaml.v2
41-
# mvdan.cc/sh v2.6.4-0.20190222161105-3c71c7be1070+incompatible
41+
# mvdan.cc/sh v2.6.4+incompatible
4242
mvdan.cc/sh/expand
4343
mvdan.cc/sh/interp
4444
mvdan.cc/sh/shell

vendor/mvdan.cc/sh/interp/builtin.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ func (r *Runner) builtinCode(ctx context.Context, pos syntax.Pos, name string, a
7070
r.errf("set: %v\n", err)
7171
return 2
7272
}
73+
r.updateExpandOpts()
7374
case "shift":
7475
n := 1
7576
switch len(args) {

vendor/mvdan.cc/sh/interp/interp.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,6 @@ func Params(args ...string) func(*Runner) error {
260260
args = args[1:]
261261
}
262262
r.Params = args
263-
r.updateExpandOpts()
264263
return nil
265264
}
266265
}
@@ -479,6 +478,7 @@ func (r *Runner) Reset() {
479478
Exec: r.Exec,
480479
Open: r.Open,
481480
KillTimeout: r.KillTimeout,
481+
opts: r.opts,
482482

483483
// emptied below, to reuse the space
484484
Vars: r.Vars,
@@ -791,7 +791,11 @@ func (r *Runner) cmd(ctx context.Context, cm syntax.Command) {
791791
switch y := x.Loop.(type) {
792792
case *syntax.WordIter:
793793
name := y.Name.Value
794-
for _, field := range r.fields(y.Items...) {
794+
items := r.Params // for i; do ...
795+
if y.InPos.IsValid() {
796+
items = r.fields(y.Items...) // for i in ...; do ...
797+
}
798+
for _, field := range items {
795799
r.setVarString(name, field)
796800
if r.loopStmtsBroken(ctx, x.Do) {
797801
break

vendor/mvdan.cc/sh/syntax/nodes.go

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -376,14 +376,21 @@ func (*WordIter) loopNode() {}
376376
func (*CStyleLoop) loopNode() {}
377377

378378
// WordIter represents the iteration of a variable over a series of words in a
379-
// for clause.
379+
// for clause. If InPos is an invalid position, the "in" token was missing, so
380+
// the iteration is over the shell's positional parameters.
380381
type WordIter struct {
381382
Name *Lit
383+
InPos Pos // position of "in"
382384
Items []*Word
383385
}
384386

385387
func (w *WordIter) Pos() Pos { return w.Name.Pos() }
386-
func (w *WordIter) End() Pos { return posMax(w.Name.End(), wordLastEnd(w.Items)) }
388+
func (w *WordIter) End() Pos {
389+
if len(w.Items) > 0 {
390+
return wordLastEnd(w.Items)
391+
}
392+
return posMax(w.Name.End(), posAddCol(w.InPos, 2))
393+
}
387394

388395
// CStyleLoop represents the behaviour of a for clause similar to the C
389396
// language.
@@ -781,8 +788,12 @@ func (a *ArrayExpr) Pos() Pos { return a.Lparen }
781788
func (a *ArrayExpr) End() Pos { return posAddCol(a.Rparen, 1) }
782789

783790
// ArrayElem represents a Bash array element.
791+
//
792+
// Index can be nil; for example, declare -a x=(value).
793+
// Value can be nil; for example, declare -A x=([index]=).
794+
// Finally, neither can be nil; for example, declare -A x=([index]=value)
784795
type ArrayElem struct {
785-
Index ArithmExpr // [i]=, ["k"]=
796+
Index ArithmExpr
786797
Value *Word
787798
Comments []Comment
788799
}
@@ -793,7 +804,12 @@ func (a *ArrayElem) Pos() Pos {
793804
}
794805
return a.Value.Pos()
795806
}
796-
func (a *ArrayElem) End() Pos { return a.Value.End() }
807+
func (a *ArrayElem) End() Pos {
808+
if a.Value != nil {
809+
return a.Value.End()
810+
}
811+
return posAddCol(a.Index.Pos(), 1)
812+
}
797813

798814
// ExtGlob represents a Bash extended globbing expression. Note that these are
799815
// parsed independently of whether shopt has been called or not.

vendor/mvdan.cc/sh/syntax/parser.go

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,11 @@ func (p *Parser) wordPart() WordPart {
10031003

10041004
p.next()
10051005
cs.StmtList = p.stmtList()
1006+
if p.tok == bckQuote && p.lastBquoteEsc < p.openBquotes-1 {
1007+
// e.g. found ` before the nested backquote \` was closed.
1008+
p.tok = _EOF
1009+
p.quoteErr(cs.Pos(), bckQuote)
1010+
}
10061011
p.postNested(old)
10071012
p.openBquotes--
10081013
cs.Right = p.pos
@@ -1587,11 +1592,16 @@ func (p *Parser) getAssign(needEqual bool) *Assign {
15871592
p.follow(left, `"[x]"`, assgn)
15881593
}
15891594
if ae.Value = p.getWord(); ae.Value == nil {
1590-
if p.tok == leftParen {
1595+
switch p.tok {
1596+
case leftParen:
15911597
p.curErr("arrays cannot be nested")
1598+
return nil
1599+
case _Newl, rightParen, leftBrack:
1600+
// TODO: support [index]=[
1601+
default:
1602+
p.curErr("array element values must be words")
1603+
break
15921604
}
1593-
p.curErr("array element values must be words")
1594-
break
15951605
}
15961606
if len(p.accComs) > 0 {
15971607
c := p.accComs[0]
@@ -2012,7 +2022,8 @@ func (p *Parser) wordIter(ftok string, fpos Pos) *WordIter {
20122022
return wi
20132023
}
20142024
p.got(_Newl)
2015-
if _, ok := p.gotRsrv("in"); ok {
2025+
if pos, ok := p.gotRsrv("in"); ok {
2026+
wi.InPos = pos
20162027
for !stopToken(p.tok) {
20172028
if w := p.getWord(); w == nil {
20182029
p.curErr("word list can only contain words")

vendor/mvdan.cc/sh/syntax/printer.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@ func (p *Printer) loop(loop Loop) {
620620
switch x := loop.(type) {
621621
case *WordIter:
622622
p.WriteString(x.Name.Value)
623-
if len(x.Items) > 0 {
623+
if x.InPos.IsValid() {
624624
p.spacedString(" in", Pos{})
625625
p.wordJoin(x.Items)
626626
}
@@ -788,7 +788,9 @@ func (p *Printer) elemJoin(elems []*ArrayElem, last []Comment) {
788788
if p.wroteIndex(el.Index) {
789789
p.WriteByte('=')
790790
}
791-
p.word(el.Value)
791+
if el.Value != nil {
792+
p.word(el.Value)
793+
}
792794
p.comments(left...)
793795
}
794796
if len(last) > 0 {

vendor/mvdan.cc/sh/syntax/walk.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,9 @@ func Walk(node Node, f func(Node) bool) {
199199
if x.Index != nil {
200200
Walk(x.Index, f)
201201
}
202-
Walk(x.Value, f)
202+
if x.Value != nil {
203+
Walk(x.Value, f)
204+
}
203205
case *ExtGlob:
204206
Walk(x.Pattern, f)
205207
case *ProcSubst:

0 commit comments

Comments
 (0)