Blob Blame History Raw
From 9bb030c5d8189f42eef3a0a881a361ce811414b0 Mon Sep 17 00:00:00 2001
From: Harald Hoyer <harald@redhat.com>
Date: Wed, 13 Apr 2016 13:57:03 +0200
Subject: [PATCH] dracut-init.sh: beautify instmods()

---
 dracut-init.sh | 31 ++++++++++++++++++++++++++++---
 1 file changed, 28 insertions(+), 3 deletions(-)

diff --git a/dracut-init.sh b/dracut-init.sh
index e26d97a..8d1d9fa 100644
--- a/dracut-init.sh
+++ b/dracut-init.sh
@@ -1001,22 +1001,47 @@ instmods() {
     local _optional="-o"
     local _silent
     local _ret
+
     [[ $no_kernel = yes ]] && return
+
     if [[ $1 = '-c' ]]; then
-        _optional=""
+        unset _optional
         shift
     fi
     if [[ $1 = '-s' ]]; then
         _silent=1
         shift
     fi
+
     if (($# == 0)); then
         read -r -d '' -a args
         set -- "${args[@]}"
     fi
-    $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"}  ${hostonly:+-H} ${omit_drivers:+-N "$omit_drivers"} ${_optional:+-o} ${_silent:+--silent} ${srcmods:+--kerneldir "$srcmods"} -m "$@"
+
+    $DRACUT_INSTALL \
+        ${initdir:+-D "$initdir"} \
+        ${loginstall:+-L "$loginstall"} \
+        ${hostonly:+-H} \
+        ${omit_drivers:+-N "$omit_drivers"} \
+        ${srcmods:+--kerneldir "$srcmods"} \
+        ${_optional:+-o} \
+        ${_silent:+--silent} \
+        -m "$@"
     _ret=$?
-    (($_ret != 0)) && [[ -z "$_silent" ]] && derror FAILED: $DRACUT_INSTALL ${initdir:+-D "$initdir"} ${loginstall:+-L "$loginstall"} ${hostonly:+-H} ${omit_drivers:+-N "$omit_drivers"} ${_optional:+-o} ${_silent:+--silent} ${srcmods:+--kerneldir "$srcmods"} -m "$@" || :
+
+    if (($_ret != 0)) && [[ -z "$_silent" ]]; then
+        derror "FAILED: " \
+            $DRACUT_INSTALL \
+                ${initdir:+-D "$initdir"} \
+                ${loginstall:+-L "$loginstall"} \
+                ${hostonly:+-H} \
+                ${omit_drivers:+-N "$omit_drivers"} \
+                ${srcmods:+--kerneldir "$srcmods"} \
+                ${_optional:+-o} \
+                ${_silent:+--silent} \
+                -m "$@"
+    fi
+
     [[ "$optional" ]] && return 0
     return $_ret
 }