Tutorials
Welcome to the sh2 learning path! These hands-on guides will take you from writing your first script to building robust, verifiable CLI tools.
Source Code & Repository
👉 https://github.com/siu-mak/sh2lang
Recommended Learning Path
- Getting Started
- Summary: Write, compile, and run your first sh2 script and snippet.
- You’ll learn: Installation,
sh2c/sh2dobasics, and the “no implicit expansion” safety rule. - Prereqs: Basic terminal usage.
- Building a Real Tool
- Summary: Build a backup rotation tool with argument parsing and validation.
- You’ll learn:
argc()/arg(n),if/else, and basic file operations. - Prereqs: Getting Started.
- Error Handling & Status
- Summary: Master the “fail-fast” model and graceful error recovery.
- You’ll learn:
allow_fail=true, checkingstatus(), andtry/catchblocks. - Prereqs: Building a Real Tool.
- Files & Directories
- Summary: Safe file I/O and directory traversal without the quoting headaches.
- You’ll learn:
read_file,write_file, scopedcwd(...), and iteration. - Prereqs: Error Handling.
- Pipelines & Text Processing
- Summary: Structured pipelines and text manipulation.
- You’ll learn:
|operator,capture(...), andsplit/join/trim. - Prereqs: Files & Directories.
Advanced Topics
- CI & Automation: Running sh2 in GitHub Actions and other CI environments.
- Refactoring Bash: A step-by-step guide to converting legacy Bash scripts to sh2.
- Packaging: Distributing your sh2 tools to users.
Jump to Reference
- Language Reference — Full syntax and semantics.
- sh2do CLI — Snippet runner documentation.
Source Code & Repository
👉 https://github.com/siu-mak/sh2lang
👉 https://github.com/siu-mak/sh2lang