Skip to content

Commit

Permalink
Bump mvdan.cc/sh/v3 from 3.9.0 to 3.10.0
Browse files Browse the repository at this point in the history
Bumps [mvdan.cc/sh/v3](https://github.com/mvdan/sh) from 3.9.0 to 3.10.0.
- [Release notes](https://github.com/mvdan/sh/releases)
- [Changelog](https://github.com/mvdan/sh/blob/master/CHANGELOG.md)
- [Commits](mvdan/sh@v3.9.0...v3.10.0)

---
updated-dependencies:
- dependency-name: mvdan.cc/sh/v3
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
  • Loading branch information
dependabot[bot] authored Oct 23, 2024
1 parent df39b0a commit c299590
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 92 deletions.
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ require (
k8s.io/code-generator v0.30.3
k8s.io/kube-openapi v0.0.0-20240709000822-3c01b740850f
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8
mvdan.cc/sh/v3 v3.9.0
mvdan.cc/sh/v3 v3.10.0
sigs.k8s.io/controller-runtime v0.18.5
sigs.k8s.io/controller-tools v0.15.0
sigs.k8s.io/yaml v1.4.0
Expand Down Expand Up @@ -257,7 +257,7 @@ require (
github.com/quasilyte/regex/syntax v0.0.0-20210819130434-b3f0c404a727 // indirect
github.com/quasilyte/stdinfo v0.0.0-20220114132959-f7386bf02567 // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/rogpeppe/go-internal v1.12.0 // indirect
github.com/rogpeppe/go-internal v1.13.1 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/ryancurrah/gomodguard v1.3.1 // indirect
github.com/ryanrolds/sqlclosecheck v0.5.1 // indirect
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ github.com/cpuguy83/go-md2man/v2 v2.0.4 h1:wfIWP927BUkWJb2NmU/kNDYIBTh/ziUX91+lV
github.com/cpuguy83/go-md2man/v2 v2.0.4/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o=
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/creack/pty v1.1.17/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/creack/pty v1.1.21 h1:1/QdRyBaHHJP61QkWMXlOIBfsgdDeeKfK8SYVUWJKf0=
github.com/creack/pty v1.1.21/go.mod h1:MOBLtS5ELjhRRrroQr9kyvTxUAFNvYEK993ew/Vr4O4=
github.com/creack/pty v1.1.23 h1:4M6+isWdcStXEf15G/RbrMPOQj1dZ7HPZCGwE4kOeP0=
github.com/creack/pty v1.1.23/go.mod h1:08sCNb52WyoAwi2QDyzUCTgcvVFhUzewun7wtTfvcwE=
github.com/curioswitch/go-reassign v0.2.0 h1:G9UZyOcpk/d7Gd6mqYgd8XYWFMw/znxwGDUstnC9DIo=
github.com/curioswitch/go-reassign v0.2.0/go.mod h1:x6OpXuWvgfQaMGks2BZybTngWjT84hqJfKoO8Tt/Roc=
github.com/daixiang0/gci v0.12.3 h1:yOZI7VAxAGPQmkb1eqt5g/11SUlwoat1fSblGLmdiQc=
Expand Down Expand Up @@ -987,8 +987,8 @@ github.com/rogpeppe/go-internal v1.1.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/rogpeppe/go-internal v1.2.2/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4=
github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII=
github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
Expand Down Expand Up @@ -1873,8 +1873,8 @@ mvdan.cc/editorconfig v0.3.0 h1:D1D2wLYEYGpawWT5SpM5pRivgEgXjtEXwC9MWhEY0gQ=
mvdan.cc/editorconfig v0.3.0/go.mod h1:NcJHuDtNOTEJ6251indKiWuzK6+VcrMuLzGMLKBFupQ=
mvdan.cc/gofumpt v0.6.0 h1:G3QvahNDmpD+Aek/bNOLrFR2XC6ZAdo62dZu65gmwGo=
mvdan.cc/gofumpt v0.6.0/go.mod h1:4L0wf+kgIPZtcCWXynNS2e6bhmj73umwnuXSZarixzA=
mvdan.cc/sh/v3 v3.9.0 h1:it14fyjCdQUk4jf/aYxLO3FG8jFarR9GzMCtnlvvD7c=
mvdan.cc/sh/v3 v3.9.0/go.mod h1:cdBk8bgoiBI7lSZqK5JhUuq7OB64VQ7fgm85xelw3Nk=
mvdan.cc/sh/v3 v3.10.0 h1:v9z7N1DLZ7owyLM/SXZQkBSXcwr2IGMm2LY2pmhVXj4=
mvdan.cc/sh/v3 v3.10.0/go.mod h1:z/mSSVyLFGZzqb3ZIKojjyqIx/xbmz/UHdCSv9HmqXY=
mvdan.cc/unparam v0.0.0-20240104100049-c549a3470d14 h1:zCr3iRRgdk5eIikZNDphGcM6KGVTx3Yu+/Uu9Es254w=
mvdan.cc/unparam v0.0.0-20240104100049-c549a3470d14/go.mod h1:ZzZjEpJDOmx8TdVU6umamY3Xy0UAQUI2DHbf05USVbI=
rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8=
Expand Down
6 changes: 3 additions & 3 deletions vendor/modules.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1014,8 +1014,8 @@ github.com/rivo/uniseg
# github.com/rodaine/hclencoder v0.0.1
## explicit; go 1.14
github.com/rodaine/hclencoder
# github.com/rogpeppe/go-internal v1.12.0
## explicit; go 1.20
# github.com/rogpeppe/go-internal v1.13.1
## explicit; go 1.22
github.com/rogpeppe/go-internal/diff
github.com/rogpeppe/go-internal/fmtsort
# github.com/russross/blackfriday/v2 v2.1.0
Expand Down Expand Up @@ -2224,7 +2224,7 @@ mvdan.cc/gofumpt/internal/govendor/go/doc/comment
mvdan.cc/gofumpt/internal/govendor/go/format
mvdan.cc/gofumpt/internal/govendor/go/printer
mvdan.cc/gofumpt/internal/version
# mvdan.cc/sh/v3 v3.9.0
# mvdan.cc/sh/v3 v3.10.0
## explicit; go 1.22
mvdan.cc/sh/v3/cmd/shfmt
mvdan.cc/sh/v3/fileutil
Expand Down
4 changes: 2 additions & 2 deletions vendor/mvdan.cc/sh/v3/cmd/shfmt/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
FROM golang:1.23.0-alpine AS build
FROM golang:1.23.2-alpine AS build

WORKDIR /src
RUN apk add --no-cache git
COPY . .
RUN CGO_ENABLED=0 go build -ldflags "-w -s -extldflags '-static' -X main.version=$(git describe --always --dirty --tags)" ./cmd/shfmt

FROM alpine:3.19.1 AS alpine
FROM alpine:3.20.3 AS alpine
COPY --from=build /src/shfmt /bin/shfmt
COPY "./cmd/shfmt/docker-entrypoint.sh" "/init"
ENTRYPOINT ["/init"]
Expand Down
18 changes: 13 additions & 5 deletions vendor/mvdan.cc/sh/v3/cmd/shfmt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ directory, all shell scripts found under that directory will be used.
-s, --simplify simplify the code
-mn, --minify minify the code to reduce its size (implies -s)
--apply-ignore always apply EditorConfig ignore rules
--filename str provide a name for the standard input file
Parser options:
-ln, --language-dialect str bash/posix/mksh/bats, default "auto"
-p, --posix shorthand for -ln=posix
--filename str provide a name for the standard input file
Printer options:
Expand All @@ -158,7 +158,9 @@ Utilities:
--to-json print syntax tree to stdout as a typed JSON
--from-json read syntax tree from stdin as a typed JSON
For more information, see 'man shfmt' and https://github.com/mvdan/sh.
Formatting options can also be read from EditorConfig files; see 'man shfmt'
for a detailed description of the tool's behavior.
For more information and to report bugs, see https://github.com/mvdan/sh.
`)
}
flag.Parse()
Expand Down Expand Up @@ -359,9 +361,9 @@ var ecQuery = editorconfig.Query{
RegexpCache: make(map[string]*regexp.Regexp),
}

func propsOptions(lang syntax.LangVariant, props editorconfig.Section) {
func propsOptions(lang syntax.LangVariant, props editorconfig.Section) (_ syntax.LangVariant, validLang bool) {
// if shell_variant is set to a valid string, it will take precedence
lang.Set(props.Get("shell_variant"))
langErr := lang.Set(props.Get("shell_variant"))
syntax.Variant(lang)(parser)

size := uint(0)
Expand All @@ -380,6 +382,8 @@ func propsOptions(lang syntax.LangVariant, props editorconfig.Section) {
syntax.KeepPadding(props.Get("keep_padding") == "true")(printer)
// TODO(v4): rename to func_next_line for consistency with flags
syntax.FunctionNextLine(props.Get("function_next_line") == "true")(printer)

return lang, langErr == nil
}

func formatPath(path string, checkShebang bool) error {
Expand Down Expand Up @@ -446,12 +450,13 @@ func editorConfigLangs(l syntax.LangVariant) []string {
}

func formatBytes(src []byte, path string, fileLang syntax.LangVariant) error {
fileLangFromEditorConfig := false
if useEditorConfig {
props, err := ecQuery.Find(path, editorConfigLangs(fileLang))
if err != nil {
return err
}
propsOptions(fileLang, props)
fileLang, fileLangFromEditorConfig = propsOptions(fileLang, props)
} else {
syntax.Variant(fileLang)(parser)
}
Expand All @@ -466,6 +471,9 @@ func formatBytes(src []byte, path string, fileLang syntax.LangVariant) error {
node, err = parser.Parse(bytes.NewReader(src), path)
if err != nil {
if s, ok := err.(syntax.LangError); ok && lang.val == syntax.LangAuto {
if fileLangFromEditorConfig {
return fmt.Errorf("%w (parsed as %s via EditorConfig)", s, fileLang)
}
return fmt.Errorf("%w (parsed as %s via -%s=%s)", s, fileLang, lang.short, lang.val)
}
return err
Expand Down
15 changes: 9 additions & 6 deletions vendor/mvdan.cc/sh/v3/cmd/shfmt/shfmt.1.scd
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ predictable. Some aspects of the format can be configured via printer flags.
Should be useful to any tools or editors which format stdin or a single file.
When printing results to stdout, an ignored file results in no output at all.

*--filename* str
Provide a name for the standard input file.

Use of this flag is necessary for EditorConfig support to work with stdin,
since EditorConfig files are found relative to the location of a script.

## Parser flags

*-ln*, *--language-dialect* <str>
Expand All @@ -70,12 +76,6 @@ predictable. Some aspects of the format can be configured via printer flags.
*-p*, *--posix*
Shorthand for *-ln=posix*.

*--filename* str
Provide a name for the standard input file.

Use of this flag is necessary for EditorConfig support to work with stdin,
since EditorConfig files are found relative to the location of a script.

## Printer flags

*-i*, *--indent* <uint>
Expand All @@ -93,6 +93,9 @@ predictable. Some aspects of the format can be configured via printer flags.
*-kp*, *--keep-padding*
Keep column alignment paddings.

This flag is *DEPRECATED* and will be removed in the next major version.
For more information, see: https://github.com/mvdan/sh/issues/658

*-fn*, *--func-next-line*
Function opening braces are placed on a separate line.

Expand Down
22 changes: 13 additions & 9 deletions vendor/mvdan.cc/sh/v3/syntax/lexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,24 @@ retry:
if p.bsp < uint(len(p.bs)) {
if b := p.bs[p.bsp]; b < utf8.RuneSelf {
p.bsp++
if b == '\x00' {
switch b {
case '\x00':
// Ignore null bytes while parsing, like bash.
p.col++
goto retry
}
if b == '\\' {
case '\r':
if p.peekByte('\n') { // \r\n turns into \n
p.col++
goto retry
}
case '\\':
if p.r == '\\' {
} else if p.peekByte('\n') {
p.bsp++
p.w, p.r = 1, escNewl
return escNewl
} else if p.peekBytes("\r\n") {
} else if p.peekBytes("\r\n") { // \\\r\n turns into \\\n
p.col++
p.bsp += 2
p.w, p.r = 2, escNewl
return escNewl
Expand All @@ -89,8 +96,8 @@ retry:
p.bsp < uint(len(p.bs)) && bquoteEscaped(p.bs[p.bsp]) {
// We turn backquote command substitutions into $(),
// so we remove the extra backslashes needed by the backquotes.
// For good position information, we still include them in p.w.
bquotes++
p.col++
goto retry
}
}
Expand All @@ -100,7 +107,7 @@ retry:
if p.litBs != nil {
p.litBs = append(p.litBs, b)
}
p.w, p.r = 1+bquotes, rune(b)
p.w, p.r = 1, rune(b)
return p.r
}
if !utf8.FullRune(p.bs[p.bsp:]) {
Expand Down Expand Up @@ -820,9 +827,6 @@ func (p *Parser) newLit(r rune) {
func (p *Parser) endLit() (s string) {
if p.r == utf8.RuneSelf || p.r == escNewl {
s = string(p.litBs)
} else if p.r == '`' && p.w > 1 {
// If we ended at a nested and escaped backquote, litBs does not include the backslash.
s = string(p.litBs[:len(p.litBs)-1])
} else {
s = string(p.litBs[:len(p.litBs)-p.w])
}
Expand Down
29 changes: 14 additions & 15 deletions vendor/mvdan.cc/sh/v3/syntax/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
package syntax

import (
"bytes"
"fmt"
"io"
"strconv"
Expand All @@ -24,7 +23,7 @@ func KeepComments(enabled bool) ParserOption {
}

// LangVariant describes a shell language variant to use when tokenizing and
// parsing shell code. The zero value is LangBash.
// parsing shell code. The zero value is [LangBash].
type LangVariant int

const (
Expand Down Expand Up @@ -63,7 +62,7 @@ const (
// commonly used by end-user applications like shfmt,
// which can guess a file's language variant given its filename or shebang.
//
// At this time, the Parser does not support LangAuto.
// At this time, [Variant] does not support LangAuto.
LangAuto
)

Expand Down Expand Up @@ -144,7 +143,7 @@ func StopAt(word string) ParserOption {
return func(p *Parser) { p.stopAt = []byte(word) }
}

// NewParser allocates a new Parser and applies any number of options.
// NewParser allocates a new [Parser] and applies any number of options.
func NewParser(options ...ParserOption) *Parser {
p := &Parser{}
for _, opt := range options {
Expand Down Expand Up @@ -804,25 +803,25 @@ type LangError struct {
}

func (e LangError) Error() string {
var buf bytes.Buffer
var sb strings.Builder
if e.Filename != "" {
buf.WriteString(e.Filename + ":")
sb.WriteString(e.Filename + ":")
}
buf.WriteString(e.Pos.String() + ": ")
buf.WriteString(e.Feature)
sb.WriteString(e.Pos.String() + ": ")
sb.WriteString(e.Feature)
if strings.HasSuffix(e.Feature, "s") {
buf.WriteString(" are a ")
sb.WriteString(" are a ")
} else {
buf.WriteString(" is a ")
sb.WriteString(" is a ")
}
for i, lang := range e.Langs {
if i > 0 {
buf.WriteString("/")
sb.WriteString("/")
}
buf.WriteString(lang.String())
sb.WriteString(lang.String())
}
buf.WriteString(" feature")
return buf.String()
sb.WriteString(" feature")
return sb.String()
}

func (p *Parser) posErr(pos Pos, format string, a ...any) {
Expand Down Expand Up @@ -1341,7 +1340,7 @@ func (p *Parser) paramExp() *ParamExp {
p.curErr("not a valid parameter expansion operator: %v", p.tok)
case pe.Excl && p.r == '}':
if !p.lang.isBash() {
p.posErr(pe.Pos(), `"${!foo`+p.tok.String()+`}" is a bash feature`)
p.posErr(pe.Pos(), `"${!foo%s}" is a bash feature`, p.tok)
}
pe.Names = ParNamesOperator(p.tok)
p.next()
Expand Down
5 changes: 5 additions & 0 deletions vendor/mvdan.cc/sh/v3/syntax/printer.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ func SpaceRedirects(enabled bool) PrinterOption {
// Note that this feature is best-effort and will only keep the
// alignment stable, so it may need some human help the first time it is
// run.
//
// Deprecated: this formatting option is flawed and buggy, and often does
// not result in what the user wants when the code gets complex enough.
// The next major version, v4, will remove this feature entirely.
// See: https://github.com/mvdan/sh/issues/658
func KeepPadding(enabled bool) PrinterOption {
return func(p *Printer) {
if enabled && !p.keepPadding {
Expand Down
8 changes: 4 additions & 4 deletions vendor/mvdan.cc/sh/v3/syntax/simplify.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

package syntax

import "bytes"
import "strings"

// Simplify modifies a node to remove redundant pieces of syntax, and returns
// whether any changes were made.
Expand Down Expand Up @@ -99,7 +99,7 @@ parts:
if lit == nil {
break
}
var buf bytes.Buffer
var sb strings.Builder
escaped := false
for _, r := range lit.Value {
switch r {
Expand All @@ -118,9 +118,9 @@ parts:
}
escaped = false
}
buf.WriteRune(r)
sb.WriteRune(r)
}
newVal := buf.String()
newVal := sb.String()
if newVal == lit.Value {
break
}
Expand Down
Loading

0 comments on commit c299590

Please sign in to comment.