simplify initialising variables in shell scripts

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2023-09-30 18:41:57 +01:00
parent 49b266eb42
commit 0a0defd325
10 changed files with 51 additions and 122 deletions
+12
View File
@@ -1,6 +1,18 @@
# SPDX-License-Identifier: MIT
# SPDX-FileCopyrightText: 2022, 2023 Leah Rowe <leah@libreboot.org>
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