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