Check if a Command Exists
Use `command -v` — portable, no subshell, returns nonzero if missing.
Author:
chris
// Language: Bash
#!/usr/bin/env bash
set -euo pipefail
need() {
command -v "$1" >/dev/null 2>&1 || {
printf 'missing required tool: %s\n' "$1" >&2
exit 1
}
}
need jq
need curl
need git