]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix: shellcheck for dracut-init.sh
authorHarald Hoyer <harald@redhat.com>
Fri, 12 Feb 2021 12:53:34 +0000 (13:53 +0100)
committerHarald Hoyer <harald@hoyer.xyz>
Mon, 15 Feb 2021 10:00:37 +0000 (11:00 +0100)
dracut-init.sh

index a5ffee6c88e8312dff59b1defc6d98d1cc86b29e..d414c7e854d9f14eb5f2e7aefe0a5f4490734d29 100644 (file)
@@ -922,7 +922,7 @@ check_module() {
         fi
     fi
 
-    for _moddep in $(module_depends $_mod $_moddir); do
+    for _moddep in $(module_depends "$_mod" "$_moddir"); do
         # handle deps as if they were manually added
         [[ " $dracutmodules " == *\ $_mod\ * ]] \
             && [[ " $dracutmodules " != *\ $_moddep\ * ]] \
@@ -934,7 +934,7 @@ check_module() {
             && [[ " $force_add_dracutmodules " != *\ $_moddep\ * ]] \
             && force_add_dracutmodules+=" $_moddep "
         # if a module we depend on fail, fail also
-        if ! check_module $_moddep; then
+        if ! check_module "$_moddep"; then
             derror "dracut module '$_mod' depends on '$_moddep', which can't be installed"
             return 1
         fi
@@ -959,7 +959,7 @@ for_each_module_dir() {
         [[ -e $_moddir/install || -e $_moddir/installkernel || \
             -e $_moddir/module-setup.sh ]] || continue
         _mod=${_moddir##*/}; _mod=${_mod#[0-9][0-9]}
-        $_func $_mod 1 $_moddir
+        $_func "$_mod" 1 "$_moddir"
     done
 
     # Report any missing dracut modules, the user has specified
@@ -987,7 +987,7 @@ dracut_kernel_post() {
 
     # generate module dependencies for the initrd
     if [[ -d $initdir/lib/modules/$kernel ]] && \
-        ! depmod -a -b "$initdir" $kernel; then
+        ! depmod -a -b "$initdir" "$kernel"; then
         dfatal "\"depmod -a $kernel\" failed."
         exit 1
     fi
@@ -1025,7 +1025,7 @@ instmods() {
         return 0
     fi
 
-    $DRACUT_INSTALL \
+    "$DRACUT_INSTALL" \
         ${initdir:+-D "$initdir"} \
         ${dracutsysrootdir:+-r "$dracutsysrootdir"} \
         ${loginstall:+-L "$loginstall"} \
@@ -1037,9 +1037,9 @@ instmods() {
         -m "$@"
     _ret=$?
 
-    if (($_ret != 0)) && [[ -z "$_silent" ]]; then
+    if ((_ret != 0)) && [[ -z "$_silent" ]]; then
         derror "FAILED: " \
-            $DRACUT_INSTALL \
+            "$DRACUT_INSTALL" \
                 ${initdir:+-D "$initdir"} \
                 ${dracutsysrootdir:+-r "$dracutsysrootdir"} \
                 ${loginstall:+-L "$loginstall"} \
@@ -1073,8 +1073,9 @@ is_qemu_virtualized() {
     # 1 if a virt environment could not be detected
     # 255 if any error was encountered
     if type -P systemd-detect-virt >/dev/null 2>&1; then
-        vm=$(systemd-detect-virt --vm >/dev/null 2>&1)
-        (($? != 0)) && return 255
+        if ! vm=$(systemd-detect-virt --vm >/dev/null 2>&1); then
+            return 255
+        fi
         [[ $vm = "qemu" ]] && return 0
         [[ $vm = "kvm" ]] && return 0
         [[ $vm = "bochs" ]] && return 0
@@ -1082,7 +1083,7 @@ is_qemu_virtualized() {
 
     for i in /sys/class/dmi/id/*_vendor; do
         [[ -f $i ]] || continue
-        read vendor < $i
+        read -r vendor < "$i"
         [[  "$vendor" == "QEMU" ]] && return 0
         [[ "$vendor" == "Red Hat" ]] && return 0
         [[  "$vendor" == "Bochs" ]] && return 0