Debian Codegraph @

CHANGELOG.md

raw
1 # Changelog
2
3 ## [3.14.1] - 2026-09-06
4
5 - **syntax**
6 - Fix the indentation of heredocs nested inside command substitutions - #1403
7 - Keep literal tabs in `<<-` heredoc bodies rather than replacing them with spaces
8 - Don't indent heredocs without dashes nested in `<<-` ones, whose output no longer parsed
9 - Zsh: don't drop the prefix in short forms like `$#"$foo"` and `$+"$foo"` - #1405
10 - **interp**
11 - Fix the build on 32-bit FreeBSD and NetBSD
12 - **expand**
13 - Don't let escaped characters such as `\*` act as glob metacharacters
14 - **pattern**
15 - Treat unclosed extended operator groups like `@(a` as literals, avoiding a panic
16
17 ## [3.14.0] - 2026-08-28
18
19 This release drops support for Go 1.25 and includes many enhancements,
20 particularly in the interpreter, which implements more shell features
21 and fixes many divergences from Bash.
22
23 - **cmd/shfmt**
24 - Add `--detect` to find shell files by executable bit or shebang - #944
25 - **syntax**
26 - Add `Preorder`, an iterator over all nodes, complementing `Walk`
27 - Add `encoding.TextUnmarshaler` implementations for each operator type
28 - Support `${ foo;}` and `${|foo;}` inside double quotes - #1368
29 - Support array elements in `{varname}` redirects, like `exec {fds[3]}>&-` - #719
30 - Backslashes inside backquotes within double quotes escape double quotes - #1083
31 - Allow pound signs in associative array keys like `${args[cmd,#]}` - #1285
32 - Don't treat `#` as the start of a comment inside `[[ ]]` tests - #1326
33 - Don't join `then` or `do` with a semicolon when heredocs are pending - #1047
34 - Print a space after `!` in arithmetic expressions, avoiding history expansion - #987
35 - Space nested closing parentheses like the opening ones - #876
36 - Make `SplitBraces` reject malformed sequences and skip backslash escapes - #1330
37 - Zsh: support the `${=name}`, `${~name}`, and `${^name}` prefixes - #1238
38 - Zsh: support the `;|` case terminator and leading parentheses for globs - #1293, #1279
39 - Zsh: parse subscript flag arguments as patterns, and allow `[` globs in arrays - #1278, #1322
40 - **syntax/typedjson**
41 - Encode operators as their syntax form, such as `">>"`, rather than integers - #1321
42 - Return errors rather than panicking on malformed input
43 - **interp**
44 - Add `BashOpts` to set Bash options like `shopt` - #962
45 - Add `AccessHandler` to control file access checks, used by `-r` and `cd` - #1318
46 - Add `HandlerContext.LastExitStatus`, and provide a `HandlerContext` to stat handlers
47 - Implement the `help` and `times` builtins, as well as `$-` - #1398
48 - Implement the `;&` and `;;&` case terminators - #1391
49 - Implement the `-N` test operator, and make `-nt` and `-ot` follow POSIX - #1340
50 - Support sparse indexed arrays such as `a=([5]=x)` - #1373
51 - Run files as shell scripts when `exec` fails with `ENOEXEC` - #1065
52 - Support empty here-documents, and don't expand quoted ones - #1390
53 - Support `js/wasm`, where subprocesses and pipes are unavailable
54 - Keep the redirections applied by `exec` with no arguments
55 - Only fire the exit trap when the shell exits, rather than after every `Run`
56 - **expand**
57 - Add `BracesSeq` with a config and error reporting, deprecating `Braces`
58 - Add `Variable.Indexes` to describe sparse indexed arrays
59 - Support integer bases in arithmetic - #339
60 - Short-circuit the arithmetic `&&` and `||` operators - #1371
61 - Apply per-element operators to quoted array expansions like `"${a[@]%o}"` - #1081
62 - Make unquoted `${!arr[@]}` consistent with the quoted form - #672
63 - Fix many divergences from Bash in arithmetic, string, and brace expansions
64 - Reject unsupported Zsh syntax rather than panicking - #1363
65 - **pattern**
66 - Treat an unmatched `[` as a literal character, like Bash - #1372
67 - Fix panics and mismatches in bracket expressions, such as `[![:space:]]`
68 - **fileutil**
69 - Recognize `dash` shebangs as POSIX shell for `-ln=auto` - #1307
70
71 ## [3.13.1] - 2026-03-09
72
73 - **cmd/shfmt**
74 - Add support for `[[zsh]]` in EditorConfig files
75 - Detect the shell variant from filenames like `.zshrc` and `.bash_profile`
76 - Fix `--apply-ignore` when used with explicit args - #1310
77 - **syntax**
78 - Revert an accidental change to how array subscripts are formatted - #1314
79 - Never join `;;` with the previous line when formatting - #1289
80 - Fix a bug where `$1[foo]` was parsed as a subscript in Zsh - #1288
81 - Correctly parse `$!` in double quotes in Zsh - #1298
82 - Allow indexing into special parameters in Zsh - #1299
83 - Allow parameter expansions with empty names in Zsh - #1280
84 - **interp**
85 - Test against Bash 5.3 and fix three new discrepancies
86 - Fix a few bugs related to `nameref` variables
87 - Avoid panics when user input encounters unimplemented features
88
89 ## [3.13.0] - 2026-03-09
90
91 This release introduces support for [Zsh](https://www.zsh.org/)
92 in the parser and formatter, which was tracked in issue #120
93 alongside the label https://github.com/mvdan/sh/labels/zsh.
94 While support is not complete, it should be far enough for many use cases.
95
96 This release also drops support for Go 1.24 and includes many other enhancements:
97
98 - **cmd/shfmt**
99 - Exit with a non-zero status when `-l` prints any filenames
100 - `shfmt -version` is now derived from the git current tag, dropping the `-ldflags` workaround
101 - **syntax**
102 - New nodes types and node fields are introduced alongside `LangZsh`
103 - `LangVariant` is now a bitset, allowing the use of sets like "Bash-like"
104 - Add `InteractiveSeq` and `StmtsSeq` iterator methods for `Parser`
105 - Stop exposing the internal buffer in `Printer` via struct embedding
106 - Support the use of brace expansions like `declare {a,b}_c=value`
107 - Fix a bug where POSIX and Bash incorrectly allowed empty command lists
108 - **interp**
109 - Add support for `shopt -s dotglob` and `shopt -s extglob`
110 - Add support for simple uses of `!(expr)` extended glob patterns
111 - Support more builtin flags for `declare`, `type`, `read`
112 - Fix various bugs relating to nulls, errors, and arrays
113 - **expand**
114 - Add `Config.DotGlob` and `Config.ExtGlob` for the interpreter
115 - Add `Variable.Flags` to get the one-character `declare` flags
116 - Do not force env vars on Windows to be uppercase
117 - Fix various bugs relating to glob pattern matching
118 - **pattern**
119 - Add `GlobLeadingDot` and `ExtendedOperators` for the interpreter
120 - Add `NegExtGlobError` to mark the use of `!(expr)` negation patterns
121
122 ## [3.12.0] - 2025-07-06
123
124 - The `mvdan-sh` JS package is discontinued in favor of `sh-syntax` - #1145
125 - **cmd/shfmt**
126 - Support the "simplify" and "minify" flags via EditorConfig - #819
127 - Do not allow `--write` to replace non-regular files - #843
128 - **interp**
129 - Add `IsBuiltin` to check if a command name is a shell built-in - #1164
130 - Add `HandlerContext.Builtin` to allow `ExecHandlerFunc` to call built-ins
131 - Initial support for `$!` and `wait PID` - #221
132 - Return non-fatal `ExecHandlerFunc` errors via the `Runner.Run` API
133 - Add `HandlerContext.Pos` to provide handlers with source positions
134 - Deprecate `NewExitStatus` and `IsExitStatus` in favor of `ExitStatus`
135 - Fix `wait` to always return the status of the last given job
136 - Copy all env vars for background subshells to avoid data races
137 - Support reading random numbers via `$RANDOM` and `$SRANDOM`
138 - Set `$BASH_REMATCH` when matching regular expressions via `=~`
139 - Support modifying local vars from the parent calling function
140 - **expand**
141 - Adjust which backslash sequences are expanded in here-docs - #1138
142 - Tweak tilde expansions to match Bash semantics
143 - **pattern**
144 - Remove the flawed and broken `Braces` mode; use `syntax.SplitBraces` instead
145 - Tweak `**` to only act as "globstar" when alone as a path element - #1149
146 - Tweak `*` and `**` to not match leading dots in basenames
147 - Add a `NoGlobStar` mode to match the POSIX semantics
148 - **fileutil**
149 - Treat all non-regular files as definitely not shell scripts - #1089
150
151 ## [3.11.0] - 2025-03-05
152
153 This release drops support for Go 1.22 and includes many enhancements.
154
155 - **cmd/shfmt**
156 - Support `-l=0` and `-f=0` to split filenames with null bytes - #1096
157 - **syntax**
158 - New iterator API: `Parser.WordsSeq`
159 - Fix `Parser.Incomplete` and `IsIncomplete` to work well with `Parser.Words` - #937
160 - Initial support for parsing incomplete shell via `RecoverErrors`
161 - Expand `LangError` to include which language was used when parsing
162 - **interp**
163 - Refactor setting variables to fix array declaration edge cases - #1108
164 - Fix `test` read/write/exec operators to work correctly on directories - #1116
165 - Replace the `cancelreader` dependency with `os.File.SetReadDeadline`
166 - Avoid waiting for process substitutions, matching Bash
167 - Skip `OpenHandler` when opening named pipes for process substitutions - #1120
168 - Use `TMPDIR` if set via `Env` to create temporary files such as named pipes
169 - **expand**
170 - New iterator API: `FieldsSeq`
171 - Correctly handle repeated backslashes in double quotes - #1106
172 - Don't expand backslashes inside here-documents - #1070
173 - Replace the `Unset` kind with a new `Variable.Set` boolean field
174
175 ## [3.10.0] - 2024-10-20
176
177 - **cmd/shfmt**
178 - Report the correct language variant in parser error messages - #1102
179 - Move `--filename` out of the parser options category - #1079
180 - **syntax**
181 - Parse all CRLF line endings as LF, including inside heredocs - #1088
182 - Count skipped backslashes inside backticks in position column numbers - #1098
183 - Count skipped null bytes in position column numbers for consistency
184 - **interp**
185 - Fix a regression in `v3.9.0` which broke redirecting files to stdin - #1099
186 - Fix a regression in `v3.9.0` where `HandlerContext.Stdin` was never nil
187 - Add an `Interactive` option to be used by interactive shells - #1100
188 - Support closing stdin, stdout, and stderr via redirections like `<&-`
189
190 ## [3.9.0] - 2024-08-16
191
192 This release drops support for Go 1.21 and includes many fixes.
193
194 - **cmd/shfmt**
195 - Switch the diff implementation to remove one dependency
196 - **syntax**
197 - Protect against overflows in position offset integers
198 - **interp**
199 - Use `os.Pipe` for stdin to prevent draining by subprocesses - #1085
200 - Support cancelling reads in builtins when stdin is a file - #1066
201 - Support the `nocaseglob` bash option - #1073
202 - Support the Bash 5.2 `@k` parameter expansion operator
203 - Support the `test -O` and `test -G` operators on non-Windows - #1080
204 - Support the `read -s` builtin flag - #1063
205 - **expand**
206 - Add support for case insensitive globbing - #1073
207 - Don't panic when pattern words are nil - #1076
208
209 A special thanks to @theclapp for their contributors to this release!
210
211 ## [3.8.0] - 2024-02-11
212
213 This release drops support for Go 1.19 and 1.20 and includes many
214 features and bugfixes, such as improving EditorConfig support in `shfmt`.
215
216 - **cmd/shfmt**
217 - Support EditorConfig language sections such as `[[shell]]` - #664
218 - Add `--apply-ignore` for tools and editors - #1037
219 - **syntax**
220 - Allow formatting redirects before all command argumetnts - #942
221 - Support brace expansions with uppercase letters - #1042
222 - Unescape backquotes in single quotes within backquotes - #1041
223 - Better error when using `function` in POSIX mode - #993
224 - Better column numbers for escapes inside backquotes - #1028
225 - **interp**
226 - Support parentheses in classic test commands - #1036
227 - Determine access to a directory via `unix.Access` - #1033
228 - Support subshells with `FuncEnviron` as `Env` - #1043
229 - Add support for `fs.DirEntry` via `ReadDirHandler2`
230 - **expand**
231 - Add support for `fs.DirEntry` via `ReadDir2`
232 - Support zero-padding in brace expansions - #1042
233
234 ## [3.7.0] - 2023-06-18
235
236 - **syntax**
237 - Correctly parse `$foo#bar` as a single word - #1003
238 - Make `&>` redirect operators an error in POSIX mode - #991
239 - Avoid producing invalid shell when minifying some heredocs - #923
240 - Revert the simplification of `${foo:-}` into `${foo-}` - #970
241 - **interp**
242 - Add `ExecHandlers` to support layering multiple middlewares - #964
243 - Add initial support for the `select` clause - #969
244 - Support combining the `errexit` and `pipefail` options - #870
245 - Set `EUID` just like `UID` - #958
246 - Replace panics on unimplemented builtins with errors - #999
247 - Tweak build tags to support building for `js/wasm` - #983
248 - **syntax/typedjson**
249 - Avoid `reflect.Value.MethodByName` to reduce binary sizes - #961
250
251 ## [3.6.0] - 2022-12-11
252
253 This release drops support for Go 1.17 and includes many features and fixes.
254
255 - **cmd/shfmt**
256 - Implement `--from-json` as the reverse of `--to-json` - [#900]
257 - Improve the quality of the `--to-json` output - [#900]
258 - Provide detected language when erroring with `-ln=auto` - [#803]
259 - **syntax**
260 - Don't require peeking two bytes after `echo *` - [#835]
261 - Simplify `${name:-}` to the equivalent `${name-}` - [#849]
262 - Don't print trailing whitespaces on nested subshells - [#814]
263 - Don't print extra newlines in some case clauses - [#779]
264 - Don't indent comments preceding case clause items - [#917]
265 - Allow escaped newlines before unquoted words again - [#873]
266 - Parse a redirections edge case without spaces - [#879]
267 - Give a helpful error when `<<<` is used in POSIX mode - [#881]
268 - Forbid `${!foo*}` and `${!foo@}` in mksh mode - [#929]
269 - Batch allocations less aggressively in the parser
270 - **syntax/typedjson**
271 - Expose `--from-json` and `--to-json` as Go APIs - [#885]
272 - **expand**
273 - Improve support for expanding array keys and values - [#884]
274 - Don't panic on unsupported syntax nodes - [#841]
275 - Don't panic on division by zero - [#892]
276 - Properly expand unquoted parameters with spaces - [#886]
277 - Trim spaces when converting strings to integers - [#928]
278 - **interp**
279 - Add initial implementation for `mapfile` and `readarray` - [#863]
280 - Improve matching patterns against multiple lines - [#866]
281 - Support `%b` in the `printf` builtin - [#955]
282 - Display all Bash options in `shopt` - [#877]
283 - **pattern**
284 - Add `EntireString` to match the entire string using `^$` - [#866]
285
286 ## [3.5.1] - 2022-05-23
287
288 - **cmd/shfmt**
289 - Fix the Docker publishing script bug which broke 3.5.0 - [#860]
290 - **interp**
291 - Support multi-line strings when pattern matching in `[[` - [#861]
292 - Invalid glob words are no longer removed with `nullglob` - [#862]
293 - **pattern**
294 - `Regexp` now returns the typed error `SyntaxError` - [#862]
295
296 ## [3.5.0] - 2022-05-11
297
298 This release drops support for Go 1.16 and includes many new features.
299
300 - **cmd/shfmt**
301 - Switch to `-ln=auto` by default to detect the shell language
302 - Add support for long flags, like `--indent` for `-i`
303 - **syntax**
304 - Allow extglob wildcards as function names like `@() { ... }`
305 - Add support for heredocs surrounded by backquotes
306 - Add support for backquoted inline comments
307 - Add `NewPos` to create `Pos` values externally
308 - Support escaped newlines with CRLF line endings
309 - `Minify` no longer omits a leading shebang comment
310 - Avoid printing escaped newlines in non-quoted words
311 - Fix some printer edge cases where comments weren't properly spaced
312 - **fileutil**
313 - Add `Shebang` to extract the shell language from a `#!` line
314 - **expand**
315 - Reimplement globstar `**` globbing for correctness
316 - Replace `os.Stat` as the last direct use of the filesystem
317 - **interp**
318 - Add `CallHandler` to intercept all interpreted `CallExpr` nodes
319 - Add `ReadDirHandler` to intercept glob expansion filesystem reads
320 - Add `StatHandler` to intercept `os.Stat` and `os.Lstat` calls
321 - Always surface exit codes from command substitutions
322 - Add initial and incomplete support for `set -x`
323 - Add support for `cd -` as `cd "$OLDPWD"`
324 - Avoid panic on `set - args`
325
326 ## [3.4.3] - 2022-02-19
327
328 - **cmd/shfmt**
329 - New Docker `v3` tag to track the latest stable version
330 - Don't duplicate errors when walking directories
331 - **interp**
332 - Properly handle empty paths in the `test` builtin
333 - Allow unsetting global vars from inside a function again
334 - Use `%w` to wrap errors in `Dir`
335
336 ## [3.4.2] - 2021-12-24
337
338 - The tests no longer assume what locales are installed
339 - **interp**
340 - Keep `PATH` list separators OS-specific to fix a recent regression
341 - Avoid negative elapsed durations in the `time` builtin
342
343 ## [3.4.1] - 2021-11-23
344
345 - **syntax**
346 - Don't return an empty string on empty input to `Quote`
347 - **expand**
348 - Properly sort in `ListEnviron` to avoid common prefix issues
349 - **interp**
350 - `export` used in functions now affects the global scope
351 - Support looking for scripts in `$PATH` in `source`
352 - Properly slice arrays in parameter expansions
353
354 ## [3.4.0] - 2021-10-01
355
356 This release drops support for Go 1.15,
357 which allows the code to start benefitting from `io/fs`.
358
359 - **cmd/shfmt**
360 - Walks directories ~10% faster thanks to `filepath.WalkDir`
361 - **syntax**
362 - Add `Quote` to mirror `strconv.Quote` for shell syntax
363 - Skip null characters when parsing, just like Bash
364 - Rewrite fuzzers with Go 1.18's native fuzzing
365 - **fileutil**
366 - Add `CouldBeScript2` using `io/fs.DirEntry`
367 - **expand**
368 - Skip or stop at null characters, just like Bash
369 - **interp**
370 - Set `GID` just like `UID`
371 - Add support for `read -p`
372 - Add support for `pwd` flags
373 - Create random FIFOs for process substitutions more robustly
374 - Avoid leaking an open file when interpreting `$(<file)`
375
376 ## [3.3.1] - 2021-08-01
377
378 - **syntax**
379 - Don't convert `&` in a separate line into `;`
380 - Fix a `BinaryNextLine` edge case idempotency bug
381 - Never start printing a command with an escaped newline
382 - **interp**
383 - Support calling `Runner.Reset` before `Runner.Run`
384 - Obey `set -e` for failed redirections
385
386 ## [3.3.0] - 2021-05-17
387
388 - **cmd/shfmt**
389 - Document the `FORCE_COLOR` env var to always use colors in diffs
390 - **syntax**
391 - Add the printer `SingleLine` option to avoid printing newlines
392 - Positions now use more bits for line numbers than column numbers
393 - Test operators like `&&` and `||` no longer escape newlines
394 - Properly handle closing backquotes in a few edge cases
395 - Properly handle trailing escaped newlines in heredocs
396 - **interp**
397 - Redesigned variable scoping to fix a number of edge cases
398 - Refactor `set -o nounset` support to fix many edge cases
399 - Deprecate `LookPath` in favor of `LookPathDir`
400 - Array element words are now expanded correctly
401 - Add support for `trap` with error and exit signals
402 - Add support for `shopt -s nullglob`
403 - Add support for `type -p`
404
405 ## [3.2.4] - 2021-03-08
406
407 - **cmd/shfmt**
408 - Don't stop handling arguments when one results in a failure
409 - **expand**
410 - Don't panic when a backslash is followed by EOF
411
412 ## [3.2.2] - 2021-01-29
413
414 - **syntax**
415 - Avoid comment position panic in the printer
416
417 ## [3.2.1] - 2020-12-02
418
419 - **syntax**
420 - Fix an endless loop when parsing single quotes in parameter expansions
421 - Properly print assignments using escaped newlines
422 - Print inline heredoc comments in the right place
423 - **interp**
424 - Always expand `~` in Bash test expressions
425 - **expand**
426 - Don't panic on out of bounds array index expansions
427
428 ## [3.2.0] - 2020-10-29
429
430 - **cmd/shfmt**
431 - Add a man page via [scdoc](https://sr.ht/~sircmpwn/scdoc/); see [shfmt.1.scd](cmd/shfmt/shfmt.1.scd)
432 - Add `-filename` to give a name to standard input
433 - **syntax**
434 - Add initial support for [Bats](https://github.com/bats-core/bats-core)
435 - Protect line and column position numbers against overflows
436 - Rewrite arithmetic parsing to fix operator precedence
437 - Don't add parentheses to `function f {...}` declarations for ksh support
438 - `KeepPadding` now obeys extra indentation when using space indentation
439 - Properly tokenize `((` within test expressions
440 - Properly tokenize single quotes within parameter expansions
441 - Obey print options inside `<<-` heredocs
442 - Don't simplify indexed parameter expansions in arithmetic expressions
443 - Improve parsing errors for missing test expressions
444 - `LangVariant` now implements [flag.Value](https://pkg.go.dev/flag#Value)
445 - **interp**
446 - Avoid panic on C-style loops which omit expressions
447 - `$@` and `$*` always exist, so `"$@"` can expand to zero words
448
449 ## [3.1.2] - 2020-06-26
450
451 - **syntax**
452 - Fix brace indentation when using `FunctionNextLine`
453 - Support indirect parameter expansions with transformations
454 - Stop heredoc bodies only when the entire line matches
455 - **interp**
456 - Make the tests pass on 32-bit platforms
457
458 ## [3.1.1] - 2020-05-04
459
460 - **cmd/shfmt**
461 - Recognise `function_next_line` in EditorConfig files
462 - **syntax**
463 - Don't ignore escaped newlines at the end of heredoc bodies
464 - Improve support for parsing regexes in test expressions
465 - Count columns for `KeepPadding` in bytes, to better support unicode
466 - Never let `KeepPadding` add spaces right after indentation
467 - **interp**
468 - Hide unset variables when executing programs
469
470 ## [3.1.0] - 2020-04-07
471
472 - Redesigned Docker images, including buildx and an Alpine variant
473 - **cmd/shfmt**
474 - Replace source files atomically when possible
475 - Support `ignore = true` in an EditorConfig to skip directories
476 - Add `-fn` to place function opening braces on the next line
477 - Improve behavior of `-f` when given non-directories
478 - Docker images and `go get` installs now embed good version information
479 - **syntax**
480 - Add support for nested here-documents
481 - Allow parsing for loops with braces, present in mksh and Bash
482 - Expand `CaseClause` to describe its `in` token
483 - Allow empty lines in Bash arrays in the printer
484 - Support disabling `KeepPadding`
485 - Avoid mis-printing some programs involving `&`
486 - **interp**
487 - Add initial support for Bash process substitutions
488 - Add initial support for aliases
489 - Fix an edge case where the status code would not be reset
490 - The exit status code can now reflect being stopped by a signal
491 - `test -t` now uses the interpreter's stdin/stdout/stderr files
492 - **expand**
493 - Improve the interaction of `@` and `*` with quotes and `IFS`
494
495 ## [3.0.2] - 2020-02-22
496
497 - **syntax**
498 - Don't indent after escaped newlines in heredocs
499 - Don't parse `*[i]=x` as a valid assignment
500 - **interp**
501 - Prevent subshells from defining funcs in the parent shells
502 - **expand**
503 - Parameters to `Fields` no longer get braces expanded in-place
504
505 ## [3.0.1] - 2020-01-11
506
507 - **cmd/shfmt**
508 - Fix an edge case where walking directories could panic
509 - **syntax**
510 - Only do a trailing read in `Parser.Stmts` if we have open heredocs
511 - Ensure comments are never folded into heredocs
512 - Properly tokenize `)` after a `=~` test regexp
513 - Stop parsing a comment at an escaped newline
514 - **expand**
515 - `"$@"` now expands to zero fields when there are zero parameters
516
517 ## [3.0.0] - 2019-12-16
518
519 This is the first stable release as a proper module, now under
520 `mvdan.cc/sh/v3/...`. Go 1.12 or later is supported.
521
522 A large number of changes have been done since the last feature release a year
523 ago. All users are encouraged to update. Below are the major highlights.
524
525 - **cmd/shfmt**
526 - Support for [EditorConfig](https://editorconfig.org/) files
527 - Drop the dependency on `diff` for the `-d` flag, now using pure Go
528 - **syntax**
529 - Overhaul escaped newlines, now represented as `WordPart` positions
530 - Improve some operator type names, to consistently convey meaning
531 - Completely remove `StmtList`
532 - Redesign `IfClause`, making its "else" another `IfClause` node
533 - Redesign `DeclClause` to remove its broken `Opts` field
534 - Brace expression parsing is now done with a `BraceExp` word part
535 - Improve comment alignment in `Printer` via a post-process step
536 - Add support for the `~` bitwise negation operator
537 - Record the use of deprecated tokens in the syntax tree
538 - **interp**
539 - Improve the module API as "handlers", to reduce confusion with Go modules
540 - Split `LookPath` out of `ExecHandler` to allow custom behavior
541 - `Run` now returns `nil` instead of `ShellExitStatus(0)`
542 - `OpenDevImpls` is removed; see `ExampleOpenHandler` for an alternative
543 - **expand**
544 - Redesign `Variable` to reduce allocations
545 - Add support for more escape sequences
546 - Make `Config` a bit more powerful via `func` fields
547 - Rework brace expansion via the new `BraceExp` word part
548 - **pattern**
549 - New package for shell pattern matching, extracted from `syntax`
550 - Add support for multiple modes, including filenames and braces
551
552 Special thanks to Konstantin Kulikov for his contribution to this release.
553
554 ## [2.6.4] - 2019-03-10
555
556 - **syntax**
557 - Support array elements without values, like `declare -A x=([index]=)`
558 - Parse `for i; do ...` uniquely, as it's short for `for i in "$@"`
559 - Add missing error on unclosed nested backquotes
560 - **expand**
561 - Don't expand tildes twice, fixing `echo ~` on Windows
562 - **interp**
563 - Fix the use of `Params` as an option to `New`
564 - Support lowercase Windows volume names in `$PATH`
565
566 ## [2.6.3] - 2019-01-19
567
568 - **expand**
569 - Support globs with path prefixes and suffixes, like `./foo/*/`
570 - Don't error when skipping non-directories in glob walks
571
572 ## [2.6.2] - 2018-12-08
573
574 - **syntax**
575 - Avoid premature reads in `Parser.Interactive` when parsing Unicode bytes
576 - Fix parsing of certain Bash test expression involving newlines
577 - `Redirect.End` now takes the `Hdoc` field into account
578 - `ValidName` now returns `false` for an empty string
579 - **expand**
580 - Environment variables on Windows are case insensitive again
581 - **interp**
582 - Don't crash on `declare $unset=foo`
583 - Fix a regression where executed programs would receive a broken environment
584
585 Note that the published Docker image was changed to set `shfmt` as the
586 entrypoint, so previous uses with arguments like `docker run mvdan/shfmt:v2.6.1
587 shfmt --version` should now be `docker run mvdan/shfmt:v2.6.2 --version`.
588
589 ## [2.6.1] - 2018-11-17
590
591 - **syntax**
592 - Fix `Parser.Incomplete` with some incomplete literals
593 - Fix parsing of Bash regex tests in some edge cases
594 - **interp**
595 - Add support for `$(<file)` special command substitutions
596
597 ## [2.6.0] - 2018-11-10
598
599 This is the biggest v2 release to date. It's now possible to write an
600 interactive shell, and it's easier and safer to perform shell expansions.
601
602 This will be the last major v2 version, to allow converting the project to a Go
603 module in v3.
604
605 - Go 1.10 or later required to build
606 - **syntax**
607 - Add `Parser.Interactive` to implement an interactive shell
608 - Add `Parser.Document` to parse a single here-document body
609 - Add `Parser.Words` to incrementally parse separate words
610 - Add the `Word.Lit` helper method
611 - Support custom indentation in `<<-` heredoc bodies
612 - **interp**
613 - Stabilize API and add some examples
614 - Introduce a constructor, and redesign `Runner.Reset`
615 - Move the context from a field to function parameters
616 - Remove `Runner.Stmt` in favor of `Run` with `ShellExitStatus`
617 - **shell**
618 - Stabilize API and add some examples
619 - Add `Expand`, as a more powerful `os.Expand`
620 - Add `Fields`, similar to the old `Runner.Fields`
621 - `Source*` functions now take a context
622 - `Source*` functions no longer try to sandbox
623 - **expand**
624 - New package, split from `interp`
625 - Allows performing shell expansions in a controlled way
626 - Redesigned `Environ` and `Variable` moved from `interp`
627
628 ## [2.5.1] - 2018-08-03
629
630 - **syntax**
631 - Fix a regression where semicolons would disappear within switch cases
632
633 ## [2.5.0] - 2018-07-13
634
635 - **syntax**
636 - Add support for Bash's `{varname}<` redirects
637 - Add `SpaceRedirects` to format redirects like `> word`
638 - Parse `$\"` correctly within double quotes
639 - A few fixes where minification would break programs
640 - Printing of heredocs within `<()` no longer breaks them
641 - Printing of single statements no longer adds empty lines
642 - Error on invalid parameter names like `${1a}`
643 - **interp**
644 - `Runner.Dir` is now always an absolute path
645 - **shell**
646 - `Expand` now supports expanding a lone `~`
647 - `Expand` and `SourceNode` now have default timeouts
648 - **cmd/shfmt**
649 - Add `-sr` to print spaces after redirect operators
650 - Don't skip empty string values in `-tojson`
651 - Include comment positions in `-tojson`
652
653 ## [2.4.0] - 2018-05-16
654
655 - Publish as a JS package, [mvdan-sh](https://www.npmjs.com/package/mvdan-sh)
656 - **syntax**
657 - Add `DebugPrint` to pretty-print a syntax tree
658 - Fix comment parsing and printing in some edge cases
659 - Indent `<<-` heredoc bodies if indenting with tabs
660 - Add support for nested backquotes
661 - Relax parser to allow quotes in arithmetic expressions
662 - Don't rewrite `declare foo=` into `declare foo`
663 - **interp**
664 - Add support for `shopt -s globstar`
665 - Replace `Runner.Env` with an interface
666 - **shell**
667 - Add `Expand` as a fully featured version of `os.Expand`
668 - **cmd/shfmt**
669 - Set appropriate exit status when `-d` is used
670
671 ## [2.3.0] - 2018-03-07
672
673 - **syntax**
674 - Case clause patterns are no longer forced on a single line
675 - Add `ExpandBraces`, to perform Bash brace expansion on words
676 - Improve the handling of backslashes within backquotes
677 - Improve the parsing of Bash test regexes
678 - **interp**
679 - Support `$DIRSTACK`, `${param[@]#word}`, and `${param,word}`
680 - **cmd/shfmt**
681 - Add `-d`, to display diffs when formatting differs
682 - Promote `-exp.tojson` to `-tojson`
683 - Add `Pos` and `End` fields to nodes in `-tojson`
684 - Inline `StmtList` fields to simplify the `-tojson` output
685 - Support `-l` on standard input
686
687 ## [2.2.1] - 2018-01-25
688
689 - **syntax**
690 - Don't error on `${1:-default}`
691 - Allow single quotes in `${x['str key']}` as well as double quotes
692 - Add support for `${!foo[@]}`
693 - Don't simplify `foo[$x]` to `foo[x]`, to not break string indexes
694 - Fix `Stmt.End` when the end token is the background operator `&`
695 - Never apply the negation operator `!` to `&&` and `||` lists
696 - Apply the background operator `&` to entire `&&` and `||` lists
697 - Fix `StopAt` when the stop string is at the beginning of the source
698 - In `N>word`, check that `N` is a valid numeric literal
699 - Fix a couple of crashers found via fuzzing
700 - **cmd/shfmt**
701 - Don't error if non-bash files can't be written to
702
703 ## [2.2.0] - 2018-01-18
704
705 - Tests on Mac and Windows are now ran as part of CI
706 - **syntax**
707 - Add `StopAt` to stop lexing at a custom arbitrary token
708 - Add `TranslatePattern` and `QuotePattern` for pattern matching
709 - Minification support added to the printer - see `Minify`
710 - Add ParamExp.Names to represent `${!prefix*}`
711 - Add TimeClause.PosixFormat for its `-p` flag
712 - Fix parsing of assignment values containing `=`
713 - Fix parsing of parameter expansions followed by a backslash
714 - Fix quotes in parameter expansion operators like `${v:-'def'}`
715 - Fix parsing of negated declare attributes like `declare +x name`
716 - Fix parsing of `${#@}`
717 - Reject bad parameter expansion operators like `${v@WRONG}`
718 - Reject inline array variables like `a=(b c) prog`
719 - Reject indexing of special vars like `${1[3]}`
720 - Reject `${!name}` when in POSIX mode
721 - Reject multiple parameter expansion actions like `${#v:-def}`
722 - **interp**
723 - Add Bash brace expansion support, including `{a,b}` and `{x..y}`
724 - Pattern matching actions are more correct and precise
725 - Exported some Runner internals, including `Vars` and `Funcs`
726 - Use the interpreter's `$PATH` to find binaries
727 - Roll our own globbing to use our own pattern matching code
728 - Support the `getopts` sh builtin
729 - Support the `read` bash builtin
730 - Numerous changes to improve Windows support
731 - **shell**
732 - New experimental package with high-level utility functions
733 - Add `SourceFile` to get the variables declared in a script
734 - Add `SourceNode` as a lower-level version of the above
735 - **cmd/shfmt**
736 - Add `-mn`, which minifies programs via `syntax.Minify`
737
738 ## [2.1.0] - 2017-11-25
739
740 - **syntax**
741 - Add `Stmts`, to parse one statement at a time
742 - Walk no longer ignores comments
743 - Parameter expansion end fixes, such as `$foo.bar`
744 - Whitespace alignment can now be kept - see `KeepPadding`
745 - Introduce an internal newline token to simplify the parser
746 - Fix `Block.Pos` to actually return the start position
747 - Fix mishandling of inline comments in two edge cases
748 - **interp**
749 - Expose `Fields` to expand words into strings
750 - First configurable modules - cmds and files
751 - Add support for the new `TimeClause`
752 - Add support for namerefs and readonly vars
753 - Add support for associative arrays (maps)
754 - More sh builtins: `exec return`
755 - More bash builtins: `command pushd popd dirs`
756 - More `test` operators: `-b -c -t -o`
757 - Configurable kill handling - see `KillTimeout`
758 - **cmd/shfmt**
759 - Add `-f` to just list all the shell files found
760 - Add `-kp` to keep the column offsets in place
761 - **cmd/gosh**
762 - Now supports a basic interactive mode
763
764 ## [2.0.0] - 2017-08-30
765
766 - The package import paths were moved to `mvdan.cc/sh/...`
767 - **syntax**
768 - Parser and Printer structs introduced with functional options
769 - Node positions are now independent - `Position` merged into `Pos`
770 - All comments are now attached to nodes
771 - Support `mksh` - MirBSD's Korn Shell, used in Android
772 - Various changes to the AST:
773 - `EvalClause` removed; `eval` is no longer parsed as a keyword
774 - Add support for Bash's `time` and `select`
775 - Merge `UntilClause` into `WhileClause`
776 - Moved `Stmt.Assigns` to `CallExpr.Assigns`
777 - Remove `Elif` - chain `IfClause` nodes instead
778 - Support for indexed assignments like `a[i]=b`
779 - Allow expansions in arithmetic expressions again
780 - Unclosed heredocs now produce an error
781 - Binary ops are kept in the same line - see `BinaryNextLine`
782 - Switch cases are not indented by default - see `SwitchCaseIndent`
783 - **cmd/shfmt**
784 - Add `-s`, which simplifies programs via `syntax.Simplify`
785 - Add `-ln <lang>`, like `-ln mksh`
786 - Add `-bn` to put binary ops in the next line, like in v1
787 - Add `-ci` to indent switch cases, like in v1
788 - **interp**
789 - Some progress made, though still experimental
790 - Most of POSIX done - some builtins remain to be done
791
792 ## [1.3.1] - 2017-05-26
793
794 - **syntax**
795 - Fix parsing of `${foo[$bar]}`
796 - Fix printer regression where `> >(foo)` would be turned into `>>(foo)`
797 - Break comment alignment on any line without a comment, fixing formatting issues
798 - Error on keywords like `fi` and `done` used as commands
799
800 ## [1.3.0] - 2017-04-24
801
802 - **syntax**
803 - Fix backslashes in backquote command substitutions
804 - Disallow some test expressions like `[[ a == ! b ]]`
805 - Disallow some parameter expansions like `${$foo}`
806 - Disallow some arithmetic expressions like `((1=3))` and `(($(echo 1 + 2)))`
807 - Binary commands like `&&`, `||` and pipes are now left-associative
808 - **fileutil**
809 - `CouldBeScript` may now return true on non-regular files such as symlinks
810 - **interp**
811 - New experimental package to interpret a `syntax.File` in pure Go
812
813 ## [1.2.0] - 2017-02-22
814
815 - **syntax**
816 - Add support for escaped characters in bash regular expressions
817 - **fileutil**
818 - New package with some code moved from `cmd/shfmt`, now importable
819 - New funcs `HasShebang` and `CouldBeScript`
820 - Require shebangs to end with whitespace to reject `#!/bin/shfoo`
821
822 ## [1.1.0] - 2017-01-05
823
824 - **syntax**
825 - Parse `[[ a = b ]]` like `[[ a == b ]]`, deprecating `TsAssgn` in favour of `TsEqual`
826 - Add support for the `-k`, `-G`, `-O` and `-N` unary operators inside `[[ ]]`
827 - Add proper support for `!` in parameter expansions, like `${!foo}`
828 - Fix a couple of crashes found via fuzzing
829 - **cmd/shfmt**
830 - Rewrite `[[ a = b ]]` into the saner `[[ a == b ]]` (see above)
831
832 ## [1.0.0] - 2016-12-13
833
834 - **syntax**
835 - Stable release, API now frozen
836 - `Parse` now reads input in chunks of 1KiB
837 - **cmd/shfmt**
838 - Add `-version` flag
839
840 ## [0.6.0] - 2016-12-05
841
842 - **syntax**
843 - `Parse` now takes an `io.Reader` instead of `[]byte`
844 - Invalid UTF-8 is now reported as an error
845 - Remove backtracking for `$((` and `((`
846 - `Walk` now takes a func literal to simplify its use
847
848 ## [0.5.0] - 2016-11-24
849
850 - **cmd/shfmt**
851 - Remove `-cpuprofile`
852 - Don't read entire files into memory to check for a shebang
853 - **syntax**
854 - Use `uint32` for tokens and positions in nodes
855 - Use `Word` and `Lit` pointers consistently instead of values
856 - Ensure `Word.Parts` is never empty
857 - Add support for expressions in array indexing and parameter expansion slicing
858
859 ## [0.4.0] - 2016-11-08
860
861 - Merge `parser`, `ast`, `token` and `printer` into a single package `syntax`
862 - Use separate operator types in nodes rather than `Token`
863 - Use operator value names that express their function
864 - Keep `;` if on a separate line when formatting
865 - **cmd/shfmt**
866 - Allow whitespace after `#!` in a shebang
867 - **syntax**
868 - Implement operator precedence for `[[ ]]`
869 - Parse `$(foo)` and ``foo`` as the same (`shfmt` then converts the latter to the former)
870 - Rename `Quoted` to `DblQuoted` for clarity
871 - Split `((foo))` nodes as their own type, `ArithmCmd`
872 - Add support for bash parameter expansion slicing
873
874 ## [0.3.0] - 2016-10-26
875
876 - Add support for bash's `coproc` and extended globbing like `@(foo)`
877 - Improve test coverage, adding tests to `cmd/shfmt` and bringing `parser` and `printer` close to 100%
878 - Support empty C-style for loops like `for ((;;)) ...`
879 - Support for the `>|` redirect operand
880 - **cmd/shfmt**
881 - Fix issue where `.sh` and `.bash` files might not be walked if running on a directory
882 - Fix issue where `-p` was not obeyed when formatting stdin
883 - **parser**
884 - `$''` now generates an `ast.SglQuoted`, not an `ast.Quoted`
885 - Support for ambiguous `((` like with `$((`
886 - Improve special parameter expansions like `$@` or `$!`
887 - Improve bash's `export` `typeset`, `nameref` and `readonly`
888 - `<>`, `>&` and `<&` are valid POSIX
889 - Support for bash's `^`, `^^`, `,` and `,,` operands inside `${}`
890
891 ## [0.2.0] - 2016-10-13
892
893 - Optimizations all around, making `shfmt` ~15% faster
894 - **cmd/shfmt**
895 - Add `-p` flag to only accept POSIX Shell programs (`parser.PosixConformant`)
896 - **parser**
897 - Add support for ambiguous `$((` as in `$((foo) | bar)`
898 - Limit more bash features to `PosixConformant` being false
899 - Don't parse heredoc bodies in nested expansions and contexts
900 - Run tests through `bash` to confirm the presence of a parse error
901 - **ast**
902 - Add `Walk(Visitor, Node)` function
903
904 ## [0.1.0] - 2016-09-20
905
906 Initial release.
907
908 [3.14.1]: https://github.com/mvdan/sh/releases/tag/v3.14.1
909 [3.14.0]: https://github.com/mvdan/sh/releases/tag/v3.14.0
910 [3.13.1]: https://github.com/mvdan/sh/releases/tag/v3.13.1
911 [3.13.0]: https://github.com/mvdan/sh/releases/tag/v3.13.0
912 [3.12.0]: https://github.com/mvdan/sh/releases/tag/v3.12.0
913 [3.11.0]: https://github.com/mvdan/sh/releases/tag/v3.11.0
914 [3.10.0]: https://github.com/mvdan/sh/releases/tag/v3.10.0
915 [3.9.0]: https://github.com/mvdan/sh/releases/tag/v3.9.0
916 [3.8.0]: https://github.com/mvdan/sh/releases/tag/v3.8.0
917 [3.7.0]: https://github.com/mvdan/sh/releases/tag/v3.7.0
918
919 [3.6.0]: https://github.com/mvdan/sh/releases/tag/v3.6.0
920 [#779]: https://github.com/mvdan/sh/issues/779
921 [#803]: https://github.com/mvdan/sh/issues/803
922 [#814]: https://github.com/mvdan/sh/issues/814
923 [#835]: https://github.com/mvdan/sh/issues/835
924 [#841]: https://github.com/mvdan/sh/issues/841
925 [#849]: https://github.com/mvdan/sh/pull/849
926 [#863]: https://github.com/mvdan/sh/pull/863
927 [#866]: https://github.com/mvdan/sh/pull/866
928 [#873]: https://github.com/mvdan/sh/issues/873
929 [#877]: https://github.com/mvdan/sh/issues/877
930 [#879]: https://github.com/mvdan/sh/pull/879
931 [#881]: https://github.com/mvdan/sh/issues/881
932 [#884]: https://github.com/mvdan/sh/issues/884
933 [#885]: https://github.com/mvdan/sh/issues/885
934 [#886]: https://github.com/mvdan/sh/issues/886
935 [#892]: https://github.com/mvdan/sh/issues/892
936 [#900]: https://github.com/mvdan/sh/pull/900
937 [#917]: https://github.com/mvdan/sh/pull/917
938 [#928]: https://github.com/mvdan/sh/issues/928
939 [#929]: https://github.com/mvdan/sh/pull/929
940 [#955]: https://github.com/mvdan/sh/pull/955
941
942 [3.5.1]: https://github.com/mvdan/sh/releases/tag/v3.5.1
943 [#860]: https://github.com/mvdan/sh/issues/860
944 [#861]: https://github.com/mvdan/sh/pull/861
945 [#862]: https://github.com/mvdan/sh/pull/862
946
947 [3.5.0]: https://github.com/mvdan/sh/releases/tag/v3.5.0
948 [3.4.3]: https://github.com/mvdan/sh/releases/tag/v3.4.3
949 [3.4.2]: https://github.com/mvdan/sh/releases/tag/v3.4.2
950 [3.4.1]: https://github.com/mvdan/sh/releases/tag/v3.4.1
951 [3.4.0]: https://github.com/mvdan/sh/releases/tag/v3.4.0
952 [3.3.1]: https://github.com/mvdan/sh/releases/tag/v3.3.1
953 [3.3.0]: https://github.com/mvdan/sh/releases/tag/v3.3.0
954 [3.2.4]: https://github.com/mvdan/sh/releases/tag/v3.2.4
955 [3.2.2]: https://github.com/mvdan/sh/releases/tag/v3.2.2
956 [3.2.1]: https://github.com/mvdan/sh/releases/tag/v3.2.1
957 [3.2.0]: https://github.com/mvdan/sh/releases/tag/v3.2.0
958 [3.1.2]: https://github.com/mvdan/sh/releases/tag/v3.1.2
959 [3.1.1]: https://github.com/mvdan/sh/releases/tag/v3.1.1
960 [3.1.0]: https://github.com/mvdan/sh/releases/tag/v3.1.0
961 [3.0.2]: https://github.com/mvdan/sh/releases/tag/v3.0.2
962 [3.0.1]: https://github.com/mvdan/sh/releases/tag/v3.0.1
963 [3.0.0]: https://github.com/mvdan/sh/releases/tag/v3.0.0
964 [2.6.4]: https://github.com/mvdan/sh/releases/tag/v2.6.4
965 [2.6.3]: https://github.com/mvdan/sh/releases/tag/v2.6.3
966 [2.6.2]: https://github.com/mvdan/sh/releases/tag/v2.6.2
967 [2.6.1]: https://github.com/mvdan/sh/releases/tag/v2.6.1
968 [2.6.0]: https://github.com/mvdan/sh/releases/tag/v2.6.0
969 [2.5.1]: https://github.com/mvdan/sh/releases/tag/v2.5.1
970 [2.5.0]: https://github.com/mvdan/sh/releases/tag/v2.5.0
971 [2.4.0]: https://github.com/mvdan/sh/releases/tag/v2.4.0
972 [2.3.0]: https://github.com/mvdan/sh/releases/tag/v2.3.0
973 [2.2.1]: https://github.com/mvdan/sh/releases/tag/v2.2.1
974 [2.2.0]: https://github.com/mvdan/sh/releases/tag/v2.2.0
975 [2.1.0]: https://github.com/mvdan/sh/releases/tag/v2.1.0
976 [2.0.0]: https://github.com/mvdan/sh/releases/tag/v2.0.0
977 [1.3.1]: https://github.com/mvdan/sh/releases/tag/v1.3.1
978 [1.3.0]: https://github.com/mvdan/sh/releases/tag/v1.3.0
979 [1.2.0]: https://github.com/mvdan/sh/releases/tag/v1.2.0
980 [1.1.0]: https://github.com/mvdan/sh/releases/tag/v1.1.0
981 [1.0.0]: https://github.com/mvdan/sh/releases/tag/v1.0.0
982 [0.6.0]: https://github.com/mvdan/sh/releases/tag/v0.6.0
983 [0.5.0]: https://github.com/mvdan/sh/releases/tag/v0.5.0
984 [0.4.0]: https://github.com/mvdan/sh/releases/tag/v0.4.0
985 [0.3.0]: https://github.com/mvdan/sh/releases/tag/v0.3.0
986 [0.2.0]: https://github.com/mvdan/sh/releases/tag/v0.2.0
987 [0.1.0]: https://github.com/mvdan/sh/releases/tag/v0.1.0