From fd82b02f1c0cd90a8d58128c904be51f9a8228f8 Mon Sep 17 00:00:00 2001 From: Alan O'Cais Date: Thu, 19 Mar 2026 16:38:36 +0100 Subject: [PATCH 1/7] Support dash init shell with Lmod approach, make sure second initialisation gives expected EESSI version --- .../workflows/scripts/test_init_scripts.sh | 4 +- init/lmod/bash | 24 +++++- init/lmod/csh | 12 ++- init/lmod/fish | 12 ++- init/lmod/ksh | 74 +------------------ init/lmod/sh | 1 + init/lmod/zsh | 74 +------------------ 7 files changed, 45 insertions(+), 156 deletions(-) mode change 100644 => 120000 init/lmod/ksh create mode 120000 init/lmod/sh mode change 100644 => 120000 init/lmod/zsh diff --git a/.github/workflows/scripts/test_init_scripts.sh b/.github/workflows/scripts/test_init_scripts.sh index f2c8b03c..633c5ffd 100755 --- a/.github/workflows/scripts/test_init_scripts.sh +++ b/.github/workflows/scripts/test_init_scripts.sh @@ -26,7 +26,7 @@ if [ ! -d assert.sh ]; then fi . assert.sh/assert.sh -TEST_SHELLS=("bash" "zsh" "fish" "ksh" "csh") +TEST_SHELLS=("bash" "zsh" "fish" "ksh" "csh" "sh") SHELLS=$@ for shell in ${SHELLS[@]}; do @@ -139,7 +139,7 @@ for shell in ${SHELLS[@]}; do fi # Optional test 10, check if the prompt has been updated - if [ "$shell" = "bash" ] || [ "$shell" = "ksh" ] || [ "$shell" = "zsh" ]; then + if [ "$shell" = "bash" ] || [ "$shell" = "ksh" ] || [ "$shell" = "zsh" ] || [ "$shell" = "sh" ]; then # Typically this is a non-interactive shell, so manually unset PS1 and reset to a non-exported variable when testing TEST_EESSI_PS1_UPDATE=$($shell -c "unset PS1 ; PS1='$ ' ; source init/lmod/$shell 2>/dev/null ; echo \"\$PS1\"") TEST_EESSI_NO_PS1_UPDATE=$($shell -c "unset PS1 ; source init/lmod/$shell 2>/dev/null ; echo \"\$PS1\"") diff --git a/init/lmod/bash b/init/lmod/bash index 54e37946..241e980f 100644 --- a/init/lmod/bash +++ b/init/lmod/bash @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env sh # SPDX-License-Identifier: GPL-2.0-only # Copyright (C) 2020-2026 EESSI contributors @@ -49,7 +49,12 @@ EESSI_CVMFS_REPO="${EESSI_CVMFS_REPO:-/cvmfs/software.eessi.io}" # (Note: in the repository which is home to this file a template value __EESSI_VERSION_DEFAULT__ is present in # the line below which is replaced within our deployment pipeline.) EESSI_VERSION_DEFAULT="${__EESSI_VERSION_USED_FOR_INIT:-__EESSI_VERSION_DEFAULT__}" -EESSI_VERSION="${EESSI_VERSION:-${EESSI_VERSION_DEFAULT}}" +if [ -z "$__Init_EESSI_Default_Modules" ]; then + EESSI_VERSION="${EESSI_VERSION:-${EESSI_VERSION_DEFAULT}}" +else + # If we have already initiaised and this is being called again, then we must want the specific version + EESSI_VERSION="__EESSI_VERSION_DEFAULT__" +fi # On the first run we want to record the EESSI version used for init as an environment variable so that if a different # version of this script is called (e.g, for a a different EESSI version) it retains a memory which EESSI # version was actually used in the initialisation. This is useful as __Init_EESSI_Default_Modules used below will @@ -75,7 +80,7 @@ if [ -z "$__Init_EESSI_Default_Modules" ]; then # Lmod version in 2023.06 has a problem with newer Lmod caches, so let's stick to more recent Lmod # (has no effect except on Lmod itself, and compatible caches are still created/supported by EESSI) - LMOD_EESSI_VERSION=${EESSI_VERSION/2023.06/2025.06} + LMOD_EESSI_VERSION=$(printf '%s\n' "$EESSI_VERSION" | sed 's/2023\.06/2025\.06/') # Let's attempt a purge of any loaded modules as any environment variables currently set will survive EESSI initialisation # (it's ok if the module command does not exist) @@ -96,10 +101,21 @@ if [ -z "$__Init_EESSI_Default_Modules" ]; then export EESSI_MODULE_UPDATE_PS1=1 fi + # Figure out what shell we have + if [ -n "${BASH_VERSION-}" ]; then + shell=bash + elif [ -n "${ZSH_VERSION-}" ]; then + shell=zsh + elif [ -n "${KSH_VERSION-}" ]; then + shell=ksh + else + shell=sh + fi + # Path to top-level module tree # - EESSI_EXTRA_MODULEPATH environment variable allows a site to append to MODULEPATH (lower priority than EESSI MODULEPATH) export MODULEPATH="${EESSI_CVMFS_REPO}/init/modules${EESSI_EXTRA_MODULEPATH:+:$EESSI_EXTRA_MODULEPATH}" - . "${EESSI_CVMFS_REPO}/versions/${LMOD_EESSI_VERSION}/compat/linux/$(uname -m)/usr/share/Lmod/init/bash" + . "${EESSI_CVMFS_REPO}/versions/${LMOD_EESSI_VERSION}/compat/linux/$(uname -m)/usr/share/Lmod/init/${shell}" module --initial_load --no_redirect restore # After initialising, we now know the architecture(s) that was/were selected so let's report them diff --git a/init/lmod/csh b/init/lmod/csh index 1270a3f4..0aabbcd4 100644 --- a/init/lmod/csh +++ b/init/lmod/csh @@ -20,8 +20,16 @@ if ( ! $?__EESSI_VERSION_USED_FOR_INIT ) then else set EESSI_VERSION_DEFAULT = "$__EESSI_VERSION_USED_FOR_INIT" endif -if ( ! $?EESSI_VERSION ) then - set EESSI_VERSION = "$EESSI_VERSION_DEFAULT" +if ( ! $?__Init_EESSI_Default_Modules ) then + if ( $?EESSI_VERSION ) then + # keep existing value + else + set EESSI_VERSION "$EESSI_VERSION_DEFAULT" + endif +else + # If we have already initialised and this is being called again, + # then we must want the specific version + set EESSI_VERSION "__EESSI_VERSION_DEFAULT__" endif # On first run, record the EESSI version used for init as an environment variable. # We use setenv to ensure it is available to child processes (equivalent to export). diff --git a/init/lmod/fish b/init/lmod/fish index 60d0beb7..e2ebe259 100644 --- a/init/lmod/fish +++ b/init/lmod/fish @@ -18,8 +18,16 @@ if not set -q __EESSI_VERSION_USED_FOR_INIT else set EESSI_VERSION_DEFAULT "$__EESSI_VERSION_USED_FOR_INIT" end -if not set -q EESSI_VERSION - set EESSI_VERSION "$EESSI_VERSION_DEFAULT" +if not set -q __Init_EESSI_Default_Modules + if set -q EESSI_VERSION + # keep existing value + else + set EESSI_VERSION $EESSI_VERSION_DEFAULT + end +else + # If we have already initialised and this is being called again, + # then we must want the specific version + set EESSI_VERSION "__EESSI_VERSION_DEFAULT__" end # Record version used for init; -x exports it to the environment diff --git a/init/lmod/ksh b/init/lmod/ksh deleted file mode 100644 index 72ff8203..00000000 --- a/init/lmod/ksh +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env ksh - -# SPDX-License-Identifier: GPL-2.0-only -# Copyright (C) 2020-2026 EESSI contributors -# -# EESSI - European Environment for Scientific Software Installations -# -# This file is a template for initialising EESSI via Lmod for the environment indicated by the shebang. -# -# Please refer to the reference bash implementation for full documentation, only minimal comments are included here - -# Choose an EESSI CVMFS repository -EESSI_CVMFS_REPO="${EESSI_CVMFS_REPO:-/cvmfs/software.eessi.io}" - -# Choose an EESSI version (the default is only used if the EESSI_VERSION environment variable is not provided) -EESSI_VERSION_DEFAULT="${__EESSI_VERSION_USED_FOR_INIT:-__EESSI_VERSION_DEFAULT__}" -EESSI_VERSION="${EESSI_VERSION:-${EESSI_VERSION_DEFAULT}}" -# On the first run we want to record the EESSI version used for init as an environment variable so that if a different -# version of this script is called (e.g, for a a different EESSI version) it retains a memory which EESSI -# version was actually used in the initialisation. This is useful as __Init_EESSI_Default_Modules used below will -# be defined on the first call and Lmod initialisation will not happen twice. -# This sets the value only on first execution, if the variable already exists in the environment -# the original value is retained. -export __EESSI_VERSION_USED_FOR_INIT="${__EESSI_VERSION_USED_FOR_INIT:-${EESSI_VERSION}}" - -# ability to predefine elsewhere the default list (with options to append or prepend) -LMOD_SYSTEM_DEFAULT_MODULES="${EESSI_DEFAULT_MODULES_PREPEND:+$EESSI_DEFAULT_MODULES_PREPEND:}EESSI/$EESSI_VERSION${EESSI_DEFAULT_MODULES_APPEND:+:$EESSI_DEFAULT_MODULES_APPEND}" -export LMOD_SYSTEM_DEFAULT_MODULES - -if [ -z "$__Init_EESSI_Default_Modules" ]; then - export __Init_EESSI_Default_Modules=1; - - # Lmod version in 2023.06 has a problem with newer Lmod caches, so let's stick to more recent Lmod - # (has no effect except on Lmod itself, and compatible caches are still created/supported by EESSI) - LMOD_EESSI_VERSION=${EESSI_VERSION/2023.06/2025.06} - - # Let's attempt a purge of any loaded modules as any environment variables currently set will survive EESSI initialisation - # (it's ok if the module command does not exist) - if [ -z "$EESSI_NO_MODULE_PURGE_ON_INIT" ]; then - module purge >/dev/null 2>&1 && echo "Modules purged before initialising EESSI" - fi - - # If there is a local Lmod, make it forget about the system set MODULEPATH - unset __LMOD_REF_COUNT_MODULEPATH - # and clear out any memory Lmod might have - unset _ModuleTable001_ - - # For the shells that use PS1 for the prompt, let's add the trigger to enable updating that by default - # (in an interactive shell PS1 is likely unset, so let's only do this if it is set) - if [ -n "$PS1" ]; then - export PS1 - export EESSI_MODULE_UPDATE_PS1=1 - fi - - # Path to top-level module tree - export MODULEPATH="${EESSI_CVMFS_REPO}/init/modules${EESSI_EXTRA_MODULEPATH:+:$EESSI_EXTRA_MODULEPATH}" - . "${EESSI_CVMFS_REPO}/versions/${LMOD_EESSI_VERSION}/compat/linux/$(uname -m)/usr/share/Lmod/init/ksh" - - module --initial_load --no_redirect restore - - # After initialising, we now know the architecture(s) that was/were selected so let's report them - echo "EESSI has selected ${EESSI_SOFTWARE_SUBDIR} as the compatible CPU target for EESSI/${EESSI_VERSION}" - if [ -n "$EESSI_ACCEL_SUBDIR" ]; then - echo "EESSI has selected ${EESSI_ACCEL_SUBDIR} as the compatible accelerator target for EESSI/${EESSI_VERSION}" - else - echo "EESSI did not identify an accelerator on the system" - fi - # If people want more detailed information about what EESSI is doing, they can also set an environment variable - # for additional information. - echo "(for debug information when loading the EESSI module, set the environment variable EESSI_MODULE_DEBUG_INIT)" -else - module reset -fi diff --git a/init/lmod/ksh b/init/lmod/ksh new file mode 120000 index 00000000..f4d7fa57 --- /dev/null +++ b/init/lmod/ksh @@ -0,0 +1 @@ +bash \ No newline at end of file diff --git a/init/lmod/sh b/init/lmod/sh new file mode 120000 index 00000000..f4d7fa57 --- /dev/null +++ b/init/lmod/sh @@ -0,0 +1 @@ +bash \ No newline at end of file diff --git a/init/lmod/zsh b/init/lmod/zsh deleted file mode 100644 index d2f603d2..00000000 --- a/init/lmod/zsh +++ /dev/null @@ -1,73 +0,0 @@ -#!/usr/bin/env zsh - -# SPDX-License-Identifier: GPL-2.0-only -# Copyright (C) 2020-2026 EESSI contributors -# -# EESSI - European Environment for Scientific Software Installations -# -# This file is a template for initialising EESSI via Lmod for the environment indicated by the shebang. -# -# Please refer to the reference bash implementation for full documentation, only minimal comments are included here - -# Choose an EESSI CVMFS repository -EESSI_CVMFS_REPO="${EESSI_CVMFS_REPO:-/cvmfs/software.eessi.io}" - -# Choose an EESSI version (the default is only used if the EESSI_VERSION environment variable is not provided) -EESSI_VERSION_DEFAULT="${__EESSI_VERSION_USED_FOR_INIT:-__EESSI_VERSION_DEFAULT__}" -EESSI_VERSION="${EESSI_VERSION:-${EESSI_VERSION_DEFAULT}}" -# On the first run we want to record the EESSI version used for init as an environment variable so that if a different -# version of this script is called (e.g, for a a different EESSI version) it retains a memory which EESSI -# version was actually used in the initialisation. This is useful as __Init_EESSI_Default_Modules used below will -# be defined on the first call and Lmod initialisation will not happen twice. -# This sets the value only on first execution, if the variable already exists in the environment -# the original value is retained. -export __EESSI_VERSION_USED_FOR_INIT="${__EESSI_VERSION_USED_FOR_INIT:-${EESSI_VERSION}}" - -# ability to predefine elsewhere the default list (with options to append or prepend) -LMOD_SYSTEM_DEFAULT_MODULES="${EESSI_DEFAULT_MODULES_PREPEND:+$EESSI_DEFAULT_MODULES_PREPEND:}EESSI/$EESSI_VERSION${EESSI_DEFAULT_MODULES_APPEND:+:$EESSI_DEFAULT_MODULES_APPEND}" -export LMOD_SYSTEM_DEFAULT_MODULES - -if [ -z "$__Init_EESSI_Default_Modules" ]; then - export __Init_EESSI_Default_Modules=1; - - # Lmod version in 2023.06 has a problem with newer Lmod caches, so let's stick to more recent Lmod - # (has no effect except on Lmod itself, and compatible caches are still created/supported by EESSI) - LMOD_EESSI_VERSION=${EESSI_VERSION/2023.06/2025.06} - - # Let's attempt a purge of any loaded modules as any environment variables currently set will survive EESSI initialisation - # (it's ok if the module command does not exist) - if [ -z "$EESSI_NO_MODULE_PURGE_ON_INIT" ]; then - module purge >/dev/null 2>&1 && echo "Modules purged before initialising EESSI" - fi - - # If there is a local Lmod, make it forget about the system set MODULEPATH - unset __LMOD_REF_COUNT_MODULEPATH - # and clear out any memory Lmod might have - unset _ModuleTable001_ - - # For the shells that use PS1 for the prompt, let's add the trigger to enable updating that by default - # (in an interactive shell PS1 is likely unset, so let's only do this if it is set) - if [ -n "$PS1" ]; then - export PS1 - export EESSI_MODULE_UPDATE_PS1=1 - fi - - # Path to top-level module tree - export MODULEPATH="${EESSI_CVMFS_REPO}/init/modules${EESSI_EXTRA_MODULEPATH:+:$EESSI_EXTRA_MODULEPATH}" - . "${EESSI_CVMFS_REPO}/versions/${LMOD_EESSI_VERSION}/compat/linux/$(uname -m)/usr/share/Lmod/init/zsh" - - module --initial_load --no_redirect restore - - # After initialising, we now know the architecture(s) that was/were selected so let's report them - echo "EESSI has selected ${EESSI_SOFTWARE_SUBDIR} as the compatible CPU target for EESSI/${EESSI_VERSION}" - if [ -n "$EESSI_ACCEL_SUBDIR" ]; then - echo "EESSI has selected ${EESSI_ACCEL_SUBDIR} as the compatible accelerator target for EESSI/${EESSI_VERSION}" - else - echo "EESSI did not identify an accelerator on the system" - fi - # If people want more detailed information about what EESSI is doing, they can also set an environment variable - # for additional information. - echo "(for debug information when loading the EESSI module, set the environment variable EESSI_MODULE_DEBUG_INIT)" -else - module reset -fi diff --git a/init/lmod/zsh b/init/lmod/zsh new file mode 120000 index 00000000..f4d7fa57 --- /dev/null +++ b/init/lmod/zsh @@ -0,0 +1 @@ +bash \ No newline at end of file From 3791d0aa06634d47da7e40137aee54432eaeddd2 Mon Sep 17 00:00:00 2001 From: Alan O'Cais Date: Thu, 19 Mar 2026 18:12:45 +0100 Subject: [PATCH 2/7] Also install `sh` --- install_scripts.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/install_scripts.sh b/install_scripts.sh index e6220c2f..022c0f9f 100755 --- a/install_scripts.sh +++ b/install_scripts.sh @@ -196,7 +196,7 @@ copy_files_by_list ${TOPDIR}/init/modules/EESSI ${INSTALL_PREFIX}/init/modules/E # Copy for init/lmod directory init_script_files=( - bash zsh ksh fish csh + bash zsh ksh fish csh sh ) copy_files_by_list ${TOPDIR}/init/lmod ${INSTALL_PREFIX}/init/lmod "${init_script_files[@]}" From af052b032b2cab5b6de404c64fd3c10e78f06864 Mon Sep 17 00:00:00 2001 From: Alan O'Cais Date: Thu, 19 Mar 2026 18:15:52 +0100 Subject: [PATCH 3/7] Add sh to CI properly --- .github/workflows/tests_init_module.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests_init_module.yml b/.github/workflows/tests_init_module.yml index 902c31e3..0e519cbe 100644 --- a/.github/workflows/tests_init_module.yml +++ b/.github/workflows/tests_init_module.yml @@ -57,6 +57,7 @@ jobs: - name: Install missing shells run: | sudo apt update + # We're in Ubuntu so dash is already installed (and is symlinked to sh) sudo apt install zsh ksh fish tcsh echo "# INIT ZSH" > ~/.zshrc @@ -65,7 +66,7 @@ jobs: export EESSI_SOFTWARE_SUBDIR_OVERRIDE=${{matrix.EESSI_SOFTWARE_SUBDIR_OVERRIDE}} export EESSI_VERSION=${{matrix.EESSI_VERSION}} export EXPECTED_EASYBUILD_VERSION=${{matrix.EXPECTED_EASYBUILD_VERSION}} - .github/workflows/scripts/test_init_scripts.sh "bash" "zsh" "ksh" "fish" "csh" + .github/workflows/scripts/test_init_scripts.sh "bash" "zsh" "ksh" "fish" "csh" "sh" - name: Run tests for available shells with system Lmod run: | # We also want to perform the same test when there is an Lmod version available on the system @@ -76,4 +77,4 @@ jobs: export EESSI_SOFTWARE_SUBDIR_OVERRIDE=${{matrix.EESSI_SOFTWARE_SUBDIR_OVERRIDE}} export EESSI_VERSION=${{matrix.EESSI_VERSION}} export EXPECTED_EASYBUILD_VERSION=${{matrix.EXPECTED_EASYBUILD_VERSION}} - .github/workflows/scripts/test_init_scripts.sh "bash" "zsh" "ksh" "fish" "csh" + .github/workflows/scripts/test_init_scripts.sh "bash" "zsh" "ksh" "fish" "csh" "sh" From e2d786d03afc1b37e1d4ffc94e01dbe0d09dc22c Mon Sep 17 00:00:00 2001 From: ocaisa Date: Thu, 19 Mar 2026 18:51:56 +0100 Subject: [PATCH 4/7] Use . instead of source --- .github/workflows/scripts/test_init_scripts.sh | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/scripts/test_init_scripts.sh b/.github/workflows/scripts/test_init_scripts.sh index 633c5ffd..4b8f49c1 100755 --- a/.github/workflows/scripts/test_init_scripts.sh +++ b/.github/workflows/scripts/test_init_scripts.sh @@ -43,7 +43,7 @@ for shell in ${SHELLS[@]}; do # TEST 1: Source Script and check Module Output expected_pattern=".*EESSI has selected $EESSI_SOFTWARE_SUBDIR_OVERRIDE as the compatible CPU target for EESSI/$EESSI_VERSION.*" - assert_raises "$shell -c 'source init/lmod/$shell' 2>&1 | grep -E \"${expected_pattern}\"" + assert_raises "$shell -c '. init/lmod/$shell' 2>&1 | grep -E \"${expected_pattern}\"" # TEST 2: Check if module overviews first section is the loaded EESSI module if [ "$shell" = "csh" ]; then @@ -53,7 +53,7 @@ for shell in ${SHELLS[@]}; do echo "source init/lmod/$shell" > ~/.cshrc MODULE_SECTIONS=($($shell -c "module ov" 2>&1 | grep -e '---')) else - MODULE_SECTIONS=($($shell -c "source init/lmod/$shell >/dev/null 2>&1; module ov 2>&1 | grep -e '---'")) + MODULE_SECTIONS=($($shell -c ". init/lmod/$shell >/dev/null 2>&1; module ov 2>&1 | grep -e '---'")) fi PATTERN="/cvmfs/software\.eessi\.io/versions/$EESSI_VERSION/software/linux/$EESSI_SOFTWARE_SUBDIR_OVERRIDE/modules/all" assert_raises 'echo "${MODULE_SECTIONS[1]}" | grep -E "$PATTERN"' @@ -68,7 +68,7 @@ for shell in ${SHELLS[@]}; do echo "source init/lmod/$shell" > ~/.cshrc command="$shell -c 'module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; eb --version' | tail -n 1 | awk '{print \$4}'" else - command="$shell -c 'source init/lmod/$shell >/dev/null 2>&1; module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; eb --version' | tail -n 1 | awk '{print \$4}'" + command="$shell -c '. init/lmod/$shell >/dev/null 2>&1; module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; eb --version' | tail -n 1 | awk '{print \$4}'" fi assert "$command" "$EXPECTED_EASYBUILD_VERSION" @@ -77,7 +77,7 @@ for shell in ${SHELLS[@]}; do echo "source init/lmod/$shell" > ~/.cshrc EASYBUILD_PATH=$($shell -c "module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; which eb") else - EASYBUILD_PATH=$($shell -c "source init/lmod/$shell 2>/dev/null; module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; which eb") + EASYBUILD_PATH=$($shell -c ". init/lmod/$shell 2>/dev/null; module load EasyBuild/${EXPECTED_EASYBUILD_VERSION}; which eb") fi # escape the dots in ${EASYBUILD_VERSION} PATTERN="/cvmfs/software\.eessi\.io/versions/$EESSI_VERSION/software/linux/$EESSI_SOFTWARE_SUBDIR_OVERRIDE/software/EasyBuild/${EXPECTED_EASYBUILD_VERSION//./\\.}/bin/eb" @@ -124,10 +124,10 @@ for shell in ${SHELLS[@]}; do TEST_EESSI_WITHOUT_PURGE=$($shell -c 'echo $EESSI_NO_MODULE_PURGE_ON_INIT') elif [ "$shell" = "fish" ]; then TEST_EESSI_WITH_PURGE=$($shell -c "source $LMOD_PKG/init/$shell 2>/dev/null ; source init/lmod/$shell 2>/dev/null") - TEST_EESSI_WITHOUT_PURGE=$($shell -c "set -x EESSI_NO_MODULE_PURGE_ON_INIT 1 ; source $LMOD_PKG/init/$shell 2>/dev/null ; source init/lmod/$shell 2>/dev/null") + TEST_EESSI_WITHOUT_PURGE=$($shell -c "set -x EESSI_NO_MODULE_PURGE_ON_INIT 1 ; source $LMOD_PKG/init/$shell 2>/dev/null ; . init/lmod/$shell 2>/dev/null") else - TEST_EESSI_WITH_PURGE=$($shell -c "source $LMOD_PKG/init/$shell 2>/dev/null ; source init/lmod/$shell 2>/dev/null") - TEST_EESSI_WITHOUT_PURGE=$($shell -c "export EESSI_NO_MODULE_PURGE_ON_INIT=1 ; source $LMOD_PKG/init/$shell 2>/dev/null ; source init/lmod/$shell 2>/dev/null") + TEST_EESSI_WITH_PURGE=$($shell -c ". $LMOD_PKG/init/$shell 2>/dev/null ; . init/lmod/$shell 2>/dev/null") + TEST_EESSI_WITHOUT_PURGE=$($shell -c "export EESSI_NO_MODULE_PURGE_ON_INIT=1 ; . $LMOD_PKG/init/$shell 2>/dev/null ; . init/lmod/$shell 2>/dev/null") fi # In the first case we should have the test and in the second case we shouldn't pattern="Modules purged before initialising EESSI" @@ -141,8 +141,8 @@ for shell in ${SHELLS[@]}; do # Optional test 10, check if the prompt has been updated if [ "$shell" = "bash" ] || [ "$shell" = "ksh" ] || [ "$shell" = "zsh" ] || [ "$shell" = "sh" ]; then # Typically this is a non-interactive shell, so manually unset PS1 and reset to a non-exported variable when testing - TEST_EESSI_PS1_UPDATE=$($shell -c "unset PS1 ; PS1='$ ' ; source init/lmod/$shell 2>/dev/null ; echo \"\$PS1\"") - TEST_EESSI_NO_PS1_UPDATE=$($shell -c "unset PS1 ; source init/lmod/$shell 2>/dev/null ; echo \"\$PS1\"") + TEST_EESSI_PS1_UPDATE=$($shell -c "unset PS1 ; PS1='$ ' ; . init/lmod/$shell 2>/dev/null ; echo \"\$PS1\"") + TEST_EESSI_NO_PS1_UPDATE=$($shell -c "unset PS1 ; . init/lmod/$shell 2>/dev/null ; echo \"\$PS1\"") pattern="{EESSI/${EESSI_VERSION}} " assert_raises 'echo "$TEST_EESSI_PS1_UPDATE" | grep "$pattern"' assert_raises 'echo "$TEST_EESSI_NO_PS1_UPDATE" | grep "$pattern"' 1 From 5d897f02b2d5149c9c2c35c55443537cba2f36c2 Mon Sep 17 00:00:00 2001 From: ocaisa Date: Thu, 19 Mar 2026 18:57:58 +0100 Subject: [PATCH 5/7] Missed one --- .github/workflows/scripts/test_init_scripts.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/scripts/test_init_scripts.sh b/.github/workflows/scripts/test_init_scripts.sh index 4b8f49c1..561c5f2e 100755 --- a/.github/workflows/scripts/test_init_scripts.sh +++ b/.github/workflows/scripts/test_init_scripts.sh @@ -97,8 +97,8 @@ for shell in ${SHELLS[@]}; do TEST_LMOD_SYSTEM_DEFAULT_MODULES=$($shell -c 'set -x EESSI_DEFAULT_MODULES_APPEND append_module ; set -x EESSI_DEFAULT_MODULES_PREPEND prepend_module ; set -x EESSI_EXTRA_MODULEPATH .github/workflows/modules ; source init/lmod/'"$shell"' 2>/dev/null; echo $LMOD_SYSTEM_DEFAULT_MODULES') TEST_MODULEPATH=$($shell -c 'set -x EESSI_DEFAULT_MODULES_APPEND append_module ; set -x EESSI_DEFAULT_MODULES_PREPEND prepend_module ; set -x EESSI_EXTRA_MODULEPATH .github/workflows/modules ; source init/lmod/'"$shell"' 2>/dev/null; echo $MODULEPATH') else - TEST_LMOD_SYSTEM_DEFAULT_MODULES=$($shell -c 'export EESSI_DEFAULT_MODULES_APPEND=append_module ; export EESSI_DEFAULT_MODULES_PREPEND=prepend_module ; export EESSI_EXTRA_MODULEPATH=.github/workflows/modules ; source init/lmod/'"$shell"' ; echo $LMOD_SYSTEM_DEFAULT_MODULES') - TEST_MODULEPATH=$($shell -c 'export EESSI_DEFAULT_MODULES_APPEND=append_module ; export EESSI_DEFAULT_MODULES_PREPEND=prepend_module ; export EESSI_EXTRA_MODULEPATH=.github/workflows/modules ; source init/lmod/'"$shell"' 2>/dev/null; echo $MODULEPATH') + TEST_LMOD_SYSTEM_DEFAULT_MODULES=$($shell -c 'export EESSI_DEFAULT_MODULES_APPEND=append_module ; export EESSI_DEFAULT_MODULES_PREPEND=prepend_module ; export EESSI_EXTRA_MODULEPATH=.github/workflows/modules ; . init/lmod/'"$shell"' ; echo $LMOD_SYSTEM_DEFAULT_MODULES') + TEST_MODULEPATH=$($shell -c 'export EESSI_DEFAULT_MODULES_APPEND=append_module ; export EESSI_DEFAULT_MODULES_PREPEND=prepend_module ; export EESSI_EXTRA_MODULEPATH=.github/workflows/modules ; . init/lmod/'"$shell"' 2>/dev/null; echo $MODULEPATH') fi LMOD_SYSTEM_DEFAULT_MODULES_PATTERN='^prepend_module:.*:append_module$' # echo "$TEST_LMOD_SYSTEM_DEFAULT_MODULES" AND "$LMOD_SYSTEM_DEFAULT_MODULES_PATTERN" From 87a850e4779f17fe1d6369a7ecf854c1e9d1801f Mon Sep 17 00:00:00 2001 From: Alan O'Cais Date: Thu, 19 Mar 2026 19:29:40 +0100 Subject: [PATCH 6/7] Fix test case for csh --- .github/workflows/scripts/test_init_scripts.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/scripts/test_init_scripts.sh b/.github/workflows/scripts/test_init_scripts.sh index 561c5f2e..b96ef9cf 100755 --- a/.github/workflows/scripts/test_init_scripts.sh +++ b/.github/workflows/scripts/test_init_scripts.sh @@ -43,7 +43,11 @@ for shell in ${SHELLS[@]}; do # TEST 1: Source Script and check Module Output expected_pattern=".*EESSI has selected $EESSI_SOFTWARE_SUBDIR_OVERRIDE as the compatible CPU target for EESSI/$EESSI_VERSION.*" - assert_raises "$shell -c '. init/lmod/$shell' 2>&1 | grep -E \"${expected_pattern}\"" + if [ "$shell" = "csh" ]; then + assert_raises "$shell -c 'source init/lmod/$shell' 2>&1 | grep -E \"${expected_pattern}\"" + else + assert_raises "$shell -c '. init/lmod/$shell' 2>&1 | grep -E \"${expected_pattern}\"" + fi # TEST 2: Check if module overviews first section is the loaded EESSI module if [ "$shell" = "csh" ]; then @@ -124,7 +128,7 @@ for shell in ${SHELLS[@]}; do TEST_EESSI_WITHOUT_PURGE=$($shell -c 'echo $EESSI_NO_MODULE_PURGE_ON_INIT') elif [ "$shell" = "fish" ]; then TEST_EESSI_WITH_PURGE=$($shell -c "source $LMOD_PKG/init/$shell 2>/dev/null ; source init/lmod/$shell 2>/dev/null") - TEST_EESSI_WITHOUT_PURGE=$($shell -c "set -x EESSI_NO_MODULE_PURGE_ON_INIT 1 ; source $LMOD_PKG/init/$shell 2>/dev/null ; . init/lmod/$shell 2>/dev/null") + TEST_EESSI_WITHOUT_PURGE=$($shell -c "set -x EESSI_NO_MODULE_PURGE_ON_INIT 1 ; source $LMOD_PKG/init/$shell 2>/dev/null ; source init/lmod/$shell 2>/dev/null") else TEST_EESSI_WITH_PURGE=$($shell -c ". $LMOD_PKG/init/$shell 2>/dev/null ; . init/lmod/$shell 2>/dev/null") TEST_EESSI_WITHOUT_PURGE=$($shell -c "export EESSI_NO_MODULE_PURGE_ON_INIT=1 ; . $LMOD_PKG/init/$shell 2>/dev/null ; . init/lmod/$shell 2>/dev/null") From e71d2c81c43c8d495e8e31725ef32c9bec3dc2ef Mon Sep 17 00:00:00 2001 From: ocaisa Date: Thu, 19 Mar 2026 20:19:04 +0100 Subject: [PATCH 7/7] Apply suggestions from code review Co-authored-by: ocaisa --- init/lmod/bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init/lmod/bash b/init/lmod/bash index 241e980f..601ed7b1 100644 --- a/init/lmod/bash +++ b/init/lmod/bash @@ -52,7 +52,7 @@ EESSI_VERSION_DEFAULT="${__EESSI_VERSION_USED_FOR_INIT:-__EESSI_VERSION_DEFAULT_ if [ -z "$__Init_EESSI_Default_Modules" ]; then EESSI_VERSION="${EESSI_VERSION:-${EESSI_VERSION_DEFAULT}}" else - # If we have already initiaised and this is being called again, then we must want the specific version + # If we have already initialised and this is being called again, then we must want the specific version EESSI_VERSION="__EESSI_VERSION_DEFAULT__" fi # On the first run we want to record the EESSI version used for init as an environment variable so that if a different