build: Fail loudly if bash variables are unset, or a pipeline errors

These bash options increase the robustness of bash scripts, increasing
the chances that errors are spotted, instead of passing silently.

errexit was already enabled (by bash -e) if the scripts were invoked as

path/to/script.sh

However bash -e would not take effect if the script was invoked as

bash path/to/script.sh

The long form of the options is used to serve as an memory aide for
readers unfamiliar with bash options.
This commit is contained in:
Alex Willmer 2020-05-11 20:43:12 +01:00
parent 39cb2c1eb0
commit fdff7839b3
3 changed files with 16 additions and 3 deletions

View File

@ -1,4 +1,8 @@
#!/bin/bash -e
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
# Ted: contact me when you make any changes

View File

@ -1,4 +1,9 @@
#!/bin/bash -e
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
SRC_DIR="$(dirname "${BASH_SOURCE[0]}")"
export GOPATH="$SRC_DIR/.build_image_gopath"
WORKPREFIX="$GOPATH/src/github.com/ava-labs/"

View File

@ -1,4 +1,8 @@
#!/bin/bash -e
#!/bin/bash
set -o errexit
set -o nounset
set -o pipefail
# Ted: contact me when you make any changes