From 189b61018f8ff215220b4dab665a528db9ee3ab6 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Thu, 10 Sep 2026 13:52:16 +0100 Subject: [PATCH] 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 --- mk | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/mk b/mk index 286e24f9..40ecfffb 100755 --- a/mk +++ b/mk @@ -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