Skip to content

Commit

Permalink
Bootstrap: move the fail function to the top
Browse files Browse the repository at this point in the history
We use fail pretty early in the script and not having
the fail function leads to non useful message about
the fail function not existing.

Fixes #2949.

PiperOrigin-RevId: 155186880
  • Loading branch information
damienmg committed May 5, 2017
1 parent e114a5e commit 511c35b
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions scripts/bootstrap/buildenv.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,19 @@ if [ -n "${BAZEL_WRKDIR}" ] ; then
fi


# We define the fail function early so we can use it when detecting the JDK
# See https://github.com/bazelbuild/bazel/issues/2949,
function fail() {
local exitCode=$?
if [[ "$exitCode" = "0" ]]; then
exitCode=1
fi
echo >&2
echo "ERROR: $@" >&2
exit $exitCode
}


# Set standard variables
DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
WORKSPACE_DIR="$(dirname "$(dirname "${DIR}")")"
Expand Down Expand Up @@ -192,16 +205,6 @@ function run() {
fi
}

function fail() {
local exitCode=$?
if [[ "$exitCode" = "0" ]]; then
exitCode=1
fi
echo >&2
echo "ERROR: $@" >&2
exit $exitCode
}

function display() {
if [[ -z "${QUIETMODE}" ]]; then
echo -e "$@" >&2
Expand Down

0 comments on commit 511c35b

Please sign in to comment.