]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(uefi-lib): shellcheck for modules.d/99uefi-lib
authorHarald Hoyer <harald@redhat.com>
Fri, 26 Mar 2021 09:29:35 +0000 (10:29 +0100)
committerHarald Hoyer <harald@hoyer.xyz>
Mon, 29 Mar 2021 08:59:40 +0000 (10:59 +0200)
modules.d/99uefi-lib/.shchkdir [new file with mode: 0644]
modules.d/99uefi-lib/uefi-lib.sh

diff --git a/modules.d/99uefi-lib/.shchkdir b/modules.d/99uefi-lib/.shchkdir
new file mode 100644 (file)
index 0000000..e69de29
index bdc87db3e882225f0afa9bbeb102016d211aa564..06004ee29c51bf2de404e10169e4561d0173d89b 100755 (executable)
@@ -24,7 +24,7 @@ getbyte() {
     # the single quote in the argument of the printf
     # yields the numeric value of $c (ASCII since LC_CTYPE=C)
     [[ -n $c ]] && c=$(printf '%u' "'$c") || c=0
-    printf "$c"
+    printf "%s" "$c"
     return $res
 }
 
@@ -33,11 +33,11 @@ getword() {
     b1=$(getbyte)
     b2=$(getbyte)
     ((val = b2 * 256 + b1))
-    echo $val
+    echo "$val"
     return 0
 }
 
-# Acpi(PNP0A08,0x0)/Pci(0x3,0x0)/Pci(0x0,0x0)/MAC(90E2BA265ED4,0x0)/Vlan(172)/Fibre(0x4EA06104A0CC0050,0x0)
+# E.g. Acpi(PNP0A08,0x0)/Pci(0x3,0x0)/Pci(0x0,0x0)/MAC(90E2BA265ED4,0x0)/Vlan(172)/Fibre(0x4EA06104A0CC0050,0x0)
 uefi_device_path() {
     data=${1:-/sys/firmware/efi/efivars/FcoeBootDevice-a0ebca23-5f9c-447a-a268-22b6c158c2ac}
     [ -f "$data" ] || return 1
@@ -72,20 +72,19 @@ uefi_device_path() {
                     getword &> /dev/null
                     getword &> /dev/null
                     printf "Fibre(0x%x%x%x%x%x%x%x%x,0x%x)" \
-                        $(getbyte) $(getbyte) $(getbyte) $(getbyte) \
-                        $(getbyte) $(getbyte) $(getbyte) $(getbyte) \
-                        $(($(getword) + $(getword) * 65536 + 4294967296 * ($(getword) + $(getword) * 65536)))
+                        "$(getbyte)" "$(getbyte)" "$(getbyte)" "$(getbyte)" \
+                        "$(getbyte)" "$(getbyte)" "$(getbyte)" "$(getbyte)" \
+                        "$(($(getword) + $(getword) * 65536 + 4294967296 * ($(getword) + $(getword) * 65536)))"
                     ;;
                 030b)
                     # MAC
-                    printf "MAC(%02x%02x%02x%02x%02x%02x," $(getbyte) $(getbyte) $(getbyte) $(getbyte) $(getbyte) $(getbyte)
+                    printf "MAC(%02x%02x%02x%02x%02x%02x," "$(getbyte)" "$(getbyte)" "$(getbyte)" "$(getbyte)" "$(getbyte)" "$(getbyte)"
                     for ((i = 0; i < 26; i++)); do tt=$(getbyte) || return 1; done
-                    #read -r -d '' -n 26 tt || return 1
-                    printf "0x%x)" $(getbyte)
+                    printf "0x%x)" "$(getbyte)"
                     ;;
                 0314)
                     # VLAN
-                    printf "VLAN(%d)" $(getword)
+                    printf "VLAN(%d)" "$(getword)"
                     ;;
                 7fff)
                     # END
@@ -101,8 +100,6 @@ uefi_device_path() {
     } < "$data"
 }
 
-# /home/harald/Downloads/FcoeBootDevice-80005007-4248-4e4b-8df4-93060220756f
-
 get_fcoe_boot_mac() {
     data=${1:-/sys/firmware/efi/efivars/FcoeBootDevice-a0ebca23-5f9c-447a-a268-22b6c158c2ac}
     [ -f "$data" ] || return 1
@@ -118,7 +115,7 @@ get_fcoe_boot_mac() {
             case $hextype in
                 030b)
                     # MAC
-                    printf "%02x:%02x:%02x:%02x:%02x:%02x" $(getbyte) $(getbyte) $(getbyte) $(getbyte) $(getbyte) $(getbyte)
+                    printf "%02x:%02x:%02x:%02x:%02x:%02x" "$(getbyte)" "$(getbyte)" "$(getbyte)" "$(getbyte)" "$(getbyte)" "$(getbyte)"
                     for ((i = 0; i < 27; i++)); do tt=$(getbyte) || return 1; done
                     ;;
                 7fff)
@@ -149,7 +146,7 @@ get_fcoe_boot_vlan() {
             case $hextype in
                 0314)
                     # VLAN
-                    printf "%d" $(getword)
+                    printf "%d" "$(getword)"
                     ;;
                 7fff)
                     # END