]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
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)
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

index 679e94b1b8eb98e9e8460ee0f4227cf41d899d19..26878929bec7a7c94471930d1d65c031b9c1a971 100755 (executable)
@@ -132,6 +132,4 @@ case "$COMMAND" in
         ret=1;;
 esac
 
-((ret+=$?))
-
 exit $ret