init.sh: use backslash for dotfiles in eval

see:

commit f0c629dcc6
Author: Leah Rowe <leah@libreboot.org>
Date:   Sat Apr 12 13:51:49 2025 +0100

    lib.sh: write version/versiondate to dotfiles

and this bug report:

https://codeberg.org/libreboot/lbmk/issues/284

The report indicates that the above commit broke bash,
when sh (on the user's system) is bash.

I know sometimes when using bash, I need to use the
back slash when dealing with dots, e.g. when grepping
something.

Also double quote references to dotfiles, e.g. when
directing the output of printf.

I never noticed the issue myself, since I use dash.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2025-04-29 11:48:39 +01:00
parent da108d1c04
commit 3045079947
+4 -4
View File
@@ -162,10 +162,10 @@ xbmk_set_env()
xbmk_set_version()
{
for fv in version versiondate; do
eval "[ ! -f \".$fv\" ] || read -r $fv < \".$fv\" || :"
eval "[ ! -f \"\.$fv\" ] || read -r $fv < \"\.$fv\" || :"
done
[ -e ".git" ] || [ -f ".version" ] || printf "unknown\n" > .version \
[ -e ".git" ] || [ -f ".version" ] || printf "unknown\n" > ".version" \
|| $err "Cannot generate unknown .version file"
[ -e ".git" ] || [ -f ".versiondate" ] || printf "1716415872\n" > \
.versiondate || $err "Cannot generate unknown .versiondate file"; :
@@ -178,8 +178,8 @@ xbmk_set_version()
--pretty='%ct' HEAD)" || versiondate="$versiondate_"
chkvars version versiondate
printf "%s\n" "$version" > .version || $err "can't save version"
printf "%s\n" "$versiondate" > .versiondate || $err "can't save date"
printf "%s\n" "$version" > ".version" || $err "can't save version"
printf "%s\n" "$versiondate" > ".versiondate" || $err "can't save date"
relname="$projectname-$version"
export LOCALVERSION="-$projectname-${version%%-*}"