sh is a collection of tools and libraries for parsing, formatting and interpreting shell programs. It supports POSIX shell, Bash, Zsh and mksh syntax, providing reusable components for applications that need to understand or process shell commands.
The project is particularly useful for developers building editors, code analysis tools, formatters and automation systems. Its parser converts shell source into a structured syntax tree that can be inspected, modified or transformed programmatically. This allows applications to operate on shell language constructs rather than relying on fragile text matching.
The project includes shfmt, a command-line formatter for shell scripts. It can apply consistent indentation and layout rules, check formatting differences and rewrite files in place. These capabilities are useful for maintaining shell code across large repositories and development teams.
The interpreter library provides an environment for executing shell scripts without invoking a separate system shell. Applications can configure how external commands are handled, which environment variables are available and how file operations are performed.
The libraries also provide helpers for shell-style word expansion, quoting, argument splitting and pattern matching. These facilities can be incorporated into other applications requiring shell-like behaviour.
This is free and open source software.
Key Features
- Parses POSIX shell, Bash, Zsh and mksh syntax.
- Converts shell source code into structured syntax trees.
- Provides reusable APIs for inspecting and modifying parsed programs.
- Includes shfmt for formatting shell scripts.
- Supports configurable indentation and formatting rules.
- Checks whether source files follow a selected formatting style.
- Rewrites shell scripts using consistent layout conventions.
- Provides an interpreter library for executing shell programs.
- Allows applications to configure command execution handlers.
- Supports custom execution environments and filesystem interfaces.
- Provides shell-style variable and tilde expansion.
- Supports argument splitting and quoting helpers.
- Offers globbing and pattern matching utilities.
- Supports integration with editors and code analysis tools.
- Provides libraries usable independently of the formatter.
- Cross-platform support – runs on Linux, macOS, and Windows.
Website: github.com/mvdan/sh
Support:
Developer: Daniel Martà and contributors
License: BSD 3-Clause ‘New’ or ‘Revised’ License
sh is written in Go. Learn Go with our recommended free books and free tutorials.
Related Software
| Shells | |
|---|---|
| zsh | Advanced and programmable command interpreter |
| Nushell | Adopts the Unix philosophy of shells where pipes connect command together |
| fish | Smart and user-friendly command line shell |
| Xonsh | Python-powered, cross-platform shell language and command prompt |
| bash | sh-compatible command language interpreter |
| Murex | Intuitive, typed and content aware shell |
| PowerShell | Cross-platform automation and configuration framework |
| Elvsh | Expressive programming language and a versatile interactive shell |
| Oils | Billed as an upgrade to bash. Written in Python. |
| DASH | POSIX-compliant implementation of sh that aims to be as small as possible |
| sh | Shell parser, formatter, and interpreter |
| tcsh | C shell with file name completion and command line editing |
| mksh | MirBSD Korn shell |
| ksh | Unix shell which was developed by David Korn at Bell Labs |
| brush | POSIX- and bash compatible shell |
| Rash | Language, library, and shell REPL for Racket. |
| ion | Modern system shell that features a simple, yet powerful, syntax |
| Cicada | Bash-like command environment with scripting and job control |
| Yash | Yet another shell |
| oksh | Portable OpenBSD ks |
| es | Extensible shell with higher-order functio |
| dune | A shell by the beach |
| cosh | Concatenative command-line she |
| Marcel | Modern command environment combining Python with Unix pipelines |
| Hilbish | Highly extensible command environment configured with Lua |
| gsh | POSIX-compatible generative shell |
| arsh | Statically typed scripting language with shell-like features |
| Sushi shell | Bash clone shell implemented in Rust |
| loksh | Linux port of OpenBSD's Korn-compatible command interpreter |
| fortsh | Shell written in Fortran |
| hsh | Slightly different take on your shell |
| ReShell | Modern shell |
| rash | Rudimentary shell |
| Dax | Custom Unix shell implementation |
| cjsh | POSIX-oriented command environment with modern interactive features |
Read our verdict in the software roundup.
LinuxLinks helps you discover the best free and open source software for Linux. Explore our extensive collection of recommended applications, including alternatives to popular proprietary software.We also publish software reviews, Linux tutorials, hardware reviews, free programming books and articles covering the wider open source community. Browse our Linux resources to discover more. Know a useful free and open source Linux application we haven't covered? Suggest a program for inclusion. Has your software been featured on LinuxLinks? Display one of our Featured on LinuxLinks badges on your website or GitHub README. |


Please read our Comment Policy before commenting.