Describe the bug
complete or complete -p commands print nothing when they are in a file that is sourced with source-sh bash <file> or with module sh-to-mod bash <file>.
To Reproduce
Steps to reproduce the behavior:
$ complete -p bash
complete -F _longopt bash
$ module show test/complete
-------------------------------------------------------------------
/path/to/modulefiles/test/complete:
setenv COMPLETE_OUTPUT {}
-------------------------------------------------------------------
$ module load test/complete
$ env | grep COMPLETE_OUTPUT
COMPLETE_OUTPUT=
__MODULES_LMSOURCESH=test/complete&bash ~/complete.sh|setenv COMPLETE_OUTPUT {}
Location and content of any modulerc or modulefile involved:
$ cat /path/to/modulefiles/test/complete
#%Module
source-sh bash ~/complete.sh
$ cat ~/complete.sh
#!/bin/bash
export COMPLETE_OUTPUT=$(complete -p bash)
Expected behavior
After module load test/complete, the variable COMPLETE_OUTPUT must be set to complete -F _longopt bash.
Error and debugging information
$ module --debug load test/complete
[...]
DEBUG [#1:load:test/complete] evaluateModulefile: getModuleContent /path/to/modulefiles/test/complete
DEBUG [#1:load:test/complete] evaluateModulefile: source-sh bash ~/complete.sh
DEBUG [#1:load:test/complete] execShAndGetEnv: running '/usr/bin/bash --noprofile --norc -c {export -p; echo %ModulesShToMod%; declare -f; echo %ModulesShToMod%; alias; echo %ModulesShToMod%; complete; echo %ModulesShToMod%; pwd; echo %ModulesShToMod%; . ~/complete.sh 2>&1; echo %ModulesShToMod%; export -p; echo %ModulesShToMod%; declare -f; echo %ModulesShToMod%; alias; echo %ModulesShToMod%; complete; echo %ModulesShToMod%; pwd}'
DEBUG [#1:load:test/complete] execShAndGetEnv: script output is '/path/to/complete.sh: line 3: complete: bash: no completion specification'
DEBUG [#1:load:test/complete] sh-to-mod: resulting env changes '{setenv COMPLETE_OUTPUT {}}'
DEBUG [#1:load:test/complete] source-sh: setenv COMPLETE_OUTPUT {}
DEBUG [#1:load:test/complete] parseSetenvCommandArgs: bhv=set, var=COMPLETE_OUTPUT, val=
DEBUG [#1:load:test/complete] unset-env: __MODULES_SHARE_COMPLETE_OUTPUT (internal=1, val=)
DEBUG [#1:load:test/complete] unset-env: __MODULES_PUSHENV_COMPLETE_OUTPUT (internal=1, val=)
DEBUG [#1:load:test/complete] set-env: COMPLETE_OUTPUT=
DEBUG [#1:load:test/complete] interp-sync-env: set var='::env(COMPLETE_OUTPUT)', val='' on interp(s) __modfile_load_1_1
DEBUG [#1:load:test/complete] evaluateModulefile: module-info mode
DEBUG [#1:load:test/complete] getModuleLoadedConflict: 'test/complete' conflicts with ''
DEBUG [#1:load:test/complete] execute-modulefile: exiting /path/to/modulefiles/test/complete
[...]
Modules version and configuration
$ module --version
Modules Release 5.6.0 (2025-07-31)
$ module config --dump-state
Additional context
It looks like the new instance of bash reset the whole environment. I can reproduce this outside of module with :
$ bash -c 'complete -p bash'
bash: line 0: complete: bash: no completion specification
I can get it to work with :
$ bash -i -c 'complete -p bash'
complete -F _longopt bash
However I only have the default environment initialized with bash. I loose any additional complete commands :
$ complete foo
$ complete -p foo
complete foo
$ bash -i -c 'complete -p foo'
bash: complete: foo: no completion specification
Describe the bug
completeorcomplete -pcommands print nothing when they are in a file that is sourced withsource-sh bash <file>or withmodule sh-to-mod bash <file>.To Reproduce
Steps to reproduce the behavior:
Location and content of any modulerc or modulefile involved:
Expected behavior
After
module load test/complete, the variableCOMPLETE_OUTPUTmust be set tocomplete -F _longopt bash.Error and debugging information
Modules version and configuration
Additional context
It looks like the new instance of bash reset the whole environment. I can reproduce this outside of module with :
I can get it to work with :
However I only have the default environment initialized with bash. I loose any additional complete commands :