bash-scripting

Featured

Use when writing or hardening a shell script that must survive another machine — a CI step, install script, cron job, git hook, devcontainer entrypoint: strict-mode leaks, quoting/word-splitting, arrays, trap cleanup, bash-vs-POSIX portability, ShellCheck findings. NOT CI workflow structure, runners, caching or matrix (that is `github-actions`).

AI & Automation 116 stars 9 forks Updated 2 days ago MIT

Install

View on GitHub

Quality Score: 92/100

Stars 20%
69
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

# Bash scripting — scripts that survive a stranger's machine You are the shell author who has been burned: by an unquoted `"$@"` that exploded a path with spaces, by `rm -rf "$DIR/"` where `$DIR` was empty, by a `trap` that fired twice, by a `set -e` that swore it caught errors and didn't. Write every script as if it will run in CI, in a container, and on a 2014 Mac with `bash 3.2` — because eventually it will. The first decision is not a line of code. It is: **which shell am I targeting?** That choice decides what you are allowed to write. Make it before the shebang. ## The header you start every bash script with ```bash #!/usr/bin/env bash set -euo pipefail # see "Strict mode, honestly" — this is a baseline, not a force field IFS=$'\n\t' # split words on newline/tab only, never on spaces ``` - `#!/usr/bin/env bash` — find bash on `PATH`; do not hardcode `/bin/bash`, which is **3.2** on macOS and may not exist on some images. - `set -e` — exit on an uncaught non-zero command. Leaky (below), still worth having. - `set -u` — error on an unset variable, so a typo'd `$OUPUT` fails loud instead of expanding to empty. - `set -o pipefail` — a pipeline fails if **any** stage fails, not just the last. Bashism — not in POSIX `sh`. - `IFS=$'\n\t'` — stops the classic "unquoted expansion splits on every space" bug at the source. ## Pick your shell first `set -o pipefail`, arrays, `[[ ]]`, and `local` are **bashisms**. If your shebang is `#!/bin/sh` you may not...

Details

Author
ericrisco
Repository
ericrisco/rsc-harness
Created
3 months ago
Last Updated
2 days ago
Language
JavaScript
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category

AI & Automation Solid

linux-bash-scripting

Defensive Bash scripting for Linux: safe foundations, argument parsing, production patterns, ShellCheck compliance. Use when writing bash scripts, shell scripts, cron jobs, or CLI tools in bash.

39 Updated 4 weeks ago
iliaal
DevOps & Infrastructure Solid

ia-linux-bash-scripting

Defensive Bash scripting for Linux: safe foundations, argument parsing, production patterns, ShellCheck compliance. Use when writing bash scripts, shell scripts, cron jobs, or CLI tools in bash.

35 Updated yesterday
iliaal
AI & Automation Listed

sota-shell-scripting

State-of-the-art shell scripting (bash and PowerShell, defensive) for writing and auditing shell scripts, CI scripts, init/deploy scripts, container entrypoints, and Makefile recipes — and equally for the ad-hoc commands you run yourself: a grep/find/rg sweep whose result you are about to report, a one-liner pasted from a checklist, a pipeline whose exit status or empty output you are about to believe. Use when creating, modifying, reviewing or hardening shell code, AND before trusting any conclusion a shell command produced — especially an ABSENCE ("no matches", "0 results"), which a quoting bug produces identically. Trigger keywords: bash, shell script, sh, zsh, shellcheck, shfmt, CI script, Makefile shell, entrypoint script, set -euo pipefail, dotfiles, install script, cron job, wrapper script, one-liner, command line, grep sweep, search the codebase, verify a claim, no matches found, empty output, exit status, word splitting, glob, PowerShell, pwsh, .ps1, Windows CI, ErrorActionPreference.

23 Updated today
martinholovsky