mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-03-26 05:49:03 +02:00
Instead of having detailed error messages, run most commands through a function that calls err() under fault conditions. Where detail is still required, err() is still called manually. Where it isn't, the error message is simply whatever command was executed to cause the error. This results in a massive sloccount reduction for lbmk; specifically, 178 sloc reduction, or a 8.1% reduction. The total sloccount is now 2022, for shell scripts. Signed-off-by: Leah Rowe <leah@libreboot.org>
30 lines
464 B
Bash
Executable File
30 lines
464 B
Bash
Executable File
# 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
|
|
}
|