roddsrod/shell-scripting-rules icon
public
Published on 4/29/2025
roddsrod/shell-scripting-rules

Shell Scripting Rules

Rules

Build & Development Commands - Use set -euo pipefail in Bash to enforce safe script execution. - In PowerShell, add Set-StrictMode -Version Latest at the top of scripts.

Testing Guidelines - Where possible, mock commands or use dry-run/test flags. - Break long scripts into testable functions.

Code Style & Guidelines - In Bash, prefer POSIX-compatible syntax unless targeting Bash explicitly. - Comment complex command chains and conditionals. - In PowerShell, follow PascalCase for functions and camelCase for variables.

Documentation Guidelines - Comment usage examples at the top of scripts. - Mention platform requirements (e.g., Linux/macOS, PowerShell Core). - Prefer Markdown for longer documentation with code blocks and notes.