summaryrefslogtreecommitdiff
path: root/include/lib.sh
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2024-06-14 13:36:31 +0100
committerLeah Rowe <leah@libreboot.org>2024-06-14 13:37:03 +0100
commit167e1a0fbe6765aaa5f5d3dc682709aa3c31260b (patch)
tree8dde0d22155b438140e3d2e22be8fb4197abe351 /include/lib.sh
parent98724d701b10a037e8ffa7ce2864a08993268517 (diff)
unified checks for variable initialisation
new function chkvars() does the job Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'include/lib.sh')
-rwxr-xr-xinclude/lib.sh8
1 files changed, 7 insertions, 1 deletions
diff --git a/include/lib.sh b/include/lib.sh
index a329fa3f..3de05c24 100755
--- a/include/lib.sh
+++ b/include/lib.sh
@@ -41,6 +41,12 @@ setvars()
done
printf "%s\n" "${_setvars% }"
}
+chkvars()
+{
+ for var in $@; do
+ eval "[ -n "\${$var+x}" ] || \$err \"$var unset\""
+ done
+}
eval "$(setvars "" xbmk_release tmpdir _nogit version board boarddir relname \
versiondate threads projectname projectsite aur_notice cfgsdir datadir)"
@@ -112,7 +118,7 @@ versiondate_="$versiondate"
[ ! -e ".git" ] || versiondate="$(git show --no-patch --no-notes \
--pretty='%ct' HEAD)" || versiondate="$versiondate_"
for p in projectname version versiondate projectsite; do
- eval "[ -n \"\$$p\" ] || $err \"$p unset\""
+ chkvars "$p"
eval "x_ printf \"%s\\n\" \"\$$p\" > $p"
done
relname="$projectname-$version"