2021-01-22 19:44:05 +03:00
|
|
|
#!/usr/bin/env bash
|
2020-12-27 17:26:43 +03:00
|
|
|
|
|
|
|
set -eo pipefail
|
2020-02-10 09:39:30 +03:00
|
|
|
|
|
|
|
script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
|
|
|
|
cd "$script_path/.."
|
|
|
|
|
2020-12-27 17:34:06 +03:00
|
|
|
if [ "$#" -eq "0" ]; then
|
|
|
|
mapfile -t files < <(
|
|
|
|
git ls-files -- \
|
|
|
|
'*.sh' \
|
|
|
|
':!:Ports' \
|
2021-02-04 05:04:22 +03:00
|
|
|
':!:Userland/Shell/Tests' \
|
|
|
|
':!:Base/home/anon/tests'
|
2020-12-27 17:34:06 +03:00
|
|
|
)
|
|
|
|
else
|
|
|
|
files=()
|
|
|
|
for file in "$@"; do
|
|
|
|
if [[ "${file}" == *".sh" ]]; then
|
|
|
|
files+=("${file}")
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
2020-02-10 09:39:30 +03:00
|
|
|
|
2020-12-27 17:34:06 +03:00
|
|
|
if (( ${#files[@]} )); then
|
2021-01-10 10:20:21 +03:00
|
|
|
if ! command -v shellcheck &>/dev/null ; then
|
|
|
|
echo "shellcheck is not available, but shell files need linting! Either skip this script, or install shellcheck."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-12-27 17:34:06 +03:00
|
|
|
shellcheck "${files[@]}"
|
|
|
|
else
|
|
|
|
echo "No .sh files to check."
|
2020-02-10 09:39:30 +03:00
|
|
|
fi
|