From 28c19dca3ccf720652f719ceec45cc39eb04b8e9 Mon Sep 17 00:00:00 2001 From: P. J. McDermott Date: Fri, 15 Aug 2014 18:41:04 -0400 Subject: use(): Detect in-place execution --- diff --git a/src/prokit.sh b/src/prokit.sh index 1eec0ef..5679e33 100644 --- a/src/prokit.sh +++ b/src/prokit.sh @@ -34,9 +34,16 @@ OPTSTRING='hV' use() { local module="${1}" + local dir= - if [ -f "${PKGDATADIR}/${module}.sm" ]; then - . "${PKGDATADIR}/${module}.sm" + if [ -f "${0%/*}/../lib/output.sm" ]; then + dir="${0%/*}/../lib" + else + dir="${PKGDATADIR}" + fi + + if [ -f "${dir}/${module}.sm" ]; then + . "${dir}/${module}.sm" else printf '%s: Error: Failed to load module "%s": %s\n' \ "${0##*/}" "${module}" 'no such file or directory' >&2 -- cgit v0.9.1