]> git.ipfire.org Git - thirdparty/dracut-ng.git/commitdiff
fix(dracut-logger): allow dlog_init to print multiple errors
authorBenjamin Drung <benjamin.drung@canonical.com>
Sat, 31 Jan 2026 18:51:45 +0000 (19:51 +0100)
committerNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>
Wed, 4 Feb 2026 12:50:59 +0000 (07:50 -0500)
Allow `dlog_init` to print multiple errors by making `errmsg` an array.

dracut-logger.sh

index 1f87e4578429c2436b09fccfd9d7a1f744f76301..321825f2732a31228ddc3e98d50361c1c752e26b 100644 (file)
@@ -103,7 +103,7 @@ export __DRACUT_LOGGER__=1
 dlog_init() {
     local __oldumask
     local ret=0
-    local errmsg=
+    local errmsgs=()
     [ -z "${stdloglvl-}" ] && stdloglvl=4
     [ -z "${sysloglvl-}" ] && sysloglvl=0
     [ -z "${kmsgloglvl-}" ] && kmsgloglvl=0
@@ -131,7 +131,7 @@ dlog_init() {
                 # We cannot log to file, so turn this facility off.
                 fileloglvl=0
                 ret=1
-                errmsg="'$logfile' is not a writable file"
+                errmsgs+=("'$logfile' is not a writable file")
             fi
         fi
     fi
@@ -156,7 +156,7 @@ dlog_init() {
             kmsgloglvl=$sysloglvl
             sysloglvl=0
             ret=1
-            errmsg="No '/dev/log' or 'logger' included for syslog logging"
+            errmsgs+=("No '/dev/log' or 'logger' included for syslog logging")
         fi
     fi
 
@@ -214,7 +214,9 @@ dlog_init() {
         dfatal() { :; }
     fi
 
-    [ -n "$errmsg" ] && derror "$errmsg"
+    for errmsg in "${errmsgs[@]}"; do
+        derror "$errmsg"
+    done
 
     return $ret
 }