]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix(kernel-modules): shellcheck regression
authorHarald Hoyer <harald@redhat.com>
Wed, 31 Mar 2021 08:01:18 +0000 (10:01 +0200)
committerHarald Hoyer <harald@hoyer.xyz>
Wed, 31 Mar 2021 09:30:49 +0000 (11:30 +0200)
`$_hostonly_drvs` contained multiple arguments and was quoted.

This patch converts `_hostonly_drvs` into an associative array, which
enables easy deduplication and proper quoting in bash.

Fixes: https://github.com/dracutdevs/dracut/issues/1276
modules.d/90kernel-modules/module-setup.sh

index bbafb289a999474d52daaac80eb83e2abdda0dae..1a1b56a299a3186754889ae6c7d5d23539560a1c 100755 (executable)
@@ -3,7 +3,7 @@
 # called by dracut
 installkernel() {
     local _blockfuncs='ahci_platform_get_resources|ata_scsi_ioctl|scsi_add_host|blk_cleanup_queue|register_mtd_blktrans|scsi_esp_register|register_virtio_device|usb_stor_disconnect|mmc_add_host|sdhci_add_host|scsi_add_host_with_dma'
-    local _hostonly_drvs
+    local -A _hostonly_drvs
 
     find_kernel_modules_external() {
         local a
@@ -17,14 +17,14 @@ installkernel() {
 
     record_block_dev_drv() {
         for _mod in $(get_dev_module /dev/block/"$1"); do
-            [[ " $_hostonly_drvs " != *$_mod* ]] && _hostonly_drvs+=" $_mod"
+            _hostonly_drvs["$_mod"]="$_mod"
         done
-        [[ "$_hostonly_drvs" ]] && return 0
+        ((${#_hostonly_drvs[@]} > 0)) && return 0
         return 1
     }
 
     install_block_modules_strict() {
-        hostonly='' instmods "$_hostonly_drvs"
+        hostonly='' instmods "${_hostonly_drvs[@]}"
     }
 
     install_block_modules() {