debian-cis/shellcheck/launch_shellcheck.sh

23 lines
534 B
Bash
Raw Normal View History

#!/bin/bash
# run-shellcheck
# please do not run this script directly but `docker_build_and_run_shellcheck.sh`
files=""
retval=0
2020-12-10 09:50:33 +01:00
if [ "$#" -eq 0 ]; then
2020-12-04 14:08:01 +01:00
files=$(find . -name "*.sh" | sort -V)
else
files="$*"
fi
for f in $files; do
if head "$f" | grep -qE "^# run-shellcheck$"; then
printf "\e[1;36mRunning shellcheck on: %s \e[0m\n" "$f"
if ! /usr/bin/shellcheck --color=always --shell=bash -x --source-path=SCRIPTDIR "$f"; then
retval=$((retval + 1))
fi
fi
done
exit "$retval"