mk: major code cleanup

we don't need a main here. it's so generic that we
can just leave it really small like it is now. now
it's much clearer what it actually does.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-09-10 19:56:36 +01:00
parent 86781a5881
commit 005f1189c1
+11 -22
View File
@@ -11,36 +11,25 @@ xrval=0
(
xbarg0="$0"
if [ "${xbarg0##*/}" = "$xbarg0" ]; then
xbarg0="`command -v "$xbarg0"`"
fi
[ "${xbarg0##*/}" = "$xbarg0" ] && \
xbarg0="`command -v "$xbarg0"`"
xbcddir="`readlink -f "$xbarg0" 2>/dev/null`"
if [ -z "$xbcddir" ]; then
xbcddir="`realpath "$xbarg0" 2>/dev/null`"
fi
xbcddir="${xbcddir%/*}"
commandv="`readlink -f "$xbarg0" 2>/dev/null`"
[ -z "$commandv" ] && \
commandv="`realpath "$xbarg0" 2>/dev/null`"
cd "$xbcddir" || exit 1
cd "${commandv%/*}" || exit 1
. "include/common.sh"
main()
{
cmd="${1-}"
[ $# -gt 0 ] && shift 1
if xeq main "${1-}" \
$xbcommands; then
if ! xeq main "$cmd" $xbcommands; then
return 0
fi
$cmd "$@"
"$@"
set -u -e
return 1
}
main "$@" || exit 0
exit 0
fi
. "include/tree.sh"