Articles
Deep dives into the design, features, and philosophy of sh2.
Source Code & Repository
👉 https://github.com/siu-mak/sh2lang
Introduction
Why sh2 exists and how it compares to other tools.
- Diff: sh2 vs Bash
- Side-by-side code comparisons showing how sh2 handles common tasks differently (and safer) than Bash.
- Bash One-Liners Ironed Out
- How sh2 transforms fragile shell idioms into robust, readable code.
- From One-Liner to Tool
- A walkthrough of growing a simple command into a full CLI tool.
- Where Bash Still Wins
- Honest assessment of when stick with pure Bash vs switching to sh2.
- The Mental Model
- How to think in sh2: separation of concerns, side-effect scoping, and data flow.
- Bash vs Python vs sh2
- Choosing the right tool for the job: glue code vs application logic.
Features
Detailed guides for specific language capabilities.
- sudo Builtin
- Using the structured
sudo(...)wrapper for safe privilege escalation.
- Using the structured
- confirm Helper
- Interactive prompts and CI/automation handling.
- No Implicit Expansion
- The core safety rule: why strings are strict literals.
- Named Arguments
- How sh2 uses named parameters for clarity and safety.
- Error Handling
- Fail-fast defaults,
allow_fail, andtry/catch.
- Fail-fast defaults,
- Logging & Redirects
- Scoped I/O redirection and structured logging.
Case Studies
Real-world examples and post-mortems.
- The Hidden Tax of Reviewing Bash
- Why reviewing shell scripts is hard and how structure helps.
- The Dollar Expansion Bug
- An analysis of a common shell bug prevented by sh2 design.
- Video Randomizer
- Building a fun, non-trivial tool with sh2.
Suggested Reading Routes
New to Shell Scripting
- Start with Tutorials: Getting Started.
- Read The Mental Model.
- Explore Error Handling.
Bash Power User
- Check Diff: sh2 vs Bash.
- Read Where Bash Still Wins.
- Deep dive into No Implicit Expansion.
- See The Hidden Tax of Reviewing Bash.
Script Maintainer / Reviewer
- Review The Hidden Tax of Reviewing Bash.
- Learn about Error Handling and Logging.
- See CI & Automation (Tutorial).
Source Code & Repository
👉 https://github.com/siu-mak/sh2lang
👉 https://github.com/siu-mak/sh2lang