summaryrefslogtreecommitdiffstats
path: root/coccinelle
diff options
context:
space:
mode:
authorFrantisek Sumsal <frantisek@sumsal.cz>2021-09-29 19:55:24 +0200
committerFrantisek Sumsal <frantisek@sumsal.cz>2021-09-29 22:24:12 +0200
commit8370da9ea608b0f59c9da495910bbc3e45236ed6 (patch)
treef2a6fce8f564926f0446154eeb2c82de979718a8 /coccinelle
parentMerge pull request #20883 from bluca/bpf_header_license (diff)
downloadsystemd-8370da9ea608b0f59c9da495910bbc3e45236ed6.tar.xz
systemd-8370da9ea608b0f59c9da495910bbc3e45236ed6.zip
ci: shellcheck-ify CI scripts
Diffstat (limited to 'coccinelle')
-rwxr-xr-xcoccinelle/run-coccinelle.sh25
1 files changed, 14 insertions, 11 deletions
diff --git a/coccinelle/run-coccinelle.sh b/coccinelle/run-coccinelle.sh
index d1af412acc..e7a6d51f49 100755
--- a/coccinelle/run-coccinelle.sh
+++ b/coccinelle/run-coccinelle.sh
@@ -10,19 +10,20 @@ EXCLUDED_PATHS=(
"src/libsystemd/sd-journal/lookup3.c"
)
-top="$(git rev-parse --show-toplevel)"
-args=
+TOP_DIR="$(git rev-parse --show-toplevel)"
+ARGS=()
# Create an array from files tracked by git...
-mapfile -t files < <(git ls-files ':/*.[ch]')
+mapfile -t FILES < <(git ls-files ':/*.[ch]')
# ...and filter everything that matches patterns from EXCLUDED_PATHS
for excl in "${EXCLUDED_PATHS[@]}"; do
- files=(${files[@]//$excl})
+ # shellcheck disable=SC2206
+ FILES=(${FILES[@]//$excl})
done
case "$1" in
-i)
- args="$args --in-place"
+ ARGS+=(--in-place)
shift
;;
esac
@@ -32,12 +33,14 @@ if ! parallel -h >/dev/null; then
exit 1
fi
-for SCRIPT in ${@-$top/coccinelle/*.cocci}; do
- echo "--x-- Processing $SCRIPT --x--"
- TMPFILE=`mktemp`
- echo "+ spatch --sp-file $SCRIPT $args ..."
+[[ ${#@} -ne 0 ]] && SCRIPTS=("$@") || SCRIPTS=("$TOP_DIR"/coccinelle/*.cocci)
+
+for script in "${SCRIPTS[@]}"; do
+ echo "--x-- Processing $script --x--"
+ TMPFILE="$(mktemp)"
+ echo "+ spatch --sp-file $script ${ARGS[*]} ..."
parallel --halt now,fail=1 --keep-order --noswap --max-args=20 \
- spatch --macro-file="$top/coccinelle/macros.h" --sp-file $SCRIPT $args ::: "${files[@]}" \
+ spatch --macro-file="$TOP_DIR/coccinelle/macros.h" --sp-file "$script" "${ARGS[@]}" ::: "${FILES[@]}" \
2>"$TMPFILE" || cat "$TMPFILE"
- echo -e "--x-- Processed $SCRIPT --x--\n"
+ echo -e "--x-- Processed $script --x--\n"
done