2019-01-17 12:39:15 +01:00
|
|
|
#!/bin/bash
|
2019-01-24 11:11:08 +01:00
|
|
|
# run-shellcheck
|
|
|
|
# please do not run this script directly but `docker_build_and_run_shellcheck.sh`
|
2019-01-17 12:39:15 +01:00
|
|
|
|
|
|
|
files=""
|
2019-01-24 11:11:08 +01:00
|
|
|
retval=0
|
2019-01-17 12:39:15 +01:00
|
|
|
|
|
|
|
if [ $# -eq 0 ]; then
|
2019-02-01 09:42:12 +01:00
|
|
|
files=$(find . -name "*.sh" | sort -V )
|
2019-01-17 12:39:15 +01:00
|
|
|
else
|
|
|
|
files="$*"
|
|
|
|
fi
|
|
|
|
|
|
|
|
for f in $files; do
|
2019-01-24 11:11:08 +01:00
|
|
|
if head "$f" | grep -qE "^# run-shellcheck$"; then
|
|
|
|
printf "\e[1;36mRunning shellcheck on: %s \e[0m\n" "$f"
|
2019-01-30 16:00:45 +01:00
|
|
|
if ! /usr/bin/shellcheck --color=always --shell=bash "$f"; then
|
2019-01-24 11:11:08 +01:00
|
|
|
retval=$((retval + 1))
|
|
|
|
fi
|
|
|
|
fi
|
2019-01-17 12:39:15 +01:00
|
|
|
done
|
2019-01-24 11:11:08 +01:00
|
|
|
exit "$retval"
|