Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/workflows/scripts/test_init_scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,14 @@ for shell in ${SHELLS[@]}; do
TEST_EESSI_EXPLICIT_NO_PS1_UPDATE_CALLED_TWICE=$($shell -c "unset PS1 ; PS1='$ ' ; export EESSI_MODULE_UPDATE_PS1=0 ; . init/lmod/$shell 2>/dev/null ; . init/lmod/$shell 2>/dev/null ; echo \"\$PS1\"")
assert_raises 'echo "$TEST_EESSI_EXPLICIT_NO_PS1_UPDATE" | grep "$pattern"' 1
assert_raises 'echo "$TEST_EESSI_EXPLICIT_NO_PS1_UPDATE_CALLED_TWICE" | grep "$pattern"' 1
# Also check complex prompts, and unloading/purging the EESSI module
prompt="\$(echo '\['✘) $ "
promptstr="\[✘ $ "
updated_promptstr="{EESSI/${EESSI_VERSION}} \[✘ $ "
TEST_EESSI_PS1_UPDATE=$($shell -c "unset PS1 ; PS1=\"$prompt\" ; . init/lmod/$shell >/dev/null 2>&1 ; echo \"\$PS1\"")
TEST_EESSI_PS1_REVERT=$($shell -c "unset PS1 ; PS1=\"$prompt\" ; . init/lmod/$shell >/dev/null 2>&1 ; module purge; echo \"\$PS1\"")
assert 'echo "$TEST_EESSI_PS1_UPDATE"' "$updated_promptstr"
assert 'echo "$TEST_EESSI_PS1_REVERT"' "$promptstr"
fi

# End Test Suite
Expand Down
9 changes: 8 additions & 1 deletion init/modules/EESSI/2023.06.lua
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,14 @@ local quiet_load = false
if os.getenv("EESSI_MODULE_UPDATE_PS1") then
local prompt = os.getenv("PS1")
if prompt then
pushenv("PS1", "{EESSI/" .. eessi_version .. "} " .. prompt)
local prefix = "{EESSI/" .. eessi_version .. "} "
if mode() == "load" then
-- Prepend prefix to PS1 without evaluating its contents
execute{cmd="PS1='" .. prefix .. "'\"$PS1\"", modeA={"load"}}
elseif mode() == "unload" then
-- Strip the prefix from beginning of PS1
execute{cmd="PS1=\"${PS1#'" .. prefix .. "'}\"", modeA={"unload"}}
end
end
end

Expand Down
Loading