summaryrefslogtreecommitdiff
path: root/include/err.sh
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-09-30 18:41:57 +0100
committerLeah Rowe <leah@libreboot.org>2023-09-30 19:09:25 +0100
commit0a0defd3256ff5e29e3b4d129a04fb7546bc31ac (patch)
tree479d686f0578b506dbe3f862300e73c090ed8bcc /include/err.sh
parent49b266eb4248f87d111e9babae86a873300afa03 (diff)
simplify initialising variables in shell scripts
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'include/err.sh')
-rwxr-xr-xinclude/err.sh12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/err.sh b/include/err.sh
index 96252534..9f7c63b0 100755
--- a/include/err.sh
+++ b/include/err.sh
@@ -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