Skip to content

Commit 511c35b

Browse files
committed
Bootstrap: move the fail function to the top
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 bazelbuild#2949. PiperOrigin-RevId: 155186880
1 parent e114a5e commit 511c35b

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

scripts/bootstrap/buildenv.sh

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ if [ -n "${BAZEL_WRKDIR}" ] ; then
3030
fi
3131

3232

33+
# We define the fail function early so we can use it when detecting the JDK
34+
# See https://github.com/bazelbuild/bazel/issues/2949,
35+
function fail() {
36+
local exitCode=$?
37+
if [[ "$exitCode" = "0" ]]; then
38+
exitCode=1
39+
fi
40+
echo >&2
41+
echo "ERROR: $@" >&2
42+
exit $exitCode
43+
}
44+
45+
3346
# Set standard variables
3447
DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
3548
WORKSPACE_DIR="$(dirname "$(dirname "${DIR}")")"
@@ -192,16 +205,6 @@ function run() {
192205
fi
193206
}
194207

195-
function fail() {
196-
local exitCode=$?
197-
if [[ "$exitCode" = "0" ]]; then
198-
exitCode=1
199-
fi
200-
echo >&2
201-
echo "ERROR: $@" >&2
202-
exit $exitCode
203-
}
204-
205208
function display() {
206209
if [[ -z "${QUIETMODE}" ]]; then
207210
echo -e "$@" >&2

0 commit comments

Comments
 (0)