ci/markdown: fix shellcheck errors (MR 2485)

Don't try to modify a variable in the while loop, as it runs in a
subshell because of the pipe. Fail on the first error instead, like we
have it in .ci/shellcheck.sh.

This can be optimized later on (for both scripts) if we really want to.

Fix for:

  In ./.ci/markdown.sh line 17:
  	markdownlint-cli "$file" || MDL_FAILED=1
                                      ^--------^ SC2030 (info): Modification of MDL_FAILED is local (to subshell caused by pipeline).
  In ./.ci/markdown.sh line 20:
  if [ "$MDL_FAILED" = "1" ]; then
        ^---------^ SC2031 (info): MDL_FAILED was modified in a subshell. That change might be lost.
This commit is contained in:
Oliver Smith 2025-02-17 00:00:34 +01:00
parent 22d777bd82
commit 3b5e66d289
No known key found for this signature in database
GPG key ID: 5AE7F5513E0885CB

View file

@ -22,14 +22,12 @@ if ! command -v "$MDL" >/dev/null; then
exit 1
fi
MDL_FAILED=0
find . -name '*.md' |
while read -r file; do
echo "mdl: $file"
"$MDL" "$file" || MDL_FAILED=1
if ! "$MDL" "$file"; then
echo
echo "markdown lint failed!"
exit 1
fi
done
if [ "$MDL_FAILED" = "1" ]; then
echo "markdown lint failed!"
exit 1
fi