|
198 | 198 | #<----- START OF part that should run under a clean alternative software environment if this was given ------ |
199 | 199 | if [ "${ALIEN_JDL_O2DPG_ASYNC_RECO_TAG}" ]; then |
200 | 200 | if [ "${LOADEDMODULES}" ]; then |
201 | | - export > env_before_stashing.env |
| 201 | + printenv > env_before_stashing.printenv |
202 | 202 | echo "Stashing initial modules" |
203 | 203 | module save initial_modules.list # we stash the current modules environment |
204 | 204 | module list --no-pager |
205 | 205 | module purge --no-pager |
206 | | - export > env_after_stashing.env |
| 206 | + printenv > env_after_stashing.printenv |
207 | 207 | echo "Modules after purge" |
208 | 208 | module list --no-pager |
209 | 209 | fi |
@@ -272,10 +272,17 @@ if [ "${ALIEN_JDL_O2DPG_ASYNC_RECO_TAG}" ]; then |
272 | 272 | echo "Restoring initial environment" |
273 | 273 | module --no-pager restore initial_modules.list |
274 | 274 | module saverm initial_modules.list |
275 | | - if [ "${ALIEN_JDL_O2DPG_OVERWRITE}" ]; then |
276 | | - echo "Setting back O2DPG_ROOT to overwritten path ${ALIEN_JDL_O2DPG_OVERWRITE}" |
277 | | - export O2DPG_ROOT=${ALIEN_JDL_O2DPG_OVERWRITE} |
278 | | - fi |
| 275 | + |
| 276 | + # Restore overwritten O2DPG variables set by modules but changed by user |
| 277 | + # (in particular custom O2DPG_ROOT and O2DPG_MC_CONFIG_ROOT) |
| 278 | + printenv > env_after_restore.printenv |
| 279 | + comm -12 <(grep '^O2DPG' env_before_stashing.printenv | cut -d= -f1 | sort) \ |
| 280 | + <(grep '^O2DPG' env_after_restore.printenv | cut -d= -f1 | sort) | |
| 281 | + while read -r var; do |
| 282 | + b=$(grep "^$var=" env_before_stashing.printenv | cut -d= -f2-) |
| 283 | + a=$(grep "^$var=" env_after_restore.printenv | cut -d= -f2-) |
| 284 | + [[ "$b" != "$a" ]] && export "$var=$b" && echo "Reapplied: $var to ${b}" |
| 285 | + done |
279 | 286 | fi |
280 | 287 | #<----- END OF part that should run under a clean alternative software environment if this was given ------ |
281 | 288 |
|
|
0 commit comments