]> git.ipfire.org Git - thirdparty/dracut.git/commit
51-dracut-rescue.install: fix exit status code
authorJavier Martinez Canillas <javierm@redhat.com>
Fri, 15 Jun 2018 08:36:27 +0000 (10:36 +0200)
committerHarald Hoyer <harald@hoyer.xyz>
Mon, 2 Jul 2018 09:33:41 +0000 (11:33 +0200)
commit4f553878293ecf7dbe167bf245e1e5fe7ccc9656
tree94dbd6a496433646bc0ec34c4a4143244f797b67
parentbca1967c90967d5453d8b215ff28552776e4fcb3
51-dracut-rescue.install: fix exit status code

After the $COMMAND case statement, the exit status of the last executed
command is added to the $ret variable.

But for the "add" pattern, this last executed command is an arithmetic
expression that also adds the exit status $? to the $ret variable. If
both $? and $ret are 0, then the arithmetic expression evaluates to 0
so is considered false and has an exit status of 1.

This makes the script to wrongly exit with an status code of 1 when it
should had been 0.

  case "$COMMAND" in
      add)
      ...
          ((ret+=$?))
  # $ret is 0 here
          ;;
  ...
  esac

  ((ret+=$?))
  # $ ret is 1 here

  exit $ret

Since $ret is set in the case statement, just exit with that status code
and remove the last arithmetic expression that wrongly sets $ret to 1.

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
51-dracut-rescue.install