summaryrefslogtreecommitdiff
path: root/include/err.sh
blob: 466e427b5c299f4fe8ccf66c05911ac520f0f530 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2022, 2023 Leah Rowe <leah@libreboot.org>

xfail=""

x_() {
	[ $# -lt 1 ] || ${@} || err "${@}"
}
xx_() {
	[ $# -lt 1 ] || ${@} || fail "${@}"
}

setvars()
{
	_setvars=""
	[ $# -lt 2 ] && err "setvars: too few arguments"
	val="${1}"
	shift 1
	for var in $@; do
		_setvars="${var}=\"${val}\"; ${_setvars}"
	done
	printf "%s\n" "${_setvars% }"
}

err()
{
	printf "ERROR %s: %s\n" "${0}" "${1}" 1>&2
	exit 1
}