(I'm sending this request to bug-bash since that's what the GNU/bash
documention said to do.
I'm also CC'ing the lmod-users community since this would be of interest
to them.
I don't know how broadly you would want to reply to this.)
I use #!/bash -eux in almost all my scripts, so I can quickly figure out
if they were doing anything wrong.
Using "modules", though, I hit a problem that the module commands all
print out huge amounts of output from the environment settings they make.
The problem is that "regular" linux commands just print out like
+ ls
but the module command is an alias to a bash function, so all its
contents are traced as well.
My current workaround is to redefine module (Lmod version) as this
function module
{ set +o xtrace; eval $($LMOD_CMD bash "$@") && eval
$(${LMOD_SETTARG_CMD:-:} -s sh); errcode=$?; set -o xtrace; return
$errcode; }
which temporarily suspends the xtrace output and only prints out these
extras
+ module load pgi
*+ set +o xtrace**
**+ return 0*
+ module list
I can live with this, but it's still a mess to explain to modules/Lmod
users.
As far as I can tell, there's no real workaround in the modules/Lmod
implementations since direct shell operations are the only way they can
work.
On the bash side, though, a solution would be to limit the "depth" to
which the xtrace setting would apply, so I could trace my top-level
commands but not the contents of function calls, or only function calls
up to a certain depth.
A syntax like this would be ok
export XTRACE_DEPTH=1
Would you consider it as an enhancement?