unified checks for variable initialisation

new function chkvars() does the job

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2024-06-14 13:36:31 +01:00
parent 98724d701b
commit 167e1a0fbe
4 changed files with 14 additions and 14 deletions
+7 -1
View File
@@ -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"