diff --git a/go.mod b/go.mod index 4d37f4d3..435d3ecb 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( golang.org/x/crypto v0.0.0-20191002192127-34f69633bfdc // indirect golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e gopkg.in/yaml.v2 v2.2.2 - mvdan.cc/sh/v3 v3.1.0 + mvdan.cc/sh/v3 v3.1.1 ) go 1.13 diff --git a/go.sum b/go.sum index 31d208e7..13af05a9 100644 --- a/go.sum +++ b/go.sum @@ -65,5 +65,5 @@ gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= mvdan.cc/editorconfig v0.1.1-0.20200121172147-e40951bde157/go.mod h1:Ge4atmRUYqueGppvJ7JNrtqpqokoJEFxYbP0Z+WeKS8= -mvdan.cc/sh/v3 v3.1.0 h1:bFxsEzIubuABloc8G1Ko78rbZZ0JspNN9e9+R/w3z5k= -mvdan.cc/sh/v3 v3.1.0/go.mod h1:F+Vm4ZxPJxDKExMLhvjuI50oPnedVXpfjNSrusiTOno= +mvdan.cc/sh/v3 v3.1.1 h1:niuYC5Ug0KzLuN6CNX3ru37v4MkVD5Wm9T4Mk2eJr9A= +mvdan.cc/sh/v3 v3.1.1/go.mod h1:F+Vm4ZxPJxDKExMLhvjuI50oPnedVXpfjNSrusiTOno= diff --git a/vendor/modules.txt b/vendor/modules.txt index 47f1bb96..6a5fb8ac 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -39,7 +39,7 @@ golang.org/x/xerrors golang.org/x/xerrors/internal # gopkg.in/yaml.v2 v2.2.2 gopkg.in/yaml.v2 -# mvdan.cc/sh/v3 v3.1.0 +# mvdan.cc/sh/v3 v3.1.1 mvdan.cc/sh/v3/expand mvdan.cc/sh/v3/interp mvdan.cc/sh/v3/pattern diff --git a/vendor/mvdan.cc/sh/v3/interp/vars.go b/vendor/mvdan.cc/sh/v3/interp/vars.go index 8a6fe35f..3529e190 100644 --- a/vendor/mvdan.cc/sh/v3/interp/vars.go +++ b/vendor/mvdan.cc/sh/v3/interp/vars.go @@ -41,6 +41,18 @@ func (o overlayEnviron) Each(f func(name string, vr expand.Variable) bool) { func execEnv(env expand.Environ) []string { list := make([]string, 0, 64) env.Each(func(name string, vr expand.Variable) bool { + if !vr.IsSet() { + // If a variable is set globally but unset in the + // runner, we need to ensure it's not part of the final + // list. Seems like zeroing the element is enough. + // This is a linear search, but this scenario should be + // rare, and the number of variables shouldn't be large. + for i, kv := range list { + if strings.HasPrefix(kv, name+"=") { + list[i] = "" + } + } + } if vr.Exported { list = append(list, name+"="+vr.String()) } diff --git a/vendor/mvdan.cc/sh/v3/syntax/lexer.go b/vendor/mvdan.cc/sh/v3/syntax/lexer.go index 9510d1ff..f80da0dc 100644 --- a/vendor/mvdan.cc/sh/v3/syntax/lexer.go +++ b/vendor/mvdan.cc/sh/v3/syntax/lexer.go @@ -993,7 +993,7 @@ func (p *Parser) advanceLitRe(r rune) { p.quote = noState return } - case ' ', '\t', '\r', '\n': + case ' ', '\t', '\r', '\n', ';', '&', '>', '<': if p.rxOpenParens <= 0 { p.tok, p.val = _LitWord, p.endLit() p.quote = noState @@ -1002,7 +1002,7 @@ func (p *Parser) advanceLitRe(r rune) { case '"', '\'', '$', '`': p.tok, p.val = _Lit, p.endLit() return - case utf8.RuneSelf, ';', '&', '>', '<': + case utf8.RuneSelf: p.tok, p.val = _LitWord, p.endLit() p.quote = noState return diff --git a/vendor/mvdan.cc/sh/v3/syntax/parser.go b/vendor/mvdan.cc/sh/v3/syntax/parser.go index d3fe6c3c..16ccd242 100644 --- a/vendor/mvdan.cc/sh/v3/syntax/parser.go +++ b/vendor/mvdan.cc/sh/v3/syntax/parser.go @@ -545,12 +545,26 @@ func (p *Parser) doHeredocs() { if i > 0 && p.r == '\n' { p.rune() } + lastLine := p.npos.line if quoted { r.Hdoc = p.quotedHdocWord() } else { p.next() r.Hdoc = p.getWord() } + if r.Hdoc != nil { + lastLine = r.Hdoc.End().line + } + if lastLine < p.npos.line { + // TODO: It seems like this triggers more often than it + // should. Look into it. + l := p.lit(p.npos, "") + if r.Hdoc == nil { + r.Hdoc = p.word(p.wps(l)) + } else { + r.Hdoc.Parts = append(r.Hdoc.Parts, l) + } + } if stop := p.hdocStops[len(p.hdocStops)-1]; stop != nil { p.posErr(r.Pos(), "unclosed here-document '%s'", stop) } diff --git a/vendor/mvdan.cc/sh/v3/syntax/printer.go b/vendor/mvdan.cc/sh/v3/syntax/printer.go index 53cce972..63f04402 100644 --- a/vendor/mvdan.cc/sh/v3/syntax/printer.go +++ b/vendor/mvdan.cc/sh/v3/syntax/printer.go @@ -165,26 +165,26 @@ type colCounter struct { lineStart bool } -func (c *colCounter) WriteByte(b byte) error { +func (c *colCounter) addByte(b byte) { switch b { case '\n': c.column = 0 c.lineStart = true - case '\t', ' ': + case '\t', ' ', tabwriter.Escape: default: c.lineStart = false } c.column++ +} + +func (c *colCounter) WriteByte(b byte) error { + c.addByte(b) return c.Writer.WriteByte(b) } func (c *colCounter) WriteString(s string) (int, error) { - c.lineStart = false - for _, r := range s { - if r == '\n' { - c.column = 0 - } - c.column++ + for _, b := range []byte(s) { + c.addByte(b) } return c.Writer.WriteString(s) } @@ -269,15 +269,15 @@ func (p *Printer) space() { } func (p *Printer) spacePad(pos Pos) { - if p.wantSpace { - p.WriteByte(' ') - p.wantSpace = false - } if p.cols.lineStart { // Never add padding at the start of a line, since this may // result in broken indentation or mixing of spaces and tabs. return } + if p.wantSpace { + p.WriteByte(' ') + p.wantSpace = false + } for !p.cols.lineStart && p.cols.column > 0 && p.cols.column < int(pos.col) { p.WriteByte(' ') } @@ -331,7 +331,7 @@ func (p *Printer) writeLit(s string) { p.WriteString(s) return } - p.WriteByte('\xff') + p.WriteByte(tabwriter.Escape) for i := 0; i < len(s); i++ { b := s[i] if b != '\t' { @@ -340,7 +340,7 @@ func (p *Printer) writeLit(s string) { } p.WriteByte(b) } - p.WriteByte('\xff') + p.WriteByte(tabwriter.Escape) } func (p *Printer) incLevel() { @@ -370,11 +370,11 @@ func (p *Printer) indent() { switch { case p.level == 0: case p.indentSpaces == 0: - p.WriteByte('\xff') + p.WriteByte(tabwriter.Escape) for i := uint(0); i < p.level; i++ { p.WriteByte('\t') } - p.WriteByte('\xff') + p.WriteByte(tabwriter.Escape) default: p.spaces(p.indentSpaces * p.level) }