xbmk: allow running from outside of work dir

i need only now implement a check for sys dirs
e.g. /etc/lbmk.cfg and check if it defines
e.g. other location for config/ and include/

then mk is a generic dispatcher and i can one
day make mk possible to install. for example, if
you have a bsd ports system and you want to
install lbmk

i could make it check user dirs too, overriding
defaults. for example /usr/local/etc/lbmk, but
then i might have ~/.config/lbmk

you no longer need to be in the xbmk directory
to run xbmk. it'll cd to itself, with this patch

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-09-10 13:52:16 +01:00
parent e973584123
commit 189b61018f
+18 -1
View File
@@ -7,15 +7,29 @@
set -u -e
xrval=0
(
ispwd="true"
xbdir=""
if [ "$0" != "./mk" ]; then
ispwd="false"
if [ "${0##*/}" != "$0" ]; then
xbdir="`readlink -f "$0" 2>/dev/null`"
if [ -z "$xbdir" ]; then
xbdir="`realpath "$0" 2>/dev/null`"
fi
cd "${xbdir%/*}" || exit 1
else
ispwd="false"
fi
fi
if [ "$ispwd" = "true" ] && [ -L "mk" ]; then
ispwd="false"
fi
if [ "$ispwd" = "false" ]; then
printf "You must run this in the proper work directory.\n" 1>&2
exit 1
fi
@@ -59,3 +73,6 @@ x_ touch "$mkhelpercfg"
. "$mkhelpercfg"
$cmd
) || xrval=1
exit $xrval