summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2024-06-25 00:18:12 +0100
committerLeah Rowe <leah@libreboot.org>2024-06-25 00:18:12 +0100
commit20ac7ec67ba31315b8cccf0ea70b6fa4a5d0efae (patch)
tree9e9208b4bca04149576b382a61ac5655dada36a5
parent4e48fa808ec123962c0203282742f9ce641a40d3 (diff)
lib.sh: simplify reading of version files
Signed-off-by: Leah Rowe <leah@libreboot.org>
-rwxr-xr-xinclude/lib.sh7
1 files changed, 3 insertions, 4 deletions
diff --git a/include/lib.sh b/include/lib.sh
index 32499bc0..c21a4a1d 100755
--- a/include/lib.sh
+++ b/include/lib.sh
@@ -45,8 +45,9 @@ chkvars()
eval `setvars "" tmpdir _nogit board boarddir relname versiondate projectsite \
projectname aur_notice cfgsdir datadir version`
-read -r projectname < projectname || :
-read -r projectsite < projectsite || :
+for fv in projectname projectsite version versiondate; do
+ eval "[ ! -f "$fv" ] || read -r $fv < \"$fv\" || :"
+done
setcfg()
{
@@ -120,11 +121,9 @@ x_() {
[ -e ".git" ] || [ -f "versiondate" ] || printf "1716415872\n" > versiondate || \
$err "Cannot generate unknown versiondate file"
-[ ! -f version ] || read -r version < version || :
version_="$version"
[ ! -e ".git" ] || version="$(git describe --tags HEAD 2>&1)" || \
version="git-$(git rev-parse HEAD 2>&1)" || version="$version_"
-[ ! -f versiondate ] || read -r versiondate < versiondate || :
versiondate_="$versiondate"
[ ! -e ".git" ] || versiondate="$(git show --no-patch --no-notes \
--pretty='%ct' HEAD)" || versiondate="$versiondate_"