tree.sh: fix globbing in multi-tree command args

this solves a bug that does not yet manifest, because
this bug *can't* currently trigger any error due to
lbmk's design. this is therefore a preventative fix,
for reasons that will become clear.

we previously put arguments in a variable, in a way
that didn't handle globbing. now we avoid a variable
and use "$@" instead, which solves the problem.

this also means that the main logic in mk can be
cleaner, as trees-specific control logic is now
placed entirely in tree.sh's main.

this means that we can now also wrap x_ around trees()

this was never a problem in the past, because all of
the arguments for trees commands never have globbing;
config names are always e.g. foo_bar, not foo bar

in commands where globbing did need to be handled,
those commands were never trees commands. e.g.
you had ./mk inject filename

yes, this is a design improvement, or a preventative
bug fix. pick your poison.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-09-14 07:54:00 +01:00
parent a82328904e
commit 4ebede5b99
2 changed files with 16 additions and 19 deletions
+15 -15
View File
@@ -17,7 +17,7 @@ eval "`newvar autoconfargs autogenargs badhash badtghash bootstrapargs \
build_depend buildtype cleanargs cmakedir cmd defconfig dest_dir elfdir \ build_depend buildtype cleanargs cmakedir cmd defconfig dest_dir elfdir \
forcepull gccdir gccfull gccver gnatdir gnatfull gnatver listfile \ forcepull gccdir gccfull gccver gnatdir gnatfull gnatver listfile \
makeargs mdir mkhelper mkhelpercfg mode postmake premake project release \ makeargs mdir mkhelper mkhelpercfg mode postmake premake project release \
rev srcdir target target_dir targets tree xarch xgcctree xlang`" rev srcdir target target_dir tree xarch xgcctree xlang`"
trees() trees()
{ {
@@ -79,7 +79,7 @@ trees()
err "missing flag ($flags)" "trees" "$@" err "missing flag ($flags)" "trees" "$@"
elif [ -z "$project" ]; then elif [ -z "$project" ]; then
fx_ "x_ ./mk $flag" x_ ls -1 config/git fx_ "x_ ./mk $flag" x_ ls -1 config/git
return 1 return 0
elif [ ! -f "config/git/$project/pkg.cfg" ]; then elif [ ! -f "config/git/$project/pkg.cfg" ]; then
err "config/git/$project/pkg.cfg missing" "trees" "$@" err "config/git/$project/pkg.cfg missing" "trees" "$@"
fi fi
@@ -100,13 +100,15 @@ trees()
x_ touch "$mkhelpercfg" x_ touch "$mkhelpercfg"
fi fi
targets="$*" cmd="build_project"
cmd="build_targets $targets" singletree "$project" || \
if singletree "$project"; then cmd="build_targets"
cmd="build_project"
fi
remkdir "${tmpgit%/*}" remkdir "${tmpgit%/*}"
x_ touch "$mkhelpercfg"
. "$mkhelpercfg"
$cmd "$@"
} }
build_project() build_project()
@@ -131,14 +133,12 @@ build_project()
build_targets() build_targets()
{ {
if [ ! -d "$configdir" ]; then [ ! -d "$configdir" ] && \
err "directory '$configdir' doesn't exist" "build_targets" "$@" err "directory '$configdir' doesn't exist" "build_targets" "$@"
elif [ $# -lt 1 ]; then [ $# -lt 1 ] && \
targets="$(ls -1 "$configdir")" || \ fx_ build_targets find "$configdir" \
err "'$configdir': can't list targets" "build_targets" "$@" -mindepth 1 -maxdepth 1 -type d
fi [ $# -gt 0 ] && for x in "$@"
for x in $targets
do do
unset CROSS_COMPILE unset CROSS_COMPILE
export PATH="$xbmkpath" export PATH="$xbmkpath"
@@ -151,7 +151,7 @@ build_targets()
printf "'make %s', '%s', '%s'\n" "$mode" "$project" "$x" printf "'make %s', '%s', '%s'\n" "$mode" "$project" "$x"
target="$x" target="${x##*/}"
x_ handle_defconfig x_ handle_defconfig
+1 -4
View File
@@ -41,9 +41,6 @@ shift 1 2>/dev/null || :
eval "$(printf "version release download inject\n" | awk '{ for (i=1; i<=NF; \ eval "$(printf "version release download inject\n" | awk '{ for (i=1; i<=NF; \
i++) $i = "[ \""$i"\" = \"$_f\" ] && x_ "$i" \"$@\" && exit 0;"; print }')" i++) $i = "[ \""$i"\" = \"$_f\" ] && x_ "$i" \"$@\" && exit 0;"; print }')"
trees "$_f" "$@" || exit 0 x_ trees "$_f" "$@"
x_ touch "$mkhelpercfg"
. "$mkhelpercfg"
$cmd
) || exit 1; : ) || exit 1; :