Skip to content

Commit

Permalink
fix: proper return code for inst_multiple in dracut-init.sh
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
ahesford authored and haraldh committed Feb 19, 2021
1 parent f8b38ec commit d437970
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dracut-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit d437970

Please sign in to comment.