Skip to content

fix EESSI prefix for complex prompts#196

Open
smoors wants to merge 3 commits intoEESSI:mainfrom
smoors:ps1
Open

fix EESSI prefix for complex prompts#196
smoors wants to merge 3 commits intoEESSI:mainfrom
smoors:ps1

Conversation

@smoors
Copy link
Copy Markdown
Contributor

@smoors smoors commented Apr 3, 2026

my prompt looks like this:

$(if [ $? != 0 ]; then echo '\[\e[0;31m\]''\[\e[0m\]'; else echo '\[\e[0;32m\]''\[\e[0m\]'; fi)\[\033[33m\][$(date '+%H:%M')]\[\033[00m\] \u@\h \[\033[01;34m\]$(fixpathvsc)\[\033[00m\] \$ $(__git_ps1 "(%s) ")$(test $(id -gn) != "vsc10009" && echo "($(id -gn)) ")

before this PR, it results in an error and a hanging shell after unloading the EESSI module:

✔ [20:21] vsc10009@login1 $VSC_HOME $ source /cvmfs/software.eessi.io/versions/2025.06/init/lmod/bash
Modules purged before initialising EESSI
Module for EESSI/2025.06 loaded successfully
EESSI has selected x86_64/intel/skylake_avx512 as the compatible CPU target for EESSI/2025.06
EESSI did not identify an accelerator on the system
(for debug information when loading the EESSI module, set the environment variable EESSI_MODULE_DEBUG_INIT)
{EESSI/2025.06} ✔ [20:21] vsc10009@login1 $VSC_HOME $ ml unload EESSI/2025.06                                                                                                                      
-bash: command substitution: line 3: unexpected EOF while looking for matching `"'                                                                                                                 
-bash: command substitution: line 4: syntax error: unexpected end of file
-bash: command substitution: line 1: unexpected EOF while looking for matching `)'
-bash: command substitution: line 2: syntax error: unexpected end of file

@ocaisa
Copy link
Copy Markdown
Member

ocaisa commented Apr 7, 2026

Can you add an additional test for this more complex case in

# Optional test 11, 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='$ ' ; . 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
# Also check when we explicitly ask for it not to be updated
TEST_EESSI_EXPLICIT_NO_PS1_UPDATE=$($shell -c "unset PS1 ; PS1='test> ' ; export EESSI_MODULE_UPDATE_PS1=0 ; . init/lmod/$shell 2>/dev/null ; echo \"\$PS1\"")
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
fi

EDIT: I guess in this case you may need a larger comparison string to make sure the evaluted content is still being evaluated. Maybe a PS1 like PS1='[$?] \w \$ ' and a chdir to verify the prompt is still being updated?
ANOTHER EDIT: I asked AI and it said not to bother trying to evaluate what prompt would be displayed, just make sure the string matches expectations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants