From b1fda669cec5c809bcc2cbaf7c09d98d38a12ce2 Mon Sep 17 00:00:00 2001
From: Juntong Liu <juntong.liu@ess.eu>
Date: Wed, 16 Jun 2021 13:19:59 +0000
Subject: [PATCH] E3-310: Update require-ess/tools/setE3Env.bash to solve a
 LD_LIBRARY_PATH related issue

---
 require-ess/tools/setE3Env.bash | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/require-ess/tools/setE3Env.bash b/require-ess/tools/setE3Env.bash
index 0a834447..dea3f30d 100644
--- a/require-ess/tools/setE3Env.bash
+++ b/require-ess/tools/setE3Env.bash
@@ -29,6 +29,7 @@
 # the ROOT build system in ${ROOTSYS}/bin/, and modified
 # a little to return its result
 # Wednesday, July 11 23:19:00 CEST 2018, jhlee
+
 drop_from_path() {
   #
   # Assert that we got enough arguments
@@ -157,9 +158,8 @@ if [ -n "$EPICS_BASE" ]; then
 
     fi
 
-    e3_ld_path=${LD_LIBRARY_PATH}
-    drop_e3_ld_path="${E3_REQUIRE_LIB}/${EPICS_HOST_ARCH}"
-    LD_LIBRARY_PATH=$(drop_from_path "${e3_ld_path}" "${drop_e3_ld_path}")
+    # Drop the require-related LD_LIBRARY pathes  set previously
+    LD_LIBRARY_PATH=$(drop_from_path "$LD_LIBRARY_PATH" "${E3_REQUIRE_LOCATION}[^:]*")
     export LD_LIBRARY_PATH
 
     unset E3_REQUIRE_NAME
@@ -327,8 +327,8 @@ export PATH
 
 old_ld_path=${LD_LIBRARY_PATH}
 E3_LD_LIBRARY_PATH="${EPICS_BASE}/lib/${EPICS_HOST_ARCH}:${E3_REQUIRE_LIB}/${EPICS_HOST_ARCH}"
-
 LD_LIBRARY_PATH=$(set_variable "${old_ld_path}" "${E3_LD_LIBRARY_PATH}")
+
 export LD_LIBRARY_PATH
 
 # Add iocsh.bash autocompletion
-- 
GitLab