xbmk: allow to run from PATH

now you can put lbmk somewhere on your system,
and symlink to the mk script from PATH

e.g. /usr/local/bin/lbmk -> /home/leah/lbmk/mk

lbmk will cd to itself, including from PATH,
because the string will then be passed through
readlink, which gets the real path.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-09-10 14:03:11 +01:00
parent 189b61018f
commit 786cf8cd9c
+9 -17
View File
@@ -10,29 +10,21 @@ set -u -e
xrval=0
(
ispwd="true"
xbdir=""
xbarg0="$0"
if [ "$0" != "./mk" ]; then
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
if [ "${0##*/}" = "$0" ]; then
xbarg0="`command -v "$0"`"
xbdir="${xbarg0%/*}"
xbcddir="$xbdir"
fi
if [ "$ispwd" = "true" ] && [ -L "mk" ]; then
ispwd="false"
xbcddir="`readlink -f "$0" 2>/dev/null`"
if [ -z "$xbcddir" ]; then
xbcddir="`realpath "$0" 2>/dev/null`"
fi
if [ "$ispwd" = "false" ]; then
printf "You must run this in the proper work directory.\n" 1>&2
exit 1
fi
cd "${xbcddir%/*}" || exit 1
. "include/lib.sh"
. "include/init.sh"