diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-09-14 07:54:00 +0100 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-09-14 08:06:51 +0100 |
| commit | 4ebede5b99270f0770a989392fd935b13010e695 (patch) | |
| tree | 1e938d0a1568ac0641f67a97b921dd845ac35e54 /include | |
| parent | a82328904e52fb74aed5083e59c8b030b15f19fd (diff) | |
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>
Diffstat (limited to 'include')
| -rw-r--r-- | include/mk/tree.sh | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/include/mk/tree.sh b/include/mk/tree.sh index 434796e2..b11c0a6c 100644 --- a/include/mk/tree.sh +++ b/include/mk/tree.sh @@ -17,7 +17,7 @@ eval "`newvar autoconfargs autogenargs badhash badtghash bootstrapargs \ build_depend buildtype cleanargs cmakedir cmd defconfig dest_dir elfdir \ forcepull gccdir gccfull gccver gnatdir gnatfull gnatver listfile \ 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() { @@ -79,7 +79,7 @@ trees() err "missing flag ($flags)" "trees" "$@" elif [ -z "$project" ]; then fx_ "x_ ./mk $flag" x_ ls -1 config/git - return 1 + return 0 elif [ ! -f "config/git/$project/pkg.cfg" ]; then err "config/git/$project/pkg.cfg missing" "trees" "$@" fi @@ -100,13 +100,15 @@ trees() x_ touch "$mkhelpercfg" fi - targets="$*" - cmd="build_targets $targets" - if singletree "$project"; then - cmd="build_project" - fi + cmd="build_project" + singletree "$project" || \ + cmd="build_targets" remkdir "${tmpgit%/*}" + x_ touch "$mkhelpercfg" + + . "$mkhelpercfg" + $cmd "$@" } build_project() @@ -131,14 +133,12 @@ build_project() build_targets() { - if [ ! -d "$configdir" ]; then + [ ! -d "$configdir" ] && \ err "directory '$configdir' doesn't exist" "build_targets" "$@" - elif [ $# -lt 1 ]; then - targets="$(ls -1 "$configdir")" || \ - err "'$configdir': can't list targets" "build_targets" "$@" - fi - - for x in $targets + [ $# -lt 1 ] && \ + fx_ build_targets find "$configdir" \ + -mindepth 1 -maxdepth 1 -type d + [ $# -gt 0 ] && for x in "$@" do unset CROSS_COMPILE export PATH="$xbmkpath" @@ -151,7 +151,7 @@ build_targets() printf "'make %s', '%s', '%s'\n" "$mode" "$project" "$x" - target="$x" + target="${x##*/}" x_ handle_defconfig |
