From 70d0060be84ed7c437461a041d04ad3ff02f1214 Mon Sep 17 00:00:00 2001
From: Florian Uhlig <f.uhlig@gsi.de>
Date: Sun, 25 Sep 2022 17:26:05 +0200
Subject: [PATCH] Change default setting of config scripts

Due to some changes in CbmRoot recently the existing PATH and LD_LIBRARY_PATH
variable were overwritten when sourcing the config scripts (config.sh and
config.csh) whithout additional parameter -a or -p.
This commit change the default setting such that the new paths are appended to
the existing PATH and (DY)LD_LIBRARY_PATH.
---
 cmake/scripts/config.csh.in | 10 ++++++----
 cmake/scripts/config.sh.in  |  8 +++++---
 2 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/cmake/scripts/config.csh.in b/cmake/scripts/config.csh.in
index b2ff55b15d..9707c2868a 100644
--- a/cmake/scripts/config.csh.in
+++ b/cmake/scripts/config.csh.in
@@ -43,9 +43,11 @@ if ( "$same_system" == "1" ) then
 			echo "hello"
 			breaksw
 		case * :
-			setenv DYLD_LIBRARY_PATH="@MY_DYLD_LIBRARY_PATH@"
-			setenv LD_LIBRARY_PATH="@MY_LD_LIBRARY_PATH@"
-			setenv PATH="@MY_PATH@"
-			breaksw
+		        echo "Default was changed"
+		        echo "Append new paths to LD_LIBRARY_PATH and PATH instead of overwritting"
+                        setenv DYLD_LIBRARY_PATH $DYLD_LIBRARY_PATH:"@MY_DYLD_LIBRARY_PATH@"
+                        setenv LD_LIBRARY_PATH $LD_LIBRARY_PATH:"@MY_LD_LIBRARY_PATH@"
+                        setenv PATH $PATH:"@MY_PATH@"
+                        breaksw
 	endsw
 endif
diff --git a/cmake/scripts/config.sh.in b/cmake/scripts/config.sh.in
index 76f286eeef..5c70fe0775 100644
--- a/cmake/scripts/config.sh.in
+++ b/cmake/scripts/config.sh.in
@@ -41,9 +41,11 @@ if [ $same_system -eq 1 ]; then
 			export PATH="@MY_PATH@":$PATH
 			;;
 		* )
-			export DYLD_LIBRARY_PATH="@MY_DYLD_LIBRARY_PATH@"
-			export LD_LIBRARY_PATH="@MY_LD_LIBRARY_PATH@"
-			export PATH="@MY_PATH@"
+                        echo "Default was changed"
+                        echo "Append new paths to LD_LIBRARY_PATH and PATH instead of overwritting"
+                        export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:"@MY_DYLD_LIBRARY_PATH@"
+                        export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:"@MY_LD_LIBRARY_PATH@"
+                        export PATH=$PATH:"@MY_PATH@"
 			;;
 	esac
 fi
-- 
GitLab