diff --git a/run_in_compat_layer_env.sh b/run_in_compat_layer_env.sh index 98b9b211..07501a7c 100755 --- a/run_in_compat_layer_env.sh +++ b/run_in_compat_layer_env.sh @@ -66,6 +66,22 @@ if [ ! -z ${EESSI_SITE_INSTALL_FORCE} ]; then fi fi +# The above propagates some hard-coded environment variables into the prefix environment +# Here, we provide a mechanism that propagates ANY variable named PROPAGATE_INTO_PREFIX_ +# into the prefix environment as "export =" +# Example: PROPAGATE_INTO_PREFIX_FOO=bar => export FOO=bar +while IFS='=' read -r var_name var_value; do + # Only act on variables that start with the marker prefix + if [[ ${var_name} == EESSI_PROPAGATE_INTO_PREFIX_* ]]; then + # Strip the marker prefix to obtain the target name + target_name=${var_name#EESSI_PROPAGATE_INTO_PREFIX_} + # Guard against empty target names + if [[ -n ${target_name} ]]; then + INPUT="export ${target_name}=${var_value}; ${INPUT}" + fi + fi +done < <(env) # feed the current environment to the while‑loop + echo "Running '${INPUT}' in EESSI (${EESSI_CVMFS_REPO}) ${EESSI_VERSION} compatibility layer environment..." ${EESSI_COMPAT_LAYER_DIR}/startprefix <<< "${INPUT}"