[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

(enhancement request) Limiting depth of xtrace enabled

From: Carl Ponder
Subject: (enhancement request) Limiting depth of xtrace enabled
Date: Sat, 5 May 2018 10:36:27 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0

(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


Would you consider it as an enhancement?

reply via email to

[Prev in Thread] Current Thread [Next in Thread]