diff options
| author | Leah Rowe <leah@libreboot.org> | 2026-09-10 14:03:11 +0100 |
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2026-09-10 14:03:11 +0100 |
| commit | 786cf8cd9cd177cefb93609675b66a125fc42db9 (patch) | |
| tree | 43c7268c47a45bb0644d46ea5d84a37b1692f07f | |
| parent | 189b61018f8ff215220b4dab665a528db9ee3ab6 (diff) | |
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>
| -rwxr-xr-x | mk | 26 |
1 files changed, 9 insertions, 17 deletions
@@ -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" |
