summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorP. J. McDermott <pj@pehjota.net>2014-08-15 18:41:04 (EDT)
committer P. J. McDermott <pj@pehjota.net>2014-08-15 18:41:04 (EDT)
commit28c19dca3ccf720652f719ceec45cc39eb04b8e9 (patch)
tree5c4dfd99afeeb114a694c6b9433796896fd935f0 /src
parent40b249b081419598d7429cebccb45c39b0123399 (diff)
use(): Detect in-place execution
Diffstat (limited to 'src')
-rw-r--r--src/prokit.sh11
1 files changed, 9 insertions, 2 deletions
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