]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
fix: proper return code for inst_multiple in dracut-init.sh
authorAndrew J. Hesford <ajh@sideband.org>
Thu, 18 Feb 2021 23:53:15 +0000 (18:53 -0500)
committerHarald Hoyer <harald@hoyer.xyz>
Fri, 19 Feb 2021 08:03:53 +0000 (09:03 +0100)
A test of the form

    if ! command; then
        _ret=$?
        ...
        return _ret
    fi

does not capture the return code of `command`, but the negation of the
return code, leaving _ret == 0. The test of this form in inst_multiple
has been refactored to capture and return the right value.

dracut-init.sh

index d414c7e854d9f14eb5f2e7aefe0a5f4490734d29..e4c7bd5e24049d71a7a06f56e4dded212c08ca1a 100644 (file)
@@ -258,12 +258,13 @@ inst_symlink() {
 
 inst_multiple() {
     local _ret
-    if ! "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} -a ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l}  ${DRACUT_FIPS_MODE:+-f} "$@"; then
+    if "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} -a ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l}  ${DRACUT_FIPS_MODE:+-f} "$@"; then
+        return 0
+    else
         _ret=$?
         derror FAILED: "$DRACUT_INSTALL" ${dracutsysrootdir:+-r "$dracutsysrootdir"} ${initdir:+-D "$initdir"} -a ${loginstall:+-L "$loginstall"} ${DRACUT_RESOLVE_DEPS:+-l}  ${DRACUT_FIPS_MODE:+-f} ${_hostonly_install:+-H} "$@" || :
         return $_ret
     fi
-    return 0
 }
 
 dracut_install() {