Files
debian-cis/shellcheck/launch_shellcheck.sh
damcav35 99bc575714 Damcava35/test pre commit (#256)
* chore: make linter happy for existing code

* fix: add missing test 2.1.2_disable_bsd_intetd.sh

* feat: add basic pre commit

Ensure a check has a corresponding test

---------

Co-authored-by: Damien Cavagnini <damien.cavagnini@corp.ovh.com>
2025-06-23 10:23:43 +02:00

24 lines
651 B
Bash
Executable File

#!/bin/bash
# run-shellcheck
# please do not run this script directly but `docker_build_and_run_shellcheck.sh`
files=""
retval=0
if [ "$#" -eq 0 ]; then
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"
# SC2317: command unreachable, sometimes has a hard time reaching the command in a function
if ! /usr/bin/shellcheck --exclude=SC2317 --color=always --shell=bash -x --source-path=SCRIPTDIR "$f"; then
retval=$((retval + 1))
fi
fi
done
exit "$retval"