[Dev] [PATCH] src/lib/librelib: separate LIBRETOOLS_LIBDIR by ':' and consider each part as a candidate for searching the requested script

Andreas Grapentin andreas at grapentin.org
Sun Apr 12 19:04:53 GMT 2020


Hi,

I would like to enable librelib to support multiple locations in
LIBRETOOLS_LIBDIR. A patch to add that functionality is attached.

comments?

Thanks,
-A

---
 src/lib/librelib | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/src/lib/librelib b/src/lib/librelib
index 004c8b1..9b6c743 100755
--- a/src/lib/librelib
+++ b/src/lib/librelib
@@ -73,11 +73,17 @@ main() {
 	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 -ra libdir_array <<< "$LIBRETOOLS_LIBDIR"
+
+  local librelib_dir
+  for librelib_dir in "${libdir_array[@]}"; do
+	  for file in ${lib} libre${lib} ${lib}.sh libre${lib}.sh; do
+		  if [[ -f "$librelib_dir/$file" ]]; then
+			  printf '%s\n' "$librelib_dir/$file"
+			  return 0 # $EXIT_SUCCESS
+		  fi
+    done
 	done
 	_l print '%s: could not find library: %s' "$cmd" "$lib" >&2
 	return 1 # $EXIT_FAILURE
-- 
2.26.0


-- 

------------------------------------------------------------------------------
Andreas Grapentin, M.Sc.          Research Assistant @ Hasso-Plattner-Institut
Operating Systems and Middleware Group              www.dcl.hpi.uni-potsdam.de
Phone: +49 (0) 331 55 09-238                        Fax: +49 (0) 331 55 09-229
my GPG Public Key:                 https://files.grapentin.org/.gpg/public.key
------------------------------------------------------------------------------
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: not available
URL: <https://lists.parabola.nu/pipermail/dev/attachments/20200412/7a7a5f1d/attachment.sig>


More information about the Dev mailing list