d1a34d
From 8d3b5eeb684f0872069fbab9e3b6470aa6a04729 Mon Sep 17 00:00:00 2001
d1a34d
From: Pavel Valena <pvalena@redhat.com>
d1a34d
Date: Tue, 15 Feb 2022 21:06:21 +0100
d1a34d
Subject: [PATCH] Fix shellcheck for a0d8caa8090a78f627f26fcd9b47c4b099cbc1ba
d1a34d
d1a34d
In modules.d/01fips/fips.sh line 137:
d1a34d
                  ((i++))
d1a34d
                  ^-----^ SC3006: In POSIX sh, standalone ((..)) is undefined.
d1a34d
                     ^-- SC3018: In POSIX sh, ++ is undefined.
d1a34d
d1a34d
In modules.d/01fips/fips.sh line 139:
d1a34d
                  if [ $i -eq ${BOOT_IMAGE:-0} ] && [ -r "$bls" ]; then
d1a34d
                       ^-- SC2086: Double quote to prevent globbing and word splitting.
d1a34d
                              ^--------------^ SC2086: Double quote to prevent globbing and word splitting.
d1a34d
d1a34d
In modules.d/01fips/fips.sh line 141:
d1a34d
                      BOOT_IMAGE=${BOOT_IMAGE:1}
d1a34d
                                 ^-------------^ SC3057: In POSIX sh, string indexing is undefined.
d1a34d
d1a34d
Related: rhbz#2050567
d1a34d
---
d1a34d
 modules.d/01fips/fips.sh | 13 +++++++------
d1a34d
 1 file changed, 7 insertions(+), 6 deletions(-)
d1a34d
d1a34d
diff --git a/modules.d/01fips/fips.sh b/modules.d/01fips/fips.sh
d1a34d
index 3297cb17..bee061ab 100755
d1a34d
--- a/modules.d/01fips/fips.sh
d1a34d
+++ b/modules.d/01fips/fips.sh
d1a34d
@@ -133,14 +133,15 @@ do_fips() {
d1a34d
                 BOOT_IMAGE="vmlinuz-${KERNEL}"
d1a34d
             elif [ -d /boot/loader/entries ]; then
d1a34d
                 i=0
d1a34d
+                # shellcheck disable=SC2012
d1a34d
                 for bls in $(ls -d /boot/loader/entries/*.conf | sort -rV); do
d1a34d
-                  ((i++))
d1a34d
+                    i=$((i + 1))
d1a34d
 
d1a34d
-                  if [ $i -eq ${BOOT_IMAGE:-0} ] && [ -r "$bls" ]; then
d1a34d
-                      BOOT_IMAGE="$(grep -e '^linux' "$bls" | grep -o ' .*$')"
d1a34d
-                      BOOT_IMAGE=${BOOT_IMAGE:1}
d1a34d
-                      break
d1a34d
-                  fi
d1a34d
+                    if [ "$i" -eq "${BOOT_IMAGE:-0}" ] && [ -r "$bls" ]; then
d1a34d
+                        BOOT_IMAGE="$(grep -e '^linux' "$bls" | grep -o ' .*$')"
d1a34d
+                        BOOT_IMAGE=${BOOT_IMAGE## }
d1a34d
+                        break
d1a34d
+                    fi
d1a34d
                 done
d1a34d
             fi
d1a34d
         fi
d1a34d