1755ca
From 69b5de6251ab7dace7ed7eb8bea7a81324cefe16 Mon Sep 17 00:00:00 2001
1755ca
From: Harald Hoyer <harald@redhat.com>
1755ca
Date: Thu, 9 Jul 2015 15:27:44 +0200
1755ca
Subject: [PATCH] guard ${arrays[@]} with ""
1755ca
1755ca
Cherry-picked from: 3721635b2c5df033fca1e19181d7598e075f5308
1755ca
Resolves: #1520721
1755ca
---
1755ca
 dracut-functions.sh                        | 8 ++++----
1755ca
 dracut.sh                                  | 6 +++---
1755ca
 lsinitrd.sh                                | 2 +-
1755ca
 modules.d/90btrfs/module-setup.sh          | 2 +-
1755ca
 modules.d/90kernel-modules/module-setup.sh | 2 +-
1755ca
 modules.d/95cifs/module-setup.sh           | 2 +-
1755ca
 modules.d/95nfs/module-setup.sh            | 2 +-
1755ca
 modules.d/95virtfs/module-setup.sh         | 2 +-
1755ca
 modules.d/99base/module-setup.sh           | 4 ++--
1755ca
 9 files changed, 15 insertions(+), 15 deletions(-)
1755ca
1755ca
diff --git a/dracut-functions.sh b/dracut-functions.sh
1755ca
index 3c4118a9..23768bdc 100755
1755ca
--- a/dracut-functions.sh
1755ca
+++ b/dracut-functions.sh
1755ca
@@ -593,7 +593,7 @@ for_each_host_dev_fs()
1755ca
     local _dev
1755ca
     local _ret=1
1755ca
 
1755ca
-    [[ "${!host_fs_types[@]}" ]] || return 0
1755ca
+    [[ "${#host_fs_types[@]}" ]] || return 0
1755ca
 
1755ca
     for _dev in "${!host_fs_types[@]}"; do
1755ca
         $_func "$_dev" "${host_fs_types[$_dev]}" && _ret=0
1755ca
@@ -654,7 +654,7 @@ for_each_host_dev_and_slaves_all()
1755ca
 
1755ca
     [[ "${host_devs[@]}" ]] || return 0
1755ca
 
1755ca
-    for _dev in ${host_devs[@]}; do
1755ca
+    for _dev in "${host_devs[@]}"; do
1755ca
         [[ -b "$_dev" ]] || continue
1755ca
         if check_block_and_slaves_all $_func $(get_maj_min $_dev); then
1755ca
             _ret=0
1755ca
@@ -670,7 +670,7 @@ for_each_host_dev_and_slaves()
1755ca
 
1755ca
     [[ "${host_devs[@]}" ]] || return 0
1755ca
 
1755ca
-    for _dev in ${host_devs[@]}; do
1755ca
+    for _dev in "${host_devs[@]}"; do
1755ca
         [[ -b "$_dev" ]] || continue
1755ca
         check_block_and_slaves $_func $(get_maj_min $_dev) && return 0
1755ca
     done
1755ca
@@ -1241,7 +1241,7 @@ check_mount() {
1755ca
     local _ret
1755ca
     local _moddep
1755ca
 
1755ca
-    [ "${#host_fs_types[*]}" -le 0 ] && return 1
1755ca
+    [ "${#host_fs_types[@]}" -le 0 ] && return 1
1755ca
 
1755ca
     # If we are already scheduled to be loaded, no need to check again.
1755ca
     [[ " $mods_to_load " == *\ $_mod\ * ]] && return 0
1755ca
diff --git a/dracut.sh b/dracut.sh
1755ca
index b34edea2..90b75e51 100755
1755ca
--- a/dracut.sh
1755ca
+++ b/dracut.sh
1755ca
@@ -1171,7 +1171,7 @@ _get_fs_type() {
1755ca
     return 1
1755ca
 }
1755ca
 
1755ca
-for dev in ${host_devs[@]}; do
1755ca
+for dev in "${host_devs[@]}"; do
1755ca
     _get_fs_type "$dev"
1755ca
     check_block_and_slaves_all _get_fs_type "$(get_maj_min "$dev")"
1755ca
 done
1755ca
@@ -1396,8 +1396,8 @@ if [[ $no_kernel != yes ]]; then
1755ca
 fi
1755ca
 
1755ca
 if [[ $kernel_only != yes ]]; then
1755ca
-    (( ${#install_items[@]} > 0 )) && inst_multiple ${install_items[@]}
1755ca
-    (( ${#install_optional_items[@]} > 0 )) && inst_multiple -o ${install_optional_items[@]}
1755ca
+    (( ${#install_items[@]} > 0 )) && inst_multiple "${install_items[@]}"
1755ca
+    (( ${#install_optional_items[@]} > 0 )) && inst_multiple -o "${install_optional_items[@]}"
1755ca
 
1755ca
     [[ $kernel_cmdline ]] && printf "%s\n" "$kernel_cmdline" >> "${initdir}/etc/cmdline.d/01-default.conf"
1755ca
 
1755ca
diff --git a/lsinitrd.sh b/lsinitrd.sh
1755ca
index 4103ee23..0fb7e3b5 100755
1755ca
--- a/lsinitrd.sh
1755ca
+++ b/lsinitrd.sh
1755ca
@@ -113,7 +113,7 @@ fi
1755ca
 extract_files()
1755ca
 {
1755ca
     (( ${#filenames[@]} == 1 )) && nofileinfo=1
1755ca
-    for f in ${!filenames[@]}; do
1755ca
+    for f in "${!filenames[@]}"; do
1755ca
         [[ $nofileinfo ]] || echo "initramfs:/$f"
1755ca
         [[ $nofileinfo ]] || echo "========================================================================"
1755ca
         $CAT $image 2>/dev/null | cpio --extract --verbose --quiet --to-stdout $f 2>/dev/null
1755ca
diff --git a/modules.d/90btrfs/module-setup.sh b/modules.d/90btrfs/module-setup.sh
1755ca
index 4804f58b..ac8cb885 100755
1755ca
--- a/modules.d/90btrfs/module-setup.sh
1755ca
+++ b/modules.d/90btrfs/module-setup.sh
1755ca
@@ -9,7 +9,7 @@ check() {
1755ca
     require_binaries btrfs || return 1
1755ca
 
1755ca
     [[ $hostonly ]] || [[ $mount_needs ]] && {
1755ca
-        for fs in ${host_fs_types[@]}; do
1755ca
+        for fs in "${host_fs_types[@]}"; do
1755ca
             [[ "$fs" == "btrfs" ]] && return 0
1755ca
         done
1755ca
         return 255
1755ca
diff --git a/modules.d/90kernel-modules/module-setup.sh b/modules.d/90kernel-modules/module-setup.sh
1755ca
index c4bf5af5..dea32602 100755
1755ca
--- a/modules.d/90kernel-modules/module-setup.sh
1755ca
+++ b/modules.d/90kernel-modules/module-setup.sh
1755ca
@@ -83,7 +83,7 @@ installkernel() {
1755ca
                     instmods '=fs'
1755ca
             fi
1755ca
         else
1755ca
-            for i in $(host_fs_all); do
1755ca
+            for i in "${host_fs_types[@]}"; do
1755ca
                 hostonly='' instmods $i
1755ca
             done
1755ca
         fi
1755ca
diff --git a/modules.d/95cifs/module-setup.sh b/modules.d/95cifs/module-setup.sh
1755ca
index 9e36f87f..e2509504 100755
1755ca
--- a/modules.d/95cifs/module-setup.sh
1755ca
+++ b/modules.d/95cifs/module-setup.sh
1755ca
@@ -7,7 +7,7 @@ check() {
1755ca
     require_binaries mount.cifs || return 1
1755ca
 
1755ca
     [[ $hostonly ]] || [[ $mount_needs ]] && {
1755ca
-        for fs in ${host_fs_types[@]}; do
1755ca
+        for fs in "${host_fs_types[@]}"; do
1755ca
             [[ "$fs" == "cifs" ]] && return 0
1755ca
         done
1755ca
         return 255
1755ca
diff --git a/modules.d/95nfs/module-setup.sh b/modules.d/95nfs/module-setup.sh
1755ca
index dc2e7221..b0bb866d 100755
1755ca
--- a/modules.d/95nfs/module-setup.sh
1755ca
+++ b/modules.d/95nfs/module-setup.sh
1755ca
@@ -8,7 +8,7 @@ check() {
1755ca
     require_binaries rpc.statd mount.nfs mount.nfs4 umount || return 1
1755ca
 
1755ca
     [[ $hostonly ]] || [[ $mount_needs ]] && {
1755ca
-        for fs in ${host_fs_types[@]}; do
1755ca
+        for fs in "${host_fs_types[@]}"; do
1755ca
             [[ "$fs" == "nfs" ]] && return 0
1755ca
             [[ "$fs" == "nfs3" ]] && return 0
1755ca
             [[ "$fs" == "nfs4" ]] && return 0
1755ca
diff --git a/modules.d/95virtfs/module-setup.sh b/modules.d/95virtfs/module-setup.sh
1755ca
index 3d80b75f..c7101c07 100755
1755ca
--- a/modules.d/95virtfs/module-setup.sh
1755ca
+++ b/modules.d/95virtfs/module-setup.sh
1755ca
@@ -4,7 +4,7 @@
1755ca
 
1755ca
 check() {
1755ca
     [[ $hostonly ]] || [[ $mount_needs ]] && {
1755ca
-        for fs in ${host_fs_types[@]}; do
1755ca
+        for fs in "${host_fs_types[@]}"; do
1755ca
             [[ "$fs" == "9p" ]] && return 0
1755ca
         done
1755ca
         return 255
1755ca
diff --git a/modules.d/99base/module-setup.sh b/modules.d/99base/module-setup.sh
1755ca
index 8fd4e80d..74a3f0c0 100755
1755ca
--- a/modules.d/99base/module-setup.sh
1755ca
+++ b/modules.d/99base/module-setup.sh
1755ca
@@ -103,13 +103,13 @@ install() {
1755ca
 
1755ca
                 . "$moddir/dracut-lib.sh"
1755ca
 
1755ca
-                for _dev in ${host_devs[@]}; do
1755ca
+                for _dev in "${host_devs[@]}"; do
1755ca
                     [[ "$_dev" == "$root_dev" ]] && continue
1755ca
 
1755ca
                     # We only actually wait for real devs - swap is only needed
1755ca
                     # for resume and udev rules generated when parsing resume=
1755ca
                     # argument take care of the waiting for us
1755ca
-                    for _dev2 in ${swap_devs[@]}; do
1755ca
+                    for _dev2 in "${swap_devs[@]}"; do
1755ca
                       [[ "$_dev" == "$_dev2" ]] && continue 2
1755ca
                     done
1755ca