shell-scripting

Generate portable Bash/Zsh scripts with robust error handling and argument parsing.

327|85|Updated Mar 30, 2026
One-click install
npx skills add https://github.com/alibaba/anolisa --skill shell-scripting-alibaba
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: shell-scripting
Source: https://github.com/alibaba/anolisa/tree/main/src/os-skills/system-admin/shell-scripting
Command: npx skills add https://github.com/alibaba/anolisa --skill shell-scripting-alibaba

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Shell scripting is essential for automating repetitive CLI tasks, but many scripts lack portability, robust error handling, and safe patterns, leading to flaky automation and wasted time.

Core Features & Use Cases

  • Robust error handling: enforce safety with safe shell options, proper quoting, and guard clauses.
  • Portable argument parsing: design cross-shell argument parsers that work in Bash, Zsh, and POSIX shells.
  • Safe file operations: atomic writes, quoting, and predictable I/O to prevent data loss.
  • Use Case: rapidly scaffold a production-grade shell tool that processes input files, validates inputs, and reports clear exit codes.

Quick Start

Ask me to generate a robust, portable Bash or Zsh script with proper error handling and argument parsing.

Frequently Asked Questions about shell-scripting

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a portable shell script that works in both Bash and Zsh?

To write a portable shell script, use POSIX-compliant syntax and design cross-shell argument parsers that operate reliably in Bash, Zsh, and POSIX shells. This ensures your CLI automation executes predictably across different Linux environments.

What is the best way to add error handling to a bash script?

The best way to add error handling to a bash script is to enforce safe shell options like set -euo pipefail, apply proper quoting, and use guard clauses. This prevents flaky automation by immediately catching failures and reporting clear exit codes.

How do I safely perform file operations in a shell script?

To safely perform file operations in a shell script, use atomic writes, proper quoting, and predictable I/O patterns. These safe file operations prevent data loss and ensure reliable processing of input files across Linux environments.

Can I generate a production-grade shell tool that validates inputs and reports exit codes?

Yes, you can rapidly scaffold a production-grade shell tool that processes input files, validates inputs, and reports clear exit codes. It enforces best practices such as dependency checks and safe shell options for reliable CLI task automation.

Why does my shell script fail when moving from Bash to Zsh?

Your shell script fails when moving from Bash to Zsh due to non-portable syntax and inconsistent quoting. Generating portable scripts with cross-shell argument parsers and enforced safety options like set -euo pipefail resolves these compatibility issues.

Do I need to manually check for dependencies in my CLI script?

No, you do not need to manually check for dependencies because the generated scripts enforce dependency checks automatically. Applying safe shell options and guard clauses ensures your CLI script fails safely with clear exit codes if requirements are missing.