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