Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. Go
  3. sh

sh

BSD-3-ClauseGov3.13.1

A Go library and toolset for parsing, formatting, and interpreting POSIX Shell, Bash, and Zsh scripts.

Visit WebsiteGitHubGitHub
8.9k stars429 forks0 contributors

What is sh?

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.

Target Audience

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.

Value Proposition

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.

Overview

A shell parser, formatter, and interpreter with bash and zsh support; includes shfmt

Use Cases

Best For

  • Automatically formatting shell scripts to enforce team coding standards
  • Building static analysis tools for shell script codebases
  • Embedding a shell interpreter within a Go application
  • Programmatically manipulating or generating shell scripts
  • Integrating shell script formatting into CI/CD pipelines
  • Developing IDE plugins or editor integrations for shell languages

Not Ideal For

  • Systems requiring accurate process forking and PID management in shell interpretation
  • Teams that need customizable formatting options or exclusion of specific code blocks
  • Projects not written in Go that require a lightweight, native shell interpreter

Pros & Cons

Pros

Multi-Shell Parser

Statically parses POSIX Shell, Bash, Zsh, and mksh into an abstract syntax tree, enabling detailed code analysis and manipulation.

Consistent Formatter

Includes shfmt, which enforces a uniform code style across scripts, reducing manual formatting effort and improving team collaboration.

Go Integration

Pure Go implementation makes it portable and easy to embed in Go applications for parsing, formatting, or interpreting shell scripts.

Shell Expansions Support

Provides high-level operations for shell expansions via the shell package, useful for programmatic string manipulation.

Cons

Parser Edge Cases

Has known issues with Bash associative array indexing and $(( ambiguity, requiring workarounds or code adjustments.

Interpreter Limitations

Due to pure Go, subshells use goroutines instead of real processes, limiting compatibility with scripts relying on PIDs or file descriptors.

Formatter Rigidity

Cannot disable formatting for specific lines or blocks, and options are minimal, which may frustrate users with unique style preferences.

Frequently Asked Questions

Quick Stats

Stars8,917
Forks429
Contributors0
Open Issues99
Last commit1 day ago
CreatedSince 2016

Tags

#developer-tools#code-formatter#interpreter#shell-scripting#go-library#posix-shell#posix#shell#bash#mksh#go#cli-tools#parser#static-analysis#beautify#formatter#zsh

Built With

G
Go

Links & Resources

Website

Included in

Go169.1kShell36.8k
Auto-fetched 16 hours ago

Related Projects

the-art-of-command-linethe-art-of-command-line

Master the command line, in one page

Stars161,891
Forks14,829
Last commit2 years ago
shellcheckshellcheck

ShellCheck, a static analysis tool for shell scripts

Stars39,755
Forks1,938
Last commit1 month ago
bash-guidebash-guide

A guide to learn bash

Stars12,313
Forks1,041
Last commit1 year ago
bats-corebats-core

Bash Automated Testing System

Stars6,173
Forks485
Last commit1 day ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub