2020-02-10 19:39:30 +13:00
|
|
|
#!/bin/bash
|
|
|
|
set -e pipefail
|
|
|
|
|
|
|
|
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 19:39:30 +13:00
|
|
|
ERRORS=()
|
|
|
|
|
2020-05-28 21:03:55 +02:00
|
|
|
while IFS= read -r f; do
|
2020-02-10 19:39:30 +13:00
|
|
|
if file "$f" | grep --quiet shell; then
|
|
|
|
{
|
2020-10-02 22:14:37 +01:00
|
|
|
shellcheck "$f" && echo -e "[\033[0;32mOK\033[0m]: successfully linted $f"
|
2020-02-10 19:39:30 +13:00
|
|
|
} || {
|
|
|
|
ERRORS+=("$f")
|
|
|
|
}
|
2020-05-28 21:03:55 +02:00
|
|
|
fi
|
|
|
|
done < <(git ls-files -- \
|
|
|
|
'*.sh' \
|
|
|
|
':!:Toolchain' \
|
|
|
|
':!:Ports' \
|
2020-06-25 01:12:26 +04:30
|
|
|
':!:Shell/Tests' \
|
2020-05-28 21:03:55 +02:00
|
|
|
)
|
2020-02-10 19:39:30 +13:00
|
|
|
|
|
|
|
if (( ${#ERRORS[@]} )); then
|
|
|
|
echo "Files failing shellcheck: ${ERRORS[*]}"
|
|
|
|
exit 1
|
|
|
|
fi
|