diff --git a/.agents/skills/lint-patch/SKILL.md b/.agents/skills/lint-patch/SKILL.md index 0590bb6e2..02ffb9cbd 100644 --- a/.agents/skills/lint-patch/SKILL.md +++ b/.agents/skills/lint-patch/SKILL.md @@ -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: CHECKPATCH: +SHELLCHECK: CODE_STYLE: COMMIT_STYLE: LINT_BASELINE: diff --git a/Makefile b/Makefile index d5a11c45a..707ca1e02 100644 --- a/Makefile +++ b/Makefile @@ -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 \ diff --git a/scripts/run-shellcheck b/scripts/run-shellcheck new file mode 100755 index 000000000..1b6b75f95 --- /dev/null +++ b/scripts/run-shellcheck @@ -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[@]}"