Bright-Computing / bic

Bright-Illumina collaboration
GNU General Public License v2.0
4 stars 5 forks source link

should `BASH_ENV` be modified at all; is there any alternative? #33

Open fgeorgatos opened 8 years ago

fgeorgatos commented 8 years ago

This could be coming from either our Lmod (ie. us) or, it could be some of profile.d under Bright; in any case, undesired (long) output appears and we need to investigate where it comes from:

[userY@nodeX ~]$ time bash -fx bashscript.sh 
+ LMOD_PKG=/usr/share/lmod/lmod
+ LMOD_DIR=/usr/share/lmod/lmod/libexec
+ LMOD_CMD=/usr/share/lmod/lmod/libexec/lmod
+ MODULESHOME=/usr/share/lmod/lmod
+ export LMOD_PKG
+ export LMOD_CMD
+ export LMOD_DIR
+ export MODULESHOME
+ LMOD_VERSION=6.1
+ export LMOD_VERSION
+ '[' : '!=' : ']'
+ unalias ml
+ true
++ echo YES
++ /usr/bin/tr '[:upper:]' '[:lower:]'
+ export_module=yes
+ '[' -n '4.1.2(1)-release' -a yes '!=' no ']'
+ export -f module
+ export -f ml
+ unset export_module
+ '[' -n '' ']'
+ '[' 4 -ge 3 ']'
+ '[' -r /usr/share/lmod/lmod/init/lmod_bash_completions ']'
+ '[' -n '' ']'
[....then the real tracing starts...]
rtmclay commented 8 years ago

That comes from setting BASH_ENV to in your case to /usr/share/lmod/lmod/init/bash. This is how a bash shell script can use the module command. You can either unset BASH_ENV and lose the ability to use the module command in a bash script OR there could be some echo statements added to init/bash to say something like "Start of init/bash for Lmod module command" and "End of init/bash for Lmod module command to start and end the script.

fgeorgatos commented 8 years ago

@rtmclay : thanks for commenting on this! indeed I was suspecting some initialization magic;

we need to understand if the current approach is desired or it can be improved upon; if possible, I'd rather not have the bash -fx spitting this long sequence; it's confusing users :-(

fgeorgatos commented 8 years ago

There are two sub-issues here:

fgeorgatos commented 8 years ago
true '## Lmod initialized ##'
set +x

The incredible part on the latter was:

We did a "ulimit -s" in the scripts in /etc/profile.d but for the * programs
that were run by bash users would fail because the system files were not read.
fgeorgatos commented 7 years ago

OK. /usr/share/lmod/lmod/init/bash now includes the set +x and shell tracing is no more annoying.

However, there is the more tricky question about bash initialization overall and the fact that one man's BASH_ENV is another one's bug (ie. only one tool can capture attention of BASH_ENV, ie. it is not a very optimal design as it has now).

fgeorgatos commented 7 years ago

@johnnydevaprasad , @rtmclay priority of handling this needs to be bumped up, because blindly setting up set +x proves to be a pain: