mirror of
https://github.com/SCST-project/scst.git
synced 2026-05-22 05:01:27 +00:00
scripts: Fix shellcheck warnings for checkpatch scripts
- Switching from 'set -e' to 'set -euo pipefail' for better error handling.
- Quoting all variable expansions to prevent word splitting and globbing.
- Replacing legacy unquoted $(...) and $@ with quoted forms.
- Using array-safe idioms where necessary (e.g., "${src_files[@]}").
This patch doesn't change any functionality.
This commit is contained in:
@@ -1,23 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
set -euo pipefail
|
||||
|
||||
rootdir=$(readlink -f $(dirname $0)/..)
|
||||
scriptsdir=${rootdir}/scripts
|
||||
outputfile=checkpatch.out
|
||||
rootdir="$(readlink -f "$(dirname "$0")/..")"
|
||||
scriptsdir="${rootdir}/scripts"
|
||||
outputfile="checkpatch.out"
|
||||
|
||||
src_files=$(${scriptsdir}/list-source-files ${rootdir} | \
|
||||
mapfile -t src_files < <(
|
||||
"${scriptsdir}/list-source-files" "${rootdir}" | \
|
||||
grep -vE '^debian/|^fcst/linux-patches|patch$|pdf$|png$|^iscsi-scst/usr|^qla|^scripts/|^scstadmin/|^usr/|^www/' | \
|
||||
while read -r filename; do echo "${rootdir}/$filename"; done)
|
||||
|
||||
${scriptsdir}/checkpatch -f $src_files 1> ${outputfile} || true
|
||||
"${scriptsdir}/checkpatch" -f "${src_files[@]}" 1> "${outputfile}" || true
|
||||
|
||||
errors=$(grep -c '^ERROR' "${outputfile}")
|
||||
warnings=$(grep -c '^WARNING' "${outputfile}")
|
||||
checks=$(grep -c '^CHECK' "${outputfile}")
|
||||
errors=$(grep -c '^ERROR' "${outputfile}" || true)
|
||||
warnings=$(grep -c '^WARNING' "${outputfile}" || true)
|
||||
checks=$(grep -c '^CHECK' "${outputfile}" || true)
|
||||
|
||||
echo "${errors} errors / ${warnings} warnings / ${checks} checks."
|
||||
|
||||
grep -E '^WARNING|^ERROR|^CHECK' "${outputfile}" |
|
||||
sort |
|
||||
sed 's/^CHECK:CAMELCASE: Avoid CamelCase:.*/CHECK:CAMELCASE Avoid CamelCase/' |
|
||||
|
||||
Reference in New Issue
Block a user