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:
Gleb Chesnokov
2026-08-21 19:58:59 +03:00
parent f788bfd0d6
commit 28b811135d
3 changed files with 43 additions and 3 deletions
+8 -2
View File
@@ -38,9 +38,14 @@ Run at least these components:
2. Run `./scripts/checkpatch_commits "$base"`. This is the tracked SCST
entry point for every commit in `base..HEAD`; the preflight makes
`HEAD == head`. Do not invent options or use an untracked helper.
3. Manually verify Linux kernel coding style for every changed kernel C and
3. If the range changes a tracked Bash script in `scripts/`,
`scripts/run-shellcheck` itself, or the `shellcheck` target in the
top-level `Makefile`, run `./scripts/run-shellcheck` from the repository
root. A missing `shellcheck` is `BLOCKED` in that case; report
`NOT_APPLICABLE` for other ranges.
4. Manually verify Linux kernel coding style for every changed kernel C and
header file. Use the diff plus enough surrounding code to judge context.
4. Inspect every commit as an independently reviewable semantic unit. Check
5. Inspect every commit as an independently reviewable semantic unit. Check
its subject and body against applicable repository rules and current SCST
history, including concise imperative wording and established prefixes.
@@ -79,6 +84,7 @@ End with exactly one marker block:
LINT_EXECUTOR: main
DIFF_CHECK: <PASS|FAIL|BLOCKED>
CHECKPATCH: <PASS|WAIVED|FAIL|NOT_APPLICABLE|BLOCKED>
SHELLCHECK: <PASS|FAIL|NOT_APPLICABLE|BLOCKED>
CODE_STYLE: <PASS|FAIL|NOT_APPLICABLE|BLOCKED>
COMMIT_STYLE: <PASS|FAIL|BLOCKED>
LINT_BASELINE: <CLEAN|PRESENT|BLOCKED>
+5 -1
View File
@@ -102,6 +102,7 @@ SCST_SOURCE_FILES = $(shell if [ -e scripts/list-source-files ]; then \
help:
@echo " tags : make tags"
@echo " cov-build : make coverity build"
@echo " shellcheck : check Bash scripts"
@echo ""
@echo " all : make all"
@echo " clean : clean files"
@@ -194,6 +195,9 @@ cov-build:
exit $$?; \
done
shellcheck:
scripts/run-shellcheck
all clean extraclean install uninstall:
if [ $@ = extraclean ]; then rm -f TAGS tags cscope.out; fi
for d in $(SCST_DIR) $(ISCSI_DIR) $(QLA_DIR) $(SRP_DIR) \
@@ -513,7 +517,7 @@ multiple-release-archives:
2debug:
cd $(SCST_DIR) && $(MAKE) $@
.PHONY: help tags cov-build all clean extraclean install uninstall \
.PHONY: help tags cov-build shellcheck all clean extraclean install uninstall \
scst scst_clean scst_extraclean scst_install scst_uninstall \
docs docs_clean docs_extraclean \
scstadm scstadm_clean scstadm_extraclean scstadm_install scstadm_uninstall \
+30
View File
@@ -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[@]}"