mirror of
https://github.com/SCST-project/scst.git
synced 2026-09-01 13:47:46 +00:00
scripts: Add ShellCheck lint target
Add a tracked runner that discovers Bash scripts under scripts/ and checks them with external source resolution enabled. Expose it through the top-level Makefile. Run the same entry point from the patch lint workflow whenever a range touches Bash lint inputs, and report its result explicitly.
This commit is contained in:
Executable
+30
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
script_dir="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
if ! command -v shellcheck >/dev/null 2>&1; then
|
||||
echo "Error: shellcheck has not been installed." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
source_files="$("$script_dir/list-source-files" "$script_dir")"
|
||||
|
||||
cd "$script_dir"
|
||||
|
||||
bash_scripts=()
|
||||
while IFS= read -r file; do
|
||||
[ -n "$file" ] || continue
|
||||
IFS= read -r first_line < "$file" || first_line=
|
||||
case "$first_line" in
|
||||
'#!'*bash*) bash_scripts+=("$file");;
|
||||
esac
|
||||
done <<<"$source_files"
|
||||
|
||||
if [ "${#bash_scripts[@]}" -eq 0 ]; then
|
||||
echo "Error: no Bash scripts found under scripts/." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
shellcheck -x -P SCRIPTDIR "${bash_scripts[@]}"
|
||||
Reference in New Issue
Block a user