#!/usr/bin/env bash # Run shellcheck on verification scripts (optional — requires shellcheck to be installed). # Usage: bash scripts/verify/run-shellcheck.sh [--optional] # --optional: exit 0 if shellcheck not installed; and do not fail the run on findings (report only). # Install: apt install shellcheck (or brew install shellcheck) set -euo pipefail SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" cd "$SCRIPT_DIR" OPTIONAL=false [[ "${1:-}" == "--optional" ]] && OPTIONAL=true if ! command -v shellcheck &>/dev/null; then echo "shellcheck not found. Install with: apt install shellcheck (or brew install shellcheck)" [[ "$OPTIONAL" == true ]] && exit 0 || exit 1 fi echo "Running shellcheck on scripts/verify/*.sh..." if [[ "$OPTIONAL" == true ]]; then shellcheck -x ./*.sh || true echo "Done (optional: exit 0)." exit 0 fi shellcheck -x ./*.sh echo "Done."