3.12.0 - 2025-07-06
- The
mvdan-shJS package is discontinued in favor ofsh-syntax- #1145 - cmd/shfmt
- Support the "simplify" and "minify" flags via EditorConfig - #819
- Do not allow
--writeto replace non-regular files - #843
- 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
3.11.0 - 2025-03-05
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
- New iterator API:
FieldsSeq - Correctly handle repeated backslashes in double quotes - #1106
- Don't expand backslashes inside here-documents - #1070
- Replace the
Unsetkind with a newVariable.Setboolean field
- New iterator API:
Consider becoming a sponsor if you benefit from the work that went into this release!
3.10.0 - 2024-10-20
- cmd/shfmt
- Report the correct language variant in parser error messages - #1102
- Move
--filenameout 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.0which broke redirecting files to stdin - #1099 - Fix a regression in
v3.9.0whereHandlerContext.Stdinwas never nil - Add an
Interactiveoption to be used by interactive shells - #1100 - Support closing stdin, stdout, and stderr via redirections like
<&-
- Fix a regression in
Consider becoming a sponsor if you benefit from the work that went into this release!
3.9.0 - 2024-08-16
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
- 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!
3.8.0 - 2024-02-11
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-ignorefor tools and editors - #1037
- Support EditorConfig language sections such as
- 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
functionin 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
FuncEnvironasEnv- #1043 - Add support for
fs.DirEntryviaReadDirHandler2
- expand
- Add support for
fs.DirEntryviaReadDir2 - Support zero-padding in brace expansions - #1042
- Add support for
3.7.0 - 2023-06-18
- syntax
- Correctly parse
$foo#baras 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
- Correctly parse
- 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
3.6.0 - 2022-12-11
This release drops support for Go 1.17 and includes many features and fixes.
- cmd/shfmt
- 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
- Don't require peeking two bytes after
- syntax/typedjson
- Expose
--from-jsonand--to-jsonas Go APIs - #885
- Expose
- expand
- interp
- pattern
- Add
EntireStringto match the entire string using^$- #866
- Add
3.5.1 - 2022-05-23
- cmd/shfmt
- Fix the Docker publishing script bug which broke 3.5.0 - #860
- interp
- pattern
Regexpnow returns the typed errorSyntaxError- #862
3.5.0 - 2022-05-11
This release drops support for Go 1.16 and includes many new features.
- cmd/shfmt
- Switch to
-ln=autoby default to detect the shell language - Add support for long flags, like
--indentfor-i
- Switch to
- syntax
- Allow extglob wildcards as function names like
@() { ... } - Add support for heredocs surrounded by backquotes
- Add support for backquoted inline comments
- Add
NewPosto createPosvalues externally - Support escaped newlines with CRLF line endings
Minifyno longer omits a leading shebang comment- Avoid printing escaped newlines in non-quoted words
- Fix some printer edge cases where comments weren't properly spaced
- Allow extglob wildcards as function names like
- fileutil
- Add
Shebangto extract the shell language from a#!line
- Add
- expand
- Reimplement globstar
**globbing for correctness - Replace
os.Statas the last direct use of the filesystem
- Reimplement globstar
- interp
- Add
CallHandlerto intercept all interpretedCallExprnodes - Add
ReadDirHandlerto intercept glob expansion filesystem reads - Add
StatHandlerto interceptos.Statandos.Lstatcalls - Always surface exit codes from command substitutions
- Add initial and incomplete support for
set -x - Add support for
cd -ascd "$OLDPWD" - Avoid panic on
set - args
- Add
3.4.3 - 2022-02-19
- cmd/shfmt
- New Docker
v3tag to track the latest stable version - Don't duplicate errors when walking directories
- New Docker
- interp
- Properly handle empty paths in the
testbuiltin - Allow unsetting global vars from inside a function again
- Use
%wto wrap errors inDir
- Properly handle empty paths in the
3.4.2 - 2021-12-24
- The tests no longer assume what locales are installed
- interp
- Keep
PATHlist separators OS-specific to fix a recent regression - Avoid negative elapsed durations in the
timebuiltin
- Keep
3.4.1 - 2021-11-23
- syntax
- Don't return an empty string on empty input to
Quote
- Don't return an empty string on empty input to
- expand
- Properly sort in
ListEnvironto avoid common prefix issues
- Properly sort in
- interp
exportused in functions now affects the global scope- Support looking for scripts in
$PATHinsource - Properly slice arrays in parameter expansions
3.4.0 - 2021-10-01
This release drops support for Go 1.15,
which allows the code to start benefitting from io/fs.
- cmd/shfmt
- Walks directories ~10% faster thanks to
filepath.WalkDir
- Walks directories ~10% faster thanks to
- syntax
- Add
Quoteto mirrorstrconv.Quotefor shell syntax - Skip null characters when parsing, just like Bash
- Rewrite fuzzers with Go 1.18's native fuzzing
- Add
- fileutil
- Add
CouldBeScript2usingio/fs.DirEntry
- Add
- expand
- Skip or stop at null characters, just like Bash
- interp
- Set
GIDjust likeUID - Add support for
read -p - Add support for
pwdflags - Create random FIFOs for process substitutions more robustly
- Avoid leaking an open file when interpreting
$(<file)
- Set
3.3.1 - 2021-08-01
- syntax
- Don't convert
&in a separate line into; - Fix a
BinaryNextLineedge case idempotency bug - Never start printing a command with an escaped newline
- Don't convert
- interp
- Support calling
Runner.ResetbeforeRunner.Run - Obey
set -efor failed redirections
- Support calling
3.3.0 - 2021-05-17
- cmd/shfmt
- Document the
FORCE_COLORenv var to always use colors in diffs
- Document the
- syntax
- Add the printer
SingleLineoption to avoid printing newlines - Positions now use more bits for line numbers than column numbers
- Test operators like
&&and||no longer escape newlines - Properly handle closing backquotes in a few edge cases
- Properly handle trailing escaped newlines in heredocs
- Add the printer
- interp
- Redesigned variable scoping to fix a number of edge cases
- Refactor
set -o nounsetsupport to fix many edge cases - Deprecate
LookPathin favor ofLookPathDir - Array element words are now expanded correctly
- Add support for
trapwith error and exit signals - Add support for
shopt -s nullglob - Add support for
type -p
3.2.4 - 2021-03-08
- cmd/shfmt
- Don't stop handling arguments when one results in a failure
- expand
- Don't panic when a backslash is followed by EOF
3.2.2 - 2021-01-29
- syntax
- Avoid comment position panic in the printer
3.2.1 - 2020-12-02
- syntax
- Fix an endless loop when parsing single quotes in parameter expansions
- Properly print assignments using escaped newlines
- Print inline heredoc comments in the right place
- interp
- Always expand
~in Bash test expressions
- Always expand
- expand
- Don't panic on out of bounds array index expansions
3.2.0 - 2020-10-29
- cmd/shfmt
- Add a man page via scdoc; see shfmt.1.scd
- Add
-filenameto give a name to standard input
- syntax
- Add initial support for Bats
- Protect line and column position numbers against overflows
- Rewrite arithmetic parsing to fix operator precedence
- Don't add parentheses to
function f {...}declarations for ksh support KeepPaddingnow obeys extra indentation when using space indentation- Properly tokenize
((within test expressions - Properly tokenize single quotes within parameter expansions
- Obey print options inside
<<-heredocs - Don't simplify indexed parameter expansions in arithmetic expressions
- Improve parsing errors for missing test expressions
LangVariantnow implements flag.Value
- interp
- Avoid panic on C-style loops which omit expressions
$@and$*always exist, so"$@"can expand to zero words
3.1.2 - 2020-06-26
- syntax
- Fix brace indentation when using
FunctionNextLine - Support indirect parameter expansions with transformations
- Stop heredoc bodies only when the entire line matches
- Fix brace indentation when using
- interp
- Make the tests pass on 32-bit platforms
3.1.1 - 2020-05-04
- cmd/shfmt
- Recognise
function_next_linein EditorConfig files
- Recognise
- syntax
- Don't ignore escaped newlines at the end of heredoc bodies
- Improve support for parsing regexes in test expressions
- Count columns for
KeepPaddingin bytes, to better support unicode - Never let
KeepPaddingadd spaces right after indentation
- interp
- Hide unset variables when executing programs
3.1.0 - 2020-04-07
- Redesigned Docker images, including buildx and an Alpine variant
- cmd/shfmt
- Replace source files atomically when possible
- Support
ignore = truein an EditorConfig to skip directories - Add
-fnto place function opening braces on the next line - Improve behavior of
-fwhen given non-directories - Docker images and
go getinstalls now embed good version information
- syntax
- Add support for nested here-documents
- Allow parsing for loops with braces, present in mksh and Bash
- Expand
CaseClauseto describe itsintoken - Allow empty lines in Bash arrays in the printer
- Support disabling
KeepPadding - Avoid mis-printing some programs involving
&
- interp
- Add initial support for Bash process substitutions
- Add initial support for aliases
- Fix an edge case where the status code would not be reset
- The exit status code can now reflect being stopped by a signal
test -tnow uses the interpreter's stdin/stdout/stderr files
- expand
- Improve the interaction of
@and*with quotes andIFS
- Improve the interaction of
3.0.2 - 2020-02-22
- syntax
- Don't indent after escaped newlines in heredocs
- Don't parse
*[i]=xas a valid assignment
- interp
- Prevent subshells from defining funcs in the parent shells
- expand
- Parameters to
Fieldsno longer get braces expanded in-place
- Parameters to
3.0.1 - 2020-01-11
- cmd/shfmt
- Fix an edge case where walking directories could panic
- syntax
- Only do a trailing read in
Parser.Stmtsif we have open heredocs - Ensure comments are never folded into heredocs
- Properly tokenize
)after a=~test regexp - Stop parsing a comment at an escaped newline
- Only do a trailing read in
- expand
"$@"now expands to zero fields when there are zero parameters
3.0.0 - 2019-12-16
This is the first stable release as a proper module, now under
mvdan.cc/sh/v3/.... Go 1.12 or later is supported.
A large number of changes have been done since the last feature release a year ago. All users are encouraged to update. Below are the major highlights.
- cmd/shfmt
- Support for EditorConfig files
- Drop the dependency on
difffor the-dflag, now using pure Go
- syntax
- Overhaul escaped newlines, now represented as
WordPartpositions - Improve some operator type names, to consistently convey meaning
- Completely remove
StmtList - Redesign
IfClause, making its "else" anotherIfClausenode - Redesign
DeclClauseto remove its brokenOptsfield - Brace expression parsing is now done with a
BraceExpword part - Improve comment alignment in
Printervia a post-process step - Add support for the
~bitwise negation operator - Record the use of deprecated tokens in the syntax tree
- Overhaul escaped newlines, now represented as
- interp
- Improve the module API as "handlers", to reduce confusion with Go modules
- Split
LookPathout ofExecHandlerto allow custom behavior Runnow returnsnilinstead ofShellExitStatus(0)OpenDevImplsis removed; seeExampleOpenHandlerfor an alternative
- expand
- Redesign
Variableto reduce allocations - Add support for more escape sequences
- Make
Configa bit more powerful viafuncfields - Rework brace expansion via the new
BraceExpword part
- Redesign
- pattern
- New package for shell pattern matching, extracted from
syntax - Add support for multiple modes, including filenames and braces
- New package for shell pattern matching, extracted from
Special thanks to Konstantin Kulikov for his contribution to this release.
2.6.4 - 2019-03-10
- syntax
- Support array elements without values, like
declare -A x=([index]=) - Parse
for i; do ...uniquely, as it's short forfor i in "$@" - Add missing error on unclosed nested backquotes
- Support array elements without values, like
- expand
- Don't expand tildes twice, fixing
echo ~on Windows
- Don't expand tildes twice, fixing
- interp
- Fix the use of
Paramsas an option toNew - Support lowercase Windows volume names in
$PATH
- Fix the use of
2.6.3 - 2019-01-19
- expand
- Support globs with path prefixes and suffixes, like
./foo/*/ - Don't error when skipping non-directories in glob walks
- Support globs with path prefixes and suffixes, like
2.6.2 - 2018-12-08
- syntax
- Avoid premature reads in
Parser.Interactivewhen parsing Unicode bytes - Fix parsing of certain Bash test expression involving newlines
Redirect.Endnow takes theHdocfield into accountValidNamenow returnsfalsefor an empty string
- Avoid premature reads in
- expand
- Environment variables on Windows are case insensitive again
- interp
- Don't crash on
declare $unset=foo - Fix a regression where executed programs would receive a broken environment
- Don't crash on
Note that the published Docker image was changed to set shfmt as the
entrypoint, so previous uses with arguments like docker run mvdan/shfmt:v2.6.1 shfmt --version should now be docker run mvdan/shfmt:v2.6.2 --version.
2.6.1 - 2018-11-17
- syntax
- Fix
Parser.Incompletewith some incomplete literals - Fix parsing of Bash regex tests in some edge cases
- Fix
- interp
- Add support for
$(<file)special command substitutions
- Add support for
2.6.0 - 2018-11-10
This is the biggest v2 release to date. It's now possible to write an interactive shell, and it's easier and safer to perform shell expansions.
This will be the last major v2 version, to allow converting the project to a Go module in v3.
- Go 1.10 or later required to build
- syntax
- Add
Parser.Interactiveto implement an interactive shell - Add
Parser.Documentto parse a single here-document body - Add
Parser.Wordsto incrementally parse separate words - Add the
Word.Lithelper method - Support custom indentation in
<<-heredoc bodies
- Add
- interp
- Stabilize API and add some examples
- Introduce a constructor, and redesign
Runner.Reset - Move the context from a field to function parameters
- Remove
Runner.Stmtin favor ofRunwithShellExitStatus
- shell
- Stabilize API and add some examples
- Add
Expand, as a more powerfulos.Expand - Add
Fields, similar to the oldRunner.Fields Source*functions now take a contextSource*functions no longer try to sandbox
- expand
- New package, split from
interp - Allows performing shell expansions in a controlled way
- Redesigned
EnvironandVariablemoved frominterp
- New package, split from
2.5.1 - 2018-08-03
- syntax
- Fix a regression where semicolons would disappear within switch cases
2.5.0 - 2018-07-13
- syntax
- Add support for Bash's
{varname}<redirects - Add
SpaceRedirectsto format redirects like> word - Parse
$\"correctly within double quotes - A few fixes where minification would break programs
- Printing of heredocs within
<()no longer breaks them - Printing of single statements no longer adds empty lines
- Error on invalid parameter names like
${1a}
- Add support for Bash's
- interp
Runner.Diris now always an absolute path
- shell
Expandnow supports expanding a lone~ExpandandSourceNodenow have default timeouts
- cmd/shfmt
- Add
-srto print spaces after redirect operators - Don't skip empty string values in
-tojson - Include comment positions in
-tojson
- Add
2.4.0 - 2018-05-16
- Publish as a JS package, mvdan-sh
- syntax
- Add
DebugPrintto pretty-print a syntax tree - Fix comment parsing and printing in some edge cases
- Indent
<<-heredoc bodies if indenting with tabs - Add support for nested backquotes
- Relax parser to allow quotes in arithmetic expressions
- Don't rewrite
declare foo=intodeclare foo
- Add
- interp
- Add support for
shopt -s globstar - Replace
Runner.Envwith an interface
- Add support for
- shell
- Add
Expandas a fully featured version ofos.Expand
- Add
- cmd/shfmt
- Set appropriate exit status when
-dis used
- Set appropriate exit status when
2.3.0 - 2018-03-07
- syntax
- Case clause patterns are no longer forced on a single line
- Add
ExpandBraces, to perform Bash brace expansion on words - Improve the handling of backslashes within backquotes
- Improve the parsing of Bash test regexes
- interp
- Support
$DIRSTACK,${param[@]#word}, and${param,word}
- Support
- cmd/shfmt
- Add
-d, to display diffs when formatting differs - Promote
-exp.tojsonto-tojson - Add
PosandEndfields to nodes in-tojson - Inline
StmtListfields to simplify the-tojsonoutput - Support
-lon standard input
- Add
2.2.1 - 2018-01-25
- syntax
- Don't error on
${1:-default} - Allow single quotes in
${x['str key']}as well as double quotes - Add support for
${!foo[@]} - Don't simplify
foo[$x]tofoo[x], to not break string indexes - Fix
Stmt.Endwhen the end token is the background operator& - Never apply the negation operator
!to&&and||lists - Apply the background operator
&to entire&&and||lists - Fix
StopAtwhen the stop string is at the beginning of the source - In
N>word, check thatNis a valid numeric literal - Fix a couple of crashers found via fuzzing
- Don't error on
- cmd/shfmt
- Don't error if non-bash files can't be written to
2.2.0 - 2018-01-18
- Tests on Mac and Windows are now ran as part of CI
- syntax
- Add
StopAtto stop lexing at a custom arbitrary token - Add
TranslatePatternandQuotePatternfor pattern matching - Minification support added to the printer - see
Minify - Add ParamExp.Names to represent
${!prefix*} - Add TimeClause.PosixFormat for its
-pflag - Fix parsing of assignment values containing
= - Fix parsing of parameter expansions followed by a backslash
- Fix quotes in parameter expansion operators like
${v:-'def'} - Fix parsing of negated declare attributes like
declare +x name - Fix parsing of
${#@} - Reject bad parameter expansion operators like
${v@WRONG} - Reject inline array variables like
a=(b c) prog - Reject indexing of special vars like
${1[3]} - Reject
${!name}when in POSIX mode - Reject multiple parameter expansion actions like
${#v:-def}
- Add
- interp
- Add Bash brace expansion support, including
{a,b}and{x..y} - Pattern matching actions are more correct and precise
- Exported some Runner internals, including
VarsandFuncs - Use the interpreter's
$PATHto find binaries - Roll our own globbing to use our own pattern matching code
- Support the
getoptssh builtin - Support the
readbash builtin - Numerous changes to improve Windows support
- Add Bash brace expansion support, including
- shell
- New experimental package with high-level utility functions
- Add
SourceFileto get the variables declared in a script - Add
SourceNodeas a lower-level version of the above
- cmd/shfmt
- Add
-mn, which minifies programs viasyntax.Minify
- Add
2.1.0 - 2017-11-25
- syntax
- Add
Stmts, to parse one statement at a time - Walk no longer ignores comments
- Parameter expansion end fixes, such as
$foo.bar - Whitespace alignment can now be kept - see
KeepPadding - Introduce an internal newline token to simplify the parser
- Fix
Block.Posto actually return the start position - Fix mishandling of inline comments in two edge cases
- Add
- interp
- Expose
Fieldsto expand words into strings - First configurable modules - cmds and files
- Add support for the new
TimeClause - Add support for namerefs and readonly vars
- Add support for associative arrays (maps)
- More sh builtins:
exec return - More bash builtins:
command pushd popd dirs - More
testoperators:-b -c -t -o - Configurable kill handling - see
KillTimeout
- Expose
- cmd/shfmt
- Add
-fto just list all the shell files found - Add
-kpto keep the column offsets in place
- Add
- cmd/gosh
- Now supports a basic interactive mode
2.0.0 - 2017-08-30
- The package import paths were moved to
mvdan.cc/sh/... - syntax
- Parser and Printer structs introduced with functional options
- Node positions are now independent -
Positionmerged intoPos - All comments are now attached to nodes
- Support
mksh- MirBSD's Korn Shell, used in Android - Various changes to the AST:
EvalClauseremoved;evalis no longer parsed as a keyword- Add support for Bash's
timeandselect - Merge
UntilClauseintoWhileClause - Moved
Stmt.AssignstoCallExpr.Assigns - Remove
Elif- chainIfClausenodes instead
- Support for indexed assignments like
a[i]=b - Allow expansions in arithmetic expressions again
- Unclosed heredocs now produce an error
- Binary ops are kept in the same line - see
BinaryNextLine - Switch cases are not indented by default - see
SwitchCaseIndent
- cmd/shfmt
- Add
-s, which simplifies programs viasyntax.Simplify - Add
-ln <lang>, like-ln mksh - Add
-bnto put binary ops in the next line, like in v1 - Add
-cito indent switch cases, like in v1
- Add
- interp
- Some progress made, though still experimental
- Most of POSIX done - some builtins remain to be done
1.3.1 - 2017-05-26
- syntax
- Fix parsing of
${foo[$bar]} - Fix printer regression where
> >(foo)would be turned into>>(foo) - Break comment alignment on any line without a comment, fixing formatting issues
- Error on keywords like
fianddoneused as commands
- Fix parsing of
1.3.0 - 2017-04-24
- syntax
- Fix backslashes in backquote command substitutions
- Disallow some test expressions like
[[ a == ! b ]] - Disallow some parameter expansions like
${$foo} - Disallow some arithmetic expressions like
((1=3))and(($(echo 1 + 2))) - Binary commands like
&&,||and pipes are now left-associative
- fileutil
CouldBeScriptmay now return true on non-regular files such as symlinks
- interp
- New experimental package to interpret a
syntax.Filein pure Go
- New experimental package to interpret a
1.2.0 - 2017-02-22
- syntax
- Add support for escaped characters in bash regular expressions
- fileutil
- New package with some code moved from
cmd/shfmt, now importable - New funcs
HasShebangandCouldBeScript - Require shebangs to end with whitespace to reject
#!/bin/shfoo
- New package with some code moved from
1.1.0 - 2017-01-05
- syntax
- Parse
[[ a = b ]]like[[ a == b ]], deprecatingTsAssgnin favour ofTsEqual - Add support for the
-k,-G,-Oand-Nunary operators inside[[ ]] - Add proper support for
!in parameter expansions, like${!foo} - Fix a couple of crashes found via fuzzing
- Parse
- cmd/shfmt
- Rewrite
[[ a = b ]]into the saner[[ a == b ]](see above)
- Rewrite
1.0.0 - 2016-12-13
- syntax
- Stable release, API now frozen
Parsenow reads input in chunks of 1KiB
- cmd/shfmt
- Add
-versionflag
- Add
0.6.0 - 2016-12-05
- syntax
Parsenow takes anio.Readerinstead of[]byte- Invalid UTF-8 is now reported as an error
- Remove backtracking for
$((and(( Walknow takes a func literal to simplify its use
0.5.0 - 2016-11-24
- cmd/shfmt
- Remove
-cpuprofile - Don't read entire files into memory to check for a shebang
- Remove
- syntax
- Use
uint32for tokens and positions in nodes - Use
WordandLitpointers consistently instead of values - Ensure
Word.Partsis never empty - Add support for expressions in array indexing and parameter expansion slicing
- Use
0.4.0 - 2016-11-08
- Merge
parser,ast,tokenandprinterinto a single packagesyntax - Use separate operator types in nodes rather than
Token - Use operator value names that express their function
- Keep
;if on a separate line when formatting - cmd/shfmt
- Allow whitespace after
#!in a shebang
- Allow whitespace after
- syntax
- Implement operator precedence for
[[ ]] - Parse
$(foo)andfooas the same (shfmtthen converts the latter to the former) - Rename
QuotedtoDblQuotedfor clarity - Split
((foo))nodes as their own type,ArithmCmd - Add support for bash parameter expansion slicing
- Implement operator precedence for
0.3.0 - 2016-10-26
- Add support for bash's
coprocand extended globbing like@(foo) - Improve test coverage, adding tests to
cmd/shfmtand bringingparserandprinterclose to 100% - Support empty C-style for loops like
for ((;;)) ... - Support for the
>|redirect operand - cmd/shfmt
- Fix issue where
.shand.bashfiles might not be walked if running on a directory - Fix issue where
-pwas not obeyed when formatting stdin
- Fix issue where
- parser
$''now generates anast.SglQuoted, not anast.Quoted- Support for ambiguous
((like with$(( - Improve special parameter expansions like
$@or$! - Improve bash's
exporttypeset,namerefandreadonly <>,>&and<&are valid POSIX- Support for bash's
^,^^,,and,,operands inside${}
0.2.0 - 2016-10-13
- Optimizations all around, making
shfmt~15% faster - cmd/shfmt
- Add
-pflag to only accept POSIX Shell programs (parser.PosixConformant)
- Add
- parser
- Add support for ambiguous
$((as in$((foo) | bar) - Limit more bash features to
PosixConformantbeing false - Don't parse heredoc bodies in nested expansions and contexts
- Run tests through
bashto confirm the presence of a parse error
- Add support for ambiguous
- ast
- Add
Walk(Visitor, Node)function
- Add
0.1.0 - 2016-09-20
Initial release.