Repository navigation
Releases: mvdan/sh
Release list
v3.14.1
- syntax
- Fix the indentation of heredocs nested inside command substitutions - #1403
- Keep literal tabs in
<<-heredoc bodies rather than replacing them with spaces - Don't indent heredocs without dashes nested in
<<-ones, whose output no longer parsed - Zsh: don't drop the prefix in short forms like
$#"$foo"and$+"$foo"- #1405
- interp
- Fix the build on 32-bit FreeBSD and NetBSD
- expand
- Don't let escaped characters such as
\*act as glob metacharacters
- Don't let escaped characters such as
- pattern
- Treat unclosed extended operator groups like
@(aas literals, avoiding a panic
- Treat unclosed extended operator groups like
Consider becoming a sponsor if you benefit from the work that went into this release!
Binaries built on go version go1.27.1 linux/amd64 with:
CGO_ENABLED=0 go build -trimpath -ldflags="-w -s"
v3.14.0
This release drops support for Go 1.25 and includes many enhancements, particularly in the interpreter, which implements more shell features and fixes many divergences from Bash.
- cmd/shfmt
- Add
--detectto find shell files by executable bit or shebang - #944
- Add
- syntax
- Add
Preorder, an iterator over all nodes, complementingWalk - Add
encoding.TextUnmarshalerimplementations for each operator type - Support
${ foo;}and${|foo;}inside double quotes - #1368 - Support array elements in
{varname}redirects, likeexec {fds[3]}>&-- #719 - Backslashes inside backquotes within double quotes escape double quotes - #1083
- Allow pound signs in associative array keys like
${args[cmd,#]}- #1285 - Don't treat
#as the start of a comment inside[[ ]]tests - #1326 - Don't join
thenordowith a semicolon when heredocs are pending - #1047 - Print a space after
!in arithmetic expressions, avoiding history expansion - #987 - Space nested closing parentheses like the opening ones - #876
- Make
SplitBracesreject malformed sequences and skip backslash escapes - #1330 - Zsh: support the
${=name},${~name}, and${^name}prefixes - #1238 - Zsh: support the
;|case terminator and leading parentheses for globs - #1293, #1279 - Zsh: parse subscript flag arguments as patterns, and allow
[globs in arrays - #1278, #1322
- Add
- syntax/typedjson
- Encode operators as their syntax form, such as
">>", rather than integers - #1321 - Return errors rather than panicking on malformed input
- Encode operators as their syntax form, such as
- interp
- Add
BashOptsto set Bash options likeshopt- #962 - Add
AccessHandlerto control file access checks, used by-randcd- #1318 - Add
HandlerContext.LastExitStatus, and provide aHandlerContextto stat handlers - Implement the
helpandtimesbuiltins, as well as$-- #1398 - Implement the
;∧;&case terminators - #1391 - Implement the
-Ntest operator, and make-ntand-otfollow POSIX - #1340 - Support sparse indexed arrays such as
a=([5]=x)- #1373 - Run files as shell scripts when
execfails withENOEXEC- #1065 - Support empty here-documents, and don't expand quoted ones - #1390
- Support
js/wasm, where subprocesses and pipes are unavailable - Keep the redirections applied by
execwith no arguments - Only fire the exit trap when the shell exits, rather than after every
Run
- Add
- expand
- Add
BracesSeqwith a config and error reporting, deprecatingBraces - Add
Variable.Indexesto describe sparse indexed arrays - Support integer bases in arithmetic - #339
- Short-circuit the arithmetic
&&and||operators - #1371 - Apply per-element operators to quoted array expansions like
"${a[@]%o}"- #1081 - Make unquoted
${!arr[@]}consistent with the quoted form - #672 - Fix many divergences from Bash in arithmetic, string, and brace expansions
- Reject unsupported Zsh syntax rather than panicking - #1363
- Add
- pattern
- Treat an unmatched
[as a literal character, like Bash - #1372 - Fix panics and mismatches in bracket expressions, such as
[![:space:]]
- Treat an unmatched
- fileutil
- Recognize
dashshebangs as POSIX shell for-ln=auto- #1307
- Recognize
Consider becoming a sponsor if you benefit from the work that went into this release!
Binaries built on go version go1.27.0 linux/amd64 with:
CGO_ENABLED=0 go build -trimpath -ldflags="-w -s"
v3.13.1
- cmd/shfmt
- Add support for
[[zsh]]in EditorConfig files - Detect the shell variant from filenames like
.zshrcand.bash_profile - Fix
--apply-ignorewhen used with explicit args - #1310
- Add support for
- 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
namerefvariables - 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
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
-lprints any filenames shfmt -versionis now derived from the git current tag, dropping the-ldflagsworkaround
- Exit with a non-zero status when
- syntax
- New nodes types and node fields are introduced alongside
LangZsh LangVariantis now a bitset, allowing the use of sets like "Bash-like"- Add
InteractiveSeqandStmtsSeqiterator methods forParser - Stop exposing the internal buffer in
Printervia 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
- New nodes types and node fields are introduced alongside
- interp
- Add support for
shopt -s dotglobandshopt -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
- Add support for
- expand
- Add
Config.DotGlobandConfig.ExtGlobfor the interpreter - Add
Variable.Flagsto get the one-characterdeclareflags - Do not force env vars on Windows to be uppercase
- Fix various bugs relating to glob pattern matching
- Add
- pattern
- Add
GlobLeadingDotandExtendedOperatorsfor the interpreter - Add
NegExtGlobErrorto mark the use of!(expr)negation patterns
- Add
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
- The
mvdan-shJS package is discontinued in favor ofsh-syntax- #1145 - cmd/shfmt
- interp
- Add
IsBuiltinto check if a command name is a shell built-in - #1164 - Add
HandlerContext.Builtinto allowExecHandlerFuncto call built-ins - Initial support for
$!andwait PID- #221 - Return non-fatal
ExecHandlerFuncerrors via theRunner.RunAPI - Add
HandlerContext.Posto provide handlers with source positions - Deprecate
NewExitStatusandIsExitStatusin favor ofExitStatus - Fix
waitto 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
$RANDOMand$SRANDOM - Set
$BASH_REMATCHwhen matching regular expressions via=~ - Support modifying local vars from the parent calling function
- Add
- expand
- Adjust which backslash sequences are expanded in here-docs - #1138
- Tweak tilde expansions to match Bash semantics
- pattern
- Remove the flawed and broken
Bracesmode; usesyntax.SplitBracesinstead - Tweak
**to only act as "globstar" when alone as a path element - #1149 - Tweak
*and**to not match leading dots in basenames - Add a
NoGlobStarmode to match the POSIX semantics
- Remove the flawed and broken
- 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
This release drops support for Go 1.22 and includes many enhancements.
- cmd/shfmt
- Support
-l=0and-f=0to split filenames with null bytes - #1096
- Support
- syntax
- New iterator API:
Parser.WordsSeq - Fix
Parser.IncompleteandIsIncompleteto work well withParser.Words- #937 - Initial support for parsing incomplete shell via
RecoverErrors - Expand
LangErrorto include which language was used when parsing
- New iterator API:
- interp
- Refactor setting variables to fix array declaration edge cases - #1108
- Fix
testread/write/exec operators to work correctly on directories - #1116 - Replace the
cancelreaderdependency withos.File.SetReadDeadline - Avoid waiting for process substitutions, matching Bash
- Skip
OpenHandlerwhen opening named pipes for process substitutions - #1120 - Use
TMPDIRif set viaEnvto create temporary files such as named pipes
- expand
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
- cmd/shfmt
- syntax
- interp
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
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.Pipefor stdin to prevent draining by subprocesses - #1085 - Support cancelling reads in builtins when stdin is a file - #1066
- Support the
nocaseglobbash option - #1073 - Support the Bash 5.2
@kparameter expansion operator - Support the
test -Oandtest -Goperators on non-Windows - #1080 - Support the
read -sbuiltin flag - #1063
- Use
- expand
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
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
- syntax
- interp
- expand
- Add support for
fs.DirEntryviaReadDir2 - Support zero-padding in brace expansions - #1042
- Add support for
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
This release drops support for Go 1.18 and includes many features and fixes.
- syntax
- interp
- Add
ExecHandlersto support layering multiple middlewares - #964 - Add initial support for the
selectclause - #969 - Support combining the
errexitandpipefailoptions - #870 - Set
EUIDjust likeUID- #958 - Replace panics on unimplemented builtins with errors - #999
- Tweak build tags to support building for
js/wasm- #983
- Add
- syntax/typedjson
- Avoid
reflect.Value.MethodByNameto reduce binary sizes - #961
- Avoid
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"