[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-5135":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":18,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":22,"hasPages":22,"topics":24,"createdAt":10,"pushedAt":10,"updatedAt":36,"readmeContent":37,"aiSummary":38,"trendingCount":16,"starSnapshotCount":16,"syncStatus":39,"lastSyncTime":40,"discoverSource":41},5135,"sh","mvdan\u002Fsh","mvdan","A shell parser, formatter, and interpreter with bash and zsh support; includes shfmt","https:\u002F\u002Fpkg.go.dev\u002Fmvdan.cc\u002Fsh\u002Fv3",null,"Go",8809,412,55,102,0,3,15,79,38.85,"BSD 3-Clause \"New\" or \"Revised\" License",false,"master",[25,26,27,28,29,30,31,32,33,34,35],"bash","beautify","formatter","go","interpreter","mksh","parser","posix","shell","shfmt","zsh","2026-06-12 02:01:08","# sh\n\n[![Go Reference](https:\u002F\u002Fpkg.go.dev\u002Fbadge\u002Fmvdan.cc\u002Fsh\u002Fv3.svg)](https:\u002F\u002Fpkg.go.dev\u002Fmvdan.cc\u002Fsh\u002Fv3)\n\nA shell parser, formatter, and interpreter.\nSupports [POSIX Shell], [Bash], [Zsh], and [mksh]. Requires Go 1.25 or later.\n\n### Quick start\n\nTo parse shell scripts, inspect them, and print them out,\nsee the [syntax package](https:\u002F\u002Fpkg.go.dev\u002Fmvdan.cc\u002Fsh\u002Fv3\u002Fsyntax).\n\nFor high-level operations like performing shell expansions on strings,\nsee the [shell package](https:\u002F\u002Fpkg.go.dev\u002Fmvdan.cc\u002Fsh\u002Fv3\u002Fshell).\n\nTo interpret or run shell scripts,\nsee the [interp package](https:\u002F\u002Fpkg.go.dev\u002Fmvdan.cc\u002Fsh\u002Fv3\u002Finterp).\n\n### shfmt\n\n\tgo install mvdan.cc\u002Fsh\u002Fv3\u002Fcmd\u002Fshfmt@latest\n\n`shfmt` formats shell programs. See [canonical.sh](syntax\u002Fcanonical.sh) for a\nquick look at its default style. For example:\n\n\tshfmt -l -w script.sh\n\nFor more information, see [its manpage](cmd\u002Fshfmt\u002Fshfmt.1.scd), which can be\nviewed directly as Markdown or rendered with [scdoc].\n\nPackages are available on [Alpine], [Arch], [Debian], [Docker], [Fedora], [FreeBSD],\n[Homebrew], [MacPorts], [NixOS], [OpenSUSE], [Scoop], [Snapcraft], [Void] and [webi].\n\n### gosh\n\n\tgo install mvdan.cc\u002Fsh\u002Fv3\u002Fcmd\u002Fgosh@latest\n\nProof of concept shell that uses the `interp` package.\n\n### Fuzzing\n\nWe use Go's native fuzzing support. For instance:\n\n\tcd syntax\n\tgo test -run=- -fuzz=ParsePrint\n\n### Caveats\n\n* When indexing Bash associative arrays, always use quotes. The static parser\n  will otherwise have to assume that the index is an arithmetic expression.\n\n```sh\n$ echo '${array[spaced string]}' | shfmt\n\u003Cstandard input>:1:16: not a valid arithmetic operator: `string`\n$ echo '${array[weird!key]}' | shfmt\n\u003Cstandard input>:1:8: reached `!` without matching `[` with `]`\n$ echo '${array[dash-string]}' | shfmt\n${array[dash - string]}\n```\n\n* `$((` and `((` ambiguity is not supported. Backtracking would complicate the\n  parser and make streaming support via `io.Reader` impossible. The POSIX spec\n  recommends to [space the operands][posix-ambiguity] if `$( (` is meant.\n\n```sh\n$ echo '$((foo); (bar))' | shfmt\n1:1: reached ) without matching $(( with ))\n```\n\n* `export`, `let`, and `declare` are parsed as keywords.\n  This allows statically building their syntax tree,\n  as opposed to keeping the arguments as a slice of words.\n  It is also required to support `declare foo=(bar)`.\n\n* The entire library is written in pure Go, which limits how closely the\n  interpreter can follow POSIX Shell and Bash semantics.\n  For example, Go does not support forking its own process, so subshells\n  use a goroutine instead, meaning that real PIDs and file descriptors\n  cannot be used directly.\n\n### Formatting FAQs\n\n* The formatter cannot be disabled for ranges of lines; most users wanting this\n  are working around a bug or they don't like how a piece of code is formatted.\n  Instead, search the issue tracker and file a new issue if necessary.\n  Formatting of partial files leads to lots of edge cases and complexity\n  which this project has no resources for, nor interest in, getting into.\n\n* We avoid adding more formatting options where possible. Each added flag interacts\n  with all others, multiplying the human cost of development, maintenance, testing,\n  and properly documenting the behavior for end users.\n\n* The true value in a formatter is consistency, especially for teams of developers.\n  We do not aim to satisfy every developer's personal choice of optimal formatting.\n\n### JavaScript\n\nThe parser and formatter are available as a third party npm package called [sh-syntax],\nwhich bundles a version of this library compiled to WASM.\n\nPreviously, we maintained an npm package called [mvdan-sh] which used GopherJS\nto bundle a JS version of this library. That npm package is now archived\ngiven its poor performance and GopherJS not being as actively developed.\nAny existing or new users should look at [sh-syntax] instead.\n\n### Docker\n\nAll release tags are published via [Docker], such as `v3.5.1`.\nThe latest stable release is currently published as `v3`,\nand the latest development version as `latest`.\nThe images only include `shfmt`; `-alpine` variants exist on Alpine Linux.\n\nTo build a Docker image, run:\n\n\tdocker build -t my:tag -f cmd\u002Fshfmt\u002FDockerfile .\n\nTo use a Docker image, run:\n\n\tdocker run --rm -u \"$(id -u):$(id -g)\" -v \"$PWD:\u002Fmnt\" -w \u002Fmnt my:tag \u003Cshfmt arguments>\n\n### Related projects\n\nThe following editor integrations wrap `shfmt`:\n\n- [BashSupport-Pro] - Bash plugin for JetBrains IDEs\n- [dockerfmt] - Dockerfile formatter using shfmt\n- [intellij-shellscript] - Intellij Jetbrains `shell script` plugin\n- [micro] - Editor with a built-in plugin\n- [neoformat] - (Neo)Vim plugin\n- [shell-format] - VS Code plugin\n- [vscode-shfmt] - VS Code plugin\n- [shfmt.el] - Emacs package\n- [Sublime-Pretty-Shell] - Sublime Text 3 plugin\n- [Trunk] - Universal linter, available as a CLI, VS Code plugin, and GitHub action\n- [vim-shfmt] - Vim plugin\n\nOther noteworthy integrations include:\n\n- [modd] - A developer tool that responds to filesystem changes\n- [prettier-plugin-sh] - [Prettier] plugin using [sh-syntax]\n- [sh-checker] - A GitHub Action that performs static analysis for shell scripts\n- [mdformat-shfmt] - [mdformat] plugin to format shell scripts embedded in Markdown with shfmt\n- [pre-commit-shfmt] - [pre-commit] shfmt hook\n- [tesh] - Run scripts with mocks, assertions, and coverage\n\n[alpine]: https:\u002F\u002Fpkgs.alpinelinux.org\u002Fpackages?name=shfmt\n[arch]: https:\u002F\u002Farchlinux.org\u002Fpackages\u002Fextra\u002Fx86_64\u002Fshfmt\u002F\n[bash]: https:\u002F\u002Fwww.gnu.org\u002Fsoftware\u002Fbash\u002F\n[BashSupport-Pro]: https:\u002F\u002Fwww.bashsupport.com\u002Fmanual\u002Feditor\u002Fformatter\u002F\n[debian]: https:\u002F\u002Ftracker.debian.org\u002Fpkg\u002Fgolang-mvdan-sh\n[docker]: https:\u002F\u002Fhub.docker.com\u002Fr\u002Fmvdan\u002Fshfmt\u002F\n[dockerfmt]: https:\u002F\u002Fgithub.com\u002Freteps\u002Fdockerfmt\n[editorconfig]: https:\u002F\u002Feditorconfig.org\u002F\n[examples]: https:\u002F\u002Fpkg.go.dev\u002Fmvdan.cc\u002Fsh\u002Fv3\u002Fsyntax#pkg-examples\n[fedora]: https:\u002F\u002Fpackages.fedoraproject.org\u002Fpkgs\u002Fgolang-mvdan-sh-3\u002Fshfmt\u002F\n[freebsd]: https:\u002F\u002Fwww.freshports.org\u002Fdevel\u002Fshfmt\n[homebrew]: https:\u002F\u002Fformulae.brew.sh\u002Fformula\u002Fshfmt\n[intellij-shellscript]: https:\u002F\u002Fwww.jetbrains.com\u002Fhelp\u002Fidea\u002Fshell-scripts.html\n[macports]: https:\u002F\u002Fports.macports.org\u002Fport\u002Fshfmt\u002Fdetails\u002F\n[mdformat-shfmt]: https:\u002F\u002Fgithub.com\u002Fhukkin\u002Fmdformat-shfmt\n[mdformat]: https:\u002F\u002Fgithub.com\u002Fexecutablebooks\u002Fmdformat\n[micro]: https:\u002F\u002Fmicro-editor.github.io\u002F\n[mksh]: http:\u002F\u002Fwww.mirbsd.org\u002Fmksh.htm\n[modd]: https:\u002F\u002Fgithub.com\u002Fcortesi\u002Fmodd\n[mvdan-sh]: https:\u002F\u002Fwww.npmjs.com\u002Fpackage\u002Fmvdan-sh\n[neoformat]: https:\u002F\u002Fgithub.com\u002Fsbdchd\u002Fneoformat\n[nixos]: https:\u002F\u002Fgithub.com\u002FNixOS\u002Fnixpkgs\u002Fblob\u002FHEAD\u002Fpkgs\u002Ftools\u002Ftext\u002Fshfmt\u002Fdefault.nix\n[OpenSUSE]: https:\u002F\u002Fbuild.opensuse.org\u002Fpackage\u002Fshow\u002FopenSUSE:Factory\u002Fshfmt\n[posix shell]: https:\u002F\u002Fpubs.opengroup.org\u002Fonlinepubs\u002F9699919799\u002Futilities\u002FV3_chap02.html\n[posix-ambiguity]: https:\u002F\u002Fpubs.opengroup.org\u002Fonlinepubs\u002F9699919799\u002Futilities\u002FV3_chap02.html#tag_18_06_03\n[pre-commit]: https:\u002F\u002Fpre-commit.com\n[pre-commit-shfmt]: https:\u002F\u002Fgithub.com\u002Fscop\u002Fpre-commit-shfmt\n[prettier-plugin-sh]: https:\u002F\u002Fgithub.com\u002Fun-ts\u002Fprettier\u002Ftree\u002Fmaster\u002Fpackages\u002Fsh\n[prettier]: https:\u002F\u002Fprettier.io\n[scdoc]: https:\u002F\u002Fsr.ht\u002F~sircmpwn\u002Fscdoc\u002F\n[scoop]: https:\u002F\u002Fgithub.com\u002FScoopInstaller\u002FMain\u002Fblob\u002FHEAD\u002Fbucket\u002Fshfmt.json\n[sh-checker]: https:\u002F\u002Fgithub.com\u002Fluizm\u002Faction-sh-checker\n[sh-syntax]: https:\u002F\u002Fgithub.com\u002Fun-ts\u002Fsh-syntax\n[shell-format]: https:\u002F\u002Fmarketplace.visualstudio.com\u002Fitems?itemName=foxundermoon.shell-format\n[shfmt.el]: https:\u002F\u002Fgithub.com\u002Fpurcell\u002Femacs-shfmt\u002F\n[snapcraft]: https:\u002F\u002Fsnapcraft.io\u002Fshfmt\n[sublime-pretty-shell]: https:\u002F\u002Fgithub.com\u002Faerobounce\u002FSublime-Pretty-Shell\n[tesh]: https:\u002F\u002Fgithub.com\u002Ffeloy\u002Ftesh\n[trunk]: https:\u002F\u002Ftrunk.io\u002Fcheck\n[vim-shfmt]: https:\u002F\u002Fgithub.com\u002Fz0mbix\u002Fvim-shfmt\n[void]: https:\u002F\u002Fgithub.com\u002Fvoid-linux\u002Fvoid-packages\u002Fblob\u002FHEAD\u002Fsrcpkgs\u002Fshfmt\u002Ftemplate\n[vscode-shfmt]: https:\u002F\u002Fmarketplace.visualstudio.com\u002Fitems?itemName=mkhl.shfmt\n[webi]: https:\u002F\u002Fwebinstall.dev\u002Fshfmt\u002F\n[Zsh]: https:\u002F\u002Fwww.zsh.org\u002F\n","mvdan\u002Fsh 是一个支持 Bash 和 Zsh 的 Shell 解析器、格式化工具和解释器。该项目使用 Go 语言编写，提供了对 POSIX Shell、Bash、Zsh 和 mksh 的支持。其核心功能包括解析 Shell 脚本、执行字符串扩展、运行脚本以及通过 shfmt 工具进行代码格式化。此外，还包含了一个实验性的 gosh 命令行 shell。mvdan\u002Fsh 适用于需要处理和分析 Shell 脚本的开发场景，如自动化脚本维护、代码审查及提高脚本可读性等任务中。",2,"2026-06-11 03:02:42","top_language"]