Riyyis Utilities for C++
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
681 B

#!/bin/sh
# Run shellcheck across the codebase
# Depends: git, shellcheck
# ------------------------------------------
error() {
b="$(tput bold)"
red="$(tput setf 4)"
n="$(tput sgr0)"
echo "${b}${red}Error:${n} $1" >&2
exit 1
}
if [ ! -d ".git" ]; then
error "please run this script from the project root"
fi
if ! command -v shellcheck > /dev/null 2>&1; then
error "shellcheck is not available, but shell-script files need linting!
Either skip this script, or install shellcheck."
fi
files="${1:-$(git --no-pager diff --cached --name-only)}"
files="$(echo "$files" | grep -E '\.sh$')"
if [ -z "$files" ]; then
exit
fi
# shellcheck disable=SC2086
shellcheck $files