2020-02-10 06:39:30 +00:00
|
|
|
#!/bin/bash
|
2020-12-27 14:26:43 +00:00
|
|
|
|
|
|
|
set -eo pipefail
|
2020-02-10 06:39:30 +00:00
|
|
|
|
|
|
|
script_path=$(cd -P -- "$(dirname -- "$0")" && pwd -P)
|
|
|
|
cd "$script_path/.."
|
|
|
|
|
2020-11-01 01:11:22 +00:00
|
|
|
if ! command -v shellcheck &>/dev/null ; then
|
|
|
|
echo "shellcheck is not available. Either skip this script, or install shellcheck."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-02-10 06:39:30 +00:00
|
|
|
ERRORS=()
|
|
|
|
|
2020-05-28 19:03:55 +00:00
|
|
|
while IFS= read -r f; do
|
2020-02-10 06:39:30 +00:00
|
|
|
if file "$f" | grep --quiet shell; then
|
|
|
|
{
|
2020-10-02 21:14:37 +00:00
|
|
|
shellcheck "$f" && echo -e "[\033[0;32mOK\033[0m]: successfully linted $f"
|
2020-02-10 06:39:30 +00:00
|
|
|
} || {
|
|
|
|
ERRORS+=("$f")
|
|
|
|
}
|
2020-05-28 19:03:55 +00:00
|
|
|
fi
|
|
|
|
done < <(git ls-files -- \
|
|
|
|
'*.sh' \
|
|
|
|
':!:Toolchain' \
|
|
|
|
':!:Ports' \
|
2020-06-24 20:42:26 +00:00
|
|
|
':!:Shell/Tests' \
|
2020-05-28 19:03:55 +00:00
|
|
|
)
|
2020-02-10 06:39:30 +00:00
|
|
|
|
|
|
|
if (( ${#ERRORS[@]} )); then
|
|
|
|
echo "Files failing shellcheck: ${ERRORS[*]}"
|
|
|
|
exit 1
|
|
|
|
fi
|