Skip to content

Releases: mvdan/sh

v3.13.1

06 Apr 21:43
v3.13.1

Choose a tag to compare

  • cmd/shfmt
    • Add support for [[zsh]] in EditorConfig files
    • Detect the shell variant from filenames like .zshrc and .bash_profile
    • Fix --apply-ignore when used with explicit args - #1310
  • syntax
    • Revert an accidental change to how array subscripts are formatted - #1314
    • Never join ;; with the previous line when formatting - #1289
    • Fix a bug where $1[foo] was parsed as a subscript in Zsh - #1288
    • Correctly parse $! in double quotes in Zsh - #1298
    • Allow indexing into special parameters in Zsh - #1299
    • Allow parameter expansions with empty names in Zsh - #1280
  • interp
    • Test against Bash 5.3 and fix three new discrepancies
    • Fix a few bugs related to nameref variables
    • Avoid panics when user input encounters unimplemented features

Consider becoming a sponsor if you benefit from the work that went into this release!

Binaries built on go version go1.26.1 linux/amd64 with:

CGO_ENABLED=0 go build -trimpath -ldflags="-w -s"

v3.13.0

09 Mar 10:37
v3.13.0

Choose a tag to compare

This release introduces support for Zsh in the parser and formatter, which was tracked in issue #120 alongside the label zsh . While support is not complete, it should be far enough for many use cases.

This release also drops support for Go 1.24 and includes many other enhancements:

  • cmd/shfmt
    • Exit with a non-zero status when -l prints any filenames
    • shfmt -version is now derived from the git current tag, dropping the -ldflags workaround
  • syntax
    • New nodes types and node fields are introduced alongside LangZsh
    • LangVariant is now a bitset, allowing the use of sets like "Bash-like"
    • Add InteractiveSeq and StmtsSeq iterator methods for Parser
    • Stop exposing the internal buffer in Printer via struct embedding
    • Support the use of brace expansions like declare {a,b}_c=value
    • Fix a bug where POSIX and Bash incorrectly allowed empty command lists
  • interp
    • Add support for shopt -s dotglob and shopt -s extglob
    • Add support for simple uses of !(expr) extended glob patterns
    • Support more builtin flags for declare, type, read
    • Fix various bugs relating to nulls, errors, and arrays
  • expand
    • Add Config.DotGlob and Config.ExtGlob for the interpreter
    • Add Variable.Flags to get the one-character declare flags
    • Do not force env vars on Windows to be uppercase
    • Fix various bugs relating to glob pattern matching
  • pattern
    • Add GlobLeadingDot and ExtendedOperators for the interpreter
    • Add NegExtGlobError to mark the use of !(expr) negation patterns

Consider becoming a sponsor if you benefit from the work that went into this release!

Binaries built on go version go1.26.1 linux/amd64 with:

CGO_ENABLED=0 go build -trimpath -ldflags="-w -s"

Note that this release no longer includes a sha256sums.txt asset; GitHub now provide digests natively.

v3.12.0

06 Jul 21:14
v3.12.0

Choose a tag to compare

  • The mvdan-sh JS package is discontinued in favor of sh-syntax - #1145
  • cmd/shfmt
    • Support the "simplify" and "minify" flags via EditorConfig - #819
    • --simplify and --minify are now formatting options, disabling the use of EditorConfig
    • Do not allow --write to replace non-regular files - #843
  • interp
    • Add IsBuiltin to check if a command name is a shell built-in - #1164
    • Add HandlerContext.Builtin to allow ExecHandlerFunc to call built-ins
    • Initial support for $! and wait PID - #221
    • Return non-fatal ExecHandlerFunc errors via the Runner.Run API
    • Add HandlerContext.Pos to provide handlers with source positions
    • Deprecate NewExitStatus and IsExitStatus in favor of ExitStatus
    • Fix wait to always return the status of the last given job
    • Copy all env vars for background subshells to avoid data races
    • Support reading random numbers via $RANDOM and $SRANDOM
    • Set $BASH_REMATCH when matching regular expressions via =~
    • Support modifying local vars from the parent calling function
  • expand
    • Adjust which backslash sequences are expanded in here-docs - #1138
    • Tweak tilde expansions to match Bash semantics
  • pattern
    • Remove the flawed and broken Braces mode; use syntax.SplitBraces instead
    • Tweak ** to only act as "globstar" when alone as a path element - #1149
    • Tweak * and ** to not match leading dots in basenames
    • Add a NoGlobStar mode to match the POSIX semantics
  • fileutil
    • Treat all non-regular files as definitely not shell scripts - #1089

Consider becoming a sponsor if you benefit from the work that went into this release!

Binaries built on go version go1.24.4 linux/amd64 with:

CGO_ENABLED=0 go build -trimpath -ldflags="-w -s -X=main.version=v3.12.0"

v3.11.0

05 Mar 22:30
v3.11.0
8a52daa

Choose a tag to compare

This release drops support for Go 1.22 and includes many enhancements.

  • cmd/shfmt
    • Support -l=0 and -f=0 to split filenames with null bytes - #1096
  • syntax
    • New iterator API: Parser.WordsSeq
    • Fix Parser.Incomplete and IsIncomplete to work well with Parser.Words - #937
    • Initial support for parsing incomplete shell via RecoverErrors
    • Expand LangError to include which language was used when parsing
  • interp
    • Refactor setting variables to fix array declaration edge cases - #1108
    • Fix test read/write/exec operators to work correctly on directories - #1116
    • Replace the cancelreader dependency with os.File.SetReadDeadline
    • Avoid waiting for process substitutions, matching Bash
    • Skip OpenHandler when opening named pipes for process substitutions - #1120
    • Use TMPDIR if set via Env to create temporary files such as named pipes
  • expand
    • New iterator API: FieldsSeq
    • Correctly handle repeated backslashes in double quotes - #1106
    • Don't expand backslashes inside here-documents - #1070
    • Replace the Unset kind with a new Variable.Set boolean field

Consider becoming a sponsor if you benefit from the work that went into this release!

Binaries built on go version go1.24.0 linux/amd64 with:

CGO_ENABLED=0 go build -trimpath -ldflags="-w -s -X=main.version=v3.11.0"

v3.10.0

20 Oct 20:42
v3.10.0
392da98

Choose a tag to compare

  • cmd/shfmt
    • Report the correct language variant in parser error messages - #1102
    • Move --filename out of the parser options category - #1079
  • syntax
    • Parse all CRLF line endings as LF, including inside heredocs - #1088
    • Count skipped backslashes inside backticks in position column numbers - #1098
    • Count skipped null bytes in position column numbers for consistency
  • interp
    • Fix a regression in v3.9.0 which broke redirecting files to stdin - #1099
    • Fix a regression in v3.9.0 where HandlerContext.Stdin was never nil
    • Add an Interactive option to be used by interactive shells - #1100
    • Support closing stdin, stdout, and stderr via redirections like <&-

Consider becoming a sponsor if you benefit from the work that went into this release!

Binaries built on go version go1.23.2 linux/amd64 with:

CGO_ENABLED=0 go build -trimpath -ldflags="-w -s -X=main.version=v3.10.0"

v3.9.0

16 Aug 22:25
v3.9.0
7bd422f

Choose a tag to compare

This release drops support for Go 1.21 and includes many fixes.

  • cmd/shfmt
    • Switch the diff implementation to remove one dependency
  • syntax
    • Protect against overflows in position offset integers
  • interp
    • Use os.Pipe for stdin to prevent draining by subprocesses - #1085
    • Support cancelling reads in builtins when stdin is a file - #1066
    • Support the nocaseglob bash option - #1073
    • Support the Bash 5.2 @k parameter expansion operator
    • Support the test -O and test -G operators on non-Windows - #1080
    • Support the read -s builtin flag - #1063
  • expand
    • Add support for case insensitive globbing - #1073
    • Don't panic when pattern words are nil - #1076

A special thanks to @theclapp for their contributors to this release!

Consider becoming a sponsor if you benefit from the work that went into this release!

Binaries built on go version go1.23.0 linux/amd64 with:

CGO_ENABLED=0 go build -trimpath -ldflags="-w -s -X=main.version=v3.9.0"

v3.8.0

11 Feb 12:45
84baa08

Choose a tag to compare

This release drops support for Go 1.19 and 1.20 and includes many features and bugfixes, such as improving EditorConfig support in shfmt.

  • cmd/shfmt
    • Support EditorConfig language sections such as [[shell]] - #664
    • Add --apply-ignore for tools and editors - #1037
  • syntax
    • Allow formatting redirects before all command argumetnts - #942
    • Support brace expansions with uppercase letters - #1042
    • Unescape backquotes in single quotes within backquotes - #1041
    • Better error when using function in POSIX mode - #993
    • Better column numbers for escapes inside backquotes - #1028
  • interp
    • Support parentheses in classic test commands - #1036
    • Determine access to a directory via unix.Access - #1033
    • Support subshells with FuncEnviron as Env - #1043
    • Add support for fs.DirEntry via ReadDirHandler2
  • expand
    • Add support for fs.DirEntry via ReadDir2
    • Support zero-padding in brace expansions - #1042

A special thanks to all the contributors to this release! @theclapp @slabstone @MaienM

Consider becoming a sponsor if you benefit from the work that went into this release!

Binaries built on go version go1.22.0 linux/amd64 with:

CGO_ENABLED=0 go build -trimpath -ldflags="-w -s -X=main.version=v3.8.0"

v3.7.0

18 Jun 11:38
v3.7.0
d3fa147

Choose a tag to compare

This release drops support for Go 1.18 and includes many features and fixes.

  • syntax
    • Correctly parse $foo#bar as a single word - #1003
    • Make &> redirect operators an error in POSIX mode - #991
    • Avoid producing invalid shell when minifying some heredocs - #923
    • Revert the simplification of ${foo:-} into ${foo-} - #970
  • interp
    • Add ExecHandlers to support layering multiple middlewares - #964
    • Add initial support for the select clause - #969
    • Support combining the errexit and pipefail options - #870
    • Set EUID just like UID - #958
    • Replace panics on unimplemented builtins with errors - #999
    • Tweak build tags to support building for js/wasm - #983
  • syntax/typedjson
    • Avoid reflect.Value.MethodByName to reduce binary sizes - #961

A special thanks to all the contributors to this release! @riacataquian @anderbubble @teefill @diamondburned

Consider becoming a sponsor if you benefit from the work that went into this release!

Binaries built on go version go1.20.5 linux/amd64 with:

CGO_ENABLED=0 go build -trimpath -ldflags="-w -s -X=main.version=v3.7.0"

v3.6.0

12 Dec 09:21
v3.6.0

Choose a tag to compare

This release drops support for Go 1.17 and includes many features and fixes.

  • cmd/shfmt
    • Implement --from-json as the reverse of --to-json - #900
    • Improve the quality of the --to-json output - #900
    • Provide detected language when erroring with -ln=auto - #803
  • syntax
    • Don't require peeking two bytes after echo * - #835
    • Simplify ${name:-} to the equivalent ${name-} - #849
    • Don't print trailing whitespaces on nested subshells - #814
    • Don't print extra newlines in some case clauses - #779
    • Don't indent comments preceding case clause items - #917
    • Allow escaped newlines before unquoted words again - #873
    • Parse a redirections edge case without spaces - #879
    • Give a helpful error when <<< is used in POSIX mode - #881
    • Forbid ${!foo*} and ${!foo@} in mksh mode - #929
    • Batch allocations less aggressively in the parser
  • syntax/typedjson
    • Expose --from-json and --to-json as Go APIs - #885
  • expand
    • Improve support for expanding array keys and values - #884
    • Don't panic on unsupported syntax nodes - #841
    • Don't panic on division by zero - #892
    • Properly expand unquoted parameters with spaces - #886
    • Trim spaces when converting strings to integers - #928
  • interp
    • Add initial implementation for mapfile and readarray - #863
    • Improve matching patterns against multiple lines - #866
    • Support %b in the printf builtin - #955
    • Display all Bash options in shopt - #877
  • pattern
    • Add EntireString to match the entire string using ^$ - #866

A special thanks to all the contributors to this release!
@fauust @graf0 @hristiy4n @ihar-orca @lollipopman @mkhl @przmv @reubeno @riacataquian @scop @tmillr

Binaries built on go version go1.19.4 linux/amd64 with:

CGO_ENABLED=0 go build -trimpath -ldflags="-w -s -X=main.version=v3.6.0"

Consider becoming a sponsor if you benefit from the work that went into this release!

v3.5.1

07 Jun 07:56

Choose a tag to compare

This release was tagged two weeks ago; we forgot to do the GitHub release with prebuilt binaries.

  • cmd/shfmt
    • Fix the Docker publishing script bug which broke 3.5.0 - #860
  • interp
    • Support multi-line strings when pattern matching in [[ - #861
    • Invalid glob words are no longer removed with nullglob - #862
  • pattern
    • Regexp now returns the typed error SyntaxError - #862

Binaries built on go version go1.18.3 linux/amd64 via a shell script.

Consider becoming a sponsor if you benefit from the work that went into this release!