summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Grapentin <andreas@grapentin.org>2020-04-12 19:13:19 +0200
committerAndreas Grapentin <andreas@grapentin.org>2021-07-16 19:44:53 +0200
commita94838e1792a85f74a540daafb6715a5b3ae2908 (patch)
treefb9826a7aae5d8067d0f3380d2fb589b9c775429 /src
parent0e6f16fd96f89b675f7748bbd21a70f6796c45e8 (diff)
src/lib/librelib: separate LIBRETOOLS_LIBDIR by ':' and consider each part as a candidate for searching the requested script, and rename LIBRETOOLS_LIBDIR to LIBRETOOLS_LIBRARY_PATH to reflect that change
Signed-off-by: Andreas Grapentin <andreas@grapentin.org>
Diffstat (limited to 'src')
-rwxr-xr-xsrc/lib/librelib22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/lib/librelib b/src/lib/librelib
index 004c8b1..b3fb9c2 100755
--- a/src/lib/librelib
+++ b/src/lib/librelib
@@ -46,7 +46,7 @@ usage() {
Hardcoding that path is the way of the dark side."
echo
prose 'By default, it looks for the files in `%s`, but this can be
- changed with the environmental variable LIBRETOOLS_LIBDIR.' "$default_libdir"
+ changed with the environmental variable LIBRETOOLS_LIBRARY_PATH.' "$default_libdir"
echo
print "Example usage:"
printf ' . $(%s conf)\n' "$cmd"
@@ -65,19 +65,25 @@ main() {
return 0 # $EXIT_SUCCESS
fi
- if [[ -z $LIBRETOOLS_LIBDIR ]]; then
- export LIBRETOOLS_LIBDIR=$default_libdir
+ if [[ -z $LIBRETOOLS_LIBRARY_PATH ]]; then
+ export LIBRETOOLS_LIBRARY_PATH=$default_libdir
fi
lib=$1
lib=${lib#libre}
lib=${lib%.sh}
- for file in ${lib} libre${lib} ${lib}.sh libre${lib}.sh; do
- if [[ -f "$LIBRETOOLS_LIBDIR/$file" ]]; then
- printf '%s\n' "$LIBRETOOLS_LIBDIR/$file"
- return 0 # $EXIT_SUCCESS
- fi
+ local libdir_array
+ IFS=: read -r -a libdir_array <<<"$LIBRETOOLS_LIBRARY_PATH"
+
+ local libdir
+ for libdir in "${libdir_array[@]}"; do
+ for file in ${lib} libre${lib} ${lib}.sh libre${lib}.sh; do
+ if [[ -f "$libdir/$file" ]]; then
+ printf '%s\n' "$libdir/$file"
+ return 0 # $EXIT_SUCCESS
+ fi
+ done
done
_l print '%s: could not find library: %s' "$cmd" "$lib" >&2
return 1 # $EXIT_FAILURE