diff mbox

[U-Boot,2/6] travis-ci: use correct exit code on errors

Message ID 20161026170536.2367-2-swarren@wwwdotorg.org
State Accepted
Commit 0c5145fc29cf2377fa364aaf848eaf89b886cc28
Delegated to: Tom Rini
Headers show

Commit Message

Stephen Warren Oct. 26, 2016, 5:05 p.m. UTC
From: Stephen Warren <swarren@nvidia.com>

The phrase "if [ $? -ne 0 ]; then exit $?; fi" doesn't work correctly;
by the time the "exit" statement runs, $? has already been over-written
by the result of the [ command. Fix this by explicitly storing $? and
then using that stored value in both the test and the error-case exit
statement.

This change also converts from textual comparison to integer comparison,
since the exit code is an integer and there's no need to convert it to
a string for comparison.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 .travis.yml | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Heiko Schocher Oct. 27, 2016, 4:21 a.m. UTC | #1
Hello Stephen,

Am 26.10.2016 um 19:05 schrieb Stephen Warren:
> From: Stephen Warren <swarren@nvidia.com>
>
> The phrase "if [ $? -ne 0 ]; then exit $?; fi" doesn't work correctly;
> by the time the "exit" statement runs, $? has already been over-written
> by the result of the [ command. Fix this by explicitly storing $? and
> then using that stored value in both the test and the error-case exit
> statement.
>
> This change also converts from textual comparison to integer comparison,
> since the exit code is an integer and there's no need to convert it to
> a string for comparison.
>
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> ---
>   .travis.yml | 7 ++++---
>   1 file changed, 4 insertions(+), 3 deletions(-)

Thanks!

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko

>
> diff --git a/.travis.yml b/.travis.yml
> index f91e1bc271fe..33685ce14777 100644
> --- a/.travis.yml
> +++ b/.travis.yml
> @@ -70,11 +70,12 @@ script:
>    - if [[ "${BUILDMAN}" != "" ]]; then
>        set +e;
>        tools/buildman/buildman ${BUILDMAN};
> -     if [[ "$?" == "0" || "$?" == "129" ]]; then
> +     ret=$?;
> +     if [[ $ret -eq 0 || $ret -eq 129 ]]; then
>          exit 0;
>        else
> -       exit $?;
> -     fi
> +       exit $ret;
> +     fi;
>      fi
>
>   matrix:
>
Tom Rini Oct. 29, 2016, 5:41 p.m. UTC | #2
On Wed, Oct 26, 2016 at 11:05:32AM -0600, Stephen Warren wrote:

> From: Stephen Warren <swarren@nvidia.com>
> 
> The phrase "if [ $? -ne 0 ]; then exit $?; fi" doesn't work correctly;
> by the time the "exit" statement runs, $? has already been over-written
> by the result of the [ command. Fix this by explicitly storing $? and
> then using that stored value in both the test and the error-case exit
> statement.
> 
> This change also converts from textual comparison to integer comparison,
> since the exit code is an integer and there's no need to convert it to
> a string for comparison.
> 
> Signed-off-by: Stephen Warren <swarren@nvidia.com>
> Reviewed-by: Heiko Schocher <hs@denx.de>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/.travis.yml b/.travis.yml
index f91e1bc271fe..33685ce14777 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -70,11 +70,12 @@  script:
  - if [[ "${BUILDMAN}" != "" ]]; then
      set +e;
      tools/buildman/buildman ${BUILDMAN};
-     if [[ "$?" == "0" || "$?" == "129" ]]; then
+     ret=$?;
+     if [[ $ret -eq 0 || $ret -eq 129 ]]; then
        exit 0;
      else
-       exit $?;
-     fi
+       exit $ret;
+     fi;
    fi
 
 matrix: