[PATCH openbmc-build-scripts] build-setup: Ensure we fail the build when a step fails

Daniel Axtens dja at axtens.net
Fri Feb 12 23:48:03 AEDT 2016


Hi Joel,

This is an excellent idea.

When writing bash scripts I tend to use the invocation from
http://redsymbol.net/articles/unofficial-bash-strict-mode/
i.e.

set -euo pipefail

Which will give you:
 - failing when a step fails (-e)
 - failing on undefined variables (-u)
 - failing when a command in a pipe fails (-o pipefail) - the default
 behaviour is to use the exit code of the final command in the pipe.

That might be an improvement over just using -e?

Regards,
Daniel

OpenBMC Patches <openbmc-patches at stwcx.xyz> writes:

> From: Joel Stanley <joel at jms.id.au>
>
> Signed-off-by: Joel Stanley <joel at jms.id.au>
> ---
>  build-setup.sh | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/build-setup.sh b/build-setup.sh
> index a96ed44..f2a37fa 100755
> --- a/build-setup.sh
> +++ b/build-setup.sh
> @@ -7,8 +7,8 @@
>  #   distro = fedora|ubuntu
>  #   WORKSPACE = 
>  
> -# Trace bash processing
> -set -x
> +# Trace bash processing. Set -e so when a step fails, we fail the build
> +set -xe
>  
>  # Default variables
>  target=${target:-qemu}
> @@ -100,7 +100,7 @@ mkdir -p ${WORKSPACE}
>  cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT
>  #!/bin/bash
>  
> -set -x
> +set -ex
>  
>  cd ${WORKSPACE}
>  
> -- 
> 2.7.1
>
>
> _______________________________________________
> openbmc mailing list
> openbmc at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/openbmc


More information about the openbmc mailing list