Harald Hoyer 0840a3
From 3721635b2c5df033fca1e19181d7598e075f5308 Mon Sep 17 00:00:00 2001
Harald Hoyer 0840a3
From: Harald Hoyer <harald@redhat.com>
Harald Hoyer 0840a3
Date: Thu, 9 Jul 2015 15:27:44 +0200
Harald Hoyer 0840a3
Subject: [PATCH] guard ${arrays[@]} with ""
Harald Hoyer 0840a3
Harald Hoyer 0840a3
---
Harald Hoyer 0840a3
 dracut-functions.sh                        | 8 ++++----
Harald Hoyer 0840a3
 dracut.sh                                  | 6 +++---
Harald Hoyer 0840a3
 lsinitrd.sh                                | 2 +-
Harald Hoyer 0840a3
 modules.d/90btrfs/module-setup.sh          | 2 +-
Harald Hoyer 0840a3
 modules.d/90kernel-modules/module-setup.sh | 2 +-
Harald Hoyer 0840a3
 modules.d/95cifs/module-setup.sh           | 2 +-
Harald Hoyer 0840a3
 modules.d/95nfs/module-setup.sh            | 2 +-
Harald Hoyer 0840a3
 modules.d/95virtfs/module-setup.sh         | 2 +-
Harald Hoyer 0840a3
 modules.d/99base/module-setup.sh           | 6 +++---
Harald Hoyer 0840a3
 9 files changed, 16 insertions(+), 16 deletions(-)
Harald Hoyer 0840a3
Harald Hoyer 0840a3
diff --git a/dracut-functions.sh b/dracut-functions.sh
Harald Hoyer 0840a3
index 639c5ae..3a0a5a2 100755
Harald Hoyer 0840a3
--- a/dracut-functions.sh
Harald Hoyer 0840a3
+++ b/dracut-functions.sh
Harald Hoyer 0840a3
@@ -596,7 +596,7 @@ for_each_host_dev_fs()
Harald Hoyer 0840a3
     local _dev
Harald Hoyer 0840a3
     local _ret=1
Harald Hoyer 0840a3
 
Harald Hoyer 0840a3
-    [[ "${!host_fs_types[@]}" ]] || return 0
Harald Hoyer 0840a3
+    [[ "${#host_fs_types[@]}" ]] || return 0
Harald Hoyer 0840a3
 
Harald Hoyer 0840a3
     for _dev in "${!host_fs_types[@]}"; do
Harald Hoyer 0840a3
         $_func "$_dev" "${host_fs_types[$_dev]}" && _ret=0
Harald Hoyer 0840a3
@@ -657,7 +657,7 @@ for_each_host_dev_and_slaves_all()
Harald Hoyer 0840a3
 
Harald Hoyer 0840a3
     [[ "${host_devs[@]}" ]] || return 0
Harald Hoyer 0840a3
 
Harald Hoyer 0840a3
-    for _dev in ${host_devs[@]}; do
Harald Hoyer 0840a3
+    for _dev in "${host_devs[@]}"; do
Harald Hoyer 0840a3
         [[ -b "$_dev" ]] || continue
Harald Hoyer 0840a3
         if check_block_and_slaves_all $_func $(get_maj_min $_dev); then
Harald Hoyer 0840a3
             _ret=0
Harald Hoyer 0840a3
@@ -673,7 +673,7 @@ for_each_host_dev_and_slaves()
Harald Hoyer 0840a3
 
Harald Hoyer 0840a3
     [[ "${host_devs[@]}" ]] || return 0
Harald Hoyer 0840a3
 
Harald Hoyer 0840a3
-    for _dev in ${host_devs[@]}; do
Harald Hoyer 0840a3
+    for _dev in "${host_devs[@]}"; do
Harald Hoyer 0840a3
         [[ -b "$_dev" ]] || continue
Harald Hoyer 0840a3
         check_block_and_slaves $_func $(get_maj_min $_dev) && return 0
Harald Hoyer 0840a3
     done
Harald Hoyer 0840a3
@@ -1276,7 +1276,7 @@ check_mount() {
Harald Hoyer 0840a3
     local _ret
Harald Hoyer 0840a3
     local _moddep
Harald Hoyer 0840a3
 
Harald Hoyer 0840a3
-    [ "${#host_fs_types[*]}" -le 0 ] && return 1
Harald Hoyer 0840a3
+    [ "${#host_fs_types[@]}" -le 0 ] && return 1
Harald Hoyer 0840a3
 
Harald Hoyer 0840a3
     # If we are already scheduled to be loaded, no need to check again.
Harald Hoyer 0840a3
     [[ " $mods_to_load " == *\ $_mod\ * ]] && return 0
Harald Hoyer 0840a3
diff --git a/dracut.sh b/dracut.sh
Harald Hoyer 0840a3
index 54358f3..fc84a41 100755
Harald Hoyer 0840a3
--- a/dracut.sh
Harald Hoyer 0840a3
+++ b/dracut.sh
Harald Hoyer 0840a3
@@ -1220,7 +1220,7 @@ _get_fs_type() {
Harald Hoyer 0840a3
     return 1
Harald Hoyer 0840a3
 }
Harald Hoyer 0840a3
 
Harald Hoyer 0840a3
-for dev in ${host_devs[@]}; do
Harald Hoyer 0840a3
+for dev in "${host_devs[@]}"; do
Harald Hoyer 0840a3
     _get_fs_type "$dev"
Harald Hoyer 0840a3
     check_block_and_slaves_all _get_fs_type "$(get_maj_min "$dev")"
Harald Hoyer 0840a3
 done
Harald Hoyer 0840a3
@@ -1455,8 +1455,8 @@ if [[ $no_kernel != yes ]]; then
Harald Hoyer 0840a3
 fi
Harald Hoyer 0840a3
 
Harald Hoyer 0840a3
 if [[ $kernel_only != yes ]]; then
Harald Hoyer 0840a3
-    (( ${#install_items[@]} > 0 )) && inst_multiple ${install_items[@]}
Harald Hoyer 0840a3
-    (( ${#install_optional_items[@]} > 0 )) && inst_multiple -o ${install_optional_items[@]}
Harald Hoyer 0840a3
+    (( ${#install_items[@]} > 0 )) && inst_multiple "${install_items[@]}"
Harald Hoyer 0840a3
+    (( ${#install_optional_items[@]} > 0 )) && inst_multiple -o "${install_optional_items[@]}"
Harald Hoyer 0840a3
 
Harald Hoyer 0840a3
     [[ $kernel_cmdline ]] && printf "%s\n" "$kernel_cmdline" >> "${initdir}/etc/cmdline.d/01-default.conf"
Harald Hoyer 0840a3
 
Harald Hoyer 0840a3
diff --git a/lsinitrd.sh b/lsinitrd.sh
Harald Hoyer 0840a3
index 94674af..d2ddd76 100755
Harald Hoyer 0840a3
--- a/lsinitrd.sh
Harald Hoyer 0840a3
+++ b/lsinitrd.sh
Harald Hoyer 0840a3
@@ -117,7 +117,7 @@ dracutlibdirs() {
Harald Hoyer 0840a3
 extract_files()
Harald Hoyer 0840a3
 {
Harald Hoyer 0840a3
     (( ${#filenames[@]} == 1 )) && nofileinfo=1
Harald Hoyer 0840a3
-    for f in ${!filenames[@]}; do
Harald Hoyer 0840a3
+    for f in "${!filenames[@]}"; do
Harald Hoyer 0840a3
         [[ $nofileinfo ]] || echo "initramfs:/$f"
Harald Hoyer 0840a3
         [[ $nofileinfo ]] || echo "========================================================================"
Harald Hoyer 0840a3
         $CAT $image | cpio --extract --verbose --quiet --to-stdout $f 2>/dev/null
Harald Hoyer 0840a3
diff --git a/modules.d/90btrfs/module-setup.sh b/modules.d/90btrfs/module-setup.sh
Harald Hoyer 0840a3
index 0771132..9303dbe 100755
Harald Hoyer 0840a3
--- a/modules.d/90btrfs/module-setup.sh
Harald Hoyer 0840a3
+++ b/modules.d/90btrfs/module-setup.sh
Harald Hoyer 0840a3
@@ -8,7 +8,7 @@ check() {
Harald Hoyer 0840a3
     require_binaries btrfs || return 1
Harald Hoyer 0840a3
 
Harald Hoyer 0840a3
     [[ $hostonly ]] || [[ $mount_needs ]] && {
Harald Hoyer 0840a3
-        for fs in ${host_fs_types[@]}; do
Harald Hoyer 0840a3
+        for fs in "${host_fs_types[@]}"; do
Harald Hoyer 0840a3
             [[ "$fs" == "btrfs" ]] && return 0
Harald Hoyer 0840a3
         done
Harald Hoyer 0840a3
         return 255
Harald Hoyer 0840a3
diff --git a/modules.d/90kernel-modules/module-setup.sh b/modules.d/90kernel-modules/module-setup.sh
Harald Hoyer 0840a3
index 40803df..41bf37d 100755
Harald Hoyer 0840a3
--- a/modules.d/90kernel-modules/module-setup.sh
Harald Hoyer 0840a3
+++ b/modules.d/90kernel-modules/module-setup.sh
Harald Hoyer 0840a3
@@ -74,7 +74,7 @@ installkernel() {
Harald Hoyer 0840a3
                     instmods '=fs'
Harald Hoyer 0840a3
             fi
Harald Hoyer 0840a3
         else
Harald Hoyer 0840a3
-            for i in $(host_fs_all); do
Harald Hoyer 0840a3
+            for i in "${host_fs_types[@]}"; do
Harald Hoyer 0840a3
                 hostonly='' instmods $i
Harald Hoyer 0840a3
             done
Harald Hoyer 0840a3
         fi
Harald Hoyer 0840a3
diff --git a/modules.d/95cifs/module-setup.sh b/modules.d/95cifs/module-setup.sh
Harald Hoyer 0840a3
index 0e69845..f711458 100755
Harald Hoyer 0840a3
--- a/modules.d/95cifs/module-setup.sh
Harald Hoyer 0840a3
+++ b/modules.d/95cifs/module-setup.sh
Harald Hoyer 0840a3
@@ -6,7 +6,7 @@ check() {
Harald Hoyer 0840a3
     require_binaries mount.cifs || return 1
Harald Hoyer 0840a3
 
Harald Hoyer 0840a3
     [[ $hostonly ]] || [[ $mount_needs ]] && {
Harald Hoyer 0840a3
-        for fs in ${host_fs_types[@]}; do
Harald Hoyer 0840a3
+        for fs in "${host_fs_types[@]}"; do
Harald Hoyer 0840a3
             [[ "$fs" == "cifs" ]] && return 0
Harald Hoyer 0840a3
         done
Harald Hoyer 0840a3
         return 255
Harald Hoyer 0840a3
diff --git a/modules.d/95nfs/module-setup.sh b/modules.d/95nfs/module-setup.sh
Harald Hoyer 0840a3
index 8eb542c..9b5b8c8 100755
Harald Hoyer 0840a3
--- a/modules.d/95nfs/module-setup.sh
Harald Hoyer 0840a3
+++ b/modules.d/95nfs/module-setup.sh
Harald Hoyer 0840a3
@@ -7,7 +7,7 @@ check() {
Harald Hoyer 0840a3
     require_binaries rpc.statd mount.nfs mount.nfs4 umount || return 1
Harald Hoyer 0840a3
 
Harald Hoyer 0840a3
     [[ $hostonly ]] || [[ $mount_needs ]] && {
Harald Hoyer 0840a3
-        for fs in ${host_fs_types[@]}; do
Harald Hoyer 0840a3
+        for fs in "${host_fs_types[@]}"; do
Harald Hoyer 0840a3
             [[ "$fs" == "nfs" ]] && return 0
Harald Hoyer 0840a3
             [[ "$fs" == "nfs3" ]] && return 0
Harald Hoyer 0840a3
             [[ "$fs" == "nfs4" ]] && return 0
Harald Hoyer 0840a3
diff --git a/modules.d/95virtfs/module-setup.sh b/modules.d/95virtfs/module-setup.sh
Harald Hoyer 0840a3
index 97d39b9..96036ee 100755
Harald Hoyer 0840a3
--- a/modules.d/95virtfs/module-setup.sh
Harald Hoyer 0840a3
+++ b/modules.d/95virtfs/module-setup.sh
Harald Hoyer 0840a3
@@ -3,7 +3,7 @@
Harald Hoyer 0840a3
 # called by dracut
Harald Hoyer 0840a3
 check() {
Harald Hoyer 0840a3
     [[ $hostonly ]] || [[ $mount_needs ]] && {
Harald Hoyer 0840a3
-        for fs in ${host_fs_types[@]}; do
Harald Hoyer 0840a3
+        for fs in "${host_fs_types[@]}"; do
Harald Hoyer 0840a3
             [[ "$fs" == "9p" ]] && return 0
Harald Hoyer 0840a3
         done
Harald Hoyer 0840a3
         return 255
Harald Hoyer 0840a3
diff --git a/modules.d/99base/module-setup.sh b/modules.d/99base/module-setup.sh
Harald Hoyer 0840a3
index 3fbdc41..cc94d00 100755
Harald Hoyer 0840a3
--- a/modules.d/99base/module-setup.sh
Harald Hoyer 0840a3
+++ b/modules.d/99base/module-setup.sh
Harald Hoyer 0840a3
@@ -101,15 +101,15 @@ install() {
Harald Hoyer 0840a3
 
Harald Hoyer 0840a3
                 . "$moddir/dracut-lib.sh"
Harald Hoyer 0840a3
 
Harald Hoyer 0840a3
-                for _dev in ${host_devs[@]}; do
Harald Hoyer 0840a3
-                    for _dev2 in ${root_devs[@]}; do
Harald Hoyer 0840a3
+                for _dev in "${host_devs[@]}"; do
Harald Hoyer 0840a3
+                    for _dev2 in "${root_devs[@]}"; do
Harald Hoyer 0840a3
                         [[ "$_dev" == "$_dev2" ]] && continue 2
Harald Hoyer 0840a3
                     done
Harald Hoyer 0840a3
 
Harald Hoyer 0840a3
                     # We only actually wait for real devs - swap is only needed
Harald Hoyer 0840a3
                     # for resume and udev rules generated when parsing resume=
Harald Hoyer 0840a3
                     # argument take care of the waiting for us
Harald Hoyer 0840a3
-                    for _dev2 in ${swap_devs[@]}; do
Harald Hoyer 0840a3
+                    for _dev2 in "${swap_devs[@]}"; do
Harald Hoyer 0840a3
                       [[ "$_dev" == "$_dev2" ]] && continue 2
Harald Hoyer 0840a3
                     done
Harald Hoyer 0840a3