blob: a223e1cdf115e21fc079a70884fc04ab1bb16b02 [file] [log] [blame]
# shellcheck shell=bash
# Copyright 2018-2021 Fairphone B.V.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Globals:
# DEBUG
# VERBOSE
set -e
DEBUG="${DEBUG:-}"
VERBOSE="${VERBOSE:-}"
# Echo formatting
color_error='\033[31m'
color_warning='\033[33m'
color_bold='\033[1m'
color_reset='\033[0m'
log_e()
{
echo "${color_error}$*${color_reset}" >&2
exit 1
}
log_w()
{
echo "${color_warning}$*${color_reset}"
}
log_i()
{
echo "$*"
}
log_v()
{
if [ -n "${VERBOSE}" ] ; then
echo "$*"
fi
}
log_bold()
{
printf "\n${color_bold}%s${color_reset}" "$*"
}
if [ -n "${DEBUG:-}" ]; then
set -x
fi