Check PIPESTATUS of each stage bash
Inspect exit code of every pipe stage; $? only reports the last command
curl -s "$url" | jq .data; echo "${PIPESTATUS[@]}"
more bash
all 12 commands →
getopts flag parsing
while getopts "n:v" o; do case $o in n) ns=$OPTARG;; v) verbose=1;; esac; done
Bound command with timeout and kill
timeout -k 5s 30s ./long_task.sh || echo "timed out: $?"
Dedicated fd for structured logging
exec 3>>audit.log; echo "$(date -Is) start" >&3; exec 3>&-
zsh recursive glob and batch rename
setopt extendedglob; print -l **/*(.); autoload zmv; zmv '(*).txt' '$1.bak'
Strict mode with safe IFS
set -euo pipefail; IFS=$'\n\t'