A Go library and toolset for parsing, formatting, and interpreting POSIX Shell, Bash, and Zsh scripts.
sh is a Go library and toolset for parsing, formatting, and interpreting shell scripts. It provides a robust parser that supports POSIX Shell, Bash, Zsh, and mksh, enabling developers to analyze and manipulate shell code programmatically. The project includes `shfmt`, a widely used formatter that ensures consistent code style, and an interpreter for running scripts within Go applications.
Developers and DevOps engineers who work extensively with shell scripts and need tools for static analysis, automated formatting, or embedding shell interpretation in Go applications. It's particularly useful for teams maintaining large codebases of shell scripts.
It offers a comprehensive, pure-Go solution for shell script processing, combining parsing, formatting, and interpretation in a single library. Unlike ad-hoc scripting or basic linters, it provides a structured AST and reliable formatting with multi-shell support, making shell code more maintainable and less error-prone.
A shell parser, formatter, and interpreter with bash and zsh support; includes shfmt
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Statically parses POSIX Shell, Bash, Zsh, and mksh into an abstract syntax tree, enabling detailed code analysis and manipulation.
Includes shfmt, which enforces a uniform code style across scripts, reducing manual formatting effort and improving team collaboration.
Pure Go implementation makes it portable and easy to embed in Go applications for parsing, formatting, or interpreting shell scripts.
Provides high-level operations for shell expansions via the shell package, useful for programmatic string manipulation.
Has known issues with Bash associative array indexing and $(( ambiguity, requiring workarounds or code adjustments.
Due to pure Go, subshells use goroutines instead of real processes, limiting compatibility with scripts relying on PIDs or file descriptors.
Cannot disable formatting for specific lines or blocks, and options are minimal, which may frustrate users with unique style preferences.